交互式删除Linux or Solaris系统下不必要的服务脚本
时间:2008-07-14 来源:jackylau
#!/bin/sh
# Author: jackylau <[email protected]>
# Description: delete disnecessary service for Linux or SunOS
PATH=/sbin:/bin:/usr/bin
case `uname -s` in
SunOS)
echo
echo "Yours Operation System is Solaris? if not,Please press "Ctrl+c"!"
delser(){
for i in `ls /etc/rc2.d/S*`
do
SERVICE=${i#/etc/rc2.d/S??}
for SE in $SERVICE
do
echo $SE
done
echo -n "Will you delete the $i service ?[y/n/Y/N/yes/no]"
SER=${i#/etc/rc2.d/}
read answer
case $answer in
Y|y|yes)
mv $SER _$SER
;;
N|n|no)
continue
;;
*)
echo -n "please Y|y or N|n,thanks!"
echo -n "Will you delete the $j service ?"
read answer
;;
esac
done
}
cd /etc/rc2.d
delser
cd /etc/rc3.d
delser
;;
Linux)
echo
echo "Yours Operation System is Linux? if not,Please press "Ctrl+c"!"
for j in `chkconfig --list|awk '{if($5~/on/ && NF>3) print $1}'|awk '{print $1}'`
do
echo -n "Will you delete the $j service ?[y/n/Y/N/yes/no]"
read answer
case $answer in
Y|y|yes)
chkconfig --level 35 $j off
;;
N|n|no)
continue
;;
*)
echo -n "please Y|y or N|n,!"
echo -n "Will you delete the $j service ?"
read answer
;;
esac
done
;;
*)
echo "Your Server don't supported the script"
;;
esac
相关阅读 更多 +