-
Notifications
You must be signed in to change notification settings - Fork 65
/
docs.sh
122 lines (107 loc) · 1.9 KB
/
docs.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
119
120
121
122
#!/bin/sh
#todo: finish find_screen func to work well
find_screen() {
if screen -ls "$1" | grep -o "^\s*[0-9]*\.$1[ "$'\t'"](" --color=NEVER -m 1 | grep -oh "[0-9]*\.$1" --color=NEVER -m 1 -q >/dev/null; then
screen -ls "$1" | grep -o "^\s*[0-9]*\.$1[ "$'\t'"](" --color=NEVER -m 1 | grep -oh "[0-9]*\.$1" --color=NEVER -m 1 2>/dev/null
return 0
else
return 1
fi
}
isRunning() {
#if screen -list | grep -q "flaxdocs"; then
if find_screen flaxdocs >/dev/null; then
return 1
else
return 0
fi
}
start() {
#if isRunning; then
# echo 'Service already running'
# return 1
#fi
echo 'Starting service...'
screen -d -m -S "flaxdocs" ./serve.sh
#if isRunning; then
echo 'Service started'
#else
# echo 'Cannot start service'
# return 1
#fi
}
stop() {
#if ! isRunning; then
# echo 'Service not running'
# return 1
#fi
echo 'Stopping service...'
screen -X -S flaxdocs quit
echo 'Service stopped'
}
status() {
if isRunning; then
echo 'Service is running'
else
echo 'Service not running'
fi
}
update() {
echo "Updating Flax Docs..."
git pull origin master
git reset --hard origin/master
chmod +x docs.sh
chmod +x serve.sh
}
build() {
echo "Preparing API metadata..."
mono docfx/docfx.exe metadata
echo "Building site..."
mono docfx/docfx.exe build
cp favicon.ico _site/favicon.ico
cp logo.svg _site/logo.svg
cp logo.png _site/logo.png
echo "Done!"
}
# Enter docs root directory
cd "$(dirname "$0")"
# Switch command
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
build)
build
;;
update)
update
;;
rebuild)
stop
update
build
start
;;
refresh)
# Uses prebuilded site from Docs.zip (archive with _site and api folders)
./docs.sh stop
./docs.sh update
rm -rf _site
rm -rf api
unzip -o Docs.zip
./docs.sh start
;;
*)
echo "Usage: $0 {start|stop|status|restart|build|update|refresh}"
esac
exit 0