Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Forked from Rhagnur/rustServerScript.sh
Created January 8, 2016 00:18
Show Gist options
  • Save CodeBrauer/3cda61e190dbe84b1b2a to your computer and use it in GitHub Desktop.
Save CodeBrauer/3cda61e190dbe84b1b2a to your computer and use it in GitHub Desktop.
Angepasstes Skript um Rust Server auf Linux zum laufen zu bekommen
#!/bin/bash
#command to manually start if you want to close this script (do it in screen)
#xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' wine RustDedicated.exe -batchmode +rcon.ip 0.0.0.0 +rcon.port "48000" +rcon.password killer +server.hostname "-LINUX RUST-US-Pro Admins-NO WIPE-NEWBS WELCOM-" +server.port "28015" +server.identity "nfo_rust_server1" +server.maxplayers "2000"
#####################################################################################
# Linux script for Rust server installing. #
# Can also be used to update Rust server and steamcmd. #
# Starts a rust server at the end. #
# #
# If you use a sudoers file please execute this command first to get root access: #
# sudo -s #
# Modded by GregTampa #
# Original by Unknown_Energy #
#####################################################################################
#######################################
# define some variables first: #
# please change it to your needs! <-- #
#######################################
#directory where everything will be saved
data_directory="/home/jan"
#steamname and steamid are need for setting an owner of rust server
owner_name="MaxMusterman"
owner_steamid="123456789"
#some setting for rust server
server_hostname="Test Server"
server_port=28015
server_identity="nfo_rust_server1"
server_maxplayers=50
rcon.port=48010
rcon.password="password123"
#####################################################################
# first install dialog and show some dialogs with questions: #
#####################################################################
apt-get install dialog
dialog --backtitle Question --title "Rust-Server" --yesno "Do you want to install/update wine and some libs?" 15 60
update_wine=${?}
dialog --backtitle Question --title "Rust-Server" --yesno "Do you want to install/update SteamCMD?" 15 60
update_steamcmd=${?}
dialog --backtitle Question --title "Rust-Server" --yesno "Do you want to install/update Rust-Server?" 15 60
update_rust=${?}
dialog --backtitle Question --title "Rust-Server" --yesno "Do you want to set serverowner?" 15 60
set_owner=${?}
dialog --backtitle Question --title "Rust-Server" --yesno "Do you want start the server?" 15 60
start_server=${?}
#####################################################################
# installs wine, other needed libs and creats "steam" user: #
#####################################################################
if [ "$update_wine" -eq "0" ]
then
#adds the wine repo
add-apt-repository -y ppa:ubuntu-wine/ppa
#makes a update
apt-get -y update
#installs the lib needed for steamcmd + xvfb for window mode of rust + wine
apt-get install -y lib32gcc1 libc6-amd64 xvfb wine1.7
fi
#####################################################################
# updates steamcmd: #
#####################################################################
if [ "$update_steamcmd" -eq "0" ]
then
#first makes directory called steamcmd/ and then downloads and unpacks steamcmd.
mkdir $data_directory/steamcmd
cd $data_directory/steamcmd
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
rm steamcmd_linux.tar.gz
fi
#####################################################################
# updates rust server: #
#####################################################################
if [ "$update_rust" -eq "0" ]
then
cd $data_directory/steamcmd
#after that steam.sh is executed with some commands: Download windows rust server, login anonymous ...
./steamcmd.sh +@sSteamCmdForcePlatformType windows +login anonymous +force_install_dir $data_directory/rust +app_update 258550 -beta experimental validate +quit
fi
#####################################################################
# sets serverowner: #
#####################################################################
if [ "$set_owner" -eq "0" ]
then
#Creates users.cfg and adds a User as owner of the server, so that this user can execute console commands with (F1 Menu).
mkdir $data_directory/rust/server/$server_identity/cfg/ -p
touch $data_directory/rust/server/$server_identity/cfg/users.cfg
echo "ownerid $owner_steamid $owner_name" > $data_directory/rust/server/$server_identity/cfg/users.cfg
echo "ownerid $owner_steamid2 $owner_name2" > $data_directory/rust/server/$server_identity/cfg/users.cfg
fi
#####################################################################
# starts server: #
#####################################################################
if [ "$start_server" -eq "0" ]
then
wineboot --update
#runs rust.exe in wine
cd $data_directory/rust; WINEARCH=win64 WINEPREFIX=~/.wine64 wine RustDedicated.exe -batchmode +rcon.ip 0.0.0.0 +rcon.port $rcon.port +rcon.password $rcon.password +server.hostname $server_hostname +server.port $server_port +server.identity $server_identity +server.maxplayers $server_maxplayers
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment