Yaoshi.sh

    技术2022-05-14  1

    #!/bin/bash ########################################### # # functions: 1:Initial System (RHEL 4.8) # 2:Initial System (Centos 5.6) # 3:Initial Oracl # 4:Websphere Profile Control # 5:Pureftpd server Control # 6:PXE Push server Control # author: Hu ShuangFeng # version 1.0: 2011-04-12. # version 2.0: 2011-05-04. # ########################################### while echo "===================================" do printf "What features you want to use? /n /n1:Initial System (RHEL 4.8) /n2:Initial System (Centos 5.6) /n3:Initial Oracle /n4:Websphere Profile Control /n5:Pureftpd server Control /n6:PXE Push server Control /n9/Q:Exit /n /n===================================/nEnter Number: " ; read NNN while [ $NNN != 1 ]&&[ $NNN != 2 ]&&[ $NNN != 3 ]&&[ $NNN != 4 ]&&[ $NNN != 5 ]&&[ $NNN != 6 ]&&[ $NNN != 9 ]&&[ $NNN != q ]&&[ $NNN != Q ] do printf "Please enter the correct option :" ; read NNN done case "$NNN" in 1) ################################# #### Init System ####### ################################# # Funtion Initial System # Author Hu Shuangfeng 2011-4-1 # Version 1.1 Date Modified 2011-4-8 #Path pwd > /tmp/pwd #Funtion Off Services. for i in `chkconfig --list |awk 'NR==1 {print $1}'` do for ii in `chkconfig --list |awk '/'"$i"'/,/zebra/ {print $1}'` do SERVERS=`echo $ii |egrep -v "acpid|arpwatch|irqbalance|sshd|network|cpuspeed|crond|syslog|sysstat|snmpd|xfs"` chkconfig $SERVERS off --levels 3 chkconfig $SERVERS off --levels 5 done done #Synchronization time ntpdate -u 195.13.1.153 #Add DNS Server echo "nameserver 202.106.0.20" > /etc/resolv.conf #Modify updatedb.conf cp /etc/updatedb.conf /etc/updatedb.conf_org echo "DAILY_UPDATE=no" >> /etc/updatedb.conf #Modify the kernel parameters cp /etc/sysconfig/iptables-config /etc/sysconfig/iptables-config.org cd /etc/sysconfig/ sed 's/IPTABLES_MODULES=/"/"/IPTABLES_MODULES=/"ip_conntrack ip_conntrack_netbios_ns /"/' iptables-config.org > iptables-config cp /etc/sysctl.conf /etc/sysctl.conf.org echo "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1800" >> /etc/sysctl.conf echo "net.ipv4.ip_conntrack_max = 16777216" >> /etc/sysctl.conf echo "net.ipv4.netfilter.ip_conntrack_max = 16777216" >> /etc/sysctl.conf #Modify limlt.conf cp /etc/security/limits.conf /etc/security/limits.conf.org echo "* soft nofile 204800" >> /etc/security/limits.conf echo "* hard nofile 204800" >> /etc/security/limits.conf #Create Directory mkdir /usr/local/src/tarbag mkdir /usr/local/src/software mkdir /usr/local/scripts #Add crontab echo "00 00 * * * /usr/sbin/ntpdate -u 195.13.1.153" >> /var/spool/cron/root #Add Synchronization time to rc.local cp /etc/rc.local /etc/rc.local_org echo "/usr/sbin/ntpdate -u 195.13.1.153" >> /etc/rc.local #Close iptables service iptables stop chkconfig iptables off #Close selinux setenforce 0 cp /etc/selinux/config /etc/selinux/config_org. cat </etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted HHH #Install ethstatus cd /usr/local/src/tarbag/ wget http://ubuntu.srt.cn/ubuntu/pool/universe/e/ethstatus/ethstatus_0.4.3.tar.gz tar zxvf ethstatus_0.4.3.tar.gz -C ../software cd ../software/ethstatus-0.4.3 make && make install cd `cat /tmp/pwd` #Install yum #wget rpm software cd /usr/local/src/tarbag/ wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.x86_64.rpm wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.x86_64.rpm wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/sqlite-3.3.6-2.x86_64.rpm wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/yum-2.4.3-4.el4.centos.noarch.rpm wget http://mirrors.163.com/centos/4.8/os/x86_64/CentOS/RPMS/yum-metadata-parser-1.0-8.el4.centos.x86_64.rpm wget ftp://ftp.isu.edu.tw/pub/Linux/CentOS/4.8/os/ia64/CentOS/RPMS/centos-yumconf-4-4.5.noarch.rpm #Install yum rpm -ivh centos-yumconf-4-4.5.noarch.rpm rpm -ivh sqlite-3.3.6-2.x86_64.rpm rpm -ivh python-sqlite-1.1.7-1.2.1.x86_64.rpm rpm -ivh python-urlgrabber-2.9.8-2.noarch.rpm rpm -ivh python-elementtree-1.2.6-5.el4.centos.x86_64.rpm rpm -ivh yum-metadata-parser-1.0-8.el4.centos.x86_64.rpm rpm -ivh yum-2.4.3-4.el4.centos.noarch.rpm #Configure yum cd /etc/yum.repos.d/ rm -rf CentOS-Base.repo cat < base.repo # CentOS-Base.repo # # This file uses a new mirrorlist system developed by Lance Davis for CentOS. # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-/$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=/$releasever&arch=/$basearch&repo=os baseurl=http://centos.ustc.edu.cn/centos/4/os//$basearch/ gpgcheck=1 gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4 #released updates [updates] name=CentOS-/$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=/$releasever&arch=/$basearch&repo=updates baseurl=http://centos.ustc.edu.cn/centos/4/updates//$basearch/ gpgcheck=1 gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4 #packages used/produced in the build but not released [addons] name=CentOS-/$releasever - Addons #mirrorlist=http://mirrorlist.centos.org/?release=/$releasever&arch=/$basearch&repo=addons baseurl=http://centos.ustc.edu.cn/centos/4/addons//$basearch/ gpgcheck=1 gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4 #additional packages that may be useful [extras] name=CentOS-/$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=/$releasever&arch=/$basearch&repo=extras baseurl=http://centos.ustc.edu.cn/centos/4/extras//$basearch/ gpgcheck=1 gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-/$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=/{1}arch=/$basearch&repo=centosplus baseurl=http://centos.ustc.edu.cn/centos/4/centosplus//$basearch/ gpgcheck=1 enabled=0 gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4 EOF #Add yum cd `cat /tmp/pwd` rpm --import http://ftp.riken.jp/Linux/centos/4.8/os/x86_64/RPM-GPG-KEY-centos4 yum clean all #Install Nrpe #Add user useradd nagios -s /sbin/nologin #Wget nrpe cd /usr/local/src/tarbag wget http://down1.chinaunix.net/distfiles/nagios-plugins-1.4.3.tar.gz wget http://admin.ooopic.com/soft/linux/nrpe-2.12.tar.gz #Add init.d nrpe cat </etc/init.d/nrpe #chkconfig:2345 88 38 #Description:this is a scripts for nrpe pid=/`ps aux |grep nrpe |grep -v grep | grep -v bash | cut -c10-15/` function start(){ if [ "/$pid" = "" ]; then echo -n "starting nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" != "" ];then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[31m[fail]/n" echo "nrpe already start" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done exit 1 else /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d >/dev/null 2>1& echo -n "starting nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" != "" ];then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[32m[ ok ]/n" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done fi } function stop(){ if [ "/$pid" != "" ]; then /bin/kill -9 /$pid echo -n "stoping nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" == "" ]; then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[32m[ ok ]/n" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done else echo -n "stoping nrpe" time=100 while [ /$time -gt 0 ] do if [ "$pid" == "" ]; then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[31m[fail]" echo "nrpe already stop" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 continue fi done exit 1 fi } case "/$1" in start) start ;; stop) stop ;; restart) /$0 stop /$0 start ;; *) echo "Usage:/$0(start|stop|restart)" ;; esac exit 0 EEE #Install cd /usr/local/src/tarbag tar -zxvf nagios-plugins-1.4.14.tar.gz -C ../software/ cd ../software/nagios-plugins-1.4.14/ ./configure --prefix=/usr/local/nagios make make install cd /usr/local/src/tarbag tar zxvf nrpe-2.12.tar.gz -C ../software/ cd ../software/nrpe-2.12/ ./configure --prefix=/usr/local/nagios make all make install-plugin make install-daemon make install-daemon-config chmod 777 /etc/init.d/nrpe chkconfig nrpe on service nrpe start ####################### echo "===================================" echo "Please reboot your system server" echo "===================================" ;; 2) ################################# ####Init System (Centos 5.6)##### ################################# # Funtion Initial System # Author Hu Shuangfeng 2011-4-1 # Version 1.1 Date Modified 2011-4-8 #Path pwd > /tmp/pwd #Funtion Off Services. for i in `chkconfig --list |awk 'NR==1 {print $1}'` do for ii in `chkconfig --list |awk '/'"$i"'/,/zebra/ {print $1}'` do SERVERS=`echo $ii |egrep -v "acpid|arpwatch|irqbalance|sshd|network|cpuspeed|crond|syslog|sysstat|snmpd|xfs"` chkconfig $SERVERS off --levels 3 chkconfig $SERVERS off --levels 5 done done #Synchronization time ntpdate -u 195.13.1.153 #Add DNS Server echo "nameserver 202.106.0.20" > /etc/resolv.conf #Modify updatedb.conf cp /etc/updatedb.conf /etc/updatedb.conf_org echo "DAILY_UPDATE=no" >> /etc/updatedb.conf #Modify the kernel parameters cp /etc/sysconfig/iptables-config /etc/sysconfig/iptables-config.org cd /etc/sysconfig/ sed 's/IPTABLES_MODULES=/"/"/IPTABLES_MODULES=/"ip_conntrack ip_conntrack_netbios_ns /"/' iptables-config.org > iptables-config cp /etc/sysctl.conf /etc/sysctl.conf.org echo "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1800" >> /etc/sysctl.conf echo "net.ipv4.ip_conntrack_max = 16777216" >> /etc/sysctl.conf echo "net.ipv4.netfilter.ip_conntrack_max = 16777216" >> /etc/sysctl.conf #Modify limlt.conf cp /etc/security/limits.conf /etc/security/limits.conf.org echo "* soft nofile 204800" >> /etc/security/limits.conf echo "* hard nofile 204800" >> /etc/security/limits.conf #Create Directory mkdir /usr/local/src/tarbag mkdir /usr/local/src/software mkdir /usr/local/scripts #Add crontab echo "00 00 * * * /usr/sbin/ntpdate -u 195.13.1.153" >> /var/spool/cron/root #Add Synchronization time to rc.local cp /etc/rc.local /etc/rc.local_org echo "/usr/sbin/ntpdate -u 195.13.1.153" >> /etc/rc.local #Close iptables service iptables stop chkconfig iptables off #Close selinux setenforce 0 cp /etc/selinux/config /etc/selinux/config_org. cat </etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted HHH #Install ethstatus cd /usr/local/src/tarbag/ wget http://ubuntu.srt.cn/ubuntu/pool/universe/e/ethstatus/ethstatus_0.4.3.tar.gz tar zxvf ethstatus_0.4.3.tar.gz -C ../software cd ../software/ethstatus-0.4.3 make && make install cd `cat /tmp/pwd` yum clean all yum list #Install Nrpe #Add user useradd nagios -s /sbin/nologin #Wget nrpe cd /usr/local/src/tarbag wget http://down1.chinaunix.net/distfiles/nagios-plugins-1.4.3.tar.gz wget http://admin.ooopic.com/soft/linux/nrpe-2.12.tar.gz #Add init.d nrpe cat </etc/init.d/nrpe #chkconfig:2345 88 38 #Description:this is a scripts for nrpe pid=/`ps aux |grep nrpe |grep -v grep | grep -v bash | cut -c10-15/` function start(){ if [ "/$pid" = "" ]; then echo -n "starting nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" != "" ];then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[31m[fail]/n" echo "nrpe already start" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done exit 1 else /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d >/dev/null 2>1& echo -n "starting nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" != "" ];then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[32m[ ok ]/n" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done fi } function stop(){ if [ "/$pid" != "" ]; then /bin/kill -9 /$pid echo -n "stoping nrpe" pid=/`ps aux | grep nrpe | grep -v grep | grep -v bash | cut -c10-15/` time=100 while [ /$time -gt 0 ] do if [ "/$pid" == "" ]; then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[32m[ ok ]/n" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 pid=/`ps aux |grep nrpe |grep -v grep | cut -c10-15/` continue fi done else echo -n "stoping nrpe" time=100 while [ /$time -gt 0 ] do if [ "$pid" == "" ]; then i=10 while [ /$i -gt 0 ] do echo -n "." sleep 0.1 i=/`expr /$i - 1/` done echo -e " /033[31m[fail]" echo "nrpe already stop" exit 0 else time=/`expr /$time - 1/` echo "." usleep 10 continue fi done exit 1 fi } case "/$1" in start) start ;; stop) stop ;; restart) /$0 stop /$0 start ;; *) echo "Usage:/$0(start|stop|restart)" ;; esac exit 0 EEE #Install cd /usr/local/src/tarbag tar -zxvf nagios-plugins-1.4.14.tar.gz -C ../software/ cd ../software/nagios-plugins-1.4.14/ ./configure --prefix=/usr/local/nagios make make install cd /usr/local/src/tarbag tar zxvf nrpe-2.12.tar.gz -C ../software/ cd ../software/nrpe-2.12/ ./configure --prefix=/usr/local/nagios make all make install-plugin make install-daemon make install-daemon-config chmod 777 /etc/init.d/nrpe chkconfig nrpe on service nrpe start ####################### echo "===================================" echo "Please reboot your system server" echo "===================================" ;; 3) ################################# #### Init oracle ####### ################################# # Funtion: Init oracle install script # Author: Hu Shuangfeng 2011-4-1 # Version: 1.0 #Install dependencies yum install -y glibc.x86_64 glibc.i686 glibc-common.x86_64 glibc-devel.x86_64 glibc-devel.i386 glibc-headers.x86_64 glibc-kernheaders.x86_64 gcc.x86_64 gcc-c++.x86_64 compat-gcc-32.x86_64 compat-gcc-32-c++.x86_64 compat-libgcc-296.i386 libstdc++.x86_64 libstdc++.i386 libstdc++-devel.x86_64 make.x86_64 gtk+.i386 gtk+.x86_64 gnome-libs.x86_64 tcp_wrappers.i386 tcp_wrappers.x86_64 ORBit.x86_64 ORBit2.i386 ORBit2.x86_64 libpng10.i386 libpng10.x86_64 libungif.x86_64 libungif.i386 imlib.x86_64 imlib.i386 setarch.x86_64 libaio.i386 audiofile.x86_64 audiofile.i386 esound.x86_64 esound.i386 #Modify /etc/sysctl.conf MEM=`df -k | grep none | awk '{print $2}'` BMEM=`echo $MEM*1024 | bc` cat <> /etc/sysctl.conf kernel.shmall = 44194304 kernel.shmmax = $BMEM kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 EOF #Modify /etc/security/limits.conf cat <>/etc/security/limits.conf oracle hard nofile 65536 oracle soft nofile 65536 oracle hard nproc 16384 oracle soft nproc 16384 LLL #Gcc version of down-conversion cd /usr/bin/ mv gcc gcc.script.bak mv g++ g++.script.bak ln -s gcc32 gcc ln -s g++32 g++ #Add User and Directory groupadd oinstall groupadd dba useradd -g oinstall -G dba oracle echo "oracle" | passwd --stdin oracle mkdir -p /opt/oracle/product/9.2.0 chown -R oracle:oinstall /opt/oracle #Modify /home/oracle/.bash_profile SID=mtdb cat <> /home/oracle/.bash_profile export LD_ASSUME_KERNEL=2.4.1 export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/product/9.2.0 export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH export ORACLE_SID= $SID export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export NLS_LANG=american_america.ZHS16GBK export LANG=en_US.UTF-8 HHH #Over echo "" echo "" echo "" echo "Init oracle install is complete ! Switch Oracle user, and requests to install the system language to English!!!" echo "" echo "" echo "" ;; 4) ################################# #### WAS CRTL ####### ################################# # Functions: Start and Stop Was app server script # Author: Hu ShuangFeng # Version 1.0: 2011-03-30. # Version 1.1: 2011-04-11. Add create appserver Features # Version 1.2: 2011-04-12 Add delete appserver ,list appserver Features #App server path S1=/opt/IBM/WebSphere/AppServer/profiles/AppSrv01 S2=/opt/IBM/WebSphere/AppServer/profiles/server2 S3=/opt/IBM/WebSphere/AppServer/profiles/server3 S4=/opt/IBM/WebSphere/AppServer/profiles/server4 #Command start and stop Start=/bin/startServer.sh Stop=/bin/stopServer.sh #User and password USERNAME=admin PASSWORD=admin #Create app server MANAGE=/opt/IBM/WebSphere/AppServer/bin/manageprofiles.sh TEMPLATEPATH=/opt/IBM/WebSphere/AppServer/profileTemplates/default/ PROFILEPATH=/opt/IBM/WebSphere/AppServer/profiles/ ############################################## #### script command ############ ############################################## while echo "===================================" do printf "What Are You Doing? /n /n1:Start All Server! /n2:Stop All Server! /n3:Start Single Server! /n4:Stop Single Server! /n5:Create App Profile ! /n6:Delete APP Profile ! /n7:ListProfiles ! /n9/Q:Exit /n /n===================================/nEnter number: " ; read number while [ $number != 1 ]&&[ $number != 2 ]&&[ $number != 3 ]&&[ $number != 4 ]&&[ $number != 5 ]&&[ $number != 6 ]&&[ $number != 7 ]&&[ $number != 9 ]&&[ $number != q ]&&[ $number != Q ] do printf "Please enter the correct option :" ; read number done case "$number" in 1) $S1$Start server1 > /dev/null 2>&1 & echo -n "Starting server1" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S2$Start server1 > /dev/null 2>&1 & echo -n "Starting server2" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S3$Start server1 > /dev/null 2>&1 & echo -n "Starting server3" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S4$Start server1 > /dev/null 2>&1 & echo -n "Starting server4" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" echo "All server started successfully!!!" ;; 2) $S1$Stop server1 -username $USERNAME -password $PASSWORD > /dev/null 2>&1 & echo -n "Shutting down server1" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S2$Stop server1 -username $USERNAME -password $PASSWORD > /dev/null 2>&1 & echo -n "Shutting down server2" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S3$Stop server1 -username $USERNAME -password $PASSWORD > /dev/null 2>&1 & echo -n "Shutting down server3" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" $S4$Stop server1 -username $USERNAME -password $PASSWORD > /dev/null 2>&1 & echo -n "Shutting down server4" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" echo "All server stopped successfully!!!" ;; 3) printf "Please enter the name of the service need to start :" ; read name case "$name" in server1) $S1$Start server1 echo -n "Starting server1" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server2) $S2$Start server1 echo -n "Starting server2" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server3) $S3$Start server1 echo -n "Starting server3" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server4) $S4$Start server1 echo -n "Starting server4" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" esac ;; 4) printf "Please enter the name of the service need to stop :" ; read name case "$name" in server1) $S1$Stop server1 -username $USERNAME -password $PASSWORD echo -n "Shutting down server1" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server2) $S2$Stop server1 -username $USERNAME -password $PASSWORD echo -n "Shutting down server2" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server3) $S3$Stop server1 -username $USERNAME -password $PASSWORD echo -n "Shutting down server3" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." sleep 3 echo -n " [OK]" echo "" ;; server4) $S4$Stop server1 -username $USERNAME -password $PASSWORD echo -n "Shutting down server4" sleep 1 echo -n "." sleep 1 echo -n "." sleep 1 echo -n "." echo -n " [OK]" sleep 3 echo "" esac ;; 5) printf "Please Enter ProfileName:"; read PNAME printf "Please Enter ProfilePath:"; read PPATH printf "/nPlease wait, this process takes about two minutes!" $MANAGE -create -templatePath $TEMPLATEPATH -profileName $PNAME -profilePath $PROFILEPATH$PPATH ;; 6) printf "Please Enter Need to be removed ProfileName:"; read DNAME $MANAGE -delete -profileName $DNAME ;; 7) $MANAGE -listProfiles ;; 9) exit ;; q) exit esac done ;; 5) ################################# #### Pureftp CRTL ####### ################################# # functions: Pureftpd script # author: Hu ShuangFeng # version 1.0: 2010-08-10. # FTP=/usr/local/pureftpd/bin/pure-pw mkpasswd=`mkpasswd -l 22 -d 5 -C 5 > /tmp/pureftpdoo` passwd1=`sed '1 w /tmp/pureftpdoo1' /tmp/pureftpdoo` passwd2=`cat /tmp/pureftpdoo >> /tmp/pureftpdoo1` passwd=/tmp/pureftpdoo1 while echo "===================================" do printf "What Are You Doing? /n /n1:UserAdd --Just enter the user name ! /n2:UserAdd --Need to enter a user name with the directory ! /n3:UserMod /n4:UserPasswd /n5:UserDel /n6:ListAllUser /n7:ListOneUser /n8:ShowUser /n9:Exit /n /n===================================/nEnter number: " ; read number while [ $number != 1 ]&&[ $number != 2 ]&&[ $number != 3 ]&&[ $number != 4 ]&&[ $number != 5 ]&&[ $number != 6 ]&&[ $number != q ]&&[ $number != 7 ]&&[ $number != 8 ]&&[ $number != 9 ] do printf "Please enter the correct option :" ; read number done case "$number" in 1) printf "Please Enter a user name :" ; read name $FTP useradd $name -u nobody -g nobody -d `pwd` y-m < $passwd echo "-----------------------------------" echo " " echo "Users [$name] create successful ! " echo " " printf "You user name is : $name /n" printf "You Password is : $passwd1 /n" printf "You directory is : `pwd` /n" echo " " ;; 2) printf "Please Enter a user name :" ; read name printf "Please enter the directory : " ; read directory $FTP useradd $name -u nobody -g nobody -d $directory -m < $passwd echo "-----------------------------------" echo " " echo "Users [$name] create successful !" echo " " printf "You user name is : $name /n" printf "You Password is : $passwd1 /n" printf "You directory is : $directory /n" echo " " ;; 3) printf "Please enter a user name :" ; read name printf "Please enter a new directory :" ; read newdirectory $FTP usermod $name -u nobody -g nobody -d $newdirectory -m echo "-----------------------------------" echo " " echo "User [$name] modify a successful !" echo " " printf "You user name is : $name /n" printf "You new directory is : $newdirectory /n" echo " " ;; 4) printf "Please enter a user name :" ; read name $FTP passwd $name -m < $passwd echo "-----------------------------------" echo " " echo "[$name] Password changed successfully !" echo " " printf "You user name is : $name /n" printf "You nwe password is : $passwd1 /n" echo " " ;; 5) printf "Please enter a user name :" ; read name $FTP userdel $name -m echo "-----------------------------------" echo " " echo "Users [$name] have been deleted !" echo " " ;; 6) $FTP list ;; 7) printf "Please enter a user name :" ; read name $FTP list | grep $name echo " " ;; 8) printf "Please enter a user name :" ; read name $FTP show $name echo " " ;; 9) exit ;; q) exit esac done ;; 6) ################################# #### push crtl ####### ################################# while echo "===================================" do printf "What Are You Doing? /n /n1:Starting push service ! /n2:Stoping push service ! /n3:Restarting push service !/n4:Status push service !/n /n===================================/nEnter number: " ; read NUMBER case "$NUMBER" in 1) service dhcpd start service vsftpd start service xinetd start service portmap start service nfs start ;; 2) service dhcpd stop service vsftpd stop service xinetd stop service portmap stop service nfs stop ;; 3) service dhcpd restart service vsftpd restart service xinetd restart service portmap restart service nfs restart ;; 4) service dhcpd status service vsftpd status service xinetd status service portmap status service nfs status ;; q) exit ;; esac done ;; 9) exit ;; q) exit esac done


    最新回复(0)