-
Notifications
You must be signed in to change notification settings - Fork 5
/
instance.sh
executable file
·198 lines (188 loc) · 5.3 KB
/
instance.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
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
#!/bin/bash
[[ "$WTL_SCRIPT_DEBUG" == "1" ]] && set -x
set -e
if [[ $(basename $0) != "instance.sh" ]] ; then
echo "[istance.sh] Wrong way to execute instance.sh"
echo -e "\e[31mFATAL ERROR \e[0m"
exit 1
fi
cd $(dirname $(realpath $0))
if [[ ! -f "const.sh" ]] ; then
echo "[instance.sh] Error changing directory"
echo -e "\e[31mFATAL ERROR \e[0m"
exit 1
fi
# -------------------------------------------------------------
. ./load-libs.sh
#if [[ ! -f $WTL_CACHE"/wtl-home-last-auto-update" ]] || [[ $(($(date +%s)-$(date +%s -r $WTL_CACHE"/wtl-home-last-auto-update"))) -gt 3300 ]] ; then
# echo "3600 sec from last WikiToLearn Home updates check..."
# $WTL_SCRIPTS/update-home.sh
# touch $WTL_CACHE"/wtl-home-last-auto-update"
# exit
#fi
if [[ $# -eq 0 ]] ; then
$0 help
exit $?
fi
if test -f $WTL_LOCK_FILE ; then
echo "WTLH lockfile ($WTL_LOCK_FILE) exists, this can be due to another process that is using $0 script"
if kill -0 $(cat $WTL_LOCK_FILE) &> /dev/null ; then
echo "The process is running, exit"
exit 1
else
echo "The process is not running"
rm -fv $WTL_LOCK_FILE
fi
fi
echo $$ > $WTL_LOCK_FILE
case $1 in
help)
echo "Please look in the doc/ directory"
;;
create)
$WTL_SCRIPTS/create.sh
;;
start)
$WTL_SCRIPTS/start.sh
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/use-instance.sh
$WTL_SCRIPTS/fix-hosts.sh
;;
first-run)
INITIAL_BACKUP=$WTL_REPO_DIR/DeveloperDump/
if [[ "$2" != "" ]]
then
if test -d "$2"
then
INITIAL_BACKUP="$2"
fi
fi
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/download-all.sh
$WTL_SCRIPTS/download-mediawiki-extensions.sh
$WTL_SCRIPTS/create.sh
$WTL_SCRIPTS/start.sh
$WTL_SCRIPTS/fix-hosts.sh
$WTL_SCRIPTS/backup-restore.sh $INITIAL_BACKUP
$WTL_SCRIPTS/use-instance.sh
$WTL_SCRIPTS/update-db.sh
$WTL_SCRIPTS/mw-import-struct-wikipages.sh
;;
stop)
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/stop.sh
;;
delete)
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/stop.sh
$WTL_SCRIPTS/delete.sh
;;
delete-volumes)
$WTL_SCRIPTS/delete-volumes.sh
;;
delete-full)
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/stop.sh
$WTL_SCRIPTS/delete.sh
$WTL_SCRIPTS/delete-volumes.sh
;;
fix-hosts)
$WTL_SCRIPTS/fix-hosts.sh
;;
update-home)
$WTL_SCRIPTS/update-home.sh
;;
download)
$WTL_SCRIPTS/download-code.sh
$WTL_SCRIPTS/download-mediawiki-extensions.sh
;;
update-docker-container)
$WTL_SCRIPTS/pull-images.sh
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/stop.sh
$WTL_SCRIPTS/delete.sh
$WTL_SCRIPTS/create.sh
$WTL_SCRIPTS/start.sh
$WTL_SCRIPTS/use-instance.sh
$WTL_SCRIPTS/fix-hosts.sh
;;
update-code-and-db)
$WTL_SCRIPTS/download-code.sh
$WTL_SCRIPTS/download-mediawiki-extensions.sh
$WTL_SCRIPTS/pull-images.sh
$WTL_SCRIPTS/unuse-instance.sh
$WTL_SCRIPTS/stop.sh
$WTL_SCRIPTS/delete.sh
$WTL_SCRIPTS/create.sh
$WTL_SCRIPTS/start.sh
$WTL_SCRIPTS/use-instance.sh
$WTL_SCRIPTS/fix-hosts.sh
$WTL_SCRIPTS/update-db.sh
$WTL_SCRIPTS/mw-import-struct-wikipages.sh
;;
devdump-import)
$WTL_SCRIPTS/backup-restore.sh $WTL_REPO_DIR/DeveloperDump/
$WTL_SCRIPTS/update-db.sh
$WTL_SCRIPTS/mw-import-struct-wikipages.sh
;;
devdump-export)
$WTL_SCRIPTS/backup-do.sh
$WTL_SCRIPTS/copy-last-backup-to-devdump.sh
;;
release-do)
$WTL_SCRIPTS/release-procedure.sh
;;
release-clean)
$WTL_SCRIPTS/backup-auto-delete.sh
$WTL_SCRIPTS/unused-instance-stop-delete.sh
$WTL_SCRIPTS/docker-images-delete-old-images.sh
$WTL_SCRIPTS/docker-images-clean.sh
;;
staging)
$WTL_SCRIPTS/release-procedure.sh
$WTL_SCRIPTS/backup-auto-delete.sh
$WTL_SCRIPTS/unused-instance-stop-delete.sh
$WTL_SCRIPTS/docker-images-delete-old-images.sh
$WTL_SCRIPTS/docker-images-clean.sh
;;
dev)
case $2 in
confirm-email)
$WTL_SCRIPTS/mw-confirm-all-email.sh
;;
*)
echo "Dev command not found ($@)"
;;
esac
;;
production)
. $WTL_SCRIPTS/load-productoin-instance.sh
case $2 in
runJobs)
$WTL_SCRIPTS/lang-foreach-php-maintenance.sh runJobs.php
;;
backup-do)
$WTL_SCRIPTS/backup-do.sh
;;
backup-do-quick)
$WTL_SCRIPTS/backup-do-quick.sh
;;
backup-auto-delete)
$WTL_SCRIPTS/backup-auto-delete.sh
;;
mw-dumps-do)
$WTL_SCRIPTS/mw-dumps-do.sh
;;
*)
echo "Production command not found ($@)"
;;
esac
;;
gpg-update)
$WTL_SCRIPTS/git-gpg-check/update-trusted-keys.sh
;;
*)
echo "Command not found ($@)"
;;
esac
rm $WTL_LOCK_FILE