forked from 2009scape/Singleplayer-Edition-Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-linux.sh
executable file
·97 lines (84 loc) · 1.85 KB
/
run-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
#!/bin/bash
#Prompt user with options on what to do
export LD_LIBRARY_PATH=$(pwd)/database/lib
echo "What would you like to do? (Type a number)"
echo "1. Run the game."
echo "2. Initialize the database. (Only has to be done once!)"
echo "3. Reset the database."
echo "4. Grant a player admin rights."
read -r playerChoice
initDB() {
cd database
if [ ! -d ./data ]; then
mkdir ./data
fi
bin/mysqld --console --skip-grant-tables --lc-messages-dir="./share/" --datadir="./data" &
sleep 5
echo | bin/mysql -u root -e "CREATE DATABASE global;"
echo | bin/mysql -u root global < ../data/global.sql
sleep 10
killall mysqld
copy_cache
sleep 3
clear
echo "Database initialized, you can now run the game!"
}
copy_cache(){
# shellcheck disable=SC2164
cd database
if [ ! -d "$HOME/.runite_rs/runescape " ]; then
mkdir "$HOME/.runite_rs"
mkdir "$HOME/.runite_rs/runescape"
fi
cd ..
pwd
cp -f data/cache/* "$HOME"/.runite_rs/runescape/
}
run() {
# shellcheck disable=SC2164
cd database
bin/mysqld --console --skip-grant-tables --lc-messages-dir="./share/" --datadir="./data" &
sleep 5
cd ..
java -jar ms.jar &
sleep 1
java -jar server.jar &
sleep 20
java -jar client.jar
killall java
killall mysqld
sleep 5
clear
}
reset_db(){
# shellcheck disable=SC2164
cd database
rm -fr data
mkdir data
cd ..
initDB
}
set_Admin(){
echo "Enter the username for the player: "
read -r USERNAME
cd database
bin/mysqld --console --skip-grant-tables --lc-messages-dir="./share/" --datadir="./data" &
sleep 5
bin/mysql -u root -e "USE global; UPDATE members SET rights=2 WHERE username = '$USERNAME';"
sleep 2
killall mysqld
sleep 3
clear
}
if [ "$playerChoice" = "1" ] ; then
run
fi
if [ "$playerChoice" = "2" ] ; then
initDB
fi
if [ "$playerChoice" = "3" ]; then
reset_db
fi
if [ "$playerChoice" = "4" ]; then
set_Admin
fi