-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate.sh
More file actions
213 lines (192 loc) · 5.24 KB
/
update.sh
File metadata and controls
213 lines (192 loc) · 5.24 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env bash
##################
# Configs #
##################
[ -z $1 ] && time=300 || time=$1
[ $time -gt 60 ] && timetext="$((time / 60)) minutes" || timetext="1 minute"
chat="Server will be down for 30 mins after shutdown for maintenance!" #inform your player that your server entering maintenance!
world1="/root/wow" #directory to your main realm
world2="/root/wow2" #directory to your second realm
sleeptime="320" #shoud be $time + 20 seks
WEBHOOK="https://discord.com/api/webhooks/" #a discord configuration for WebHooks
modules_world1=(
#EDIT to your modules
"$world1/modules/mod-anticheat"
"$world1/modules/mod-multi-client-check"
)
modules_world2=(
#EDIT to your modules
"$world2/modules/mod-account-achievements"
"$world2/modules/mod-anticheat"
"$world2/modules/mod-eluna"
"$world2/modules/mod-pvp-titles"
"$world2/modules/mod-autobalance"
"$world2/modules/mod-guildhouse"
"$world2/modules/mod-reward-played-time"
"$world2/modules/mod-cfbg"
"$world2/modules/mod-transmog"
"$world2/modules/mod-weekend-xp"
"$world2/modules/mod-ah-bot"
"$world2/modules/mod-duel-reset"
"$world2/modules/mod-multi-client-check"
)
# Function to send notification to the realm
send_notification_world() {
tmux send-keys -t world ".nameannounce $chat" ENTER \;
if [[ $? -ne 0 ]]; then
echo "Aunnonceis not send!"
exit $?
fi
echo "Notification for maintenance sent successfully!"
}
send_notification_world2() {
tmux send-keys -t world2 ".nameannounce $chat" ENTER \;
if [[ $? -ne 0 ]]; then
echo "Aunnonceis not send!"
exit $?
fi
echo "Notification for maintenance sent successfully!"
}
# Function to update modules for the realm
update_modules_world() {
for module in "${modules_world1[@]}"
do
cd $module
git pull
if [[ $? -ne 0 ]]; then
echo "Git pull error, check log files!"
exit $?
fi
echo "Downloading updates for $module"
done
}
update_modules_world2() {
for i in "${modules_world2[@]}"; do
cd "$i"
git pull
if [[ $? -ne 0 ]]; then
echo "Git pull error for module $(basename $i), check log files!"
exit $?
fi
echo "Downloading updates for module $(basename $i)!"
done
}
# Function to stop the realm
stop_realm_world() {
tmux send-keys -t world ".server shutdown $time" ENTER \;
if [[ $? -ne 0 ]]; then
echo "Realm is not shutting down, check log files!"
exit $?
fi
echo "Realm will shutdown after $timetext!"
sleep_time=$sleeptime
# Start sleep in background process
sleep $sleep_time &
pid=$!
for ((i=1; i<=sleep_time; i++)); do
percentage=$(( (i*100)/sleep_time ))
printf "\rProgress: [%3d%%]" $percentage
sleep 1
done
# Wait for sleep process to finish
wait $pid
# Continue with the script
echo "The script continues"
tmux kill-session -t auth
tmux kill-session -t world
echo "Blizzlike realm successfully shutdown!"
}
stop_realm_world2() {
tmux send-keys -t world2 ".server shutdown $time" ENTER \;
if [[ $? -ne 0 ]]; then
echo "Realm is not shutting down, check log files!"
exit $?
fi
echo "Realm will shutdown after $timetext!"
sleep_time=$sleeptime
# Start sleep in background process
sleep $sleep_time &
pid=$!
for ((i=1; i<=sleep_time; i++)); do
percentage=$(( (i*100)/sleep_time ))
printf "\rProgress: [%3d%%]" $percentage
sleep 1
done
# Wait for sleep process to finish
wait $pid
# Continue with the script
echo "The script continues"
tmux kill-session -t world2
echo "Second realm successfully shutdown!"
}
###################
# Logs #
###################
current_date=$(date +%Y-%m-%d)
log_path="$HOME/wow/logs/" #Edit the Log folder "Need to be created beaufore you run the script"
log_file="$log_path/update-$current_date.log"
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec &> >(tee -a "$log_file") 2>&1
# Main script
send_notification_world
stop_realm_world
cd $world1
git pull
if [[ $? -ne 0 ]]; then
echo "Git pull error, check log files!"
exit $?
fi
echo "Downloading updates for Blizzlike realm!"
./acore.sh client-data
if [[ $? -ne 0 ]]; then
echo "Client Data update error, check log files!"
exit $?
fi
echo "Downloading Client Data updates for Blizzlike realm!"
update_modules_world
cd $world1
./acore.sh compiler build
if [[ $? -ne 0 ]]; then
echo "Build updates error, check log files!"
exit $?
fi
echo "Build updates finished!"
cd $world1
./start.sh
# Second realm updates
send_notification_world2
stop_realm_world2
cd $world2
git pull
if [[ $? -ne 0 ]]; then
echo "Git pull error, check log files!"
exit $?
fi
echo "Downloading updates for the second realm!"
./acore.sh client-data
if [[ $? -ne 0 ]]; then
echo "Client Data update error, check log files!"
exit $?
fi
echo "Downloading Client Data updates for the second realm!"
update_modules_world2
cd $world2
./acore.sh compiler build
if [[ $? -ne 0 ]]; then
echo "Build updates error, check log files!"
exit $?
fi
echo "Build updates finished!"
cd $world2
./start.sh
sleep 60
###############
## DISCORD ##
###############
cd ~/wow/discord
./discord.sh \
--webhook-url=$WEBHOOK \
--file $log_file \
--username "The Watcher" \
--text "This is an update for $current_date\nPlece take a look for errors!"