#!/bin/bash

##########################################################################
#                               README
#  this script for debian 64 ,initial configure,before run this
#  script,you must keep your server  connect INTERNET .

#  1 modify vim
#  2 clock rsync
#  3 remove unusable server
#  4 set unlimit
#  5 modify global environment
#
#  the other configures were not writen in this script ,because those
#  need debian command to change 

#  6 change langues
#    #dpkg-reconfigure  locales
#  7 change crontab
#    #update-alternatives  --config editor
#
##########################################################################
# version 20110505
###########################################################################


if [ $(id -u) != "0" ] ; then
   printf "Error:You must be root to run this script!\n"
   exit 1
fi

## install packages
apt-get -y install vim ntpdate locales >/dev/null 2>&1

## modify vim configure
sed -i 's/"syntax on/syntax on/g' /etc/vim/vimrc
sed -i 's/"set incsearch/set incsearch/g' /etc/vim/vimrc

## time sync use ntpdate
if [ "$(date | awk '{print $5}')" != "CST" ] ; then
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate cn.pool.ntp.org >/dev/null 2>&1
else
   ntpdate cn.pool.ntp.org >/dev/null 2>&1
fi

## set ulimit
echo "ulimit -HSn 65536" >> /etc/profile

## modify global environment for usual habit
if [ -f /etc/profile.bak ]; then
echo "profile has backuped to /etc/profiled.bak"
else
cp /etc/profile /etc/profile.bak
fi

cat >> /etc/profile <<EOF


### add
#export LS_OPTIONS='--color=auto'
 alias ls='ls --color=auto'
 alias ll='ls --color=auto -l'
 alias l='ls --color=auto -lA'
 alias rm='rm -i'
 alias cp='cp -i'
 alias mv='mv -i'
EOF

 

## remove unusable servers
/etc/init.d/exim4 stop >/dev/null 2>&1
/etc/init.d/nfs-common stop >/dev/null 2>&1
/etc/init.d/portmap stop >/dev/null 2>&1

update-rc.d exim4 remove  >/dev/null 2>&1
update-rc.d nfs-common remove >/dev/null 2>&1
update-rc.d portmap remove >/dev/null 2>&1


echo "please restart your server now!!!"