feat: add V Rising server #22

Closed
polpetta wants to merge 11 commits from vrising into master
2 changed files with 187 additions and 0 deletions

View File

@ -0,0 +1,60 @@
version: "3.9"
services:
vrising:
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"
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: "StandardPvP"
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"

127
vrising/src/vrising.sh Executable file
View File

@ -0,0 +1,127 @@
#!/bin/bash
set -e
### ###
# #
# V Rising on-the-fly shell #
# v0.2 #
### ###
stdout() {
echo "${1}"
}
stderr() {
>&2 echo "${1}"
}
log() {
local action="${1}"
local when=""
when="$(date +%R:%S)"
echo "${when} - ${action}" >> "${THIS_LOG}"
}
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 disconnect from the server"
log "Server restart"
(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 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)
}
ctrl_c_handler() {
# shellcheck disable=SC2317
log "Logout with ctrl-c"
# shellcheck disable=SC2317
exit 0
}
trap 'ctrl_c_handler' INT
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"
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
stdout """
Select one of the following actions:
0 - exit
1 - edit ${GAME_SETTINGS}
2 - edit ${HOST_SETTINGS}
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"
read -rp "> " ACTION
case "${ACTION}" in
0)
log "Exit"
exit 0
;;
1)
editWithRestart "${BASE_VRISING_FOLDER}${GAME_SETTINGS}"
;;
2)
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)
;;
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)
;;
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)
;;
*)
log "Invalid input: ${ACTION}"
stderr "The provided input is not valid. Please chose a valid action"
;;
esac
done
exit 0