-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathragnarok.sh
More file actions
216 lines (196 loc) · 10.1 KB
/
ragnarok.sh
File metadata and controls
216 lines (196 loc) · 10.1 KB
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
#!/bin/bash
MARIADB_ROOT_PASS=ragnarok
RAGNAROK_DATABASE_PASS=ragnarok
RO_PACKET_VER=20121004
##
# install required packages
export NEEDRESTART_MODE=a
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password password $MARIADB_ROOT_PASS"
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password_again password $MARIADB_ROOT_PASS"
sudo apt-get -y update && sudo apt-get upgrade --yes && sudo apt-get -y install net-tools build-essential nginx \
php8.1-fpm zlib1g-dev libpcre3-dev libmariadb-dev libmariadb-dev-compat mariadb-server mariadb-client npm
# grab ip
WAN_IP=`dig @resolver4.opendns.com myip.opendns.com +short`
echo ${WAN_IP}
#
##
##
# configure nginx for php
cd /etc/nginx/sites-available/
sudo mv default default.old
sudo echo "server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files \$uri \$uri/ /index.php\$is_args\$args;
}
location ~ \.php\$ {
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}" > default
sudo chmod 777 -R /etc/nginx/sites-available/
sudo systemctl restart nginx # restart to finalize changes
sudo systemctl restart php8.1-fpm
#
##
##
# clone repo for robrowser and install it - a javascript based web client for ragnarok online
cd /var/www/html/ && sudo git clone https://github.com/MrAntares/roBrowserLegacy.git
#hack to fix equip on 20121004
sudo sed -i 's/if(PACKETVER.value >= 20120925) {/if(PACKETVER.value >= 20130320) {/g' /var/www/html/roBrowserLegacy/src/Network/PacketStructure.js
#
# write the frontend's index.html
sudo echo "
<!DOCTYPE html>
<html>
<head>
<title>Ragnarok</title>
<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=yes\" />
<script type=\"text/javascript\" src=\"roBrowserLegacy/api.js\"></script>
<script type=\"text/javascript\">
function initialize() {
var ROConfig = {
target: document.getElementById(\"robrowser\"),
type: ROBrowser.TYPE.FRAME,
application: ROBrowser.APP.ONLINE,
development: true,
servers: [{
display: \"Demo Server\",
desc: \"roBrowser's demo server\",
address: \"localhost\",
port: 6900,
version: 25,
langtype: 12,
packetver: ${RO_PACKET_VER},
packetKeys: false,
socketProxy: \"ws://${WAN_IP}:5999/\",
adminList: []
}],
skipServerList: true,
skipIntro: true,
};
var RO = new ROBrowser(ROConfig);
RO.start();
}
window.addEventListener(\"load\", initialize, false);
</script>
</head>
<body bgcolor=\"black\" style=\"overflow: hidden;\">
<div id=\"robrowser\" style=\"height:100vh; width:100vw; position: fixed; left: 0; top:0; overflow: hidden;\"></div>
</body>
</html>
" > /var/www/html/index.html
#
##
##
# install wsproxy - forward broadcast traffic to TCP
sudo mkdir /home/ragnarok/
cd /home/ragnarok/
sudo npm install wsproxy -g
#
##
##
# get rathena from github and compile it
sudo mkdir /home/rathena && cd /home/rathena && sudo git clone https://github.com/rathena/rathena.git
# testing a hack somebody provided for rathena's packets
sudo sed -i '48 s/^/\/\/ /' /home/rathena/rathena/src/config/packets.hpp
sudo sed -i '56 s/^/\/\/ /' /home/rathena/rathena/src/config/packets.hpp
# set packetver and compile rathena
cd /home/rathena/rathena
sudo bash /home/rathena/rathena/configure --enable-epoll=yes --enable-prere=no --enable-vip=no --enable-packetver=${RO_PACKET_VER}
sudo make clean && sudo make server
#
##
##
# install ragnarok databases
sudo echo "FLUSH PRIVILEGES;
drop user if exists 'ragnarok'@'localhost';
drop user if exists ragnarok; DROP DATABASE IF EXISTS ragnarok;
create user 'ragnarok'@'localhost' identified by '${RAGNAROK_DATABASE_PASS}';
FLUSH PRIVILEGES;
CREATE DATABASE ragnarok; GRANT ALL ON ragnarok.* TO 'ragnarok'@'localhost';
FLUSH PRIVILEGES;
use ragnarok;
show tables;
source /home/rathena/rathena/sql-files/item_db.sql;
source /home/rathena/rathena/sql-files/item_db_equip.sql;
source /home/rathena/rathena/sql-files/item_db_equip.sql;
source /home/rathena/rathena/sql-files/item_db_etc.sql;
source /home/rathena/rathena/sql-files/item_db_re.sql;
source /home/rathena/rathena/sql-files/item_db_re_equip.sql;
source /home/rathena/rathena/sql-files/item_db_re_etc.sql;
source /home/rathena/rathena/sql-files/item_db2.sql;
source /home/rathena/rathena/sql-files/item_db_re_usable.sql;
source /home/rathena/rathena/sql-files/item_db_usable.sql;
source /home/rathena/rathena/sql-files/item_db2_re.sql;
source /home/rathena/rathena/sql-files/main.sql;
source /home/rathena/rathena/sql-files/mob_db.sql;
source /home/rathena/rathena/sql-files/mob_skill_db.sql;
source /home/rathena/rathena/sql-files/mob_db_re.sql;
source /home/rathena/rathena/sql-files/mob_db2.sql;
source /home/rathena/rathena/sql-files/mob_db2_re.sql;
source /home/rathena/rathena/sql-files/mob_skill_db2_re.sql;
source /home/rathena/rathena/sql-files/mob_skill_db_re.sql;
source /home/rathena/rathena/sql-files/mob_skill_db2.sql;
source /home/rathena/rathena/sql-files/web.sql;
source /home/rathena/rathena/sql-files/roulette_default_data.sql;
source /home/rathena/rathena/sql-files/logs.sql;
" > create_user.sql
sudo mysql < create_user.sql
#
##
##
# set ragnarok database pass in rathena config
sudo sed -i 's/login_server_pw: ragnarok/login_server_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/ipban_db_pw: ragnarok/ipban_db_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/char_server_pw: ragnarok/char_server_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/map_server_pw: ragnarok/map_server_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/web_server_pw: ragnarok/web_server_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/log_db_pw: ragnarok/log_db_pw: '"$RAGNAROK_DATABASE_PASS"'/g' /home/rathena/rathena/conf/login_athena.conf
#
##
##
# rathena QOL changes to configuration
sudo sed -i 's/new_account: no/new_account: yes/g' /home/rathena/rathena/conf/login_athena.conf
sudo sed -i 's/start_point: iz_int,18,26:iz_int01,18,26:iz_int02,18,26:iz_int03,18,26:iz_int04,18,26/start_point: prontera,155,187/g' /home/rathena/rathena/conf/char_athena.conf
sudo sed -i 's/start_point_pre: new_1-1,53,111:new_2-1,53,111:new_3-1,53,111:new_4-1,53,111:new_5-1,53,111/start_point: prontera,155,187/g' /home/rathena/rathena/conf/char_athena.conf
sudo sed -i 's/start_point_doram: lasa_fild01,48,297/start_point: prontera,155,187/g' /home/rathena/rathena/conf/char_athena.conf
sudo sed -i 's/server_name: rAthena/server_name: ragnarok.sh/g' /home/rathena/rathena/conf/char_athena.conf
#
##
##
# enable rathena base custom npcs
sudo sed -i 's/\/\/npc: npc\/custom\/warper.txt/npc: npc\/custom\/warper.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/jobmaster.txt/npc: npc\/custom\/jobmaster.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/platinum_skills.txt/npc: npc\/custom\/platinum_skills.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/healer.txt/npc: npc\/custom\/healer.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/breeder.txt/npc: npc\/custom\/breeder.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/card_seller.txt/npc: npc\/custom\/card_seller.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/itemmall.txt/npc: npc\/custom\/itemmall.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/stylist.txt/npc: npc\/custom\/stylist.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/resetnpc.txt/npc: npc\/custom\/resetnpc.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/card_remover.txt/npc: npc\/custom\/card_remover.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/item_signer.txt/npc: npc\/custom\/item_signer.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
sudo sed -i 's/\/\/npc: npc\/custom\/woe_controller.txt/npc: npc\/custom\/woe_controller.txt/g' /home/rathena/rathena/npc/scripts_custom.conf
#
##
##
#add to crontab so it starts the server on reboot
(crontab -l 2>/dev/null; echo "@reboot sleep 5 && cd /home/rathena/rathena/ && nohup bash athena-start start \&") | crontab -
(crontab -l 2>/dev/null; echo "@reboot sleep 6 && wsproxy -p 5999 -a localhost:6900,localhost:6121,localhost:5121") | crontab -
#
##
##
# start server first time. Note, for further restarts just restart the whole ass server. See that crontab up there? yep.
cd /home/rathena/rathena/
sudo nohup bash athena-start start &
sudo wsproxy -p 5999 -a localhost:6900,localhost:6121,localhost:5121
##