-
Notifications
You must be signed in to change notification settings - Fork 14
/
toolbelt.sh
executable file
·107 lines (94 loc) · 2.1 KB
/
toolbelt.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
#!/bin/sh
show_help(){
echo "
Why Hello there! You must be looking for help\n\
\n\
The Flags: \n\
r - run \n\
t - test \n\
d - deploy \n\
b - backup \n\
i - init fom backup \n\
s - setup\n\
l - train model\n\
p - ci push
c - clean
\n\
Chain em together as you see fit \n\
"
}
APP_ID=rowdybot
current_datetime=$(date '+%Y%m%d_%H%M%S')
filename="backup_$current_datetime.txt"
setup(){
export FILE=$(curl https://storage.googleapis.com/appengine-sdks/ | grep -oP '(?<=featured/)go_appengine_sdk_linux_amd64-[^\<]*' | head -1)
curl -qO https://storage.googleapis.com/appengine-sdks/featured/$FILE
unzip -q $FILE
}
run(){
./go_appengine/goapp serve;
}
try(){
ln -sf `pwd`/bot go_appengine/goroot/src/;
./go_appengine/goapp build ./bot || exit 1;
./go_appengine/goapp test ./tests;
rm `pwd`/go_appengine/goroot/src/bot;
}
deploy(){
echo $PASSWORD | go_appengine/appcfg.py --no_cookies --email=$EMAIL --passin update ./
}
backup(){
go_appengine/appcfg.py download_data --application=$APP_ID --url=http://$APP_ID.appspot.com/_ah/remote_api --filename=backups/$filename --email=$EMAIL;
}
init(){
appcfg.py upload_data --application=$APP_ID --filename=backups/$filename --url=http://localhost:8080/_ah/remote_api --email=$EMAIL;
}
push(){
try || exit 1;
git branch | grep "\*\ [^(master)\]" || {
deploy;
}
}
clean(){
rm -rf go_appengine*;
rm _go_manifest.txt;
rm bulkloader*;
}
train(){
fuser 8080/tcp && {
curl -s http://localhost:8080/flush
echo "\nStarting run:"
while :
do
resp=$(curl -s http://localhost:8080/learn)
test "$resp" = "Stop" && exit 0
echo "$resp"
sleep 300
done
}
}
while getopts "h?rtpsibcldx:" opt; do
case "$opt" in
h|\?)
show_help
;;
s) setup
;;
d) deploy
;;
b) backup
;;
i) init
;;
r) run
;;
t) try
;;
p) push
;;
c) clean
;;
l) train
;;
esac
done