| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- #!/bin/bash
- # LinuxGSM command_backup.sh function
- # Author: Daniel Gibbs
- # Contributor: UltimateByte
- # Website: https://linuxgsm.com
- # Description: Wipes server data, useful after updates for some games like Rust
- local commandname="WIPE"
- local commandaction="data wipe"
- local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
- check.sh
- fn_print_header
- fn_script_log "Entering ${gamename} ${commandaction}"
- # Process to server wipe
- fn_wipe_server_process(){
- check_status.sh
- if [ "${status}" != "0" ]; then
- exitbypass=1
- command_stop.sh
- fn_wipe_server_remove_files
- exitbypass=1
- command_start.sh
- else
- fn_wipe_server_remove_files
- fi
- echo "server data wiped"
- fn_script_log "server data wiped."
- }
- # Provides an exit code upon error
- fn_wipe_exit_code(){
- ((exitcode=$?))
- if [ ${exitcode} -ne 0 ]; then
- fn_script_log_fatal "${currentaction}"
- core_exit.sh
- else
- fn_print_ok_eol_nl
- fi
- }
- # Removes files to wipe server
- fn_wipe_server_remove_files(){
- # Rust Wipe
- if [ "${gamename}" == "Rust" ]; then
- # Wipe pocedural map
- if [ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.map")" ]; then
- currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.map"
- echo -en "Removing procedural map proceduralmap.*.map file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "proceduralmap.*.map" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No procedural map file to remove"
- fn_script_log_info "No procedural map file to remove."
- sleep 0.5
- fi
- #Wipe procedural map save
- if [ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.sav")" ]; then
- currentaction="Removing procedural map save(s): ${serveridentitydir}/proceduralmap.*.sav"
- echo -en "Removing map saves proceduralmap.*.sav file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "proceduralmap.*.sav" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No procedural map save to remove"
- fn_script_log_info "No procedural map save to remove."
- sleep 0.5
- fi
- # Wipe Barren map
- if [ -n "$(find "${serveridentitydir}" -type f -name "barren*.map")" ]; then
- currentaction="Removing map file(s): ${serveridentitydir}/barren*.map"
- echo -en "Removing barren map barren*.map file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "barren*.map" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No barren map file to remove"
- fn_script_log_info "No barren map file to remove."
- sleep 0.5
- fi
- # Wipe barren map save
- if [ -n "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]; then
- currentaction="Removing barren map save(s): ${serveridentitydir}/barren*.sav"
- echo -en "Removing barren map saves barren*.sav file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "barren*.sav" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No barren map save to remove"
- fn_script_log_info "No barren map save to remove."
- sleep 0.5
- fi
- # Wipe user dir, might be a legacy thing, maybe to be removed
- if [ -d "${serveridentitydir}/user" ]; then
- currentaction="Removing user directory: ${serveridentitydir}/user"
- echo -en "Removing user directory..."
- sleep 0.5
- fn_script_log "${currentaction}"
- rm -rf "${serveridentitydir:?}/user"
- fn_wipe_exit_code
- sleep 0.5
- # We do not print additional information if there is nothing to remove since this might be obsolete
- fi
- # Wipe storage dir, might be a legacy thing, maybe to be removed
- if [ -d "${serveridentitydir}/storage" ]; then
- currentaction="Removing storage directory: ${serveridentitydir}/storage"
- echo -en "Removing storage directory..."
- sleep 0.5
- fn_script_log "${currentaction}"
- rm -rf "${serveridentitydir:?}/storage"
- fn_wipe_exit_code
- sleep 0.5
- # We do not print additional information if there is nothing to remove since this might be obsolete
- fi
- # Wipe player death files
- if [ -n "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]; then
- currentaction="Removing player death files: ${serveridentitydir}/player.deaths.*.db"
- echo -en "Removing player deaths player.deaths.*.db file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "player.deaths.*.db" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No player death to remove"
- fn_script_log_info "No player death to remove."
- sleep 0.5
- fi
- # Wipe blueprints only if wipeall command was used
- if [ "${wipeall}" == "1" ]; then
- if [ -n "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then
- currentaction="Removing blueprint file(s): ${serveridentitydir}/player.blueprints.*.db"
- echo -en "Removing procedural blueprints player.blueprints.*.db file(s)..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "player.blueprints.*.db" -delete
- fn_wipe_exit_code
- sleep 0.5
- else
- fn_print_information_nl "No blueprint file to remove"
- fn_script_log_info "No blueprint file to remove."
- sleep 0.5
- fi
- elif [ -n "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then
- fn_print_information_nl "Keeping blueprints"
- fn_script_log_info "Keeping blueprints."
- sleep 0.5
- else
- fn_print_information_nl "No blueprints found"
- fn_script_log_info "No blueprints found."
- sleep 0.5
- fi
- # Wipe some logs that might be there
- if [ -n "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]; then
- currentaction="Removing log files: ${serveridentitydir}/Log.*.txt"
- echo -en "Removing Log files..."
- sleep 0.5
- fn_script_log "${currentaction}"
- find "${serveridentitydir:?}" -type f -name "Log.*.txt" -delete
- fn_wipe_exit_code
- sleep 0.5
- # We do not print additional information if there are no logs to remove
- fi
- # You can add an "elif" here to add another game or engine
- fi
- }
- # Check if there is something to wipe, prompt the user, and call appropriate functions
- # Rust Wipe
- if [ "${gamename}" == "Rust" ]; then
- if [ -d "${serveridentitydir}/storage" ]||[ -d "${serveridentitydir}/user" ]||[ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then
- fn_print_warning_nl "Any user, storage, log and map data from ${serveridentitydir} will be erased."
- if ! fn_prompt_yn "Continue?" Y; then
- echo Exiting; core_exit.sh
- fi
- fn_script_log_info "User selects to erase any user, storage, log and map data from ${serveridentitydir}"
- sleep 0.5
- fn_wipe_server_process
- else
- fn_print_information_nl "No data to wipe was found"
- fn_script_log_info "No data to wipe was found."
- sleep 0.5
- core_exit.sh
- fi
- # You can add an "elif" here to add another game or engine
- else
- # Game not listed
- fn_print_information_nl "Wipe is not available for this game"
- fn_script_log_info "Wipe is not available for this game."
- sleep 0.5
- core_exit.sh
- fi
- core_exit.sh
|