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
157 lines (129 loc) · 4.71 KB
/
tf2servers
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
#!/bin/bash
version="Version 0.4"
#lets define some things
home="/home/game"
includes="/includes"
#LA details
user1="game"
host1="la.moevsmachine.tf"
#other server details
user2="game"
host2="gnome.moe"
#start servers
if [ "$1" == "start" ]; then
echo "Erecting a server!"
parallel -k --jobs 5 < "$home$includes/starttf2.sh"
printf "Servers started!"
#stop servers
elif [ "$1" == "stop" ]; then
echo "Timberrrrr! Servers going down!"
parallel -k < "$home$includes/stoptf2.sh"
printf "Servers stopped!"
#update servers
elif [ "$1" == "update" ]; then
echo "Inb4 localisation files, updating servers!"
printf "Stopping the servers" #stop them
parallel -k < "$home$includes/stoptf2.sh"
printf "Running update script" #run the update script
parallel -k --jobs 4 < "$home$includes/updatetf2.sh"
printf "Starting the servers" #start them again
parallel -k --jobs 5 < "$home$includes/starttf2.sh"
#reboot servers
elif [ "$1" == "restart" ]; then
echo "Turn it off and on again"
printf "Stopping the servers" #stop them
parallel -k < "$home$includes/stoptf2.sh"
printf "Starting the servers" #start them again
parallel -k --jobs 5 < "$home$includes/starttf2.sh"
elif [ "$1" == "info" ]; then
if [ "$2" == "local" ]; then
echo "Pulling local stats"
echo ""
echo "Uptime"
uptime
echo ""
echo "File System Usage"
df -h
echo ""
echo "RAM Usage"
free -h
elif [ "$2" == "la" ]; then
echo "Pulling LA 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'
else
echo "Available Options:"
echo ""
echo -e "\tLocal - Local Resource Usages & Uptime"
echo -e "\tLA - Remote Resource Usages & Uptime"
fi
#REMOTE SERVER EXECUTE
#SSH Keys then remote execution?
elif [ "$1" == "la" ]; then
#start remote servers
if [ "$2" == "start" ]; then
echo "Erecting a remote server!"
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
#ssh $user1@$host1 'bash -s' < script.sh
#parallel -k < "$home$includes/starttf2.sh"
printf "Remote servers started!"
#stop remote servers
elif [ "$2" == "stop" ]; then
echo "Timberrrrr! Servers going down!"
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
#parallel -k < "$home$includes/stoptf2.sh"
printf "Remote servers stopped!"
#update remote servers
elif [ "$2" == "update" ]; then
echo "Inb4 remote localisation files, updating servers!"
printf "Stopping the remote servers" #stop them
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
#parallel -k < "$home$includes/stoptf2.sh"
printf "Running the remote update script" #run the update script
ssh $user1@$host1 'parallel -k < "/home/game/includes/updatetf2.sh"'
#parallel -k --jobs 4 < "$home$includes/updatetf2.sh"
printf "Starting the remote servers" #start them again
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
#parallel -k --jobs 5 < "$home$includes/starttf2.sh"
#reboot remote servers
elif [ "$2" == "restart" ]; then
echo "Turn it off and on again, remotely!"
printf "Stopping the remote servers" #stop them
ssh $user1@$host1 'parallel -k < "/home/game/includes/stoptf2.sh"'
#parallel -k < "$home$includes/stoptf2.sh"
printf "Starting the remote servers" #start them again
ssh $user1@$host1 'parallel -k < "/home/game/includes/starttf2.sh"'
#parallel -k --jobs 5 < "$home$includes/starttf2.sh"
else
echo "Available Options:"
echo ""
echo -e "\tStart - start all REMOTE TF2 servers"
echo -e "\tStop - stop all REMOTE TF2 servers"
echo -e "\tUpdate - update all REMOTE TF2 servers"
echo -e "\tRestart - restart all REMOTE TF2 servers"
fi
#print options
else
echo ""
echo "Available Options:"
echo ""
echo -e "\tStart - start all LOCAL TF2 servers"
echo -e "\tStop - stop all LOCAL TF2 servers"
echo -e "\tUpdate - update all LOCAL TF2 servers"
echo -e "\tRestart - restart all LOCAL TF2 servers"
echo -e "\tInfo - Pull Local & Remote Uptime, Disk usage, memory usage & load average"
echo -e "\tla - Push remote commands"
echo ""
echo "$version"
echo ""
fi
#echo ""
#echo $(date '+%d %b %Y %H:%M:%S')."- Complete";
#echo "-----"