From 6c1f36bef9a29fb677db227efebf90abd4db5ef8 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Thu, 25 May 2023 11:35:41 +0200 Subject: [PATCH] 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)