From a814ec077bf21f3bbfdf8727f54dbc1d7a621cdd Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Sun, 21 May 2023 12:37:28 +0200 Subject: [PATCH 01/10] feat: add V Rising server --- vrising/docker-compose.yml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 vrising/docker-compose.yml diff --git a/vrising/docker-compose.yml b/vrising/docker-compose.yml new file mode 100644 index 0000000..b7801d5 --- /dev/null +++ b/vrising/docker-compose.yml @@ -0,0 +1,59 @@ +version: "3.9" +services: + vrising: + image: didstopia/vrising-server:latest + container_name: vrising + restart: unless-stopped + environment: + # Configure the server + V_RISING_SERVER_PERSISTENT_DATA_PATH: "/app/vrising" + V_RISING_SERVER_BRANCH: "public" + V_RISING_SERVER_START_MODE: "0" # Install/update and start server + # V_RISING_SERVER_START_MODE: "1" # Install/update and exit + # V_RISING_SERVER_START_MODE: "2" # Install, skip update check and start server + V_RISING_SERVER_UPDATE_MODE: "1" # Enable update checking + + # Customize the server + V_RISING_SERVER_NAME: "V Rising Clownfiesta Server" + V_RISING_SERVER_DESCRIPTION: "V Rising server for Clownfiesta clan" + V_RISING_SERVER_GAME_PORT: 9876 + V_RISING_SERVER_QUERY_PORT: 9877 + V_RISING_SERVER_RCON_PORT: 9878 + V_RISING_SERVER_RCON_ENABLED: "true" + V_RISING_SERVER_MAX_CONNECTED_USERS: 100 + V_RISING_SERVER_MAX_CONNECTED_ADMINS: 100 + V_RISING_SERVER_SAVE_NAME: "clownfiesta_server_1" + V_RISING_SERVER_LIST_ON_MASTER_SERVER: "false" + V_RISING_SERVER_LIST_ON_STEAM: "false" + V_RISING_SERVER_LIST_ON_EOS: "false" + V_RISING_SERVER_AUTO_SAVE_COUNT: 5 + V_RISING_SERVER_AUTO_SAVE_INTERVAL: 10 + V_RISING_SERVER_GAME_SETTINGS_PRESET: "StandardPvE" + env_file: .vrising.env # For server passwords + ports: + - "9876:9876/udp" + - "9877:9877/udp" + - "9878:9878/tcp" + volumes: + - vrising_saves:/app/vrising + - vrising_data:/steamcmd/vrising + logging: + driver: "json-file" + options: + max-size: "5m" + max-file: "1" + +volumes: + vrising_saves: + driver: local + driver_opts: + type: none + o: bind + device: "/srv/docker/vrising/saves" + vrising_data: + driver: local + driver_opts: + type: none + o: bind + device: "/srv/docker/vrising/data" + -- 2.40.1 From 582b694c4df2427a557a7b72ed15db6154fbaae6 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Sun, 21 May 2023 12:44:11 +0200 Subject: [PATCH 02/10] feat: specify stop grade period --- vrising/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/vrising/docker-compose.yml b/vrising/docker-compose.yml index b7801d5..f6453ea 100644 --- a/vrising/docker-compose.yml +++ b/vrising/docker-compose.yml @@ -4,6 +4,7 @@ services: image: didstopia/vrising-server:latest container_name: vrising restart: unless-stopped + stop_grace_period: 2m30s # Avoid data loss environment: # Configure the server V_RISING_SERVER_PERSISTENT_DATA_PATH: "/app/vrising" -- 2.40.1 From 3805b6e861012c58a7eac4f034e1cc8a538654d7 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Tue, 23 May 2023 09:34:31 +0200 Subject: [PATCH 03/10] feat: switch to PvP mode --- vrising/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vrising/docker-compose.yml b/vrising/docker-compose.yml index f6453ea..d2c3315 100644 --- a/vrising/docker-compose.yml +++ b/vrising/docker-compose.yml @@ -29,7 +29,7 @@ services: V_RISING_SERVER_LIST_ON_EOS: "false" V_RISING_SERVER_AUTO_SAVE_COUNT: 5 V_RISING_SERVER_AUTO_SAVE_INTERVAL: 10 - V_RISING_SERVER_GAME_SETTINGS_PRESET: "StandardPvE" + V_RISING_SERVER_GAME_SETTINGS_PRESET: "StandardPvP" env_file: .vrising.env # For server passwords ports: - "9876:9876/udp" -- 2.40.1 From b466024001b151b30d73c95c5d1e95acab387f82 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 10:19:39 +0200 Subject: [PATCH 04/10] feat: add shell for vrising server editing --- vrising/src/vrising.sh | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 vrising/src/vrising.sh diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh new file mode 100755 index 0000000..390316c --- /dev/null +++ b/vrising/src/vrising.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +set -e + +### ### +# # +# V Rising on-the-fly shell # +# v0.1 # +### ### + +stdout() { + echo "${1}" +} + +stderr() { + >&2 echo "${1}" +} + +editWithRestart() { + local full_path_file_to_edit="${1}" + nano "${full_path_file_to_edit}" + stdout "The server will now be restarted and you will be attached to the logs." + stdout "Use ctrl-c to detach from the logs (the service will continue to run)" + sleep 2 + (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) +} + +USERNAME="${1}" + +shift + +BASE_VRISING_FOLDER="/srv/docker/vrising/saves/Settings/" +GAME_SETTINGS="ServerGameSettings.json" +HOST_SETTINGS="ServerHostSettings.json" +VRISING_COMPOSE_HOME="/home/davide/services/vrising/" +LOGS_FOLDER="${HOME}/logs" + +mkdir -p "${LOGS_FOLDER}" || (stderr "Unable to create logs folder, exiting" && exit 1) + +stdout "Welcome ${USERNAME}, please remember that your current activity in the server is logged!" +stdout "Exit and logout at any moment by pressing ctrl-c" + +while true +do + stdout """ +Select one of the following actions: +0 - exit +1 - edit ${GAME_SETTINGS} +2 - edit ${HOST_SETTINGS} +3 - inspect server logs +4 - restart server +5 - recreate server (destroy and recreate container) +""" + + ACTION="-1" + read -r ACTION + + case "${ACTION}" in + 0) + exit 0 + ;; + 1) + editWithRestart "${BASE_VRISING_FOLDER}${GAME_SETTINGS}" + ;; + 2) + editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}" + ;; + 3) + stdout "Use ctrl-c to detach from the logs at any time" + sleep 2 + (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) + ;; + 4) + stdout "Use ctrl-c to detach from the logs at any time" + sleep 2 + (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) + ;; + 5) + stdout "Use ctrl-c to detach from the logs at any time" + sleep 2 + (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) + ;; + *) + stderr "The provided input is not valid. Please chose from the listed actions" + ;; + esac +done + +exit 0 -- 2.40.1 From 15ce6246fea11bdd57ddf76fbec4e3e41defc294 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 10:54:45 +0200 Subject: [PATCH 05/10] fix: avoid closing connection when SIGINT --- vrising/src/vrising.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index 390316c..7d7a729 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -20,9 +20,8 @@ editWithRestart() { local full_path_file_to_edit="${1}" nano "${full_path_file_to_edit}" stdout "The server will now be restarted and you will be attached to the logs." - stdout "Use ctrl-c to detach from the logs (the service will continue to run)" - sleep 2 - (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) + stdout "Use ctrl-c to detach from the logs (the service will continue to run in background)" + (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose restart && docker-compose logs -f") } USERNAME="${1}" @@ -53,7 +52,7 @@ Select one of the following actions: """ ACTION="-1" - read -r ACTION + read -rp "> " ACTION case "${ACTION}" in 0) @@ -67,18 +66,15 @@ Select one of the following actions: ;; 3) stdout "Use ctrl-c to detach from the logs at any time" - sleep 2 - (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) + (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose logs -f") ;; 4) stdout "Use ctrl-c to detach from the logs at any time" - sleep 2 - (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) + (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose restart && docker-compose logs -f") ;; 5) stdout "Use ctrl-c to detach from the logs at any time" - sleep 2 - (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) + (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f") ;; *) stderr "The provided input is not valid. Please chose from the listed actions" -- 2.40.1 From c47158ee8814584b0d1c4e632ba957e3f9f83d35 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 10:58:51 +0200 Subject: [PATCH 06/10] fix: explicitly ignore SIGINT signal --- vrising/src/vrising.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index 7d7a729..9806969 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -21,7 +21,7 @@ editWithRestart() { nano "${full_path_file_to_edit}" stdout "The server will now be restarted and you will be attached to the logs." stdout "Use ctrl-c to detach from the logs (the service will continue to run in background)" - (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose restart && docker-compose logs -f") + (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) } USERNAME="${1}" @@ -37,7 +37,8 @@ LOGS_FOLDER="${HOME}/logs" mkdir -p "${LOGS_FOLDER}" || (stderr "Unable to create logs folder, exiting" && exit 1) stdout "Welcome ${USERNAME}, please remember that your current activity in the server is logged!" -stdout "Exit and logout at any moment by pressing ctrl-c" + +trap "" INT while true do @@ -66,15 +67,15 @@ Select one of the following actions: ;; 3) stdout "Use ctrl-c to detach from the logs at any time" - (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose logs -f") + (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) ;; 4) stdout "Use ctrl-c to detach from the logs at any time" - (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose restart && docker-compose logs -f") + (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) ;; 5) stdout "Use ctrl-c to detach from the logs at any time" - (cd "${VRISING_COMPOSE_HOME}" && bash -c "docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f") + (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) ;; *) stderr "The provided input is not valid. Please chose from the listed actions" -- 2.40.1 From c3cfd99f173217636e1df89d1e1478003459800b Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 11:13:30 +0200 Subject: [PATCH 07/10] fix: add log, set handler for SIGINT --- vrising/src/vrising.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index 9806969..8c70e02 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -5,7 +5,7 @@ set -e ### ### # # # V Rising on-the-fly shell # -# v0.1 # +# v0.2 # ### ### stdout() { @@ -16,14 +16,33 @@ stderr() { >&2 echo "${1}" } +log() { + local action="${1}" + local when="" + when="$(date +%R:%S)" + + echo "${when} - ${action}" >> "${THIS_LOG}" 2>&1 /dev/null +} + editWithRestart() { local full_path_file_to_edit="${1}" nano "${full_path_file_to_edit}" + log "File edit - ${full_path_file_to_edit}" stdout "The server will now be restarted and you will be attached to the logs." stdout "Use ctrl-c to detach from the logs (the service will continue to run in background)" + log "Server restart" (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) } +ctrl_c_handler() { + # shellcheck disable=SC2317 + log "Logout with ctrl-c" + # shellcheck disable=SC2317 + exit 0 +} + +trap 'ctrl_c_handler' INT + USERNAME="${1}" shift @@ -33,13 +52,12 @@ GAME_SETTINGS="ServerGameSettings.json" HOST_SETTINGS="ServerHostSettings.json" VRISING_COMPOSE_HOME="/home/davide/services/vrising/" LOGS_FOLDER="${HOME}/logs" +THIS_LOG="${USERNAME}-$(date --iso-8601=ns).log" mkdir -p "${LOGS_FOLDER}" || (stderr "Unable to create logs folder, exiting" && exit 1) stdout "Welcome ${USERNAME}, please remember that your current activity in the server is logged!" -trap "" INT - while true do stdout """ @@ -57,6 +75,7 @@ Select one of the following actions: case "${ACTION}" in 0) + log "Exit" exit 0 ;; 1) @@ -67,18 +86,22 @@ Select one of the following actions: ;; 3) stdout "Use ctrl-c to detach from the logs at any time" + log "Show logs" (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) ;; 4) stdout "Use ctrl-c to detach from the logs at any time" + log "Server restart" (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) ;; 5) stdout "Use ctrl-c to detach from the logs at any time" + log "Recreate server" (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) ;; *) - stderr "The provided input is not valid. Please chose from the listed actions" + log "Invalid input: ${ACTION}" + stderr "The provided input is not valid. Please chose a valid action" ;; esac done -- 2.40.1 From 9ebb0a056d66ce1d03d2483d9b4df23c97093409 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 11:17:57 +0200 Subject: [PATCH 08/10] fix: set right path for log, update output --- vrising/src/vrising.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index 8c70e02..34ab67b 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -21,7 +21,7 @@ log() { local when="" when="$(date +%R:%S)" - echo "${when} - ${action}" >> "${THIS_LOG}" 2>&1 /dev/null + echo "${when} - ${action}" >> "${THIS_LOG}" } editWithRestart() { @@ -29,7 +29,7 @@ editWithRestart() { nano "${full_path_file_to_edit}" log "File edit - ${full_path_file_to_edit}" stdout "The server will now be restarted and you will be attached to the logs." - stdout "Use ctrl-c to detach from the logs (the service will continue to run in background)" + stdout "Use ctrl-c to disconnect from the server" log "Server restart" (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) } @@ -52,7 +52,7 @@ GAME_SETTINGS="ServerGameSettings.json" HOST_SETTINGS="ServerHostSettings.json" VRISING_COMPOSE_HOME="/home/davide/services/vrising/" LOGS_FOLDER="${HOME}/logs" -THIS_LOG="${USERNAME}-$(date --iso-8601=ns).log" +THIS_LOG="${LOGS_FOLDER}/${USERNAME}-$(date --iso-8601=ns).log" mkdir -p "${LOGS_FOLDER}" || (stderr "Unable to create logs folder, exiting" && exit 1) @@ -85,17 +85,17 @@ Select one of the following actions: editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}" ;; 3) - stdout "Use ctrl-c to detach from the logs at any time" + stdout "Use ctrl-c to disconnect from the server at any time" log "Show logs" (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) ;; 4) - stdout "Use ctrl-c to detach from the logs at any time" + stdout "Use ctrl-c to disconnect from the server at any time" log "Server restart" (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) ;; 5) - stdout "Use ctrl-c to detach from the logs at any time" + stdout "Use ctrl-c to disconnect from the server at any time" log "Recreate server" (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) ;; -- 2.40.1 From 6c1f36bef9a29fb677db227efebf90abd4db5ef8 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 11:35:41 +0200 Subject: [PATCH 09/10] feat: add possibility to edit docker-compose --- vrising/src/vrising.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index 34ab67b..b82757d 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -34,6 +34,19 @@ editWithRestart() { (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) } +editCompose() { + local full_path_file_to_edit="${1}" + log "Server stop" + stdout "Stopping the Server before editing" + (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v) + nano "${full_path_file_to_edit}" + log "File edit - ${full_path_file_to_edit}" + stdout "The server will now be recreated and you will be attached to the logs." + stdout "Use ctrl-c to disconnect from the server" + log "Server recreate" + (cd "${VRISING_COMPOSE_HOME}" && sleep 1 && docker-compose up -d && docker-compose logs -f) +} + ctrl_c_handler() { # shellcheck disable=SC2317 log "Logout with ctrl-c" @@ -65,9 +78,10 @@ Select one of the following actions: 0 - exit 1 - edit ${GAME_SETTINGS} 2 - edit ${HOST_SETTINGS} -3 - inspect server logs -4 - restart server -5 - recreate server (destroy and recreate container) +3 - edit docker-compose definition (stop, edit and recreate the container) +4 - inspect server logs +5 - restart server +6 - recreate server (destroy and recreate container) """ ACTION="-1" @@ -85,16 +99,19 @@ Select one of the following actions: editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}" ;; 3) + editCompose "${VRISING_COMPOSE_HOME}/docker-compose.yml" + ;; + 4) stdout "Use ctrl-c to disconnect from the server at any time" log "Show logs" (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) ;; - 4) + 5) stdout "Use ctrl-c to disconnect from the server at any time" log "Server restart" (cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) ;; - 5) + 6) stdout "Use ctrl-c to disconnect from the server at any time" log "Recreate server" (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v && sleep 1 && docker-compose up -d && docker-compose logs -f) -- 2.40.1 From f34b13b347f03ecb29f0dc7318ddb4f879881b87 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 11:41:14 +0200 Subject: [PATCH 10/10] chore: minor clean up --- vrising/src/vrising.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vrising/src/vrising.sh b/vrising/src/vrising.sh index b82757d..244eeba 100755 --- a/vrising/src/vrising.sh +++ b/vrising/src/vrising.sh @@ -41,7 +41,7 @@ editCompose() { (cd "${VRISING_COMPOSE_HOME}" && docker-compose down -v) nano "${full_path_file_to_edit}" log "File edit - ${full_path_file_to_edit}" - stdout "The server will now be recreated and you will be attached to the logs." + stdout "The server will be now recreated and you will be attached to the logs." stdout "Use ctrl-c to disconnect from the server" log "Server recreate" (cd "${VRISING_COMPOSE_HOME}" && sleep 1 && docker-compose up -d && docker-compose logs -f) @@ -70,6 +70,7 @@ THIS_LOG="${LOGS_FOLDER}/${USERNAME}-$(date --iso-8601=ns).log" mkdir -p "${LOGS_FOLDER}" || (stderr "Unable to create logs folder, exiting" && exit 1) stdout "Welcome ${USERNAME}, please remember that your current activity in the server is logged!" +stdout "With ctrl-c you will instantly disconnected from the server" while true do @@ -99,7 +100,7 @@ Select one of the following actions: editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}" ;; 3) - editCompose "${VRISING_COMPOSE_HOME}/docker-compose.yml" + editCompose "${VRISING_COMPOSE_HOME}docker-compose.yml" ;; 4) stdout "Use ctrl-c to disconnect from the server at any time" -- 2.40.1