Skip to content

Instantly share code, notes, and snippets.

@andrelug
Last active September 5, 2015 06:44

Revisions

  1. andrelug revised this gist Sep 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blabla
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ fallocate -l 6G /datadrive/swapfile
    chmod 600 /datadrive/swapfile
    mkswap /datadrive/swapfile
    swapon /datadrive/swapfile
    sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
    sh -c 'echo "/datadrive/swapfile none swap sw 0 0" >> /etc/fstab'

    # Increase file usage limit
    echo "increasing file usage limits"
  2. andrelug created this gist Sep 4, 2015.
    116 changes: 116 additions & 0 deletions blabla
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,116 @@
    #!/bin/bash

    # Updating Ubunut
    echo "updating ubunutu... please be patient"
    apt-get update && apt-get upgrade -y

    echo "installing required packages... please be patient"
    apt-get install htop lib32gcc1 -y

    # Create steam user if needed
    echo "creating steam user"
    read -s -p "User Password: " password
    echo
    adduser steam --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
    echo "steam:$password" | chpasswd
    gpasswd -a steam sudo


    # Configure SSH
    echo "configuring ssh"
    port=$((1025 + $RANDOM))
    echo "using port $port"
    file=/etc/ssh/sshd_config
    cp -p $file $file.old &&
    awk '
    $1=="Port" {$2="'$port'"}
    $1=="PermitRootLogin" {$2="no"}
    {print}
    ' $file.old > $file
    service ssh restart

    # Create the swap
    echo "creating swap"
    fallocate -l 6G /datadrive/swapfile
    chmod 600 /datadrive/swapfile
    mkswap /datadrive/swapfile
    swapon /datadrive/swapfile
    sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'

    # Increase file usage limit
    echo "increasing file usage limits"
    sh -c 'echo "* soft nofile 1000000" >> /etc/security/limits.conf'
    sh -c 'echo "* hard nofile 1000000" >> /etc/security/limits.conf'
    sh -c 'echo "session required pam_limits.so" >> /etc/security/limits.conf'

    # Install SteamCMD if needed
    if [ ! -d "/home/steam/steamcmd" ]; then
    echo "installing SteamCMD"
    mkdir /home/steam/steamcmd
    cd /home/steam/steamcmd
    wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
    tar -xvzf steamcmd_linux.tar.gz
    rm steamcmd_linux.tar.gz
    chown -R steam:steam /home/steam/steamcmd
    fi

    # Install ark
    echo "installing ark"
    curl -sL http://git.io/vtf5N | bash -s steam
    su - steam -c "arkmanager install"

    # Configure the server
    # server name
    while true; do
    read -p "ARK Server Name (no special characters): " ark_SessionName
    if ! [[ "$ark_SessionName" =~ [^(a-zA-Z0-9|[:blank])] ]]; then
    if [[ -z "${ark_SessionName// }" ]]; then
    echo "Cannot be empty"
    else
    break
    fi
    else
    echo 'Invalid input!'
    fi
    done


    # server password
    while true; do
    read -p "ARK Server Password (blank for none, no special characters): " ark_ServerPassword
    if ! [[ "$ark_ServerPassword" =~ [^a-zA-Z0-9] ]]; then
    break
    else
    echo 'Invalid input!'
    fi
    done

    # server admin password
    while true; do
    read -p "ARK Server Admin Password (no special characters): " ark_ServerAdminPassword
    if ! [[ "$ark_ServerAdminPassword" =~ [^a-zA-Z0-9] ]]; then
    if [[ -z "${ark_ServerAdminPassword// }" ]]; then
    echo "Cannot be empty"
    else
    break
    fi
    else
    echo 'Invalid input!'
    fi
    done

    file="/etc/arkmanager/arkmanager.cfg"
    tmp_file="/etc/arkmanager/_arkmanager.cfg"
    awk '{gsub("ark_SessionName=\"ARK Server Tools\"", "ark_SessionName=\"'"$ark_SessionName"'\""); print $0}' $file > $tmp_file && mv $tmp_file $file
    awk '{gsub("ark_ServerPassword=\"\"", "ark_ServerPassword=\"'"$ark_ServerPassword"'\""); print $0}' $file > $tmp_file && mv $tmp_file $file
    awk '{gsub("ark_ServerAdminPassword=\"keyboardcat\"", "ark_ServerAdminPassword=\"'"$ark_ServerAdminPassword"'\""); print $0}' $file > $tmp_file && mv $tmp_file $file
    awk '{gsub("ark_MaxPlayers=\"70\"", "ark_MaxPlayers=\"10\""); print $0}' $file > $tmp_file && mv $tmp_file $file
    su - steam -c "arkmanager start"

    echo "installation finished, please note the following important information"
    echo "ssh port: $port"
    echo "ssh user: steam"
    echo "ssh user password: $password"
    echo "ark server name: $ark_SessionName"
    echo "ark server password: $ark_ServerPassword"
    echo "ark server admin password: $ark_ServerAdminPassword"