-
Notifications
You must be signed in to change notification settings - Fork 38
/
InstallServer.sh
198 lines (141 loc) · 5.35 KB
/
InstallServer.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
#!/bin/bash
############################
# intitial install section #
############################
#Switch to non-interactive mode (system will not ask for any confirmations)
export DEBIAN_FRONTEND "noninteractive"
#enable 'debug mode'. this will print every command as output, so you can follow the process ;)
set +x
#Update package list from repo
apt update
#Install basics packages without confirmation
# vim is a text editor, wget is to download stuff, software-properties-common will be necessary to add and validate more repo.
apt install -y vim wget software-properties-common
############################
# steamcmd install section #
############################
#Add the multiverse repo (where steam cmd package is located)
add-apt-repository -y multiverse
#Change Architecture instructions to 32bits
dpkg --add-architecture i386
#again update repo packages list to have thoses presents on Multiverse repo
apt update
#Automatic answer to the questions during steam install
echo steam steam/question select "I AGREE" | debconf-set-selections && echo steam steam/license note '' | debconf-set-selections
#Install without prompting the libraries for steamcmd & steamcmd itself
apt install -y lib32z1 lib32gcc-s1 lib32stdc++6 steamcmd
#Create group steam
groupadd steam
#Create steam user, create his home dir & add it to steam group
useradd -m steam -g steam && passwd -d steam
#Change owner of steamcmd sh folder to the user/group
chown -R steam:steam /usr/games
#Create symlink to steamcmd in steam home directory
ln -s /usr/games/steamcmd /home/steam/steamcmd
#Execute steam update
su steam -c "/home/steam/steamcmd +quit"
########################
# wine install section #
########################
#Change architecture instructions to 64bits
dpkg --add-architecture amd64
#Create the local folder who will contain the repos keys
mkdir -pm755 /etc/apt/keyrings
#Add the repo key
wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
#Add the repo
wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
#Again update packages list
apt update
#Install wine
apt install -y --install-recommends winehq-staging
#Install the needed packages to make wine work
apt install -y --allow-unauthenticated cabextract winbind screen xvfb
#Get winetricks
wget -O /usr/local/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
#Make .sh executable
chmod +x /usr/local/bin/winetricks
#Create the init script of whinetricks
touch /home/steam/winetricks.sh
#Write the content of the file
cat << EOF >> /home/steam/winetricks.sh
#!/bin/bash
export DISPLAY=:1.0
Xvfb :1 -screen 0 1024x768x16 &
env WINEDLLOVERRIDES="mscoree=d" wineboot --init /nogui
winetricks corefonts
winetricks sound=disabled
winetricks -q --force vcrun2022
wine winecfg -v win10
rm -rf /home/steam/.cache
EOF
#Make it executable
chmod +x /home/steam/winetricks.sh
#Create Wineprefix directory
mkdir /home/steam/.enshrouded_prefix
########################
# Game Server section #
########################
#Create enshrouded directories
mkdir -p /home/steam/enshrouded
mkdir -p /home/steam/enshrouded/savegame
mkdir -p /home/steam/enshrouded/logs
#Ask for values of the server name, password, number of players
read -p "What is the name of Enshrouded server ?" ENSHROUDED_SERVER_NAME
read -p "What is the password of Enshrouded server ?" ENSHROUDED_SERVER_PASSWORD
read -p "What is the player limit of Enshrouded server (max is 16) ?" ENSHROUDED_SERVER_MAXPLAYERS
#Create config file
touch /home/steam/enshrouded/enshrouded_server.json
#Write the configuration
cat << EOF >> /home/steam/enshrouded/enshrouded_server.json
{
"name": "$(echo $ENSHROUDED_SERVER_NAME)",
"password": "$(echo $ENSHROUDED_SERVER_PASSWORD)",
"saveDirectory": "./savegame",
"logDirectory": "./logs",
"ip": "0.0.0.0",
"gamePort": 15636,
"queryPort": 15637,
"slotCount": $(echo $ENSHROUDED_SERVER_MAXPLAYERS)
}
EOF
#Create service script
touch /home/steam/enshrouded/StartEnshroudedServer.sh
#write the startupscript
cat << EOF >> /home/steam/enshrouded/StartEnshroudedServer.sh
#!/bin/sh
export WINEARCH=win64
#export WINEPREFIX=/home/steam/.enshrouded_prefix
#export WINEDEBUG=-all
wine64 /home/steam/enshrouded/enshrouded_server.exe
EOF
#Make it exectutable
chmod +x /home/steam/enshrouded/StartEnshroudedServer.sh
#Update owner of the steam home folder
chown -R steam:steam /home/steam/
#install server
sudo su steam -c "/home/steam/steamcmd +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/enshrouded +login anonymous +app_update 2278520 +quit"
##########################
# Create service section #
##########################
#déclaration du service
touch /etc/systemd/system/enshrouded.service
cat << EOF >> /etc/systemd/system/enshrouded.service
[Unit]
Description=Enshrouded Server
After=syslog.target network.target
[Service]
ExecStartPre=/usr/games/steamcmd +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/enshrouded +login anonymous +app_update 2278520 +quit
ExecStart=/home/steam/enshrouded/StartEnshroudedServer.sh
User=steam
Group=steam
Type=simple
Restart=on-failure
RestartSec=50s
[Install]
WantedBy=multi-user.target
EOF
#actualisation des services
systemctl daemon-reload
#integration du service au démarrage et lancement du serveur
systemctl enable enshrouded.service