mirror of
https://ceregatti.org/git/daniel/dayzdockerserver.git
synced 2025-05-06 14:21:18 +00:00
Added Steam login step, which is done interactively.
Factor out all the unused stuff from dayzserver. Rework the logic. Started support for workshop items. Updated docs.
This commit is contained in:
parent
6be82b1adc
commit
e7ba76acf7
6 changed files with 94 additions and 368 deletions
47
README.md
47
README.md
|
@ -1,10 +1,15 @@
|
|||
# DayZDockerServer
|
||||
|
||||
A Linux DayZ server in a Docker container. Uses a modified version of https://github.com/thelastnoc/dayz-sa_linuxserver
|
||||
for all the Steam management. More info here https://steamcommunity.com/sharedfiles/filedetails/?id=1517338673.
|
||||
### Caveat Emptor
|
||||
Uses a docker volume for the unprivileged user's home directory, which stores the DayZ server files plus SteamCMD, a
|
||||
utility used to manage Steam content from the command line. This volume can get quite large. Out of the box, as of this
|
||||
writing, DayZ Experimental is at 1.17 and the volume comes to about 1.8G of disk space once all the files are downloaded.
|
||||
|
||||
### Setup
|
||||
### Setup, Build. and Configure
|
||||
|
||||
Edit `files/serverDZ.cfg` and set the server name:
|
||||
Edit `files/serverDZ.cfg` and set the server name (You don't really have to, but you should):
|
||||
|
||||
```
|
||||
hostname = "Something other than Server Name"; // Server name
|
||||
|
@ -13,10 +18,40 @@ Optionally edit `files/beserver_x64.cfg` and set the rcon password:
|
|||
```
|
||||
RConPassword h4CKm3
|
||||
```
|
||||
### Running
|
||||
Build the container, run it, tail the logs:
|
||||
If the above step is not performed, a random rcon password will be generated and output on the first run. It can also be
|
||||
obtained later and reset.
|
||||
|
||||
Add your Steam credentials. This step is necessary if you want to add mods. The vanilla server is installable by setting
|
||||
the steamlogin to `anonymous`. Edit `files/steamlogin` and set the steam username.
|
||||
```
|
||||
steamlogin=your_real_steam_username_or_anonymous
|
||||
```
|
||||
If you choose not to be anonymous, then you must login using your credentials. This is an interactive process that will
|
||||
prompt for the password and Steam Guard code. This only needs to be done once.
|
||||
|
||||
Either way, we must build the container fist:
|
||||
```
|
||||
docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
Now login:
|
||||
```
|
||||
docker-compose run --rm config
|
||||
```
|
||||
### Run
|
||||
Launch the container into the background:
|
||||
```
|
||||
docker-compose up -d dayzserver
|
||||
```
|
||||
Tail the log:
|
||||
```
|
||||
docker-compose logs -f dayzserver
|
||||
```
|
||||
```
|
||||
### Workshop (TODO)
|
||||
* Update/Add/Remove workshop files
|
||||
* Makage -mod= command line
|
||||
### Maintenance (TODO)
|
||||
* Update the server
|
||||
* Restart the server
|
||||
* Rcon to the server?
|
||||
* List current rocn password
|
||||
* Detect changes to config files and propagate them
|
|
@ -5,6 +5,13 @@ volumes:
|
|||
|
||||
services:
|
||||
|
||||
config:
|
||||
build: .
|
||||
command: /files/login.sh
|
||||
volumes:
|
||||
- homedir:/home/user
|
||||
- ./files:/files
|
||||
|
||||
dayzserver:
|
||||
build: .
|
||||
ports:
|
||||
|
|
392
files/dayzserver
392
files/dayzserver
|
@ -1,16 +1,7 @@
|
|||
#!/bin/bash
|
||||
#############################################
|
||||
### THIS IS WORK IN PROGRESS!
|
||||
### DayZ Standalone linuxserver script
|
||||
### maintained by thelastnoc, fork of linuxgsm
|
||||
### contribute as you like
|
||||
#############################################
|
||||
#!/usr/bin/env bash
|
||||
|
||||
version=26
|
||||
appid=1042420
|
||||
dayz_id=221100
|
||||
#stable=223350
|
||||
#exp_branch=1042420
|
||||
|
||||
if [ "${ansi}" != "off" ]; then
|
||||
# echo colors
|
||||
|
@ -27,25 +18,18 @@ if [ "${ansi}" != "off" ]; then
|
|||
creeol="\r\033[K"
|
||||
fi
|
||||
|
||||
fn_checkroot_dayz(){
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
printf "[ ${red}FAIL${default} ] ${yellow}Do NOT run this script as root!\n"
|
||||
printf "\tSwitch to the dayz user!${default}\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
fn_loadconfig_dayz(){
|
||||
source /files/default.cfg
|
||||
# Handle adding the server name from the environment to the serverFZ.cfg file.
|
||||
# Handle adding the server cfg file
|
||||
if [ ! -f ${HOME}/serverfiles/serverDZ.cfg ]
|
||||
then
|
||||
cp /files/serverDZ.cfg "${HOME}/serverfiles/serverDZ.cfg"
|
||||
sed -i "${HOME}/serverfiles/serverDZ.cfg" -e "s/SERVER_NAME/${SERVER_NAME}/"
|
||||
fi
|
||||
}
|
||||
|
||||
fn_create_beconfig(){
|
||||
# Set a random RCON password, unless one's set in the environment
|
||||
if [ -d "${HOME}/serverfiles" ] && [ ! -f "${HOME}/serverfiles/battleye/beserver_x64.cfg" ]
|
||||
if [ -d "${HOME}/serverfiles/battleye" ] && [ ! -f "${HOME}/serverfiles/battleye/beserver_x64.cfg" ]
|
||||
then
|
||||
echo -n "Creating Battle Eye RCON file "
|
||||
cp /files/beserver_x64.cfg "${HOME}/serverfiles/battleye/beserver_x64.cfg"
|
||||
|
@ -53,69 +37,17 @@ fn_loadconfig_dayz(){
|
|||
then
|
||||
RCON_PASSWORD=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c10)
|
||||
echo -e "using random RCON password ${yellow}${RCON_PASSWORD}"
|
||||
sed -i "${HOME}/serverfiles/battleye/beserver_x64.cfg" -e "s/RCON_PASSWORD/${RCON_PASSWORD}/"
|
||||
else
|
||||
echo "using the RCON_PASSWORD already set in files/beserver_x64.cfg."
|
||||
fi
|
||||
sed -i "${HOME}/serverfiles/battleye/beserver_x64.cfg" -e "s/RCON_PASSWORD/${RCON_PASSWORD}/"
|
||||
fi
|
||||
|
||||
# # default config
|
||||
# if [ ! -f "${HOME}/.default.cfg" ]; then
|
||||
# wget -P ${HOME}/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/.default.cfg
|
||||
# fi
|
||||
# source ${HOME}/.default.cfg
|
||||
# # script config
|
||||
# if [ ! -f "${HOME}/.dayzserver.cfg" ] || [ "$(grep dayzparameter ${HOME}/.dayzserver.cfg)" == "" ]; then
|
||||
# cp ${HOME}/.default.cfg ${HOME}/.dayzserver.cfg
|
||||
# fi
|
||||
# source ${HOME}/.dayzserver.cfg
|
||||
# hostname/servername
|
||||
# if [ ! -f "${HOME}/serverfiles/serverDZ.cfg" ]; then
|
||||
# wget -P ${HOME}/serverfiles/ -q https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/serverDZ.cfg
|
||||
# fi
|
||||
# defaultservername=$(grep -rwi ${HOME}/serverfiles/serverDZ.cfg -e 'EXAMPLE NAME')
|
||||
# if [ "${defaultservername}" != "" ]; then
|
||||
# printf "[ ${magenta}SERVER${default} ] Servername is set on default! 'EXAMPLE NAME'\n\n"
|
||||
# read -p "Enter a new Servername: " servername
|
||||
# sed -i "/hostname/ s/EXAMPLE NAME/${servername}/" "${HOME}/serverfiles/serverDZ.cfg"
|
||||
# fi
|
||||
# # battleye config and rconpassword setup
|
||||
# if [ ! -f "${HOME}/serverfiles/battleye/beserver_x64.cfg" ]; then
|
||||
# wget -P ${HOME}/serverfiles/battleye/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/beserver_x64.cfg
|
||||
# passwd=$(openssl rand -base64 8 | tr -dc 'A-Za-z0-9')
|
||||
# if [ "${passwd}" == "" ]; then
|
||||
# passwd=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c10)
|
||||
# fi
|
||||
# if [ "${passwd}" == "" ]; then
|
||||
# printf "[ ${red}FAIL${default} ] Could not generate a passwort for RCON!\nOpen the Battleye config with './dayzserver cfg' and enter '3' to open it."
|
||||
# exit 1
|
||||
# else
|
||||
# sed -i "/RConPassword/ s/CHANGEME/${passwd}/" "${HOME}/serverfiles/battleye/beserver_x64.cfg"
|
||||
# printf "[ ${cyan}INFO${default} ] ${yellow}New "
|
||||
# grep RConPassword ${HOME}/serverfiles/battleye/beserver_x64.cfg
|
||||
# printf "${default}"
|
||||
# fi
|
||||
# fi
|
||||
# # workshop
|
||||
# if [ ! -f "${HOME}/.workshop.cfg" ]; then
|
||||
# wget -P ${HOME}/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/.workshop.cfg
|
||||
# fi
|
||||
}
|
||||
|
||||
fn_status_dayz(){
|
||||
dayzstatus=$(tmux list-sessions -F $(whoami)-tmux 2> /dev/null | grep -Ecx $(whoami)-tmux)
|
||||
}
|
||||
|
||||
fn_start_dayz(){
|
||||
# fn_status_dayz
|
||||
# if [ "${dayzstatus}" == "1" ]; then
|
||||
# printf "[ ${yellow}DayZ${default} ] Server already running.\n"
|
||||
# exit 1
|
||||
# else
|
||||
fn_loadconfig_dayz
|
||||
fn_workshop_mods
|
||||
printf "[ ${green}DayZ${default} ] Starting server...\n"
|
||||
# sleep 0.5
|
||||
fn_loadconfig_dayz
|
||||
# sleep 0.5
|
||||
cd ${HOME}/serverfiles
|
||||
./DayZServer $dayzparameter "$workshop" || (
|
||||
echo
|
||||
|
@ -130,93 +62,13 @@ fn_start_dayz(){
|
|||
echo
|
||||
echo -e "${yellow}========================================== End crash log ======================================"
|
||||
)
|
||||
# tmux new-session -d -x 23 -y 80 -s $(whoami)-tmux ./DayZServer $dayzparameter "$workshop"
|
||||
# sleep 1
|
||||
# cd ${HOME}
|
||||
# date > ${HOME}/.dayzlockfile
|
||||
# fi
|
||||
}
|
||||
|
||||
fn_stop_dayz(){
|
||||
fn_status_dayz
|
||||
if [ "${dayzstatus}" == "1" ]; then
|
||||
printf "[ ${magenta}...${default} ] Stopping Server graceful."
|
||||
# waits up to 60 seconds giving the server time to shutdown gracefuly
|
||||
for seconds in {1..60}; do
|
||||
fn_status_dayz
|
||||
if [ "${dayzstatus}" == "0" ]; then
|
||||
printf "\r[ ${green}OK${default} ] Stopping Server graceful.\n"
|
||||
rm -f ${HOME}/.dayzlockfile
|
||||
break
|
||||
fi
|
||||
printf "\r[ ${magenta}...${default} ] Stopping Server graceful: ${seconds} seconds"
|
||||
tmux send-keys C-c -t $(whoami)-tmux > /dev/null 2>&1
|
||||
sleep 1
|
||||
done
|
||||
fn_status_dayz
|
||||
if [ "${dayzstatus}" != "0" ]; then
|
||||
printf "\n[ ${red}FAIL${default} ] Stopping Server graceful failed. Stop Signal.\n"
|
||||
sleep 2
|
||||
rm -f ${HOME}/.dayzlockfile
|
||||
tmux kill-session -t $(whoami)-tmux
|
||||
#killall -u $(whoami)
|
||||
fi
|
||||
else
|
||||
printf "[ ${yellow}DayZ${default} ] Server not running.\n"
|
||||
fi
|
||||
}
|
||||
|
||||
fn_restart_dayz(){
|
||||
fn_stop_dayz
|
||||
sleep 1
|
||||
fn_start_dayz
|
||||
}
|
||||
|
||||
fn_monitor_dayz(){
|
||||
if [ ! -f ".dayzlockupdate" ]; then
|
||||
fn_status_dayz
|
||||
if [ "${dayzstatus}" == "0" ] && [ -f "${HOME}/.dayzlockfile" ]; then
|
||||
fn_restart_dayz
|
||||
elif [ "${dayzstatus}" != "0" ] && [ -f "${HOME}/.dayzlockfile" ]; then
|
||||
printf "[ ${lightblue}INFO${default} ] Server should be online!\n"
|
||||
else
|
||||
printf "[ ${yellow}INFO${default} ] Don't use monitor to start the server. Use the start command.\n"
|
||||
fi
|
||||
else
|
||||
printf "[ ${yellow}INFO${default} ] Serverfiles being updated\n."
|
||||
fi
|
||||
}
|
||||
|
||||
fn_console_dayz(){
|
||||
printf "[${yellow} Warning ${default}] Press \"CTRL+b\" then \"d\" to exit console.\n Do NOT press CTRL+c to exit.\n\n"
|
||||
sleep 0.1
|
||||
while true; do
|
||||
read -e -i "Y" -p "Continue? [Y/n] " -r answer
|
||||
case "${answer}" in
|
||||
[Yy]|[Yy][Ee][Ss]) tmux a -t $(whoami)-tmux
|
||||
return 0;;
|
||||
[Nn]|[Nn][Oo]) return 1 ;;
|
||||
*) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
fn_steamlogin_dayz(){
|
||||
if [ ! -f "${HOME}/.steamlogin" ]; then
|
||||
wget -P ${HOME}/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/.steamlogin
|
||||
fi
|
||||
source ${HOME}/.steamlogin
|
||||
if [ "${steamlogin}" == "" ]; then
|
||||
printf "\n[ ${magenta}STEAM${default} ] "
|
||||
read -p "Please type in your Steamlogin (username): " steamname
|
||||
sleep 0.5
|
||||
sed -i "/steamlogin/ s/=/=$steamname/" ${HOME}/.steamlogin
|
||||
sleep 0.5
|
||||
source ${HOME}/.steamlogin
|
||||
fi
|
||||
source /files/steamlogin
|
||||
}
|
||||
|
||||
fn_install_dayz(){
|
||||
fn_install_steamcmd(){
|
||||
if [ ! -f "${HOME}/steamcmd/steamcmd.sh" ]; then
|
||||
mkdir ${HOME}/steamcmd &> /dev/null
|
||||
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxf - -C steamcmd
|
||||
|
@ -224,6 +76,9 @@ fn_install_dayz(){
|
|||
else
|
||||
printf "[ ${lightblue}STEAM${default} ] Steamcmd already installed\n"
|
||||
fi
|
||||
}
|
||||
|
||||
fn_install_dayz(){
|
||||
if [ ! -f "${HOME}/serverfiles/DayZServer" ]; then
|
||||
mkdir ${HOME}/serverfiles &> /dev/null
|
||||
mkdir ${HOME}/serverprofile &> /dev/null
|
||||
|
@ -232,13 +87,12 @@ fn_install_dayz(){
|
|||
fn_runvalidate_dayz
|
||||
else
|
||||
printf "[ ${lightblue}DayZ${default} ] The Server is already installed.\n"
|
||||
fn_opt_usage
|
||||
fi
|
||||
}
|
||||
|
||||
fn_runupdate_dayz(){
|
||||
fn_loadconfig_dayz
|
||||
${HOME}/steamcmd/steamcmd.sh +force_install_dir ${HOME}/serverfiles +login "${steamlogin}" +app_update "${appid}" +quit
|
||||
${HOME}/steamcmd/steamcmd.sh +force_install_dir ${HOME}/serverfiles +login "${steamlogin}" +app_update "${appid}" +quit
|
||||
}
|
||||
|
||||
fn_update_dayz(){
|
||||
|
@ -257,42 +111,22 @@ fn_update_dayz(){
|
|||
availablebuild=$(${HOME}/steamcmd/steamcmd.sh +login "${steamlogin}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | sed -n '/branch/,$p' | grep -m 1 buildid | tr -cd '[:digit:]')
|
||||
if [ -z "${availablebuild}" ]; then
|
||||
printf "\r[ ${red}FAIL${default} ] Checking for update: SteamCMD\n"
|
||||
sleep 0.5
|
||||
printf "\r[ ${red}FAIL${default} ] Checking for update: SteamCMD: Not returning version info\n"
|
||||
exit
|
||||
else
|
||||
printf "\r[ ${green}OK${default} ] Checking for update: SteamCMD"
|
||||
sleep 0.5
|
||||
fi
|
||||
# compare builds
|
||||
if [ "${currentbuild}" != "${availablebuild}" ]; then
|
||||
printf "\r[ ${green}OK${default} ] Checking for update: SteamCMD: Update available\n"
|
||||
printf "Update available:\n"
|
||||
sleep 0.5
|
||||
printf "\tCurrent build: ${red}${currentbuild}${default}\n"
|
||||
printf "\tAvailable build: ${green}${availablebuild}${default}\n"
|
||||
printf "\thttps://steamdb.info/app/${appid}/\n"
|
||||
sleep 0.5
|
||||
date > ${HOME}/.dayzlockupdate
|
||||
printf "\nApplying update"
|
||||
for seconds in {1..3}; do
|
||||
printf "."
|
||||
sleep 1
|
||||
done
|
||||
printf "\n"
|
||||
# run update
|
||||
fn_status_dayz
|
||||
if [ "${dayzstatus}" == "0" ]; then
|
||||
fn_runupdate_dayz
|
||||
fn_workshop_mods
|
||||
rm -f ${HOME}/.dayzlockupdate
|
||||
else
|
||||
fn_stop_dayz
|
||||
fn_runupdate_dayz
|
||||
fn_workshop_mods
|
||||
fn_start_dayz
|
||||
rm -f ${HOME}/.dayzlockupdate
|
||||
fi
|
||||
fn_runupdate_dayz
|
||||
fn_workshop_mods
|
||||
else
|
||||
printf "\r[ ${green}OK${default} ] Checking for update: SteamCMD: No update available\n"
|
||||
printf "\nNo update available:\n"
|
||||
|
@ -307,31 +141,20 @@ fn_runvalidate_dayz(){
|
|||
${HOME}/steamcmd/steamcmd.sh +force_install_dir ${HOME}/serverfiles +login "${steamlogin}" +app_update "${appid}" validate +quit
|
||||
}
|
||||
|
||||
fn_validate_dayz(){
|
||||
fn_status_dayz
|
||||
fn_steamlogin_dayz
|
||||
if [ "${dayzstatus}" == "0" ]; then
|
||||
fn_runvalidate_dayz
|
||||
else
|
||||
date > ${HOME}/.dayzlockupdate
|
||||
fn_stop_dayz
|
||||
fn_runvalidate_dayz
|
||||
fn_workshop_mods
|
||||
rm -f ${HOME}/.dayzlockupdate
|
||||
fn_start_dayz
|
||||
fi
|
||||
}
|
||||
|
||||
fn_workshop_mods(){
|
||||
fn_steamlogin_dayz
|
||||
fn_loadconfig_dayz
|
||||
declare -a workshopID
|
||||
workshopfolder="${HOME}/serverfiles/steamapps/workshop/content/221100"
|
||||
workshoplist=""
|
||||
if [ ! -f "${HOME}/.workshop.cfg" ]; then
|
||||
wget -P ${HOME}/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/.workshop.cfg
|
||||
if [ ! -f /files/workshop.cfg ]
|
||||
then
|
||||
echo "No workshop mods..."
|
||||
return
|
||||
else
|
||||
echo "Syncing workshop mods..."
|
||||
fi
|
||||
mapfile -t -s 4 workshopID < "${HOME}/.workshop.cfg"
|
||||
mapfile -t -s 1 workshopID < /files/workshop.cfg
|
||||
# gather mods
|
||||
for i in "${workshopID[@]}"
|
||||
do
|
||||
|
@ -353,172 +176,17 @@ fn_workshop_mods(){
|
|||
fi
|
||||
done
|
||||
if ls ${HOME}/serverfiles/@* 1> /dev/null 2>&1; then
|
||||
printf "\n[ ${green}DayZ${default} ] Copy Key Files from Mods...\n"
|
||||
cp -vu ${HOME}/serverfiles/@*/keys/* "${HOME}/serverfiles/keys/" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
fn_backup_dayz(){
|
||||
fn_status_dayz
|
||||
if [ ! -d "${HOME}/backup" ]; then
|
||||
mkdir ${HOME}/backup &> /dev/null
|
||||
fi
|
||||
missionfolder=$(grep template ${HOME}/serverfiles/serverDZ.cfg | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d \ -f3)
|
||||
if [ "${dayzstatus}" == "0" ]; then
|
||||
printf "[ ${green}DayZ${default} ] Creating backup of Missionfolder: ${cyan}${missionfolder}${default}\n"
|
||||
tar -cf ${HOME}/backup/${missionfolder}-$(date +%Y-%m-%d).tar ${HOME}/serverfiles/mpmissions/${missionfolder}
|
||||
else
|
||||
fn_stop_dayz
|
||||
printf "[ ${green}DayZ${default} ] Creating backup of Missionfolder: ${cyan}${missionfolder}${default}\n"
|
||||
tar -cf ${HOME}/backup/${missionfolder}-$(date +%Y-%m-%d).tar ${HOME}/serverfiles/mpmissions/${missionfolder}
|
||||
sleep 0.5
|
||||
fn_start_dayz
|
||||
fi
|
||||
}
|
||||
|
||||
fn_wipe_dayz(){
|
||||
missionfolder=$(grep template ${HOME}/serverfiles/serverDZ.cfg | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d \ -f3)
|
||||
printf "[ ${red}WARNING${default} ] Wiping Players and reset Central Economy state from...\n"
|
||||
for seconds in {9..0}; do
|
||||
printf "\r\t Selected Mission: ${cyan}${missionfolder}${default} in ${red}"${seconds}"${default} seconds."
|
||||
sleep 1
|
||||
done
|
||||
printf "\n"
|
||||
if [ "${dayzstatus}" == "0" ]; then
|
||||
rm -f ${HOME}/serverfiles/mpmissions/${missionfolder}/storage_1/players.db
|
||||
rm -f ${HOME}/serverfiles/mpmissions/${missionfolder}/storage_1/data/*
|
||||
printf "[ ${yellow}DayZ${default} ] Player.db and Storage-data wiped!\n"
|
||||
else
|
||||
fn_stop_dayz
|
||||
rm -f ${HOME}/serverfiles/mpmissions/${missionfolder}/storage_1/players.db
|
||||
rm -f ${HOME}/serverfiles/mpmissions/${missionfolder}/storage_1/data/*
|
||||
printf "[ ${yellow}DayZ${default} ] Player.db and Storage-data wiped!\n"
|
||||
sleep 0.5
|
||||
fn_start_dayz
|
||||
fi
|
||||
}
|
||||
|
||||
fn_updatescript_dayz(){
|
||||
checkversion=$(curl -s https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/version)
|
||||
if [ ${checkversion} -gt ${version} ]; then
|
||||
wget -P ${HOME}/ -qN https://raw.githubusercontent.com/thelastnoc/dayz-sa_linuxserver/master/script/dayzserver --show-progress
|
||||
chmod u+x dayzserver
|
||||
else
|
||||
printf "No update\n"
|
||||
fi
|
||||
}
|
||||
|
||||
fn_config_dayz(){
|
||||
fn_loadconfig_dayz
|
||||
printf "\nFollowing config Files available!\n\\n\t[${yellow}1${default}] - script\t(.dayzserver.cfg)\n\t[${yellow}2${default}] - serverDZ\t(serverDZ.cfg)\n\t[${yellow}3${default}] - workshop\t(.workshop.cfg)\n\t[${yellow}4${default}] - battleye\t(beserver_x64.cfg)\n\t[${yellow}5${default}] - steamlogin\n\t[${yellow}0${default}] - script-default (read only!)\n\t[${yellow}x${default}] - exit\n\n"
|
||||
read -p "Select the config File: " configfile
|
||||
case "$configfile" in
|
||||
1|script) nano -c ${HOME}/.dayzserver.cfg;;
|
||||
2|server|serverDZ) nano -c ${HOME}/serverfiles/serverDZ.cfg;;
|
||||
3|workshop) nano -c ${HOME}/.workshop.cfg && ./dayzserver ws;;
|
||||
4|battleye) nano -c $(ls ${HOME}/serverfiles/battleye/beserver_x64.cfg);;
|
||||
5|steamlogin) nano -c ${HOME}/.steamlogin;;
|
||||
0|default) nano -cv ${HOME}/.default.cfg;;
|
||||
*) exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_start=( "st;start" "fn_start_dayz" "Start the server." )
|
||||
cmd_stop=( "sp;stop" "fn_stop_dayz" "Stop the server." )
|
||||
cmd_restart=( "r;restart" "fn_restart_dayz" "Restart the server.")
|
||||
cmd_monitor=( "m;monitor" "fn_monitor_dayz" "Check server status and restart if crashed." )
|
||||
cmd_config=( "cfg;config" "fn_config_dayz" "Edit any Config File." )
|
||||
cmd_console=( "c;console" "fn_console_dayz" "Access server console." )
|
||||
cmd_install=( "i;install" "fn_install_dayz" "Install steamcmd and DayZ Server-Files." )
|
||||
cmd_update=( "u;update" "fn_update_dayz" "Check and apply any server updates." )
|
||||
cmd_validate=( "v;validate" "fn_validate_dayz" "Validate server files with SteamCMD." )
|
||||
cmd_workshop=( "ws;workshop" "fn_workshop_mods" "Download Mods from Steam Workshop." )
|
||||
cmd_backup=( "b;backup" "fn_backup_dayz" "Create backup archives of the server (mpmission)." )
|
||||
cmd_wipe=( "wi;wipe" "fn_wipe_dayz" "Wipe your server data (Player and Storage)." )
|
||||
cmd_updatescript=( "us;update-script" "fn_updatescript_dayz" "Update the script." )
|
||||
|
||||
### Set specific opt here ###
|
||||
currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_config[@]}" "${cmd_console[@]}" "${cmd_install[@]}" "${cmd_update[@]}" "${cmd_validate[@]}" "${cmd_workshop[@]}" "${cmd_backup[@]}" "${cmd_wipe[@]}" "${cmd_updatescript[@]}" )
|
||||
|
||||
### Build list of available commands
|
||||
optcommands=()
|
||||
index="0"
|
||||
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
|
||||
cmdamount="$(echo "${currentopt[index]}" | awk -F ';' '{ print NF }')"
|
||||
for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do
|
||||
optcommands+=( "$(echo "${currentopt[index]}" | awk -F ';' -v x=${cmdindex} '{ print $x }')" )
|
||||
done
|
||||
done
|
||||
|
||||
# Shows LinuxGSM usage
|
||||
fn_opt_usage(){
|
||||
printf "\nDayZ 1.15 Exp - Linux Game Server - Version: "${version}""
|
||||
printf "\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=1517338673"
|
||||
printf "\nUsage:${lightblue} $0 [command]${default}\n\n"
|
||||
printf "${lightyellow}Commands${default}\n"
|
||||
# Display available commands
|
||||
index="0"
|
||||
{
|
||||
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
|
||||
# Hide developer commands
|
||||
if [ "${currentopt[index+2]}" != "DEVCOMMAND" ]; then
|
||||
echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t|${currentopt[index+2]}"
|
||||
fi
|
||||
done
|
||||
} | column -s $'\t' -t
|
||||
exit 1
|
||||
printf "\n[ ${green}DayZ${default} ] Copy Key Files from Mods...\n"
|
||||
cp -vu ${HOME}/serverfiles/@*/keys/* "${HOME}/serverfiles/keys/" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Make sure we don't start collecting core files
|
||||
ulimit -c 0
|
||||
|
||||
# start functions
|
||||
fn_checkroot_dayz
|
||||
#fn_checktmux
|
||||
#fn_checkscreen
|
||||
|
||||
# Use an anonymous login for the server files
|
||||
if [ ! -f ${HOME}/.steamlogin ]
|
||||
if [[ ${1} = "start" ]]
|
||||
then
|
||||
echo "steamlogin=anonymous" > ${HOME}/.steamlogin
|
||||
fn_install_dayz
|
||||
fn_create_beconfig
|
||||
fn_start_dayz
|
||||
fi
|
||||
|
||||
getopt=$1
|
||||
if [ ! -f "${HOME}/steamcmd/steamcmd.sh" ] || [ ! -f "${HOME}/serverfiles/DayZServer" ] && [ "${getopt}" != "cfg" ]; then
|
||||
printf "[ ${yellow}INFO${default} ] No installed steamcmd and/or serverfiles found!\n"
|
||||
# chmod u+x ${HOME}/dayzserver
|
||||
fn_install_dayz
|
||||
if [ -f "${HOME}/steamcmd/steamcmd.sh" ] && [ -f "${HOME}/serverfiles/DayZServer" ]; then
|
||||
fn_start_dayz
|
||||
fi
|
||||
echo "Something failed? Shouldn't make it here..."
|
||||
exit
|
||||
else
|
||||
### Check if user commands exist and run corresponding scripts, or display script usage
|
||||
if [ -z "${getopt}" ]; then
|
||||
fn_opt_usage
|
||||
fi
|
||||
fi
|
||||
|
||||
# Command exists
|
||||
for i in "${optcommands[@]}"; do
|
||||
if [ "${i}" == "${getopt}" ] ; then
|
||||
# Seek and run command
|
||||
index="0"
|
||||
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
|
||||
currcmdamount="$(echo "${currentopt[index]}" | awk -F ';' '{ print NF }')"
|
||||
for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do
|
||||
if [ "$(echo "${currentopt[index]}" | awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then
|
||||
# Run command
|
||||
eval "${currentopt[index+1]}"
|
||||
exit 1
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# If we're executing this, it means command was not found
|
||||
echo -e "${red}Unknown command${default}: $0 ${getopt}"
|
||||
fn_opt_usage
|
||||
|
|
14
files/login.sh
Executable file
14
files/login.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ -f ${HOME}/.steamlogin ]
|
||||
then
|
||||
echo "The file .steamlogin already exists. Remove it first then run this again. (See README.md)"
|
||||
exit 1
|
||||
else
|
||||
source /files/dayzserver
|
||||
fn_install_steamcmd
|
||||
echo "Setting up Steam credentials"
|
||||
cp /files/steamlogin "${HOME}/.steamlogin"
|
||||
source "${HOME}/.steamlogin"
|
||||
${HOME}/steamcmd/steamcmd.sh +force_install_dir ${HOME}/serverfiles +login "${steamlogin}" +quit
|
||||
fi
|
1
files/steamlogin
Normal file
1
files/steamlogin
Normal file
|
@ -0,0 +1 @@
|
|||
steamlogin=your_real_steam_username_or_anonymous
|
1
files/workshop.cfg
Normal file
1
files/workshop.cfg
Normal file
|
@ -0,0 +1 @@
|
|||
# Add one id per line
|
Loading…
Add table
Reference in a new issue