不过,现默认你至少要比我的shell基础扎实得多,不然会有些麻烦!
但,不必担心的,高手们一般认为我写的这个东东就跟没学shell基础一个级别呢,呵呵
代码: 全选
#! /bin/bash
sudo ifconfig eth0 up
#换源,这里假设在"~/"或者"/media/sda5"下存有sources.list备份文件
echo "changing the sources list, which includes fjtu,cn99,vmmatrix and ubuntu official repositories..."
sources_default="/etc/apt/sources.list"
s_array=(`find {~/,/media/sda5} -iname sources.list`)
sources_backup=${s_array[0]}
#比较一下先
echo "compare the default sources with the backup sources..."
diff -q $sources_default $sources_backup
#异则换,同则否
if [ $? -ne 0 ]
then
sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
sudo cp $sources_backup /etc/apt/sources.list
else
echo "not necessary to change the repositories."
fi
#更新软件库
echo ' '
echo -e "updating packages from repositories...\nthis may take several minutes, it's up to your network."
sudo apt-get update 2>&1
sudo apt-get upgrade 2>&1
#自定义bash command,终端关闭即unset
export f="-y --force-yes"
export ps="ps -U $USER"
export ins="sudo apt-get install"
export rem="sudo apt-get remove --purge"
#安装fcitx,已有则不执行
echo ' '
echo "fcitx will be installed if not detected..."
$ps | grep -q fcitx
if [ $? -eq 1 ]
then
$ins fcitx ^scim{,-*}- $f && sudo apt-get autoremove $f
scim_ID=`pidof scim`
if [ -z $scim_ID ]
then
echo ' '
echo "scim processing is not found, launch the IM_client fcitx directly."
break
else
kill -9 $scim_ID
fi
fcitx &
echo ' '
echo "scim has been removed and replaced by fcitx."
else
echo "fcitx is running."
fi
#安装codecs for MPlayer,不想用MPlayer就注释之
echo ' '
echo "installing MPlayer codecs-20061022..."
if [ ! -d /usr/lib/codecs ]
then
wget -c http://www1.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
tar jxvf essential-*.tar.bz2 -C ./
sudo mkdir -p /usr/lib/codecs && sudo cp ./essential-20061022/* /usr/lib/codecs/
echo "MPlayer codecs package has been installed sucessfully. back up the codecs package..."
mv essential-*.tar.bz2 ~/backup
rm -rf essential-*
else
echo "there is MPlayer codecs package installed."
fi
#安装编译环境
echo ' '
echo "installing compiling components..."
if [ ! -d /usr/share/build-essential ]
then
$ins build-essential make automake autoconf gcc g++ libc6-dev $f
echo ' '
else
echo "not necessary to install compiling requirements"
fi
#安装MPlayer主程序,这里从官方下载,编译安装,仅作为一个例子,没有别的意思
echo ' '
echo "installing MPlayer-1.0rc1... "
if [ -z `type mplayer`]
then
wget -c http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2
tar jxvf MPlayer-*.tar.bz2 -C ./
cd MPlayer-1.0rc1
./configure --enable-gui --language=zh_CN
make && sudo make install
echo ' '
echo "MPlayer program has been installed successfully. back up the sources package..."
mv MPlayer-*.tar.bz2 ~/backup/
rm -rf MPlayer-*
else
echo "MPlayer has been detected."
fi
#安装MPlayer附件
echo ' '
echo "installing MPlayer attachments..."
$ins mplayer-{fonts,skins} mozilla-mplayer $f
echo "attachments have been completed."
#安装MS-fonts,也只是个例子,旨在说明字体的简单安装配置,也假设MS-fonts文件放在"~/"或者"/media/sda5"下面
echo ' '
echo "installing MS-fonts..."
if [ -f ~/.fonts/tahoma.ttf ]
then
echo "you have installed MS-fonts."
else
MS_fonts=(`find {~/,/media/sda5} -iname MS-fonts`)
mkdir ~/.fonts && cp ${MS_fonts[0]}/* ~/.fonts/
cd ~/.fonts
sudo mkfontdir && sudo mkfontscale
sudo fc-cache -fv
echo "MS-fonts have been installed successfully."
fi
#安装java,并配置,这里无法做到“无人看管”
echo ' '
echo "java will be installed..."
if [ ! -f `which java` ]
then
$ins sun-java5-jre $f
sudo update-alterntives --config java
echo "have installed the lastest sun-java."
else
echo "java has existed."
fi
#安装stardict,只举一个词典的例子,有人可能说可以从源安装,it's up to you
echo ' '
echo "installing stardict and its dictionaries...maybe it will take a long time!"
$ins stardict{,-common} $f
wget -c http://easynews.dl.sourceforge.net/sourceforge/stardict/stardict-kdic-computer-gb-2.4.2.tar.bz2
tar jxf stardict-kdic-computer-gb-2.4.2.tar.bz2 -C ~/.stardict/dic
echo ' '
echo "cleaning temporary packages about stardict..."
rm stardict-*.tar.bz2
#其它更简单softwares
echo ' '
echo "install other used-widely softwares..."
$ins xchat xchat-systray amarok amule w32codecs libxine-extracodecs xfonts-wqy flash{plugin,player}-nonfree mozilla-firefox-locale-zh-cn $f
echo ' '
echo -e "config has been finished.enjoy linux world!\nRestarting X-Window is strongly recommended!"
#重启X-Window
#sudo /etc/init.d/gdm restart