-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_steamcmd.sh
executable file
·39 lines (29 loc) · 1.13 KB
/
install_steamcmd.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
#!/bin/bash
set -o nounset -o errexit -o pipefail
shopt -s inherit_errexit
declare -r STEAMCMD_HOME=/opt/steamcmd
declare -r STEAMCMD_BIN="${STEAMCMD_HOME}/steamcmd.sh"
declare -r STEAMCMD_USER=steam
declare -r STEAMCMD_INSTALLER='https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz'
function main() {
if [[ $EUID -ne 0 ]]; then
echo 'ERROR: script must be run with root privileges.'
exit 1
fi
if [[ "${1:-}" == '--clean' ]]; then
rm -Rf "${STEAMCMD_HOME}"
fi
# necessary dependencies
dpkg --add-architecture i386
apt-get update -q=2 -y
apt-get install -y lib32gcc1 default-jdk-headless libsdl2-2.0-0:i386
# create user if does not exist
getent passwd "${STEAMCMD_USER}" >/dev/null || adduser --system --group --home "${STEAMCMD_HOME}" "${STEAMCMD_USER}"
mkdir -p "${STEAMCMD_HOME}"
# extract steamcmd
wget -nv -O- "${STEAMCMD_INSTALLER}" | tar xzf - --no-same-owner --no-same-permissions -C "${STEAMCMD_HOME}"
chown -R "${STEAMCMD_USER}:${STEAMCMD_USER}" "${STEAMCMD_HOME}"
# perform first run
sudo -u "${STEAMCMD_USER}" -s /bin/bash "${STEAMCMD_BIN}" +login anonymous +quit
}
main "$@"