#!/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 #准备安装的screen会话 #判断是否存在screen这个命令 if type -p screen >/dev/null; then #如果存在的话,执行下列命令,执行安装和配置LANMP环境 screen -d -m -S $SCREEN_NAME -t lanmp -s /bin/bash sleep 1.5 if [ -z "$SCREEN_HARDSTATUS" ]; then SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' fi screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" NL=$(echo -ne '\015') screen -S $SCREEN_NAME -p lanmp -X stuff \ "(./lanmp.sh|tee lanmp_ins.log);(./wdcp.sh|tee wdcp_ins.log)$NL" screen -r $SCREEN_NAME #如果不存在的话,则先安装screen这个命令 else echo "Cannot find 'screen' command,install without screen(default yes)?" sleep 0.1 read -p "(Yes/No): " i case $i in no|No|NO|n|N) echo "Please install 'screen' before install lanmp." echo "for ubuntu/debian: apt-get update && apt-get install screen" echo "for CentOS/RHEL: yum update && yum install screen" exit ;; *) ./lanmp.sh|tee lanmp_ins.log ./wdcp.sh|tee wdcp_ins.log ;; esac fi
wdcp的环境搭建shell脚本分析--install.sh
原创
©著作权归作者所有:来自51CTO博客作者wr1985624的原创作品,谢绝转载,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
ltp (三) autofs*.sh脚本分析
ltp autofs*.sh脚本分析 && 优化(去除软盘)
文件系统 自动挂载 autofs ltp