-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathinstall.sh
executable file
·154 lines (136 loc) · 5.4 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
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
#!/usr/bin/env bash
##################################################################################
# #
# Installs CSGO Server Launcher #
# #
# Copyright (C) 2012-2025 CrazyMax #
# #
# Counter-Strike : Global Offensive Server Launcher is free software; you can #
# redistribute it and/or modify it under the terms of the GNU Lesser General #
# Public License as published by the Free Software Foundation, either version 3 #
# of the License, or (at your option) any later version. #
# #
# Counter-Strike : Global Offensive Server Launcher is distributed in the hope #
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied #
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with this program. If not, see http://www.gnu.org/licenses/. #
# #
# Website: https://github.com/crazy-max/csgo-server-launcher #
# #
##################################################################################
# Check distrib
if ! command -v apt-get >/dev/null 2>/dev/null; then
echo "ERROR: OS distribution not supported..."
exit 1
fi
# Check root
if [ "$EUID" -ne 0 ]; then
echo "ERROR: Please run this script as root..."
exit 1
fi
# Install dependencies
echo "Installing dependencies..."
if ! dpkg --add-architecture i386 >/dev/null; then
echo "ERROR: Cannot add i386 architecture..."
exit 1
fi
apt-get update >/dev/null
allpkgs=("curl" "dnsutils" "gdb" "screen" "tar" "lib32gcc1" "lib32gcc-s1" "lib32stdc++6" "lib32z1" "libsdl2-2.0-0:i386")
instpkgs=""
for p in "${allpkgs[@]}"; do
if [ -n "$(apt-cache madison $p 2>/dev/null)" ]; then
instpkgs="$instpkgs $p"
fi
done
if ! apt-get install -q -y $instpkgs; then
echo "ERROR: Cannot install packages..."
exit 1
fi
: "${CSGOSL_VERSION=v1.18.0}"
: "${CSGOSL_DOWNLOAD_URL=https://github.com/crazy-max/csgo-server-launcher/releases/download/$CSGOSL_VERSION}"
: "${CSGOSL_BASE_DIR=}"
### Vars
version=$CSGOSL_VERSION
downloadUrl=$CSGOSL_DOWNLOAD_URL
scriptName="csgo-server-launcher"
scriptPath="/etc/init.d/$scriptName"
confPath="/etc/csgo-server-launcher/csgo-server-launcher.conf"
steamcmdPath="/var/steamcmd"
user="steam"
ipAddress=$(dig -4 +short myip.opendns.com @resolver1.opendns.com)
if [ -z "$ipAddress" ]; then
echo "ERROR: Cannot retrieve your public IP address..."
exit 1
fi
### Start
echo ""
echo "Starting CSGO Server Launcher install (${version})..."
echo ""
if [ -n "$CSGOSL_BASE_DIR" ]; then
echo "Copying CSGO Server Launcher script..."
if ! cp -f "$CSGOSL_BASE_DIR/csgo-server-launcher.sh" "$scriptPath"; then
echo "ERROR: Cannot copy CSGO Server Launcher script..."
exit 1
fi
else
echo "Downloading CSGO Server Launcher script..."
if ! curl -sSLk "${downloadUrl}/csgo-server-launcher.sh" -o ${scriptPath}; then
echo "ERROR: Cannot download CSGO Server Launcher script..."
exit 1
fi
fi
if ! chmod +x ${scriptPath}; then
echo "ERROR: Cannot chmod CSGO Server Launcher script..."
exit 1
fi
echo "Install System-V style init script link..."
if ! update-rc.d csgo-server-launcher defaults >/dev/null; then
echo "ERROR: Cannot install System-V style init script link..."
exit 1
fi
mkdir -p /etc/csgo-server-launcher/
if [ -n "$CSGOSL_BASE_DIR" ]; then
echo "Copying CSGO Server Launcher configuration..."
if ! cp -f "$CSGOSL_BASE_DIR/csgo-server-launcher.conf" "$confPath"; then
echo "ERROR: Cannot copy CSGO Server Launcher configuration..."
exit 1
fi
else
echo "Downloading CSGO Server Launcher configuration..."
if [ ! -f $confPath ]; then
if ! curl -sSLk "${downloadUrl}/csgo-server-launcher.conf" -o ${confPath}; then
echo "ERROR: Cannot download CSGO Server Launcher configuration..."
exit 1
fi
fi
fi
echo "Checking $user user exists..."
if ! getent passwd ${user} >/dev/null 2>/dev/null; then
echo "Adding $user user..."
if ! useradd -m ${user}; then
echo "ERROR: Cannot add user $user..."
exit 1
fi
else
mkdir -p ~${user}
fi
echo "Creating $steamcmdPath folder..."
mkdir -p "$steamcmdPath"
chown -R ${user}: "$steamcmdPath"
echo "Updating USER in config file..."
sed "s#USER=\"steam\"#USER=\"$user\"#" -i "$confPath" 1>nul
echo "Updating IP in config file..."
sed "s#IP=\"198.51.100.0\"#IP=\"$ipAddress\"#" -i "$confPath"
echo "Updating DIR_STEAMCMD in config file..."
sed "s#DIR_STEAMCMD=\"/var/steamcmd\"#DIR_STEAMCMD=\"$steamcmdPath\"#" -i "$confPath" 1>nul
echo ""
echo "Done!"
echo ""
echo "DO NOT FORGET to edit the configuration in '$confPath'"
echo "Then type:"
echo " '$scriptPath create' to install steam and csgo"
echo " '$scriptPath start' to start the csgo server!"
echo ""