mirror of
https://ceregatti.org/git/daniel/dayzdockerserver.git
synced 2025-05-07 06:41:17 +00:00
Continue splitting up the functionality. Only put functions and files that pertain to the container and/or volume.
Set forceSameBuild = 0 because the release build we have, while it works, reports a few revisions behind. WIP getting all this working again.
This commit is contained in:
parent
4cb4a4409d
commit
206c838f9d
4 changed files with 92 additions and 95 deletions
|
@ -104,17 +104,6 @@ check_install(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assemble the workshop variables
|
|
||||||
get_mods(){
|
|
||||||
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
|
||||||
workshoplist=""
|
|
||||||
for i in "${workshopID[@]}"
|
|
||||||
do
|
|
||||||
ID=$(echo ${i} | cut -d: -f1)
|
|
||||||
workshoplist+=" +workshop_download_item "${release_client_appid}" "${ID}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
get_mod_id_by_index(){
|
get_mod_id_by_index(){
|
||||||
# If we were passed a valid mod id, just return it
|
# If we were passed a valid mod id, just return it
|
||||||
if [[ -d "${workshopdir}/${1}" ]]
|
if [[ -d "${workshopdir}/${1}" ]]
|
||||||
|
|
|
@ -7,7 +7,7 @@ maxPlayers = 60; // Maximum amount of players
|
||||||
|
|
||||||
verifySignatures = 2; // Verifies .pbos against .bisign files. (only 2 is supported)
|
verifySignatures = 2; // Verifies .pbos against .bisign files. (only 2 is supported)
|
||||||
|
|
||||||
forceSameBuild = 1; // When enabled, the server will allow the connection only to clients with same the .exe revision as the server (value 0-1)
|
forceSameBuild = 0; // When enabled, the server will allow the connection only to clients with same the .exe revision as the server (value 0-1)
|
||||||
|
|
||||||
disableVoN = 0; // Enable/disable voice over network (value 0-1)
|
disableVoN = 0; // Enable/disable voice over network (value 0-1)
|
||||||
vonCodecQuality = 30; // Voice over network codec quality, the higher the better (values 0-30)
|
vonCodecQuality = 30; // Voice over network codec quality, the higher the better (values 0-30)
|
||||||
|
|
|
@ -13,18 +13,20 @@ SERVER_CFG_DST="${SERVER_PROFILE}/${SERVER_CFG_FILE}"
|
||||||
SERVER_CFG_SRC="${CFG_SRC_FILES}/${SERVER_CFG_FILE}"
|
SERVER_CFG_SRC="${CFG_SRC_FILES}/${SERVER_CFG_FILE}"
|
||||||
|
|
||||||
# Command line parameters except mod, as that is handled separately.
|
# Command line parameters except mod, as that is handled separately.
|
||||||
parameters="-config=${SERVER_CFG_FILE} -port=${port} -freezecheck -BEpath=${SERVER_FILES}/battleye -profiles=${SERVER_PROFILE} -nologs"
|
parameters="-config=${SERVER_CFG_DST} -port=${port} -freezecheck -BEpath=${SERVER_PROFILE}/battleye -profiles=${SERVER_PROFILE} -nologs"
|
||||||
|
|
||||||
# Used to check if dayZ is installed
|
# Used to check if dayZ is installed
|
||||||
SERVER_INSTALL_FILE="${SERVER_FILES}/DayZServer"
|
SERVER_INSTALL_FILE="${SERVER_FILES}/DayZServer"
|
||||||
|
|
||||||
# Workshop. This file will store metadata about what mods are installed.
|
# Workshop. This file will store metadata about what mods are in use in this server instance
|
||||||
WORKSHOP_CFG="${HOME}/workshop.cfg"
|
WORKSHOP_CFG="${HOME}/workshop.cfg"
|
||||||
if [ ! -f "${WORKSHOP_CFG}" ]
|
if [ ! -f "${WORKSHOP_CFG}" ]
|
||||||
then
|
then
|
||||||
touch "${WORKSHOP_CFG}"
|
touch "${WORKSHOP_CFG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
INSTALLED_MODS="${SERVER_FILES}/workshop.cfg"
|
||||||
|
|
||||||
# An array to store Workshop items. Each element contains the mod's ID, name, and state (active or not).
|
# An array to store Workshop items. Each element contains the mod's ID, name, and state (active or not).
|
||||||
declare -a workshopID
|
declare -a workshopID
|
||||||
workshopfolder="${SERVER_FILES}/steamapps/workshop/content/${release_client_appid}"
|
workshopfolder="${SERVER_FILES}/steamapps/workshop/content/${release_client_appid}"
|
||||||
|
@ -91,60 +93,6 @@ report() {
|
||||||
echo -e "========================================== End log ======================================${default}"
|
echo -e "========================================== End log ======================================${default}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensures all is installed and ready before allowing operations that depends on things being ready.
|
|
||||||
# Installs the initial server config file from its template.
|
|
||||||
# Handles the importing of changes to that template.
|
|
||||||
# Installs the initial Battleye RCON config.
|
|
||||||
loadconfig(){
|
|
||||||
# check_install
|
|
||||||
# Handle the initial server configuration file
|
|
||||||
if [ ! -f ${SERVER_CFG_DST} ]
|
|
||||||
then
|
|
||||||
echo "Creating initial server configuration file"
|
|
||||||
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
|
||||||
fi
|
|
||||||
# battleye config and rconpassword setup
|
|
||||||
# The server creates a new file from this file, which it then uses.
|
|
||||||
# Let's make sure to delete it first
|
|
||||||
BE_SERVER_FILE="${SERVER_FILES}/battleye/beserver_x64.cfg"
|
|
||||||
ALT_BE_SERVER_FILE=$(find ${SERVER_FILES}/battleye -name "beserver_x64_active*")
|
|
||||||
if [ ! -f "${BE_SERVER_FILE}" ] && [ ! -f "${ALT_BE_SERVER_FILE}" ]
|
|
||||||
then
|
|
||||||
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 rcon'."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
cat > "${BE_SERVER_FILE}" <<EOF
|
|
||||||
RConPassword ${passwd}
|
|
||||||
RestrictRCon 0
|
|
||||||
RConPort ${rcon_port}
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
printf "[ ${cyan}INFO${default} ] New RCON password: ${yellow}${passwd}${default}\n"
|
|
||||||
else
|
|
||||||
if [ -f "${BE_SERVER_FILE}" ]
|
|
||||||
then
|
|
||||||
FILE="${BE_SERVER_FILE}"
|
|
||||||
elif [ -f "${ALT_BE_SERVER_FILE}" ]
|
|
||||||
then
|
|
||||||
FILE="${ALT_BE_SERVER_FILE}"
|
|
||||||
fi
|
|
||||||
passwd=$(grep RConPassword ${FILE} | awk '{print $2}')
|
|
||||||
# printf "[ ${cyan}INFO${default} ] Using existing RCON password: ${yellow}${passwd}${default}\n"
|
|
||||||
fi
|
|
||||||
cp /usr/local/py3rcon/configexample.json ~/py3rcon.config.json
|
|
||||||
jq --arg port 2303 --arg rcon_password b0fNIBVfkM \
|
|
||||||
'.logfile="py3rcon.log" | .loglevel=0 | .server.port=$port | .server.rcon_password=$rcon_password | del(.repeatMessage)' \
|
|
||||||
/usr/local/py3rcon/configexample.json \
|
|
||||||
> ~/py3rcon.config.json
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start the server in the foreground
|
# Start the server in the foreground
|
||||||
start(){
|
start(){
|
||||||
# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions.
|
# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions.
|
||||||
|
@ -210,6 +158,16 @@ config(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assemble the workshop variables
|
# Assemble the workshop variables
|
||||||
|
get_installed_mods(){
|
||||||
|
mapfile -t installedModsID < "${INSTALLED_MODS}"
|
||||||
|
workshoplist=""
|
||||||
|
for i in "${installedModsID[@]}"
|
||||||
|
do
|
||||||
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
|
workshoplist+=" +workshop_download_item "${release_client_appid}" "${ID}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
get_mods(){
|
get_mods(){
|
||||||
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
||||||
workshoplist=""
|
workshoplist=""
|
||||||
|
@ -284,10 +242,10 @@ activate(){
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
# List mods
|
# List available mods
|
||||||
list(){
|
list(){
|
||||||
# The state may have changed since we started
|
get_installed_mods
|
||||||
get_mods
|
|
||||||
if [[ "${workshopID[@]}" = "" ]]
|
if [[ "${workshopID[@]}" = "" ]]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
|
@ -376,8 +334,8 @@ rcon(){
|
||||||
|
|
||||||
# Display the status of everything
|
# Display the status of everything
|
||||||
status(){
|
status(){
|
||||||
|
loadconfig
|
||||||
INSTALLED="${NO}"
|
INSTALLED="${NO}"
|
||||||
LOGGED_IN="${NO}"
|
|
||||||
RUNNING="${NO}"
|
RUNNING="${NO}"
|
||||||
|
|
||||||
# DayZ Server files installation
|
# DayZ Server files installation
|
||||||
|
@ -385,17 +343,6 @@ status(){
|
||||||
then
|
then
|
||||||
INSTALLED="${YES}"
|
INSTALLED="${YES}"
|
||||||
fi
|
fi
|
||||||
# Logged into Steam
|
|
||||||
if [ -f "${STEAM_LOGIN}" ]
|
|
||||||
then
|
|
||||||
LOGGED_IN="${YES}"
|
|
||||||
if grep -q anonymous "${STEAM_LOGIN}"
|
|
||||||
then
|
|
||||||
ANONYMOUS="${yellow}(as anonymous)${default}"
|
|
||||||
else
|
|
||||||
ANONYMOUS="${green}(not anonymous)${default}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Running or not
|
# Running or not
|
||||||
if pidof DayZServer > /dev/null
|
if pidof DayZServer > /dev/null
|
||||||
then
|
then
|
||||||
|
@ -410,7 +357,9 @@ status(){
|
||||||
# Current parameters
|
# Current parameters
|
||||||
RUNNING="${RUNNING}\nRunning Parameters: $(cat /tmp/parameters)\nRunning mod parameter: $(cat /tmp/mod_command_line)"
|
RUNNING="${RUNNING}\nRunning Parameters: $(cat /tmp/parameters)\nRunning mod parameter: $(cat /tmp/mod_command_line)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mod_cmd
|
mod_cmd
|
||||||
|
|
||||||
MAP="none"
|
MAP="none"
|
||||||
# Map name
|
# Map name
|
||||||
if [[ -f ${SERVER_CFG_DST} ]]
|
if [[ -f ${SERVER_CFG_DST} ]]
|
||||||
|
|
83
web/bin/dz
83
web/bin/dz
|
@ -13,6 +13,8 @@ fi
|
||||||
declare -a workshopID
|
declare -a workshopID
|
||||||
workshopfolder="${SERVER_FILES}/steamapps/workshop/content/${release_client_appid}"
|
workshopfolder="${SERVER_FILES}/steamapps/workshop/content/${release_client_appid}"
|
||||||
|
|
||||||
|
workshoplist=""
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
@ -36,6 +38,60 @@ ${default}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ensures all is installed and ready before allowing operations that depends on things being ready.
|
||||||
|
# Installs the initial server config file from its template.
|
||||||
|
# Handles the importing of changes to that template.
|
||||||
|
# Installs the initial Battleye RCON config.
|
||||||
|
loadconfig(){
|
||||||
|
# check_install
|
||||||
|
# Handle the initial server configuration file
|
||||||
|
if [ ! -f ${SERVER_CFG_DST} ]
|
||||||
|
then
|
||||||
|
echo "Creating initial server configuration file"
|
||||||
|
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
||||||
|
fi
|
||||||
|
# battleye config and rconpassword setup
|
||||||
|
# The server creates a new file from this file, which it then uses.
|
||||||
|
# Let's make sure to delete it first
|
||||||
|
BE_SERVER_FILE="${SERVER_FILES}/battleye/beserver_x64.cfg"
|
||||||
|
ALT_BE_SERVER_FILE=$(find ${SERVER_FILES}/battleye -name "beserver_x64_active*")
|
||||||
|
if [ ! -f "${BE_SERVER_FILE}" ] && [ ! -f "${ALT_BE_SERVER_FILE}" ]
|
||||||
|
then
|
||||||
|
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 rcon'."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
cat > "${BE_SERVER_FILE}" <<EOF
|
||||||
|
RConPassword ${passwd}
|
||||||
|
RestrictRCon 0
|
||||||
|
RConPort ${rcon_port}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
printf "[ ${cyan}INFO${default} ] New RCON password: ${yellow}${passwd}${default}\n"
|
||||||
|
else
|
||||||
|
if [ -f "${BE_SERVER_FILE}" ]
|
||||||
|
then
|
||||||
|
FILE="${BE_SERVER_FILE}"
|
||||||
|
elif [ -f "${ALT_BE_SERVER_FILE}" ]
|
||||||
|
then
|
||||||
|
FILE="${ALT_BE_SERVER_FILE}"
|
||||||
|
fi
|
||||||
|
passwd=$(grep RConPassword ${FILE} | awk '{print $2}')
|
||||||
|
# printf "[ ${cyan}INFO${default} ] Using existing RCON password: ${yellow}${passwd}${default}\n"
|
||||||
|
fi
|
||||||
|
cp /usr/local/py3rcon/configexample.json ~/py3rcon.config.json
|
||||||
|
jq --arg port 2303 --arg rcon_password b0fNIBVfkM \
|
||||||
|
'.logfile="py3rcon.log" | .loglevel=0 | .server.port=$port | .server.rcon_password=$rcon_password | del(.repeatMessage)' \
|
||||||
|
/usr/local/py3rcon/configexample.json \
|
||||||
|
> ~/py3rcon.config.json
|
||||||
|
}
|
||||||
|
|
||||||
# Handle the Steam login information.
|
# Handle the Steam login information.
|
||||||
login(){
|
login(){
|
||||||
loadconfig
|
loadconfig
|
||||||
|
@ -149,29 +205,34 @@ modupdate(){
|
||||||
|
|
||||||
# List mods
|
# List mods
|
||||||
list(){
|
list(){
|
||||||
# The state may have changed since we started
|
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
||||||
get_mods
|
workshoplist=""
|
||||||
|
for i in "${workshopID[@]}"
|
||||||
|
do
|
||||||
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
|
workshoplist+=" +workshop_download_item "${release_client_appid}" "${ID}
|
||||||
|
done
|
||||||
if [[ "${workshopID[@]}" = "" ]]
|
if [[ "${workshopID[@]}" = "" ]]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
X=1
|
X=1
|
||||||
spaces=" "
|
spaces=" "
|
||||||
echo -e "\n ID Name Active URL Size"
|
echo -e "\n ID Name URL Size"
|
||||||
echo "------------------------------------------------------------------------------------------------------------------------"
|
echo "------------------------------------------------------------------------------------------------------------------------"
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
do
|
do
|
||||||
ID=$(echo ${i} | cut -d: -f1)
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
NAME=$(echo ${i} | cut -d: -f2)
|
NAME=$(echo ${i} | cut -d: -f2)
|
||||||
ACTIVE=$(echo ${i} | cut -d: -f3)
|
# ACTIVE=$(echo ${i} | cut -d: -f3)
|
||||||
SIZE=$(du -sh ${SERVER_FILES}/steamapps/workshop/content/221100/${ID} | awk '{print $1}')
|
SIZE=$(du -sh ${SERVER_FILES}/steamapps/workshop/content/221100/${ID} | awk '{print $1}')
|
||||||
if [[ ${ACTIVE} = "1" ]]
|
# if [[ ${ACTIVE} = "1" ]]
|
||||||
then
|
# then
|
||||||
C="${green}"
|
C="${green}"
|
||||||
else
|
# else
|
||||||
C="${red}"
|
# C="${red}"
|
||||||
fi
|
# fi
|
||||||
printf "${C}%.3d %s %.23s %s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ACTIVE} ${ID} ${SIZE}
|
printf "${C}%.3d %s %.23s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ID} ${SIZE}
|
||||||
X=$((X+1))
|
X=$((X+1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -224,8 +285,6 @@ shift || {
|
||||||
usage
|
usage
|
||||||
}
|
}
|
||||||
|
|
||||||
get_mods
|
|
||||||
|
|
||||||
case "${C}" in
|
case "${C}" in
|
||||||
add)
|
add)
|
||||||
add "${@}"
|
add "${@}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue