標籤:shell
#!/bin/bash####定義screen的名字,下面安裝會用screen這個命令SCREEN_NAME="lanmp"#根據$UID判斷使用者是否為root,必須root才能執行if [ $UID != 0 ]; then echo "You must be root to run the install script." exitfi#根據命令列參數判斷,參數為un或者uninstall時,停止服務,刪除檔案,卸載掉整個WDCP服務if [ "$1" == "un" -o "$1" == "uninstall" ]; then service httpd stop service nginxd stop service mysqld stop service pureftpd stop service wdapache stop #建立檔案備份目錄 mkdir /www/backup bf=$(date +%Y%m%d) #打包資料庫檔案 tar zcf /www/backup/mysqlbk_$bf.tar.gz /www/wdlinux/mysql/var rm -fr /www/wdlinux rm -f /tmp/*_ins.txt reboot exitfi#對當前系統中是否存在screen進程進行判斷,如果已經存在lanmp的screen進程,則提示,並退出if type -p screen >/dev/null && screen -ls |grep -q "[0-9].$SCREEN_NAME"; then echo "Seems another lanmp install session is taken place." echo "Rejoin this session plz type: ‘screen -r $SCREEN_NAME‘." exit 1fi#根據/etc/issue判斷當前系統類別型,然後根據type的返回結果,判斷是否安裝screen,沒有安裝,就進行安裝if grep -qi ‘debian\|ubuntu‘ /etc/issue; then type -p screen >/dev/null || apt-get -y install screenelse type -p screen >/dev/null || yum -y install screenfi
本文出自 “實踐就是真道理” 部落格,謝絕轉載!
wdcp的環境搭建shell指令碼分析--install.sh