feat: add shell for vrising server editing
parent
3805b6e861
commit
b466024001
|
@ -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
|
Loading…
Reference in New Issue