Skip to content

Commit

Permalink
this indetnation?
Browse files Browse the repository at this point in the history
  • Loading branch information
phyzical committed Jul 27, 2024
1 parent 8bae321 commit 41f6993
Showing 1 changed file with 83 additions and 83 deletions.
166 changes: 83 additions & 83 deletions install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,56 @@ BRANCH="master"

# Check if MOD_BRANCH is set and not empty
if [ -n "$MOD_BRANCH" ]; then
BRANCH="$MOD_BRANCH"
BRANCH="$MOD_BRANCH"
fi

CUSTOM_FILES="${CUSTOM_FOLDER:-custom_files}"

# 32 or 64 bit Operating System
# If BITS environment variable is not set, try determine it
if [ -z "$BITS" ]; then
# Determine the operating system architecture
architecture=$(uname -m)

# Set OS_BITS based on the architecture
if [[ $architecture == *"64"* ]]; then
export BITS=64
elif [[ $architecture == *"i386"* ]] || [[ $architecture == *"i686"* ]]; then
export BITS=32
else
echo "Unknown architecture: $architecture"
exit 1
fi
# Determine the operating system architecture
architecture=$(uname -m)

# Set OS_BITS based on the architecture
if [[ $architecture == *"64"* ]]; then
export BITS=64
elif [[ $architecture == *"i386"* ]] || [[ $architecture == *"i686"* ]]; then
export BITS=32
else
echo "Unknown architecture: $architecture"
exit 1
fi
fi

if [[ -z $IP ]]; then
IP_ARGS=""
IP_ARGS=""
else
IP_ARGS="-ip ${IP}"
IP_ARGS="-ip ${IP}"
fi

if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
DISTRO_OS=$NAME
DISTRO_VERSION=$VERSION_ID
# freedesktop.org and systemd
. /etc/os-release
DISTRO_OS=$NAME
DISTRO_VERSION=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
DISTRO_OS=$(lsb_release -si)
DISTRO_VERSION=$(lsb_release -sr)
# linuxbase.org
DISTRO_OS=$(lsb_release -si)
DISTRO_VERSION=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
DISTRO_OS=$DISTRIB_ID
DISTRO_VERSION=$DISTRIB_RELEASE
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
DISTRO_OS=$DISTRIB_ID
DISTRO_VERSION=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
DISTRO_OS=Debian
DISTRO_VERSION=$(cat /etc/debian_version)
# Older Debian/Ubuntu/etc.
DISTRO_OS=Debian
DISTRO_VERSION=$(cat /etc/debian_version)
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
DISTRO_OS=$(uname -s)
DISTRO_VERSION=$(uname -r)
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
DISTRO_OS=$(uname -s)
DISTRO_VERSION=$(uname -r)
fi

echo "Starting on $DISTRO_OS: $DISTRO_VERSION..."
Expand All @@ -67,46 +67,46 @@ echo "With $FREE_SPACE Gb free space..."

# Check root
if [ "$EUID" -ne 0 ]; then
echo "ERROR: Please run this script as root..."
exit 1
echo "ERROR: Please run this script as root..."
exit 1
fi

PUBLIC_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)

if [ -z "$PUBLIC_IP" ]; then
echo "ERROR: Cannot retrieve your public IP address..."
exit 1
echo "ERROR: Cannot retrieve your public IP address..."
exit 1
fi

# Update DuckDNS with our current IP
if [ ! -z "$DUCK_TOKEN" ]; then
echo url="http://www.duckdns.org/update?domains=$DUCK_DOMAIN&token=$DUCK_TOKEN&ip=$PUBLIC_IP" | curl -k -o /duck.log -K -
echo url="http://www.duckdns.org/update?domains=$DUCK_DOMAIN&token=$DUCK_TOKEN&ip=$PUBLIC_IP" | curl -k -o /duck.log -K -
fi

echo "Checking $user user exists..."
getent passwd ${user} 2 >/dev/null &>1
if [ "$?" -ne "0" ]; then
echo "Adding $user user..."
addgroup ${user} &&
adduser --system --home /home/${user} --shell /bin/false --ingroup ${user} ${user} &&
usermod -a -G tty ${user} &&
mkdir -m 777 /home/${user}/cs2 &&
chown -R ${user}:${user} /home/${user}/cs2
if [ "$?" -ne "0" ]; then
echo "ERROR: Cannot add user $user..."
exit 1
fi
echo "Adding $user user..."
addgroup ${user} &&
adduser --system --home /home/${user} --shell /bin/false --ingroup ${user} ${user} &&
usermod -a -G tty ${user} &&
mkdir -m 777 /home/${user}/cs2 &&
chown -R ${user}:${user} /home/${user}/cs2
if [ "$?" -ne "0" ]; then
echo "ERROR: Cannot add user $user..."
exit 1
fi
fi

