标签: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." exit fi #根据命令行参数判断,参数为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 exit fi #对当前系统中是否存在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 1 fi #根据/etc/issue判断当前系统类型,然后根据type的返回结果,判断是否安装screen,没有安装,就进行安装 if grep -qi ‘debian\|ubuntu‘ /etc/issue; then type -p screen >/dev/null || apt-get -y install screen else type -p screen >/dev/null || yum -y install screen fi
本文出自 “实践就是真道理” 博客,谢绝转载!
wdcp的环境搭建shell脚本分析--install.sh
标签:shell
原文地址:http://44994.blog.51cto.com/34994/1664413