mirror of
https://ceregatti.org/git/daniel/dayzdockerserver.git
synced 2025-05-07 06:41:17 +00:00
Big refactor: Remove all the fn_ crap and normalize whitespace.
This commit is contained in:
parent
5e48a3c3e3
commit
c728c743b7
1 changed files with 250 additions and 276 deletions
526
files/dayzserver
526
files/dayzserver
|
@ -12,17 +12,17 @@ cyan="\e[36m"
|
||||||
|
|
||||||
# Make sure to report and clean up on exit, as these files remain in the container's volume
|
# Make sure to report and clean up on exit, as these files remain in the container's volume
|
||||||
function report() {
|
function report() {
|
||||||
echo
|
echo
|
||||||
echo -e "${yellow}========================================== error.log =========================================="
|
echo -e "${yellow}========================================== error.log =========================================="
|
||||||
find "${HOME}" -name error.log -exec head {} \; -exec tail {} \; -exec rm -f {} \;
|
find "${HOME}" -name error.log -exec head {} \; -exec tail {} \; -exec rm -f {} \;
|
||||||
echo
|
echo
|
||||||
echo -e "${yellow}========================================== script*.log ========================================"
|
echo -e "${yellow}========================================== script*.log ========================================"
|
||||||
find "${HOME}" -name "script*.log" -exec head {} \; -exec tail {} \; -exec rm -f {} \;
|
find "${HOME}" -name "script*.log" -exec head {} \; -exec tail {} \; -exec rm -f {} \;
|
||||||
echo
|
echo
|
||||||
echo -e "${yellow}========================================== *.RPT =============================================="
|
echo -e "${yellow}========================================== *.RPT =============================================="
|
||||||
find "${HOME}" -name "*.RPT" -exec ls -la {} \; -exec tail {} \; -exec rm -f {} \;
|
find "${HOME}" -name "*.RPT" -exec ls -la {} \; -exec tail {} \; -exec rm -f {} \;
|
||||||
echo
|
echo
|
||||||
echo -e "${yellow}========================================== End crash log ======================================"
|
echo -e "${yellow}========================================== End crash log ======================================"
|
||||||
}
|
}
|
||||||
|
|
||||||
# DayZ Experimental SteamID, because there is no release version of the Linux server yet
|
# DayZ Experimental SteamID, because there is no release version of the Linux server yet
|
||||||
|
@ -51,7 +51,7 @@ profile="-profiles=${SERVER_PROFILE}"
|
||||||
logs="-nologs"
|
logs="-nologs"
|
||||||
|
|
||||||
# Put them all together
|
# Put them all together
|
||||||
dayzparameter=" -config=${config} -port=${port} -freezecheck -fps=60 -BEpath=${SERVER_FILES}/battleye ${profile} ${logs}"
|
parameters=" -config=${config} -port=${port} -freezecheck -fps=60 -BEpath=${SERVER_FILES}/battleye ${profile} ${logs}"
|
||||||
|
|
||||||
# Server configuration file
|
# Server configuration file
|
||||||
SERVER_CFG_FILE="serverDZ.cfg"
|
SERVER_CFG_FILE="serverDZ.cfg"
|
||||||
|
@ -81,7 +81,7 @@ mod_command_line="-mod="
|
||||||
YES="${green}yes${default}"
|
YES="${green}yes${default}"
|
||||||
NO="${red}no${default}"
|
NO="${red}no${default}"
|
||||||
|
|
||||||
fn_usage(){
|
usage(){
|
||||||
echo -e "
|
echo -e "
|
||||||
${red}Bad option or arguments! ${yellow}${*}${default}
|
${red}Bad option or arguments! ${yellow}${*}${default}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ Options and arguments:
|
||||||
activate id [id...] - Activate one or many installed DayZ Workshop items by id
|
activate id [id...] - Activate one or many installed DayZ Workshop items by id
|
||||||
add id [id...] - Add one or many DayZ Workshop items by id. Added items become active by default
|
add id [id...] - Add one or many DayZ Workshop items by id. Added items become active by default
|
||||||
config - Update the internal serverDZ.cfg file from files/serverDZ.cfg on the host. Presents a unified diff if the internal file doesn't match the host file.
|
config - Update the internal serverDZ.cfg file from files/serverDZ.cfg on the host. Presents a unified diff if the internal file doesn't match the host file.
|
||||||
deactivate id [id...] - Deactivate one or many installed DayZ Workshop items by id - Keeps the addon files but excludes from -mod=
|
deactivate id [id...] - Deactivate one or many installed DayZ Workshop items by id - Keeps the mod files but excludes from -mod=
|
||||||
install - Install the DayZ server files
|
install - Install the DayZ server files
|
||||||
list - List Workshop items and if they are active or not
|
list - List Workshop items and if they are active or not
|
||||||
login - Login to Steam
|
login - Login to Steam
|
||||||
|
@ -105,184 +105,185 @@ ${default}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_prompt_yn(){
|
prompt_yn(){
|
||||||
echo -n "${1} (y|N) " >&2
|
echo -n "${1} (y|N) " >&2
|
||||||
read -s -n 1 a
|
read -s -n 1 a
|
||||||
a=$(echo ${a} | tr A-Z a-z)
|
a=$(echo ${a} | tr A-Z a-z)
|
||||||
echo
|
echo
|
||||||
if [[ "${a}" = "y" ]]
|
if [[ "${a}" = "y" ]]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_loadconfig_dayz(){
|
loadconfig(){
|
||||||
if [ ! -f "${SERVER_INSTALL_FILE}" ]
|
if [ ! -f "${SERVER_INSTALL_FILE}" ]
|
||||||
then
|
then
|
||||||
echo
|
echo
|
||||||
echo -e "The DayZ server files are not installed. Run '${green}docker-compose run --rm main dayzserver install${default}'"
|
echo -e "The DayZ server files are not installed. Run '${green}docker-compose run --rm main dayzserver install${default}'"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Handle the initial server configuration file
|
# Handle the initial server configuration file
|
||||||
if [ ! -f ${SERVER_CFG_DST} ]
|
if [ ! -f ${SERVER_CFG_DST} ]
|
||||||
then
|
then
|
||||||
echo "Creating initial server configuration file"
|
echo "Creating initial server configuration file"
|
||||||
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
||||||
fi
|
fi
|
||||||
# battleye config and rconpassword setup
|
# battleye config and rconpassword setup
|
||||||
# The server creates a new file from this file, which it then uses.
|
# The server creates a new file from this file, which it then uses.
|
||||||
# Let's make sure to delete it first
|
# Let's make sure to delete it first
|
||||||
BE_SERVER_FILE="${HOME}/serverfiles/battleye/beserver_x64.cfg"
|
BE_SERVER_FILE="${HOME}/serverfiles/battleye/beserver_x64.cfg"
|
||||||
ALT_BE_SERVER_FILE=$(find ${HOME}/serverfiles/battleye -name "beserver_x64_active*")
|
ALT_BE_SERVER_FILE=$(find ${HOME}/serverfiles/battleye -name "beserver_x64_active*")
|
||||||
if [ ! -f "${BE_SERVER_FILE}" ] && [ ! -f "${ALT_BE_SERVER_FILE}" ]
|
if [ ! -f "${BE_SERVER_FILE}" ] && [ ! -f "${ALT_BE_SERVER_FILE}" ]
|
||||||
then
|
then
|
||||||
passwd=$(openssl rand -base64 8 | tr -dc 'A-Za-z0-9')
|
passwd=$(openssl rand -base64 8 | tr -dc 'A-Za-z0-9')
|
||||||
if [ "${passwd}" == "" ]; then
|
if [ "${passwd}" == "" ]
|
||||||
passwd=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c10)
|
then
|
||||||
fi
|
passwd=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c10)
|
||||||
if [ "${passwd}" == "" ]; then
|
fi
|
||||||
printf "[ ${red}FAIL${default} ] Could not generate a passwort for RCON!\nOpen the Battleye config with 'dayzserver rcon'."
|
if [ "${passwd}" == "" ]
|
||||||
exit 1
|
then
|
||||||
else
|
printf "[ ${red}FAIL${default} ] Could not generate a passwort for RCON!\nOpen the Battleye config with 'dayzserver rcon'."
|
||||||
cat > "${BE_SERVER_FILE}" <<EOF
|
exit 1
|
||||||
|
else
|
||||||
|
cat > "${BE_SERVER_FILE}" <<EOF
|
||||||
RConPassword ${passwd}
|
RConPassword ${passwd}
|
||||||
RestrictRCon 0
|
RestrictRCon 0
|
||||||
RConPort ${rcon_port}
|
RConPort ${rcon_port}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
printf "[ ${cyan}INFO${default} ] New RCON password: ${yellow}${passwd}${default}\n"
|
printf "[ ${cyan}INFO${default} ] New RCON password: ${yellow}${passwd}${default}\n"
|
||||||
else
|
else
|
||||||
if [ -f "${BE_SERVER_FILE}" ]
|
if [ -f "${BE_SERVER_FILE}" ]
|
||||||
then
|
then
|
||||||
FILE="${BE_SERVER_FILE}"
|
FILE="${BE_SERVER_FILE}"
|
||||||
elif [ -f "${ALT_BE_SERVER_FILE}" ]
|
elif [ -f "${ALT_BE_SERVER_FILE}" ]
|
||||||
then
|
then
|
||||||
FILE="${ALT_BE_SERVER_FILE}"
|
FILE="${ALT_BE_SERVER_FILE}"
|
||||||
fi
|
fi
|
||||||
passwd=$(grep RConPassword ${FILE} | awk '{print $2}')
|
passwd=$(grep RConPassword ${FILE} | awk '{print $2}')
|
||||||
# printf "[ ${cyan}INFO${default} ] Using existing RCON password: ${yellow}${passwd}${default}\n"
|
# printf "[ ${cyan}INFO${default} ] Using existing RCON password: ${yellow}${passwd}${default}\n"
|
||||||
fi
|
fi
|
||||||
cp /usr/local/py3rcon/configexample.json ~/py3rcon.config.json
|
cp /usr/local/py3rcon/configexample.json ~/py3rcon.config.json
|
||||||
jq --arg port 2303 --arg rcon_password b0fNIBVfkM \
|
jq --arg port 2303 --arg rcon_password b0fNIBVfkM \
|
||||||
'.logfile="py3rcon.log" | .loglevel=0 | .server.port=$port | .server.rcon_password=$rcon_password | del(.repeatMessage)' \
|
'.logfile="py3rcon.log" | .loglevel=0 | .server.port=$port | .server.rcon_password=$rcon_password | del(.repeatMessage)' \
|
||||||
/usr/local/py3rcon/configexample.json \
|
/usr/local/py3rcon/configexample.json \
|
||||||
> ~/py3rcon.config.json
|
> ~/py3rcon.config.json
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_start_dayz(){
|
start(){
|
||||||
# Check for interactive shell
|
# Check for interactive shell
|
||||||
if [ -t 0 ]
|
if [ -t 0 ]
|
||||||
then
|
then
|
||||||
echo
|
echo
|
||||||
echo -e "Not starting the server in an interactive shell. Start the server using '${green}docker-compose up -d${default}'"
|
echo -e "Not starting the server in an interactive shell. Start the server using '${green}docker-compose up -d${default}'"
|
||||||
echo
|
echo
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
# 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.
|
||||||
trap '
|
trap '
|
||||||
report
|
report
|
||||||
' EXIT
|
' EXIT
|
||||||
fn_mod_cmd
|
mod_cmd
|
||||||
cd ${SERVER_FILES}
|
cd ${SERVER_FILES}
|
||||||
# Run the server. Allow docker to restart the container if the script exits with a code other than 0. This is so we can
|
# Run the server. Allow docker to restart the container if the script exits with a code other than 0. This is so we can
|
||||||
# safely shut the container down without killing the server within.
|
# safely shut the container down without killing the server within.
|
||||||
printf "[ ${green}DayZ${default} ] Server starting...\n"
|
printf "[ ${green}DayZ${default} ] Server starting...\n"
|
||||||
./DayZServer "${mod_command_line}" ${dayzparameter}
|
./DayZServer "${mod_command_line}" ${parameters}
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
if [ -f ${SERVER_FILES}/restart ]
|
if [ -f ${SERVER_FILES}/restart ]
|
||||||
then
|
then
|
||||||
rm -f ${SERVER_FILES}/restart
|
rm -f ${SERVER_FILES}/restart
|
||||||
EXIT_CODE=42
|
EXIT_CODE=42
|
||||||
fi
|
fi
|
||||||
printf "[ ${yellow}DayZ${default} ] Server exited. Exit code: ${EXIT_CODE}\n"
|
printf "[ ${yellow}DayZ${default} ] Server exited. Exit code: ${EXIT_CODE}\n"
|
||||||
exit ${EXIT_CODE}
|
exit ${EXIT_CODE}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_restart(){
|
restart(){
|
||||||
touch "${SERVER_FILES}/restart"
|
touch "${SERVER_FILES}/restart"
|
||||||
echo "Restarting DayZ server..."
|
echo "Restarting DayZ server..."
|
||||||
kill -TERM $(pidof DayZServer)
|
kill -TERM $(pidof DayZServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_stop_dayz(){
|
stop(){
|
||||||
echo "Stopping DayZ server..."
|
echo "Stopping DayZ server..."
|
||||||
kill -TERM $(pidof DayZServer)
|
kill -TERM $(pidof DayZServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_steam_login(){
|
login(){
|
||||||
if [ -f "${STEAM_LOGIN}" ]
|
loadconfig
|
||||||
then
|
if [ -f "${STEAM_LOGIN}" ]
|
||||||
if fn_prompt_yn "The steam login is already set. Reset it?"
|
then
|
||||||
then
|
if prompt_yn "The steam login is already set. Reset it?"
|
||||||
rm -f "${STEAM_LOGIN}"
|
then
|
||||||
else
|
rm -f "${STEAM_LOGIN}"
|
||||||
echo "Not reset."
|
else
|
||||||
exit 0
|
echo "Not reset."
|
||||||
fi
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ ! -f "${STEAM_LOGIN}" ]
|
fi
|
||||||
then
|
if [ ! -f "${STEAM_LOGIN}" ]
|
||||||
echo "Setting up Steam credentials"
|
then
|
||||||
echo -n "Steam Username (anonymous): "
|
echo "Setting up Steam credentials"
|
||||||
read steamlogin
|
echo -n "Steam Username (anonymous): "
|
||||||
if [[ "${steamlogin}" = "" ]]
|
read steamlogin
|
||||||
then
|
if [[ "${steamlogin}" = "" ]]
|
||||||
echo "Steam login set to 'anonymous'"
|
then
|
||||||
steamlogin="anonymous"
|
echo "Steam login set to 'anonymous'"
|
||||||
fi
|
steamlogin="anonymous"
|
||||||
echo "steamlogin=${steamlogin}" > "${STEAM_LOGIN}"
|
fi
|
||||||
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +quit
|
echo "steamlogin=${steamlogin}" > "${STEAM_LOGIN}"
|
||||||
fi
|
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +quit
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_steamlogin_dayz(){
|
dologin(){
|
||||||
if [ -f "${STEAM_LOGIN}" ]
|
loadconfig
|
||||||
then
|
if [ -f "${STEAM_LOGIN}" ]
|
||||||
source "${STEAM_LOGIN}"
|
then
|
||||||
else
|
source "${STEAM_LOGIN}"
|
||||||
echo "No cached Steam credentials. Please configure this now: "
|
else
|
||||||
fn_steam_login
|
echo "No cached Steam credentials. Please configure this now: "
|
||||||
fi
|
login
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_runvalidate_dayz(){
|
install(){
|
||||||
# fn_loadconfig_dayz
|
loadconfig
|
||||||
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +app_update "${appid}" validate +quit
|
if [ ! -f "${SERVER_INSTALL_FILE}" ] || [[ ${1} = "force" ]]
|
||||||
}
|
then
|
||||||
|
|
||||||
fn_install_dayz(){
|
|
||||||
if [ ! -f "${SERVER_INSTALL_FILE}" ]; then
|
|
||||||
mkdir -p "${SERVER_FILES}"
|
mkdir -p "${SERVER_FILES}"
|
||||||
mkdir -p "${SERVER_PROFILE}"
|
mkdir -p "${SERVER_PROFILE}"
|
||||||
printf "[ ${yellow}DayZ${default} ] Downloading DayZ Server-Files!\n"
|
printf "[ ${yellow}DayZ${default} ] Downloading DayZ Server-Files!\n"
|
||||||
fn_steamlogin_dayz
|
dologin
|
||||||
fn_runvalidate_dayz
|
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +app_update "${appid}" validate +quit
|
||||||
else
|
else
|
||||||
printf "[ ${lightblue}DayZ${default} ] The Server is already installed.\n"
|
printf "[ ${lightblue}DayZ${default} ] The Server is already installed.\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_config(){
|
config(){
|
||||||
if ! diff -q "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
if ! diff -q "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
||||||
then
|
then
|
||||||
echo "========================================================================="
|
echo "========================================================================="
|
||||||
diff -Nau --color "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}" || echo ""
|
diff -Nau --color "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}" || echo ""
|
||||||
echo "========================================================================="
|
echo "========================================================================="
|
||||||
if fn_prompt_yn "The new server configuration file differs from what's installed. Use it?"
|
if prompt_yn "The new server configuration file differs from what's installed. Use it?"
|
||||||
then
|
then
|
||||||
echo "Updating the server configuration file"
|
echo "Updating the server configuration file"
|
||||||
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}"
|
||||||
else
|
else
|
||||||
echo "NOT updating the server configuration file"
|
echo "NOT updating the server configuration file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_update_dayz(){
|
update(){
|
||||||
fn_steamlogin_dayz
|
dologin
|
||||||
appmanifestfile=${SERVER_FILES}/steamapps/appmanifest_"${appid}".acf
|
appmanifestfile=${SERVER_FILES}/steamapps/appmanifest_"${appid}".acf
|
||||||
printf "[ ... ] Checking for update:"
|
printf "[ ... ] Checking for update:"
|
||||||
# gets currentbuild
|
# gets currentbuild
|
||||||
|
@ -310,9 +311,9 @@ fn_update_dayz(){
|
||||||
printf "\thttps://steamdb.info/app/${appid}/\n"
|
printf "\thttps://steamdb.info/app/${appid}/\n"
|
||||||
printf "\nApplying update"
|
printf "\nApplying update"
|
||||||
# run update
|
# run update
|
||||||
fn_steamlogin_dayz
|
dologin
|
||||||
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +app_update "${appid}" +quit
|
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +app_update "${appid}" +quit
|
||||||
fn_update_mods
|
modupdate
|
||||||
else
|
else
|
||||||
printf "\r[ ${green}OK${default} ] Checking for update:: No update available\n"
|
printf "\r[ ${green}OK${default} ] Checking for update:: No update available\n"
|
||||||
printf "\nNo update available:\n"
|
printf "\nNo update available:\n"
|
||||||
|
@ -322,7 +323,7 @@ fn_update_dayz(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_get_mods(){
|
get_mods(){
|
||||||
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
mapfile -t workshopID < "${WORKSHOP_CFG}"
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
do
|
do
|
||||||
|
@ -333,13 +334,15 @@ fn_get_mods(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_update_mods(){
|
modupdate(){
|
||||||
fn_get_mods
|
get_mods
|
||||||
|
echo "Updating mods..."
|
||||||
|
dologin
|
||||||
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" ${workshoplist} +quit
|
${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" ${workshoplist} +quit
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_add_mod(){
|
add(){
|
||||||
if [ -d "${workshopfolder}/${1}" ]
|
if [ -d "${workshopfolder}/${1}" ]
|
||||||
then
|
then
|
||||||
echo -e "${yellow}Warning: The mod directory ${workshopfolder}/${1} already exists!${default}"
|
echo -e "${yellow}Warning: The mod directory ${workshopfolder}/${1} already exists!${default}"
|
||||||
|
@ -356,7 +359,7 @@ fn_add_mod(){
|
||||||
fi
|
fi
|
||||||
echo "Adding mod id ${1}"
|
echo "Adding mod id ${1}"
|
||||||
echo "${1}:MODNAME:1" >> ${WORKSHOP_CFG}
|
echo "${1}:MODNAME:1" >> ${WORKSHOP_CFG}
|
||||||
fn_update_mods
|
modupdate
|
||||||
# Make sure the install succeeded
|
# Make sure the install succeeded
|
||||||
if [ ! -d "${workshopfolder}/${1}" ]
|
if [ ! -d "${workshopfolder}/${1}" ]
|
||||||
then
|
then
|
||||||
|
@ -367,29 +370,26 @@ fn_add_mod(){
|
||||||
mv /tmp/workshop.cfg.tmp "${WORKSHOP_CFG}"
|
mv /tmp/workshop.cfg.tmp "${WORKSHOP_CFG}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# Get the name of the newly added addon
|
# Get the name of the newly added mod
|
||||||
MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp))
|
MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp))
|
||||||
# Symlink it
|
# Symlink it
|
||||||
if [ ! -L "${SERVER_FILES}/@${MODNAME}" ]
|
if [ ! -L "${SERVER_FILES}/@${MODNAME}" ]
|
||||||
then
|
then
|
||||||
ln -s ${workshopfolder}/${1} "${SERVER_FILES}/@${MODNAME}"
|
ln -s ${workshopfolder}/${1} "${SERVER_FILES}/@${MODNAME}"
|
||||||
echo "Created symlink for mod id ${1}"
|
echo "Created symlink ${workshopfolder}/${1} ${SERVER_FILES}/@${MODNAME}"
|
||||||
fi
|
fi
|
||||||
# Lower case all the files in mod directories.
|
# Lower case all the files in mod directories.
|
||||||
find "${workshopfolder}/${1}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
|
find "${workshopfolder}/${1}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
|
||||||
# Copy the key files
|
# Copy the key files
|
||||||
if ls ${SERVER_FILES}/@* 1> /dev/null 2>&1
|
echo "Copying key files..."
|
||||||
then
|
cp -v ${workshopfolder}/${1}/keys/* "${SERVER_FILES}/keys/"
|
||||||
echo "Copying key files..."
|
|
||||||
cp -vu "${workshopfolder}/*/keys/*" "${SERVER_FILES}/keys/" 2> /dev/null
|
|
||||||
fi
|
|
||||||
# Set the mod name in the workshop config file, as we don't know this at the start.
|
# Set the mod name in the workshop config file, as we don't know this at the start.
|
||||||
sed -i "${WORKSHOP_CFG}" -e "s/${1}:MODNAME/${1}:${MODNAME}/"
|
sed -i "${WORKSHOP_CFG}" -e "s/${1}:MODNAME/${1}:${MODNAME}/"
|
||||||
echo -e "Mod id ${1} - ${green}${MODNAME}${default} - added"
|
echo -e "Mod id ${1} - ${green}${MODNAME}${default} - added"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_remove_mod(){
|
remove(){
|
||||||
if [ -d "${workshopfolder}/${1}" ]
|
if [ -d "${workshopfolder}/${1}" ]
|
||||||
then
|
then
|
||||||
MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp))
|
MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp))
|
||||||
|
@ -409,8 +409,8 @@ fn_remove_mod(){
|
||||||
echo "Mod id ${1} - ${MODNAME} - removed"
|
echo "Mod id ${1} - ${MODNAME} - removed"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_activate_mod(){
|
activate(){
|
||||||
fn_get_mods
|
get_mods
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
do
|
do
|
||||||
ID=$(echo ${i} | cut -d: -f1)
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
|
@ -429,8 +429,8 @@ fn_activate_mod(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_deactivate_mod(){
|
deactivate(){
|
||||||
fn_get_mods
|
get_mods
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
do
|
do
|
||||||
ID=$(echo ${i} | cut -d: -f1)
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
|
@ -449,8 +449,8 @@ fn_deactivate_mod(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_list_mods(){
|
list(){
|
||||||
fn_get_mods
|
get_mods
|
||||||
spaces=" "
|
spaces=" "
|
||||||
echo -e "ID\t\tName\t\t\tActive\tURL"
|
echo -e "ID\t\tName\t\t\tActive\tURL"
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
|
@ -462,8 +462,8 @@ fn_list_mods(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_mod_cmd(){
|
mod_cmd(){
|
||||||
fn_get_mods
|
get_mods
|
||||||
for i in "${workshopID[@]}"
|
for i in "${workshopID[@]}"
|
||||||
do
|
do
|
||||||
ID=$(echo ${i} | cut -d: -f1)
|
ID=$(echo ${i} | cut -d: -f1)
|
||||||
|
@ -478,55 +478,15 @@ fn_mod_cmd(){
|
||||||
mod_command_line="${mod_command_line::-1}"
|
mod_command_line="${mod_command_line::-1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_workshop_mods(){
|
rcon(){
|
||||||
# Check usage
|
exec /usr/local/py3rcon/py3rcon.py --gui ~/py3rcon.config.json
|
||||||
if [[ ${1} = "" ]]
|
|
||||||
then
|
|
||||||
fn_usage
|
|
||||||
fi
|
|
||||||
if [[ ${1} != "list" ]] && [[ ${2} = "" ]]
|
|
||||||
then
|
|
||||||
fn_usage
|
|
||||||
fi
|
|
||||||
# Most mods require a valid Steam login. Not all will work with the anonymous user.
|
|
||||||
fn_steamlogin_dayz
|
|
||||||
# Options
|
|
||||||
case "${1}" in
|
|
||||||
activate)
|
|
||||||
fn_activate_mod ${2}
|
|
||||||
;;
|
|
||||||
add)
|
|
||||||
fn_add_mod ${2}
|
|
||||||
;;
|
|
||||||
deactivate)
|
|
||||||
fn_deactivate_mod ${2}
|
|
||||||
;;
|
|
||||||
list)
|
|
||||||
fn_list_mods
|
|
||||||
;;
|
|
||||||
|
|
||||||
remove)
|
|
||||||
fn_remove_mod ${2}
|
|
||||||
;;
|
|
||||||
update)
|
|
||||||
echo "Updating mods..."
|
|
||||||
fn_update_mods
|
|
||||||
;;
|
|
||||||
**)
|
|
||||||
fn_usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_rcon(){
|
status(){
|
||||||
exec /usr/local/py3rcon/py3rcon.py --gui ~/py3rcon.config.json
|
|
||||||
}
|
|
||||||
|
|
||||||
fn_status(){
|
|
||||||
INSTALLED="${NO}"
|
INSTALLED="${NO}"
|
||||||
LOGGED_IN="${NO}"
|
LOGGED_IN="${NO}"
|
||||||
RUNNING="${NO}"
|
RUNNING="${NO}"
|
||||||
fn_get_mods
|
get_mods
|
||||||
MODS_INSTALLED="${green}${#workshopID[@]}${default}"
|
MODS_INSTALLED="${green}${#workshopID[@]}${default}"
|
||||||
# DayZ Server files installation
|
# DayZ Server files installation
|
||||||
if [ -f "${SERVER_INSTALL_FILE}" ]
|
if [ -f "${SERVER_INSTALL_FILE}" ]
|
||||||
|
@ -549,63 +509,77 @@ fn_status(){
|
||||||
then
|
then
|
||||||
RUNNING="${YES}"
|
RUNNING="${YES}"
|
||||||
fi
|
fi
|
||||||
fn_mod_cmd
|
mod_cmd
|
||||||
# Uptime
|
# Uptime
|
||||||
UPTIME=$(date -d@$(($(date +%s) - $(date +%s -r ${SERVER_PROFILE}/server_console.log))) -u +%H:%M:%S)
|
UPTIME=$(date -d@$(($(date +%s) - $(date +%s -r ${SERVER_PROFILE}/server_console.log))) -u +%H:%M:%S)
|
||||||
# Number of mods plus the list denoting on or off
|
# Number of mods plus the list denoting on or off
|
||||||
echo -e "
|
echo -e "
|
||||||
Status:
|
Status:
|
||||||
|
|
||||||
Uptime: ${green}${UPTIME}${default}
|
Uptime: ${green}${UPTIME}${default}
|
||||||
Logged in to Steam: ${LOGGED_IN} ${ANONYMOUS}
|
Logged in to Steam: ${LOGGED_IN} ${ANONYMOUS}
|
||||||
Server files installed: ${INSTALLED}
|
Server files installed: ${INSTALLED}
|
||||||
Mods installed: ${MODS_INSTALLED}
|
Mods installed: ${MODS_INSTALLED}
|
||||||
Server running: ${RUNNING}
|
Server running: ${RUNNING}
|
||||||
Default parameters:${dayzparameter}
|
Default parameters:${parameters}
|
||||||
Mod parameter: ${mod_command_line}
|
Mod parameter: ${mod_command_line}
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${1}" in
|
C=${1}
|
||||||
cmd)
|
|
||||||
fn_mod_cmd
|
shift
|
||||||
;;
|
|
||||||
config)
|
case "${C}" in
|
||||||
fn_config
|
activate)
|
||||||
;;
|
activate "${@}"
|
||||||
install)
|
;;
|
||||||
fn_loadconfig_dayz
|
add)
|
||||||
fn_install_dayz
|
add "${@}"
|
||||||
;;
|
;;
|
||||||
login)
|
cmd)
|
||||||
fn_loadconfig_dayz
|
mod_cmd "${@}"
|
||||||
fn_steam_login
|
;;
|
||||||
;;
|
config)
|
||||||
rcon)
|
config "${@}"
|
||||||
fn_rcon "${2}"
|
;;
|
||||||
;;
|
deactivate)
|
||||||
restart)
|
deactivate "${@}"
|
||||||
fn_restart
|
;;
|
||||||
;;
|
install)
|
||||||
start)
|
install "${@}"
|
||||||
fn_loadconfig_dayz
|
;;
|
||||||
fn_start_dayz
|
list)
|
||||||
;;
|
list "${@}"
|
||||||
status)
|
;;
|
||||||
fn_status
|
login)
|
||||||
;;
|
login "${@}"
|
||||||
stop)
|
;;
|
||||||
fn_stop_dayz
|
modupdate)
|
||||||
;;
|
modupdate "${@}"
|
||||||
update)
|
;;
|
||||||
fn_loadconfig_dayz
|
rcon)
|
||||||
fn_update_dayz
|
rcon "${@}"
|
||||||
;;
|
;;
|
||||||
workshop)
|
remove)
|
||||||
fn_loadconfig_dayz
|
remove "${@}"
|
||||||
fn_workshop_mods ${2} ${3} ${4}
|
;;
|
||||||
;;
|
restart)
|
||||||
**)
|
restart "${@}"
|
||||||
fn_usage "$*"
|
;;
|
||||||
;;
|
start)
|
||||||
|
start "${@}"
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status "${@}"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop "${@}"
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
update "${@}"
|
||||||
|
;;
|
||||||
|
**)
|
||||||
|
usage "$*"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Reference in a new issue