echo "Checking steamcmd exists..."
if [ ! -d "/steamcmd" ]; then
mkdir /steamcmd && cd /steamcmd || exit
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
mkdir -p /root/.steam/sdk32/
ln -s /steamcmd/linux32/steamclient.so /root/.steam/sdk32/
mkdir -p /root/.steam/sdk64/
ln -s /steamcmd/linux64/steamclient.so /root/.steam/sdk64/
mkdir /steamcmd && cd /steamcmd || exit
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
mkdir -p /root/.steam/sdk32/
ln -s /steamcmd/linux32/steamclient.so /root/.steam/sdk32/
mkdir -p /root/.steam/sdk64/
ln -s /steamcmd/linux64/steamclient.so /root/.steam/sdk64/
fi

chown -R ${user}:${user} /steamcmd
Expand All @@ -116,13 +116,13 @@ chown -R ${user}:${user} /home/${user}

# https://developer.valvesoftware.com/wiki/Command_line_options
sudo -u $user /steamcmd/steamcmd.sh \
+api_logging 1 1 \
+@sSteamCmdForcePlatformType linux \
+@sSteamCmdForcePlatformBitness "$BITS" \
+force_install_dir /home/${user}/cs2 \
+login anonymous \
+app_update 730 \
+quit
+api_logging 1 1 \
+@sSteamCmdForcePlatformType linux \
+@sSteamCmdForcePlatformBitness "$BITS" \
+force_install_dir /home/${user}/cs2 \
+login anonymous \
+app_update 730 \
+quit

cd /home/${user} || exit

Expand Down Expand Up @@ -155,36 +155,36 @@ REGEX_TO_CHECK="^[[:space:]]*Game[[:space:]]*csgo/addons/metamod"

# Check if the line already exists in the file, ignoring spaces
if grep -qE "$REGEX_TO_CHECK" "$FILE"; then
echo "$FILE already patched for Metamod."
echo "$FILE already patched for Metamod."
else
# If the line isn't there, use awk to add it after the pattern
awk -v pattern="$PATTERN" -v lineToAdd="$LINE_TO_ADD" '{
# If the line isn't there, use awk to add it after the pattern
awk -v pattern="$PATTERN" -v lineToAdd="$LINE_TO_ADD" '{
print $0;
if ($0 ~ pattern) {
print lineToAdd;
}
}' "$FILE" >tmp_file && mv tmp_file "$FILE"
echo "$FILE successfully patched for Metamod."
echo "$FILE successfully patched for Metamod."
fi

echo "Starting server on $PUBLIC_IP:$PORT"
# https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers#Command-Line_Parameters
sudo -u $user ./game/bin/linuxsteamrt64/cs2 \
-dedicated \
-console \
-usercon \
-autoupdate \
-tickrate "$TICKRATE" \
"$IP_ARGS" \
-port "$PORT" \
+map de_dust2 \
-maxplayers "$MAXPLAYERS" \
-authkey "$API_KEY" \
+sv_setsteamaccount "$STEAM_ACCOUNT" \
+game_type 0 \
+game_mode 0 \
+mapgroup mg_active \
+sv_lan "$LAN" \
+sv_password "$SERVER_PASSWORD" \
+rcon_password "$RCON_PASSWORD" \
+exec "$EXEC"
-dedicated \
-console \
-usercon \
-autoupdate \
-tickrate "$TICKRATE" \
"$IP_ARGS" \
-port "$PORT" \
+map de_dust2 \
-maxplayers "$MAXPLAYERS" \
-authkey "$API_KEY" \
+sv_setsteamaccount "$STEAM_ACCOUNT" \
+game_type 0 \
+game_mode 0 \
+mapgroup mg_active \
+sv_lan "$LAN" \
+sv_password "$SERVER_PASSWORD" \
+rcon_password "$RCON_PASSWORD" \
+exec "$EXEC"

0 comments on commit 41f6993

Please sign in to comment.