Skip to content

Instantly share code, notes, and snippets.

@PatPeter
Last active April 14, 2019 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatPeter/49fdcb73f3cc240d2f57f9f5e7ebc671 to your computer and use it in GitHub Desktop.
Save PatPeter/49fdcb73f3cc240d2f57f9f5e7ebc671 to your computer and use it in GitHub Desktop.
Bootloader and Initialization scripts for Unigamia game servers
#!/bin/bash
servername=
read -p "Please enter the name of the server... " servername
if [ -z $servername ]
then
echo "Server name must be provided!"
exit
fi
serverip=
read -p "Please enter the IP of the server... " serverip
if [ -z $serverip ]
then
echo "Server IP must be provided!"
exit
fi
if [ -e $servername.root.txt ]
then
ssh -i ${servername}.root.txt root@${serverip} 'bash -s' < unigamia.init.sh "$servername"
else
echo "Enter the root password to run the initialization script..."
ssh root@${serverip} 'bash -s' < unigamia.init.sh "$servername"
echo "Enter your password to copy the root RSA key..."
scp root@${serverip}:/root/.ssh/id_rsa .
mv id_rsa ${servername}.root.txt
fi
if [ ! -e $servername.steam.txt ]
then
scp -i ${servername}.root.txt root@${serverip}:/home/steam/.ssh/id_rsa .
mv id_rsa ${servername}.steam.txt
echo $servername.steam.txt has been created.
else
ssh -i ${servername}.steam.txt steam@${serverip} 'echo "Steam user exists and ius capable of logging in!"'
fi
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
# https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value
unameout=`uname -a`
if [[ "$unameout" == "CYGWIN"* ]]
then
# https://www.ssh.com/ssh/putty/linux/puttygen
"/cygdrive/c/Program Files (x86)/PuTTY/puttygen.exe" "${servername}.root.txt" -O private -o "${servername}.root.ppk"
"/cygdrive/c/Program Files (x86)/PuTTY/puttygen.exe" "${servername}.steam.txt" -O private -o "${servername}.steam.ppk"
fi
# TODO: Figure out how to load PuTTY entries into the Windows registry for instant login
#!/bin/bash
if [ -z $1 ]
then
echo "Server name must be provided!"
exit 1
fi
#
# Step 1. Generate RSA ID file for root user
#
if [ ! -e /root/.ssh/id_rsa.pub ]
then
ssh-keygen -f /root/.ssh/id_rsa -t rsa -b 4096 -N ""
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
fi
# Added scp to bootloader file instead
#echo "========== Copy this into $1.root.txt =========="
#cat /root/.ssh/id_rsa
#
# Step 2. Create Steam User
#
steamgrp=`getent group steam`
if [ $? -ne 0 ]
then
addgroup --gid 1000 steam
fi
steamid=`id -u steam 2>/dev/null`
if [ $? -eq 1 ]
then
adduser --uid 1000 --gid 1000 --disabled-password --gecos "" steam
fi
#
# Step 3. Generate RSA ID file for steam user
#
if [ ! -d /home/steam/.ssh ]
then
sudo -u steam mkdir -p /home/steam/.ssh
fi
if [ ! -e /home/steam/.ssh/id_rsa.pub ]
then
sudo -u steam ssh-keygen -f /home/steam/.ssh/id_rsa -t rsa -b 4096 -N ""
sudo -u steam cat /home/steam/.ssh/id_rsa.pub >> /home/steam/.ssh/authorized_keys
fi
#
# Step 4. Set time zone to CST
#
timedatectl set-timezone America/Chicago
timedatectl set-ntp on
#
# Step 5. Install game server dependencies
#
#dpkg --configure -a
#apt-get -y remove steam steamcmd
#apt-get -y autoremove
# https://askubuntu.com/questions/854997/how-to-accept-steam-license-when-installing-steam
# Creates OK prompt which would require debconf just like the options below
# apt -y purge steam steamcmd
# https://askubuntu.com/questions/506909/how-can-i-accept-the-lience-agreement-for-steam-prior-to-apt-get-install/
echo steam steam/question select "I AGREE" | debconf-set-selections
echo steam steam/license note '' | debconf-set-selections
apt -y install steam steamcmd
apt-get -y install screen gdb lib32tinfo5 unzip lrzip mono-complete default-jre mysql-client mysql-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment