-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathinstall.sh
executable file
·70 lines (67 loc) · 2.06 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
###
SCREEN_NAME="lanmp"
if [ $UID != 0 ]; then
echo "You must be root to run the install script."
exit
fi
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/*install.lock
rm -f /etc/init.d/{httpd,nginxd,mysqld,pureftpd,wdapache}
reboot
exit
fi
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 now"
if screen -ls | grep -q Attached; then
screen -d $SCREEN_NAME
fi
screen -r $SCREEN_NAME
exit
fi
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
chmod 755 lanmp.sh
chmod 755 wdcp.sh
# prepare screen session for install
if type -p screen >/dev/null; then
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
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