diff --git a/README.md b/README.md index e67f03b..4e78f6f 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,26 @@ # DayZDockerServer -A Linux [DayZ](https://dayz.com) server in a [Docker](https://docs.docker.com/) container. The main script's -functionality is derived from [this project](https://github.com/thelastnoc/dayz-sa_linuxserver). That functionality is -described [here](https://steamcommunity.com/sharedfiles/filedetails/?id=1517338673). The goal is to reproduce some of -that functionality but also add more features. +A Linux [DayZ](https://dayz.com) server in a [Docker](https://docs.docker.com/) container. The main script's functionality is derived from [this project](https://github.com/thelastnoc/dayz-sa_linuxserver). That functionality is described [here](https://steamcommunity.com/sharedfiles/filedetails/?id=1517338673). The goal is to reproduce some of that functionality but also add more features. + +The main goal is to provide a turnkey DayZ server with mod support that can be spun up with as little as a machine running Linux with Docker and Docker Compose installed. ## Caveat Emptor -As of DayZ release 1.15, a [Linux DayZ server](https://steamdb.info/app/1042420/) was made available in Dayz -Experimental. This has not been officially released, so this will only run a DayZ Experimental server at the -moment. Only the [DayZ Experimental client](https://dayz.fandom.com/wiki/Experimental) will be able to connect to it. -The goal is to have a working implementation once the Linux server is officially released, presumably -[here](https://steamdb.info/app/223350/). +As of DayZ release 1.15, a [Linux DayZ server](https://steamdb.info/app/1042420/) was made available in Dayz Experimental. This has not been officially released, so this will only run a DayZ Experimental server at the moment. Only the [DayZ Experimental client](https://dayz.fandom.com/wiki/Experimental) will be able to connect to it. The goal is to have a working implementation once the Linux server is officially released, presumably [here](https://steamdb.info/app/223350/). -This process will create a docker volume for the unprivileged user's home directory, which stores the DayZ server files. -This volume can get quite large. It will require at least 2G of disk space for the default install. Much more with mods. -Some map mods are as large as 10G. Make sure you have that much disk space in the location where docker stores its -volumes, usually `/var/lib/docker/volumes`. +This process will create several docker volumes for the following sets of files: +* serverfiles: The base server files +* mpmissions: The mpmissions directory of the base server files. +* mods: All mods will be stored here +* homedir: The user home directory. Each container gets its own. Where [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) keeps its resource files. +* profiles: A running server's profile. A server container gets its own volume. +* servermpmissions: A running -server's mpmissions directory. A server container gets its own volume. -## Goals - -* Provide a turnkey DayZ server with mod support. +These volumes can get quite large. The `serverfiles` one will require at least 2.7G of disk space for the default install. The mods one can fill up very quickly, with some map mods being as large as 10G. Make sure you have that much disk space in the location where docker stores its volumes, usually `/var/lib/docker/volumes`. ## Configure and Build -Ensure [Docker](https://docs.docker.com/engine/install/) and [Docker compose](https://docs.docker.com/compose/install/) -are properly installed. This means setting it up so it runs as your user. Make sure you're running these commands as -your user, in your home directory. +Ensure [Docker](https://docs.docker.com/engine/install/) and [Docker compose](https://docs.docker.com/compose/install/) are properly installed. This means setting it up so it runs as your user. Make sure you're running these commands as your user, in your home directory. Clone the repo, and change into the newly created directory: @@ -35,14 +29,7 @@ git clone https://ceregatti.org/git/daniel/dayzdockerserver.git cd dayzdockerserver ``` -Edit `files/serverDZ.cfg` and set the values of any variables there. -See the [documentation](https://forums.dayz.com/topic/239635-dayz-server-files-documentation/): - -``` -hostname = "Something other than Server Name"; // Server name -``` - -Build the Docker image: +Build the Docker images: ``` docker compose build @@ -50,40 +37,38 @@ docker compose build ### Steam Integration -[SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) is used to manage Steam downloads. A vanilla DayZ server -can be installed with the `anonymous` Steam user, but most mods cannot. If the goal is to add mods, a real Steam login -must be used. Login: +[SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) is used to manage Steam downloads. A vanilla DayZ server can be installed with the `anonymous` Steam user, but most mods cannot. If the goal is to add mods, a real Steam login must be used. Login: ``` -docker compose run --rm main dayzserver login +docker compose run --rm web dz login ``` -Follow the prompts. Hit enter to accept the default, which is to use the `anonymous` user, otherwise use your real -username and keep following the prompts to add your password and Steam Guard code. With Steam Guard enabled on the Steam -account, entering the password will trigger the sending of an email with the code. This process will wait indefinitely -until the code is entered. +Follow the prompts. Hit enter to accept the default, which is to use the `anonymous` user, otherwise use your real username and keep following the prompts to add your password and Steam Guard code. This process will wait indefinitely until the code is entered. -The credentials will be managed by [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD). How it encrypts or -otherwise obfuscates the credentials is beyond the scope of this document. Suffice to say that they are stored in the -docker volume. All subsequent SteamCMD commands will use the stored credentials. so this process does not need to be -repeated unless the session expires or the docker volume is deleted. +The credentials will be managed by [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD). How it encrypts or otherwise obfuscates the credentials is beyond the scope of this document. Suffice to say that they are stored in the docker volume. All subsequent SteamCMD commands will use the stored credentials. so this process does not need to be repeated unless the session expires or the docker volume is deleted. -Run the command again to manage the login. See [Manage](#manage). +To manage the login credentials, simply run the command again. See [Manage](#manage). ## Install The server files must be installed before the server can be run: ``` -docker compose run --rm main dayzserver install +docker compose run --rm web dz install ``` -This process will download the several gigabyes of files required to run the server. +This process will download the several gigabytes (about 2.7G) of files required to run the server. ## Run -Launch the container into the background: +Edit `files/serverDZ.cfg` and set the values of any variables there. See the [documentation](https://forums.dayz.com/topic/239635-dayz-server-files-documentation/): ``` -docker compose up -d +hostname = "Something other than Server Name"; // Server name +``` + +Launch the server container into the background: + +``` +docker compose up -d server ``` Tail the log: @@ -95,7 +80,7 @@ docker compose logs -f To stop the DayZ server: ``` -docker compose exec main dz stop +docker compose exec server dz stop ``` If it exits cleanly, the container will also stop. Otherwise the server will restart @@ -115,14 +100,14 @@ A terminal-based RCON client is included: https://github.com/indepth666/py3rcon. The dayzserver script manages what's necessary to configure and run it: ``` -docker compose exec main dayzserver rcon +docker compose exec server dayzserver rcon ``` To reset the RCON password in the Battle Eye configuration file, simply delete it, and a random one will be generated on the next server startup: ``` -docker compose run --rm main rm serverfiles/battleye/baserver_x64_active* +docker compose run --rm server rm serverfiles/battleye/baserver_x64_active* ``` ### Update the DayZ server files @@ -136,7 +121,7 @@ docker compose down Then run the command: ``` -docker compose run --rm main dayzserver update +docker compose run --rm web dayzserver update ``` Don't forget to [bring it back up](#run). @@ -144,13 +129,13 @@ Don't forget to [bring it back up](#run). ### Stop the server ``` -docker compose exec main dayzserver stop +docker compose exec server dayzserver stop ``` The server doesn't always exit when stopping it (SIGINT). When this happens, it's necessary to force stop it (SIGKILL): ``` -docker compose exec main dayzserver force +docker compose exec server dayzserver force ``` When the server exits cleanly, i.e. exit code 0, the container also stops. Otherwise, a crash is presumed, and the server will be restarted. @@ -163,8 +148,8 @@ required. This is not a clean exit, and will cause the server to restart. Manual Interactive interface for managing mods. ``` -docker compose exec main dayzserver activate id | add id1 | deactivate id | list | modupdate | remove id -docker compose exec main dayzserver a id | add id1 | d id | l | m | r id +docker compose exec server dayzserver activate id | add id1 | deactivate id | list | modupdate | remove id +docker compose exec server dayzserver a id | add id1 | d id | l | m | r id ``` Look for mods in the [DayZ Workshop](https://steamcommunity.com/app/221100/workshop/). Browse to one. In its URL will be @@ -172,7 +157,7 @@ an `id` parameter. Here is the URL to SimpleAutoRun: https://steamcommunity.com/ add it: ``` -docker compose exec main dayzserver add 2264162971 +docker compose exec web dayzserver add 2264162971 ``` Adding and removing mods will add and remove their names from the `-mod=` parameter. @@ -189,12 +174,12 @@ All the server files persist in a docker volume that represents the container's the running container: ``` -docker compose exec main bash +docker compose exec web bash ``` Or open a shell into a new container if the docker stack is not up: ``` -docker compose run --rm main bash +docker compose run --rm web bash ``` All the files used by the server are in a docker volume. Any change made will be reflected upon the next container startup. diff --git a/files/bin/dz-common b/files/bin/dz-common index f3a6969..72ec382 100755 --- a/files/bin/dz-common +++ b/files/bin/dz-common @@ -43,15 +43,10 @@ SERVER_INSTALL_FILE="${SERVER_FILES}/DayZServer" STEAM_LOGIN="${HOME}/steamlogin" STEAMCMD=steamcmd -# Workshop files (mods) -WORKSHOP_DIR="${SERVER_FILES}/steamapps/workshop/content/${release_client_appid}" - # Other stuff YES="${green}yes${default}" NO="${red}no${default}" -# Functions - # Convenience function prompt_yn(){ echo -n "${1} (y|N) " >&2 @@ -65,71 +60,3 @@ prompt_yn(){ return 1 fi } - -check_mod_install(){ - # See if this mod id exists in files/mods, and offer to install other server side files if an install.sh is found - if [ -f ${FILES}/mods/${1}/${2}.sh ] - then - echo "An ${2}.sh was found for mod id ${1}. Running..." - ${FILES}/mods/${1}/${2}.sh - fi - # A generic map install script. Presumes a git repo as the source - if [ -f ${FILES}/mods/${1}/install.env ] - then - echo "An ${2}.env was found for mod id ${1}. Performing ${2}..." - source ${FILES}/mods/${1}/install.env - ${FILES}/mods/install.sh ${1} ${2} - fi -} - -get_mod_id_by_index2(){ - # If we were passed a valid mod id, just return it - if [ -d "${WORKSHOP_DIR}/${1}" ] - then - echo -n ${1} - return - fi - X=1 - # Loop over mods - for dir in $(ls -tr ${WORKSHOP_DIR}) - do - ID=${dir} - if [[ ${X} = ${1} ]] - then - echo -n ${ID} - return - fi - X=$((X+1)) - done -} - -# Get mod name by ID or index -get_mod_name(){ - ID=$(get_mod_id_by_index2 ${1}) - if ! [ -d "${WORKSHOP_DIR}/${ID}" ] - then - echo "Mod ID ${1} doesn't exist" >&2 - exit 1 - fi - NAME=$(grep name ${WORKSHOP_DIR}/${ID}/meta.cpp | cut -d '"' -f2 | sed -r 's/\s+//g') - echo -n ${NAME} -} - -# List mods -list(){ - X=1 - C="${green}" - spaces=" " - echo "Installed mods:" - echo -e " ID Name URL Size" - echo "------------------------------------------------------------------------------------------------------------------------" - for dir in $(ls -tr ${WORKSHOP_DIR}) - do - ID=${dir} - NAME=$(grep name "${WORKSHOP_DIR}/${dir}/meta.cpp" | cut -d '"' -f2 | sed -r 's/\s+//g') - SIZE=$(du -sh "${WORKSHOP_DIR}/${dir}" | awk '{print $1}') - printf "${C}%.3d %s %.30s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ID} ${SIZE} - X=$((X+1)) - done - echo -} diff --git a/server/start.sh b/server/start.sh index e388e39..812f304 100755 --- a/server/start.sh +++ b/server/start.sh @@ -7,9 +7,8 @@ export PS1="${debian_chroot:+($debian_chroot)}\u@dz-server:\w\$ " EOF # Uncomment the line below to run things manually in the container, then run: -# docker compose exec main bash -#tail -f /dev/null -#exit 0 +# docker compose exec main bash, and from within the container: dz start (or do whatever) +tail -f /dev/null # Otherwise, start the server normally -dz start +#dz start diff --git a/web/bin/dz b/web/bin/dz index 9a4f962..19db892 100755 --- a/web/bin/dz +++ b/web/bin/dz @@ -30,6 +30,41 @@ ${default}" exit 1 } +get_mod_id(){ + # If we were passed a valid mod id, just return it + if [ -d "${WORKSHOP_DIR}/${1}" ] + then + echo -n ${1} + return + fi + X=1 + # Loop over mods + for dir in $(ls -tr ${WORKSHOP_DIR}) + do + ID=${dir} + if [[ ${X} = ${1} ]] + then + echo -n ${ID} + return + fi + X=$((X+1)) + done +} + +# Get mod name by ID or index +get_mod_name(){ + ID=$(get_mod_id ${1}) + echo "ID: ${ID}" >&2 + exit 0 + if ! [ -d "${WORKSHOP_DIR}/${ID}" ] + then + echo "Mod ID ${1} doesn't exist" >&2 + exit 1 + fi + NAME=$(grep name ${WORKSHOP_DIR}/${ID}/meta.cpp | cut -d '"' -f2 | sed -r 's/\s+//g') + echo -n ${NAME} +} + # "Manage" XML files. xml(){ /files/mods/xml.sh ${1} @@ -246,7 +281,7 @@ get_mods(){ mod_command_line="" for link in $(ls -tdr ${SERVER_FILES}/@* 2> /dev/null) do - ID=$(readlink ${link} | cut -d/ -f7) + ID=$(readlink ${link} | awk -F/ '{print $NF}') MODNAME=$(get_mod_name ${ID}) workshoplist+=" +workshop_download_item "${release_client_appid}" "${ID} mod_command_line+="@${MODNAME};" @@ -313,6 +348,41 @@ Mods: " echo -e "${MODS}" } +check_mod_install(){ + # See if this mod id exists in files/mods, and offer to install other server side files if an install.sh is found + if [ -f ${FILES}/mods/${1}/${2}.sh ] + then + echo "An ${2}.sh was found for mod id ${1}. Running..." + ${FILES}/mods/${1}/${2}.sh + fi + # A generic map install script. Presumes a git repo as the source + if [ -f ${FILES}/mods/${1}/install.env ] + then + echo "An ${2}.env was found for mod id ${1}. Performing ${2}..." + source ${FILES}/mods/${1}/install.env + ${FILES}/mods/install.sh ${1} ${2} + fi +} + +# List mods +list(){ + X=1 + C="${green}" + spaces=" " + echo "Installed mods:" + echo -e " ID Name URL Size" + echo "------------------------------------------------------------------------------------------------------------------------" + for dir in $(ls -tr ${WORKSHOP_DIR}) + do + ID=${dir} + NAME=$(grep name "${WORKSHOP_DIR}/${dir}/meta.cpp" | cut -d '"' -f2 | sed -r 's/\s+//g') + SIZE=$(du -sh "${WORKSHOP_DIR}/${dir}" | awk '{print $1}') + printf "${C}%.3d %s %.30s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ID} ${SIZE} + X=$((X+1)) + done + echo +} + # Capture the first argument and shift it off so we can pass $@ to every function C=${1} shift || { diff --git a/web/root/index.css b/web/root/index.css index 2134262..755a1da 100644 --- a/web/root/index.css +++ b/web/root/index.css @@ -1,8 +1,3 @@ -body { - padding: 10px; - background-color: black; -} - button { padding: 5px; margin: 10px; @@ -12,9 +7,6 @@ th, td { padding-right: 10px } -.result { - padding: 5px; -} .selected { background-color: cyan; @@ -24,3 +16,7 @@ th, td { cursor: pointer; text-underline: blue; } + +.simulink:hover { + background-color: cyan; +} diff --git a/web/root/index.html b/web/root/index.html index d29c9d3..ce5b859 100644 --- a/web/root/index.html +++ b/web/root/index.html @@ -4,19 +4,20 @@