Shell Dialog实现的软件安装界面
时间:2006-03-24 来源:jiahaolin
#!/bin/sh
#File :CnsInstall.sh
#Author :cnscn
#Time :2006-03-23 10:00
#欢迎使用转载,敬请保留作者信息, 谢谢
#
#25 height of outer border
#50 width
#20 heigt of inner border
#软件包内的各软件目录名称
#the directory names array of softs
arrdirs=(
"adobe" \
"baghira-release" \
"eva4.0" \
"fcitx-3.1.1" \
"firefox" \
"j2sdk" \
"mplayer" \
"mytget-0.1.0" \
"ncftp-3.1.9" \
"rar" \
"stardict" \
"vera" \
"vim7/src" \
"_vim" \
"vmware" \
"xmms" \
"ZendStudioClient-5.0.0" \
)
#生成安装管理界面
#make the dialog
dialog \
--separate-output \
--checklist "CNSCN Softs Mangemet System" \
25 50 20 \
\
0 "adobe pdf reader" on \
1 "baghira-release" on \
2 "eva4.0" on \
3 "fcitx-3.1.1" on \
4 "firefox" on \
5 "j2sdk" on \
6 "mplayer" on \
7 "mytget-0.1.0" on \
8 "ncftp-3.1.9" on \
9 "rar" on \
10 "stardict" on \
11 "vera" on \
12 "vim7.0.a" on \
13 ".vim" on \
14 "vmware5.5" on \
15 "xmms" on \
16 "ZendStudioClient-5.0.0" on \
\
2>output
in=$(<output)
#确认函数
#the function of confirm
function Confirm()
{
#text height witdh
dialog --yesno "Are you sure to install ...?" 6 36
if [ $? -eq 0 ]
then
isConfirmed=0
return 0
else
isConfirmed=1
return 1
fi
}
#进行确认是否进行安装
#whether confirm of not
if [ -n "$in" ]
then
Confirm
if [ $? -eq 1 ]
then
exit 1
fi
fi
#开始循环安装各软件
#loop to install the softs
for i in $in
do
f=${arrdirs[$i]}
cd ./$f
./cns-install.sh
if [ "$f" == "vim7/src" ]
then
cd ../../
else
cd ..
fi
#休眠2秒,从而可以看清当前软件的安装结果
#sleep 1 seconds, so we can see the results
sleep 2
done
#删除变量output
rm output
#End of Script
======================使用效果======================================
./CnsInstall.sh
出现软件包管理界面
500)this.width=500;" border="0">
要求进行安装确认
500)this.width=500;" border="0">
开始进行安装
500)this.width=500;" border="0" width="500">
[附]
1)软件包结构
[root@cnscn-88-linux cns-softs-install]# ls
adobe
checkinstall.sh
fcitx-3.1.1
j2sdk
ncftp-3.1.9
vera
ZendStudioClient-5.0.0
CnsInstall.sh
firefox
mplayer
output
stardict
_vim
vmware
baghira-release
eva4.0
myget-0.1.0
rar
vim7
xmms
2)每一个软件目录下有一个cns-install.sh, 里面有用shell写好的安装本软件包的安装脚本, 如
[root@cnscn-88-linux cns-softs-install]# ls adobe/
AdobeReader_enu-7.0.0-2.i386.rpm cns-install.sh
3)安装脚本:
安装脚本有的简单只有几行,有的却复杂,这和安装软件及配置的步骤有关
# cat fcitx-3.1.1/cns-install.sh
#!/bin/sh
echo "Installing fcitx-3.1.1..."
./configure
make
make install
make clean
#make fcitx is the input daemon
if [ -e /etc/X11/xinit/xinput.d/zh_CN ]
then
mv /etc/X11/xinit/xinput.d/zh_CN /etc/X11/xinit/xinput.d/zh_CN-bk
fi
touch /etc/X11/xinit/xinput.d/zh_CN
fname="/etc/X11/xinit/xinput.d/zh_CN"
echo "XIM=fcitx" >$fname
echo "XIM_PROGRAM=fcitx" >>$fname
echo "GTK_IM_MODULE=fcitx" >>$fname
echo "gnome-im-settings-daemon > /dev/null" >>$fname
echo "Install fcitx-3.1.1 ... [OK]"
#End of the script
#File :CnsInstall.sh
#Author :cnscn
#Time :2006-03-23 10:00
#欢迎使用转载,敬请保留作者信息, 谢谢
#
#25 height of outer border
#50 width
#20 heigt of inner border
#软件包内的各软件目录名称
#the directory names array of softs
arrdirs=(
"adobe" \
"baghira-release" \
"eva4.0" \
"fcitx-3.1.1" \
"firefox" \
"j2sdk" \
"mplayer" \
"mytget-0.1.0" \
"ncftp-3.1.9" \
"rar" \
"stardict" \
"vera" \
"vim7/src" \
"_vim" \
"vmware" \
"xmms" \
"ZendStudioClient-5.0.0" \
)
#生成安装管理界面
#make the dialog
dialog \
--separate-output \
--checklist "CNSCN Softs Mangemet System" \
25 50 20 \
\
0 "adobe pdf reader" on \
1 "baghira-release" on \
2 "eva4.0" on \
3 "fcitx-3.1.1" on \
4 "firefox" on \
5 "j2sdk" on \
6 "mplayer" on \
7 "mytget-0.1.0" on \
8 "ncftp-3.1.9" on \
9 "rar" on \
10 "stardict" on \
11 "vera" on \
12 "vim7.0.a" on \
13 ".vim" on \
14 "vmware5.5" on \
15 "xmms" on \
16 "ZendStudioClient-5.0.0" on \
\
2>output
in=$(<output)
#确认函数
#the function of confirm
function Confirm()
{
#text height witdh
dialog --yesno "Are you sure to install ...?" 6 36
if [ $? -eq 0 ]
then
isConfirmed=0
return 0
else
isConfirmed=1
return 1
fi
}
#进行确认是否进行安装
#whether confirm of not
if [ -n "$in" ]
then
Confirm
if [ $? -eq 1 ]
then
exit 1
fi
fi
#开始循环安装各软件
#loop to install the softs
for i in $in
do
f=${arrdirs[$i]}
cd ./$f
./cns-install.sh
if [ "$f" == "vim7/src" ]
then
cd ../../
else
cd ..
fi
#休眠2秒,从而可以看清当前软件的安装结果
#sleep 1 seconds, so we can see the results
sleep 2
done
#删除变量output
rm output
#End of Script
======================使用效果======================================
./CnsInstall.sh
出现软件包管理界面
500)this.width=500;" border="0">
要求进行安装确认
500)this.width=500;" border="0">
开始进行安装
500)this.width=500;" border="0" width="500">
[附]
1)软件包结构
[root@cnscn-88-linux cns-softs-install]# ls
adobe
checkinstall.sh
fcitx-3.1.1
j2sdk
ncftp-3.1.9
vera
ZendStudioClient-5.0.0
CnsInstall.sh
firefox
mplayer
output
stardict
_vim
vmware
baghira-release
eva4.0
myget-0.1.0
rar
vim7
xmms
2)每一个软件目录下有一个cns-install.sh, 里面有用shell写好的安装本软件包的安装脚本, 如
[root@cnscn-88-linux cns-softs-install]# ls adobe/
AdobeReader_enu-7.0.0-2.i386.rpm cns-install.sh
3)安装脚本:
安装脚本有的简单只有几行,有的却复杂,这和安装软件及配置的步骤有关
# cat fcitx-3.1.1/cns-install.sh
#!/bin/sh
echo "Installing fcitx-3.1.1..."
./configure
make
make install
make clean
#make fcitx is the input daemon
if [ -e /etc/X11/xinit/xinput.d/zh_CN ]
then
mv /etc/X11/xinit/xinput.d/zh_CN /etc/X11/xinit/xinput.d/zh_CN-bk
fi
touch /etc/X11/xinit/xinput.d/zh_CN
fname="/etc/X11/xinit/xinput.d/zh_CN"
echo "XIM=fcitx" >$fname
echo "XIM_PROGRAM=fcitx" >>$fname
echo "GTK_IM_MODULE=fcitx" >>$fname
echo "gnome-im-settings-daemon > /dev/null" >>$fname
echo "Install fcitx-3.1.1 ... [OK]"
#End of the script
相关阅读 更多 +