-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
121 lines (95 loc) · 3.09 KB
/
install.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
#!/bin/bash
enable_zram=false
enable_auto_restart=false
server_port=""
for arg in "$@"
do
case $arg in
--enable-zram)
enable_zram=true
;;
--enable-auto-restart)
enable_auto_restart=true
;;
--server-port=*)
server_port="${arg#*=}"
;;
esac
done
steam_user=steam
log_path=/tmp/pal_server.log
sudo rm /tmp/pal_server.log
if getent passwd "$steam_user" >/dev/null 2>&1; then
echo "User $steam_user exists."
else
echo "User $steam_user does not exist.Adding $steam_user ..."
sudo useradd -m -s /bin/bash $steam_user
fi
steam_user_path=~steam
exec_start="$steam_user_path/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS"
# Apply arguments
current_path=$(dirname "$(readlink -f "$0")")
zram_script_name=zram.sh
zram_script_name="$current_path/$zram_script_name"
echo "ZRAM script name: $zram_script_name"
chmod +x "$zram_script_name"
restart_script_name=restart.sh
restart_script_name="$current_path/$restart_script_name"
echo "Restart script name: $restart_script_name"
chmod +x "$restart_script_name"
if [ "$enable_zram" = true ]; then
echo "Enabling Zram..."
sh "$zram_script_name"
fi
if [ "$enable_auto_restart" = true ]; then
echo "Enabling auto restart on high memory usage..."
sh "$restart_script_name"
fi
if [ ! -z "$server_port" ]; then
echo "PAL server port set to $server_port"
exec_start="$exec_start -port=$server_port"
fi
echo "Installing SteamCMD..."
sudo add-apt-repository multiverse -y > $log_path
sudo dpkg --add-architecture i386 >> $log_path
sudo apt update -y >> $log_path
sudo apt-get remove needrestart -y >> $log_path
echo steam steam/license note '' | sudo debconf-set-selections
echo steam steam/question select "I AGREE" | sudo debconf-set-selections
sudo apt install steamcmd -y >> $log_path
steamcmd_path=$(which steamcmd)
if [ -z "$steamcmd_path" ]; then
echo "Error: Install SteamCMD failed"
exit 1
else
echo "Install SteamCMD successfully"
fi
sudo -u $steam_user mkdir -p $steam_user_path/.steam/sdk64/ >> $log_path
echo "Downloading palServer..."
sudo -u $steam_user $steamcmd_path +login anonymous +app_update 1007 validate +quit >> $log_path
sudo -u $steam_user $steamcmd_path +login anonymous +app_update 2394010 validate +quit >> $log_path
sudo cp $steam_user_path/Steam/steamapps/common/Steamworks\ SDK\ Redist/linux64/steamclient.so $steam_user_path/.steam/sdk64/
systemd_unit=pal-server
cat <<EOF > $systemd_unit.service
[Unit]
Description=$systemd_unit.service
[Service]
Type=simple
User=$steam_user
Restart=on-failure
RestartSec=30s
ExecStart=$exec_start
[Install]
WantedBy=multi-user.target
EOF
sudo mv $systemd_unit.service /usr/lib/systemd/system/
echo "Starting palServer..."
sudo systemctl enable $systemd_unit
sudo systemctl restart $systemd_unit
sudo systemctl -l --no-pager status $systemd_unit
if systemctl --quiet is-active "$systemd_unit"
then
echo -e "\nPalServer is running successfully, enjoy!"
else
echo -e "\nThere were some problems with the installation, please check the log $log_path."
fi