-
-
Save zachskaggs/79b06f9ee502b96b7fceaf71a1cf0a7b to your computer and use it in GitHub Desktop.
DO Ubuntu 14.04 Droplet to ARK Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment