-
Notifications
You must be signed in to change notification settings - Fork 129
/
Start-Linux.sh
executable file
·236 lines (222 loc) · 7.65 KB
/
Start-Linux.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
#!/bin/bash
exec 0</dev/tty
RED=$(tput setaf 1)
NC=$(tput sgr0) # No Color
function pause() {
read -r -s -n 1 -p "Press any key to continue . . ."
echo ""
}
function start() {
clear
echo ""
echo "OpenRSC: Striving for a replica RSC game and more
What would you like to do?
Choices:
${RED}1${NC} - Compile and start the game
${RED}2${NC} - Start the game (faster if already compiled)
${RED}3${NC} - Change a player's in-game role
${RED}4${NC} - Change a player's name
${RED}5${NC} - Backup database
${RED}6${NC} - Restore database
${RED}7${NC} - Perform a fresh install
${RED}8${NC} - Exit"
echo ""
echo "Type the choice number and press enter."
echo ""
read -r action
clear
if [ "$action" == "1" ]; then # Compile and start the game
echo "Starting OpenRSC."
make compile
pause
echo "What would you like to do?
Choices:
${RED}1${NC} - Start single player edition (launch client and server)
${RED}2${NC} - Start the server only (public hosting)"
read -r start
if [ "$start" == "1" ]; then
make run-server && sleep 5 && make run-client
elif [ "$start" == "2" ]; then
make run-server
fi
clear
pause
start
elif [ "$action" == "2" ]; then # Start the game (faster if already compiled)
echo "What would you like to do?
Choices:
${RED}1${NC} - Start single player edition (launch client and server)
${RED}2${NC} - Start the server only (public hosting)"
read -r start
if [ "$start" == "1" ]; then
make run-server && sleep 5 && make run-client
elif [ "$start" == "2" ]; then
make run-server
fi
echo ""
pause
start
elif [ "$action" == "3" ]; then # Change a player's in-game role
echo "Make sure you are logged out first!"
echo "Type the username of the player you wish to set and press enter."
echo ""
read -r username
clear
echo "What role should the player be set to?
Choices:
${RED}1${NC} - Admin
${RED}2${NC} - Mod
${RED}10${NC} - Player (default)"
read -r group
echo "Type the name of the database where the player is saved."
echo ""
echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
echo ""
echo "The default player database is named preservation."
echo ""
echo ""
read -r db
clear
echo "Which database are you using?
Choices:
${RED}1${NC} - SQLite (default)
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make rank-sqlite db=$db group=$group username=$username
elif [ "$sql" == "2" ]; then
make rank-mariadb db=$db group=$group username=$username
fi
clear
echo "$username has been made group role $group in database $db!"
pause
start
elif [ "$action" == "4" ]; then # Change a player's name
echo "Make sure you are logged out first!"
echo "What existing player should have their name changed?"
echo ""
read -r oldname
echo ""
echo "What would you like to change $oldname's name to?"
echo ""
read -r newname
clear
echo "Type the name of the database where the player is saved."
echo ""
echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
echo ""
echo "The default player database is named preservation."
echo ""
echo ""
read -r db
clear
echo "Which database are you using?
Choices:
${RED}1${NC} - SQLite (default)
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make namechange-sqlite db=$db oldname=$oldname newname=$newname
elif [ "$sql" == "2" ]; then
make namechange-mariadb db=$db oldname=$oldname newname=$newname
fi
clear
echo "$oldname has been renamed to $newname!"
pause
start
elif [ "$action" == "5" ]; then # Backup database
echo "Type the name of the database that you wish to backup."
echo ""
echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
echo ""
echo "The default player database is named preservation."
echo ""
read -r db
clear
echo "Which database are you using?
Choices:
${RED}1${NC} - SQLite (default)
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make backup-sqlite-local db=$db
elif [ "$sql" == "2" ]; then
make backup-mariadb-local db=$db
fi
clear
echo "Database $db backup complete."
pause
start
elif [ "$action" == "6" ]; then # Restore database
echo "==========================================================================="
ls Backups
echo "==========================================================================="
echo ""
echo "Type the filename of the backup file listed above that you wish to restore."
echo "(Copy and paste it exactly, including the .zip file extension)"
echo ""
read -r filename
clear
echo "Which database should this be restored to? (preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
echo ""
read -r db
clear
echo "Which database are you using?
Choices:
${RED}1${NC} - SQLite (default)
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make restore-sqlite-local name=$filename db=$db
elif [ "$sql" == "2" ]; then
make restore-mariadb-local name=$filename db=$db
fi
clear
echo "File $filename was restored to database $db."
echo ""
pause
start
elif [ "$action" == "7" ]; then # Perform a fresh install
clear
echo "Are you ABSOLUTELY SURE that you want to perform a fresh install and reset any existing game databases?"
echo ""
echo "To confirm the database reset, type yes and press enter."
echo ""
read -r confirmwipe
echo ""
if [ "$confirmwipe" == "yes" ]; then
clear
echo "Which database are you using?
Choices:
${RED}1${NC} - SQLite (default)
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make import-authentic-sqlite db=preservation
make import-authentic-sqlite db=openrsc
make import-authentic-sqlite db=uranium
make import-custom-sqlite db=cabbage
make import-custom-sqlite db=coleslaw
make import-custom-sqlite db=openpk
make import-retro-sqlite db=2001scape
elif [ "$sql" == "2" ]; then
make import-authentic-mariadb db=preservation
make import-authentic-mariadb db=openrsc
make import-authentic-mariadb db=uranium
make import-custom-mariadb db=cabbage
make import-custom-mariadb db=coleslaw
make import-custom-mariadb db=openpk
make import-retro-mariadb db=2001scape
fi
else
echo "Error! $confirmwipe is not a valid option."
pause
start
fi
elif [ "$action" == "8" ]; then # Exits
exit
fi
}
while true; do
start
done