forked from nathawut1992/ak_oneclick_installer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tsinstall.sh
171 lines (143 loc) · 6.49 KB
/
tsinstall.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
#!/bin/bash
# define colors
RED='\e[0;31m'
GREEN='\e[1;32m'
RC='\e[0m'
# make sure lists are up to date
apt-get -qq update
# install sudo in case it is missing
apt-get -qq install sudo -y
# test for the main folder
if [ -d "/root/ryuu" ] ; then
echo "The folder /root/ryuu already exists, please rename or delete it before running the script."
echo "Delete existing folder? (y/n)"
read INVAR
if [ "$INVAR" != "y" ] && [ "$INVAR" != "Y" ] ; then
exit
fi
rm -rf "/root/ryuu"
fi
mkdir "/root/ryuu" -m 777
cd "/root/ryuu"
# get ip info; select ip
IP=$(ip a | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
if [ "$IP" != "" ] ; then
echo -e "Select your IP:\n1) IP: $IP\n2) Input other IP"
read INVAR
else
INVAR="2"
fi
if [ "$INVAR" = "2" ] ; then
echo "Please enter IP:"
read IP
fi
# select server version
echo -e "Select the version you want to install.\n1) xiaoguai475 - v1249 (recommended)"
read TSVERSION
# make sure start / stop commands are working
sudo apt-get -qq install psmisc -y
# install wget in case it is missing
sudo apt-get -qq install wget -y
# install unzip in case it is missing
sudo apt-get -qq install unzip -y
# install postgresql in case it is missing
sudo apt-get -qq install postgresql -y
POSTGRESQLVERSION=$(psql --version | cut -c 19-20)
# install pwgen in case it is missing
sudo apt-get -qq install pwgen -y
# generate database password
DBPASS=$(pwgen -s 32 1)
# setup postgresql
cd "/etc/postgresql/$POSTGRESQLVERSION/main"
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf
sed -i "s+host all all 127.0.0.1/32 md5+host all all 0.0.0.0/0 md5+g" pg_hba.conf
# change password for the postgres account
sudo -u postgres psql -c "ALTER user postgres WITH password '$DBPASS';"
# ready ip for hexpatch
PATCHIP=$(printf '\\x%02x\\x%02x\\x%02x\n' $(echo "$IP" | grep -o [0-9]* | head -n1) $(echo "$IP" | grep -o [0-9]* | head -n2 | tail -n1) $(echo "$IP" | grep -o [0-9]* | head -n3 | tail -n1))
# set version name
VERSIONNAME="NONE"
# set link to RaGEZONE thread
THREADLINK="NONE"
# make sure that vsyscall is emulate
if [ "$(cat /proc/cmdline | grep vsyscall=emulate)" == "" ] ; then
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"/GRUB_CMDLINE_LINUX_DEFAULT=\"vsyscall=emulate /g" "/etc/default/grub"
sudo update-grub
VSYSCALLWARNING="You have to reboot your system before starting the server, please run ${RED}sudo reboot${RC}"
fi
# --------------------------------------------------
# xiaoguai475 - v1249
# --------------------------------------------------
if [ "$TSVERSION" = 1 ] ; then
cd "/root/ryuu"
wget --no-check-certificate "https://raw.githubusercontent.com/RyuuSlayer/TwinSaga-Oneclick-Installer/master/xiaoguai475_v1249" -O "xiaoguai475_v1249"
chmod 777 xiaoguai475_v1249
. "/root/ryuu/xiaoguai475_v1249"
# config files
wget --no-check-certificate "$MAINCONFIG" -O "config.zip"
unzip "config.zip"
rm -f "config.zip"
sed -i "s/xxxxxxxx/$DBPASS/g" "setup.ini"
# subservers
wget --no-check-certificate --load-cookies "/tmp/cookies.txt" "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$SUBSERVERSID" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$SUBSERVERSID" -O "server.zip" && rm -rf "/tmp/cookies.txt"
unzip "server.zip"
rm -f "server.zip"
sed -i "s/xxxxxxxx/$DBPASS/g" "GatewayServer/setup.ini"
sed -i "s/\x44\x24\x0c\x28\x62\x34/\x44\x24\x0c\x08\x49\x40/g" "MissionServer/MissionServer"
sed -i "s/\x3d\xc0\xa8\xb2/\x3d$PATCHIP/g" "WorldServer/WorldServer"
sed -i "s/\x3d\xc0\xa8\xb2/\x3d$PATCHIP/g" "ZoneServer/ZoneServer"
# Data folder
wget --no-check-certificate --load-cookies "/tmp/cookies.txt" "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$DATAFOLDER" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$DATAFOLDER" -O "data.zip" && rm -rf "/tmp/cookies.txt"
unzip "data.zip" -d "data"
rm -f "data.zip"
# SQL files
wget --no-check-certificate "$SQLFILES" -O "SQL.zip"
unzip "SQL.zip" -d "SQL"
rm -f "SQL.zip"
# set permissions
chmod 777 /root -R
# install postgresql database
service postgresql restart
sed -i "s/^version [0-9]*$//g" /root/ryuu/SQL/sk_schema_alter
sed -i "s/^version [0-9]*$//g" /root/ryuu/SQL/ska_schema_alter
sudo -u postgres psql -c "create database \"ARAccount\" encoding 'SQL_ASCII' template template0;"
sudo -u postgres psql -c "create database \"ARDB1\" encoding 'SQL_ASCII' template template0;"
sudo -u postgres psql -c "create database \"ARMember\" encoding 'SQL_ASCII' template template0;"
sudo -u postgres psql -d ARAccount -c "\i '/root/ryuu/SQL/ska_schema';"
sudo -u postgres psql -d ARAccount -c "\i '/root/ryuu/SQL/ska_schema_alter';"
sudo -u postgres psql -d ARDB1 -c "\i '/root/ryuu/SQL/sk_schema';"
sudo -u postgres psql -d ARDB1 -c "\i '/root/ryuu/SQL/sk_schema_alter';"
sudo -u postgres psql -d ARMember -c "\i '/root/ryuu/SQL/FFMember.bak';"
# remove server setup files
rm -f xiaoguai475_v1249
# setup info
VERSIONNAME="xiaoguai475 - v1249"
CREDITS="xiaoguai475"
THREADLINK="https://forum.ragezone.com/threads/release-x-legend-server-files-ffo-ffo2-aro-djo-dso-sdo.1217568/"
fi
if [ "$VERSIONNAME" = "NONE" ] ; then
# display error
echo -e "${RED}--------------------------------------------------"
echo -e "Installation failed!"
echo -e "--------------------------------------------------"
echo -e "The selected version could not be installed. Please try again and choose a different version.${RC}"
else
# display info screen
echo -e "${GREEN}--------------------------------------------------"
echo -e "Installation complete!"
echo -e "--------------------------------------------------"
echo -e "Server version: $VERSIONNAME"
echo -e "Server IP: $IP"
echo -e "Postgresql version: $POSTGRESQLVERSION"
echo -e "Database user: postgres"
echo -e "Database password: $DBPASS"
echo -e "Server path: /root/ryuu/"
echo -e "Postgresql configuration path: /etc/postgresql/$POSTGRESQLVERSION/main/"
echo -e "Release info / Client download: $THREADLINK"
echo -e "\nMake sure to thank $CREDITS!"
echo -e "\nTo start the server, please run /root/ryuu/start"
echo -e "To stop the server, please run /root/ryuu/stop${RC}"
if [ "$VSYSCALLWARNING" != "" ] ; then
echo -e "\n$VSYSCALLWARNING"
fi
fi