-
Notifications
You must be signed in to change notification settings - Fork 1
/
lenses-setup.sh
executable file
·118 lines (90 loc) · 2.55 KB
/
lenses-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
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
#!/usr/bin/env bash
ROOT=~/Documents
HOME_DIR="$ROOT/lenses"
COMPOSER="lenses-freeform" #th-lens-composer
GIT_ORG="lenses" #lenses
COMPOSER_DIR="$HOME_DIR/$COMPOSER"
if [ $# -eq 0 ]; then
echo "";
#echo "-------------------------------------------------------------- "
echo "";
echo "Usage: $0 setup|run-server|update|kill-server";
echo "";
echo "setup: To setup the Lenses environment in $HOME_DIR";
echo "run-server: To run server";
echo "update: To update environment with latest code";
echo "kill-server: To shut down server";
echo "";
#echo "-------------------------------------------------------------- "
exit 1;
fi
setup ()
{
if test -w $HOME_DIR; then
if test -w $HOME_DIR.bak; then
echo "Directory $HOME_DIR and backup directory $HOME_DIR.bak both exist. Backup or delete either one to run. bye."
exit 1
fi
mv -f $HOME_DIR $HOME_DIR.bak
echo "Your original $HOME_DIR has been backed up to $HOME_DIR.bak"
fi
echo "Creating director $HOME_DIR for local lenses installation"
mkdir -p $HOME_DIR
cd $HOME_DIR
pwd
git clone [email protected]:$GIT_ORG/$COMPOSER
cd $COMPOSER_DIR
pwd
bower install
startServer
#kill $(ps aux | grep 'python -m SimpleHTTPServer 8008' | awk '{print $2}')
#exit 0
}
startServer ()
{
cd $HOME_DIR
echo "shutting down already running server..."
kill $(ps aux | grep 'python -m SimpleHTTPServer 8008' | awk '{print $2}')
echo "running python server in background"
#nohup python -m SimpleHTTPServer 8008 &
nohup python -m SimpleHTTPServer 8008 0<&- &>/dev/null &
echo "Python $? is running on port 8008. Lenses app is at http://localhost:8008/$COMPOSER/demo.html"
}
updateWorkspace ()
{
echo "Running update will pull changes from server. It will not touch the components you have created but may erase your local modifications (like changes to th-component-list. Do you want to continue? (yes/no)"
read continueUpdate
if [ $continueUpdate == "yes" ]; then
cd $COMPOSER_DIR
git pull origin master
bower update
else
echo "Aborting..."
fi
}
echo $1
case "$1" in
setup)
echo "setup"
setup
exit 0
;;
run-server)
echo "running server"
startServer
exit 0
;;
update)
echo "updating workspace"
updateWorkspace
exit 0
;;
kill-server)
echo "turning off python server"
kill $(ps aux | grep 'python -m SimpleHTTPServer 8008' | awk '{print $2}')
exit 0
;;
*)
echo $"Usage: $0 {setup|run-server|update|kill-server}"
exit 1
esac