This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtf2servers_v3.sh
238 lines (229 loc) · 8.82 KB
/
tf2servers_v3.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
version="Version 3.1.2"
#requires SSH keys
#requres GNU parallel
#optinal - dos2unix
#server details
user1="game"
host1="uk.moevsmachine.tf"
host2="vps.moevsmachine.tf"
host3="miku.gnome.moe"
echo "Current Filename: $(basename $BASH_SOURCE)"
echo ""
dos2unix $(basename $BASH_SOURCE) #fixes formatting/line ending issues between platforms.
echo ""
#start main funtions
if [ "$1" == "start" ]; then
if [ "$2" == "tf2" ]; then
echo "Starting UK servers."
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
echo "Servers started!"
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
elif [ "$2" == "l4d2" ]; then
echo "Starting the servers" #start them
#ssh $user1@$host1 '/home/game/l4d2_1.sh && sleep 10s && /home/game/l4d2_2.sh && sleep 10s && /home/game/l4d2_3.sh && sleep 10s && /home/game/l4d2_4.sh;'
echo ""
#ssh $user1@$host1 'screen -list | grep "l4d2"'
else
echo "No option selected"
echo -e "\tstart tf2 - Start TF2 servers"
echo -e "\tstart l4d2 - Start L4D2 servers"
fi
#stop servers
elif [ "$1" == "stop" ]; then
if [ "$2" == "tf2" ]; then
echo "Stopping UK servers."
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
echo "Servers stopped!"
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
elif [ "$2" == "l4d2" ]; then
echo "Stopping the servers" #stop them
#ssh $user1@$host1 'screen -S l4d2_1 -X quit; screen -S l4d2_2 -X quit; screen -S l4d2_3 -X quit; screen -S l4d2_4 -X quit'
else
echo "No option selected"
echo -e "\tstop tf2 - Stop TF2 servers"
echo -e "\tstop l4d2 - Stop L4D2 servers"
fi
#update servers
elif [ "$1" == "update" ]; then
if [ "$2" == "tf2" ]; then
echo "Inb4 localisation files, updating servers!"
sleep 5s
echo "Stopping the servers" #stop them
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
echo "Running update script" #run the update script
ssh $user1@$host1 '/home/game/mvmx10_7_machine_attacks update; /home/game/mvmx10_1 update; /home/game/mvmx10_3 update; /home/game/tf2_betamaps update; /home/game/mvmx10_4 update; /home/game/mvmx10_6 update'
echo "Starting the servers" #start them again
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
elif [ "$2" == "l4d2" ]; then
echo "updating L4D2"
sleep 5s
echo "Stopping the servers" #stop them
#ssh $user1@$host1 'screen -S l4d2_1 -X quit; screen -S l4d2_2 -X quit; screen -S l4d2_3 -X quit; screen -S l4d2_4 -X quit'
#echo "Running update script, this will freeze on waiting for user info..." #run the update script
#ssh $user1@$host1 '/home/game/includes/update_l4d2.sh'
echo "Starting the servers" #start them again
#ssh $user1@$host1 '/home/game/l4d2_1.sh && sleep 10s && /home/game/l4d2_2.sh && sleep 10s && /home/game/l4d2_3.sh && sleep 10s && /home/game/l4d2_4.sh;'
echo "Checking status"
#ssh $user1@$host1 'screen -list | grep "l4d2"'
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
else
echo "no option selected"
echo -e "\tupdate tf2 - Update TF2 servers"
echo -e "\tupdate l4d2 - Update L4D2 servers"
fi
#reboot servers
elif [ "$1" == "restart" ]; then
if [ "$2" == "tf2" ]; then
echo "Restarting TF2 servers!"
echo "Stopping the servers" #stop them
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
echo "Starting the servers" #start them again
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
elif [ "$2" == "l4d2" ]; then
echo "Restarting L4D2 severs!"
echo "Stopping the servers" #stop them
#ssh $user1@$host1 'screen -S l4d2_1 -X quit; screen -S l4d2_2 -X quit; screen -S l4d2_3 -X quit; screen -S l4d2_4 -X quit'
echo "Starting L4D2 servers"
#ssh $user1@$host1 '/home/game/l4d2_1.sh && sleep 10s && /home/game/l4d2_2.sh && sleep 10s && /home/game/l4d2_3.sh && sleep 10s && /home/game/l4d2_4.sh;'
echo ""
#ssh $user1@$host1 'screen -list | grep "l4d2"'
else
echo "no option selected"
echo -e "\trestart tf2 - Restart TF2 servers"
echo -e "\trestart l4d2 - Restart L4D2 servers"
fi
#pull system information
elif [ "$1" == "info" ]; then
echo "Pulling UK stats"
echo ""
echo "Uptime"
ssh $user1@$host1 'uptime'
echo ""
echo "File System Usage"
ssh $user1@$host1 'df -h'
echo ""
echo "RAM Usage"
ssh $user1@$host1 'free -h'
echo ""
echo "Pulling running screens"
ssh $user1@$host1 'screen -list'
#start ALL core servers/services
elif [ "$1" == "startup" ]; then
echo "Starting Hlstatsx"
echo ""
ssh $user1@$host1 '/home/game/statsscripts/run_hlstats start'
echo "Starting TF2 Discord bot"
echo ""
ssh $user1@$host1 '/home/game/start_discord.sh'
# echo "Starting L4D2 Discord bot"
#echo ""
#ssh $user1@$host1 '/home/game/start_l4d2_chat.sh'
#ssh $user1@$host1 'screen -list | grep "discord"'
#echo "Starting Minecraft Server"
#echo ""
#ssh $user1@$host1 'cd /home/game/minecraft6/ && ./startmc.sh'
echo "Starting TF2 Servers."
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
echo "Servers started!"
echo ""
#echo "Starting Insurgency servers"
#ssh $user1@$host1 '/home/game/insserver start; /home/game/insserver_1 start'
#echo ""
echo "Starting L4D2 servers"
#ssh $user1@$host1 '/home/game/l4d2_1.sh && sleep 10s && /home/game/l4d2_2.sh && sleep 10s && /home/game/l4d2_3.sh && sleep 10s && /home/game/l4d2_4.sh;'
#ssh $user1@$host1 'screen -list'
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
#stop ALL core servers/services
elif [ "$1" == "shutdown" ]; then
echo "Stopping TF2 Discord bot"
echo ""
ssh $user1@$host1 'screen -S discordbot -X quit'
echo "Stopping L4D2 Discord bot"
echo ""
ssh $user1@$host1 'screen -S l4d2_discordbot -X quit'
echo "Stopping Minecraft Server"
echo ""
ssh $user1@$host1 'screen -S minecraft -p 0 -X stuff "stop^M"'
#echo "REQUIRES MANUAL SHUTDOWN"
echo "Stopping TF2 Servers."
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
echo "Servers down!"
echo ""
#echo "Stopping Insurgency servers"
#ssh $user1@$host1 '/home/game/insserver stop; /home/game/insserver_1 stop'
echo "Stopping the L4D2 servers" #stop them
#ssh $user1@$host1 'screen -S l4d2_1 -X quit; screen -S l4d2_2 -X quit; screen -S l4d2_3 -X quit; screen -S l4d2_4 -X quit'
echo "Servers down!"
echo ""
echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
echo "-----"
elif [ "$1" == "mirror" ]; then
echo "Mirror Information"
echo ""
read -p 'VPS Login: ' user2
read -sp 'VPS Password: ' user2pass
echo ""
echo ""
echo "Uptime"
sshpass -p $user2pass ssh $user2@$host2 'uptime'
#pword, port, user, host, permissions1
echo ""
echo "File System Usage"
sshpass -p $user2pass ssh $user2@$host2 'df -h'
echo ""
echo "RAM Usage"
sshpass -p $user2pass ssh $user2@$host2 'free -h'
#Proxmox Host
#elif [ "$1" == "host" ]; then
# echo "Host Information"
# echo ""
# read -p 'Host Login: ' user3
# read -sp 'Host Password: ' user3pass
# port="8222"
# echo ""
# echo ""
# echo "Uptime"
# sshpass -p $user3pass ssh -p $port $user3@$host3 'uptime'
# #pword, port, user, host, permissions1
# echo ""
# echo "File System Usage"
# sshpass -p $user3pass ssh -p $port $user3@$host3 'df -h'
# echo ""
# echo "RAM Usage"
# sshpass -p $user3pass ssh -p $port $user3@$host3 'free -h'
#print options
else
echo ""
echo "Available Options:"
echo ""
echo -e "\tStart - Start servers"
echo -e "\tStop - Stop servers"
echo -e "\tUpdate - Update servers"
echo -e "\tRestart - Restart servers"
echo -e "\tInfo - Pull local disk usage, memory usage & load average"
echo -e "\tStartup - Start all core servers/services"
echo -e "\tShutdown - Stop all core servers/services"
echo -e "\tMirror - Pull TF2C mirror information"
echo -e "\tHost - Pull host information - BROKEN"
echo -e "\t"
echo ""
echo "$version"
echo ""
fi
#echo ""
#echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
#echo "-----"