feat: add possibility to edit docker-compose
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

vrising
Davide Polonio 2023-05-25 11:35:41 +02:00
parent 9ebb0a056d
commit 6c1f36bef9
1 changed files with 22 additions and 5 deletions

View File

@ -34,6 +34,19 @@ editWithRestart() {
(cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) (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() { ctrl_c_handler() {
# shellcheck disable=SC2317 # shellcheck disable=SC2317
log "Logout with ctrl-c" log "Logout with ctrl-c"
@ -65,9 +78,10 @@ Select one of the following actions:
0 - exit 0 - exit
1 - edit ${GAME_SETTINGS} 1 - edit ${GAME_SETTINGS}
2 - edit ${HOST_SETTINGS} 2 - edit ${HOST_SETTINGS}
3 - inspect server logs 3 - edit docker-compose definition (stop, edit and recreate the container)
4 - restart server 4 - inspect server logs
5 - recreate server (destroy and recreate container) 5 - restart server
6 - recreate server (destroy and recreate container)
""" """
ACTION="-1" ACTION="-1"
@ -85,16 +99,19 @@ Select one of the following actions:
editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}" editWithRestart "${BASE_VRISING_FOLDER}${HOST_SETTINGS}"
;; ;;
3) 3)
editCompose "${VRISING_COMPOSE_HOME}/docker-compose.yml"
;;
4)
stdout "Use ctrl-c to disconnect from the server at any time" stdout "Use ctrl-c to disconnect from the server at any time"
log "Show logs" log "Show logs"
(cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f) (cd "${VRISING_COMPOSE_HOME}" && docker-compose logs -f)
;; ;;
4) 5)
stdout "Use ctrl-c to disconnect from the server at any time" stdout "Use ctrl-c to disconnect from the server at any time"
log "Server restart" log "Server restart"
(cd "${VRISING_COMPOSE_HOME}" && docker-compose restart && docker-compose logs -f) (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" stdout "Use ctrl-c to disconnect from the server at any time"
log "Recreate server" log "Recreate server"
(cd "${VRISING_COMPOSE_HOME}" && 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)