forked from nisargjhaveri/saathi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·80 lines (71 loc) · 1.19 KB
/
setup.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
71
72
73
74
75
76
77
78
79
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
_install() {
if [ ! -e /usr/bin/saathi ];
then
ln -s `readlink -f $0` /usr/bin/saathi
if [ ! $? -eq 0 ];
then
echo "${YELLOW}Re-run as sudo to setup this script${NC}"
fi
apt-get install lamp-server^ # install the whole goddammed lamp stack
fi
}
_check() {
if [ -f app/config.php ];
then
echo "${GREEN}Using config `pwd`/app/config.php${NC}"
else
echo "${RED}Config not Found.. Please copy the config file and make changes.${NC}"
exit 1
fi
}
_start () {
_check
php -S localhost:8000 > /dev/null &
#Please edit this script if you are not using php development server
if [ $? -eq 0 ];
then
# is never seen; :P
echo "${GREEN}Start Sucessful${NC}"
else
echo "${RED}Start Failed${NC}"
fi
echo
}
_stop () {
killall php # because why not?
if [ $? -eq 0 ];
then
echo "${GREEN}Stop Sucessful${NC}"
else
echo "${RED}Stop Failed${NC}"
fi
echo
}
_install
case "$1" in
start)
_start
;;
stop)
_stop
;;
status)
_check
;;
install)
_install
;;
restart|reload)
_stop
_start
;;
*)
echo "Usage : $0 {start|stop|restart|reload|status|install}"
exit 1
esac
exit 0