脚本实现自动化安装lamp&lnmp

#备注:前提是将lnmp和lnmp自动化脚本写好放在相应的路径, 脚本已写好,请查看我博客中的 shell脚本 专栏!

 1 #!/bin/bash
 2 #安装lamp或者lnmp
 3 
 4 path=/server/scripts        #定义两个脚本路径
 5 [ ! -d "$path" ] && mkdir -p $path
 6 
 7 cat <<EOF
 8     1.[ install lamp ]
 9     2.[ install lnmp ]
10     3.[ exit ]
11     please input num you want:
12 EOF
13 
14 read num
15 [[ ! $num =~ [1-3] ]] && {
16     echo "the num you input must be:  1 | 2 | 3 "
17     exit 4
18 }
19 
20 [ $num -eq 1 ] && {            #如果用户选择1,则执行lamp安装命令
21     echo "start installing lamp..."
22     [ -x "$path/lamp.sh" ] && {        #判断脚本是否可执行
23         echo "$path/lamp.sh does not exist or can not be exec"
24         exit 1
25     }
26 source $path/lamp.sh
27 exit $?
28 }
29 
30 [ $num -eq 2 ] && {            #如果用户选择2,则执行lnmp安装命令
31     echo "start installing lnmp..."
32     [ -x "$path/lnmp.sh" ] && {        #判断脚本是否可执行
33         echo "$path/lnmp.sh does not exist or can not be exec"
34         exit 1
35     }
36 source $path/lnmp.sh
37 exit $?
38 }
39 
40 [ $num -eq 3 ] && {
41     echo goodbye!
42     exit 3
43 }

猜你喜欢

转载自www.cnblogs.com/zhoul/p/9923890.html