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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
| #!/bin/bash
USAGE(){
cat <<EOF
1:start php,nginx,varnish;
2:stop php,nginx,varnish;
3:restart php,nginx,varnish;
4:online;
5:contact wifi;
EOF
}
function online (){
echo 'get ip';
sudo dhcpcd eth0
echo 'starting goagent...';
sudo /etc/rc.d/goagent start
echo 'starting dnsmasq...';
sudo /etc/rc.d/dnsmasq start
}
function start\_php\_nginx_varnish (){
echo 'starting php-fpm...';
sudo /etc/rc.d/php-fpm start
echo 'starting nginx...';
sudo /etc/rc.d/nginx start
echo 'starting varnish';
sudo varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080
sudo /etc/rc.d/varnish start
}
function stop\_php\_nginx_varnish (){
echo 'stop webserver';
sudo /etc/rc.d/php-fpm stop
sudo /etc/rc.d/nginx stop
sudo /etc/rc.d/varnish stop
sudo pkill varnish
}
function restart\_php\_nginx_varnish (){
stop\_php\_nginx_varnish
start\_php\_nginx_varnish
}
function mysql_control(){
echo "you chose $@ mysql"
case "$1" in
START|start) echo "now start mysql"
sudo /etc/rc.d/mysqld start;;
STOP|stop) echo "now stop mysql"
sudo /etc/rc.d/mysqld stop;;
RESTART|restart)
sudo /etc/rc.d/mysqld restart;;
q|Q) done="true"
;;
*) echo "Invalid option, choose again...";;
esac
}
count_input=0
while \[ "$switch" == '' \]; do
read -p "what are you doing?" switch
((count_input++))
if \[ $count_input -ge 3 \];then
USAGE
fi
if \[ $count_input -ge 5 \];then
echo 'are u nuts!!!'
mytime=5
less_time=10
while \[ $mytime -ge -4 \];do
sleep 1
((less_time--))
echo $less_time
((mytime--))
done
echo 'quitting....'
exit 0
fi
done
if \[ "$switch" == "1" \];then
start\_php\_nginx_varnish
read -p 'Do you start mysql(type:1=yes or 2=no)' is\_start\_mysql
if \[ "$is\_start\_mysql" == "1" \];then
mysql_control 'start'
fi
fi
if \[ "$switch" == "2" \];then
stop\_php\_nginx_varnish
read -p 'Do you stop mysql(type:1=yes or 2=no)' is\_start\_mysql
if \[ "$is\_start\_mysql" == "1" \];then
mysql_control 'stop'
fi
fi
if \[ "$switch" == "3" \];then
restart\_php\_nginx_varnish
read -p 'Do you restart mysql(type:1=yes or 2=no)' is\_start\_mysql
if \[ "$is\_start\_mysql" == "1" \];then
mysql_control 'restart'
else
echo 'i chose no'
fi
fi
if \[ "$switch" == "4" \];then
online
fi
if \[ "$switch" == "5" \];then
echo 'scan wifi...';
echo -n 'You have';cat /tmp/enable_wifi|wc -l;'to use';
echo 'enable wifi';
awk '{num=num+1; printf"%d:%sn", num, $0}' /tmp/enable_wifi
read -p "Chose which one?" index\_of\_wifi_ESSID
sed -n "$index\_of\_wifi\_ESSID p" /tmp/enable\_wifi;
fi
|