|
|
@ -9,26 +9,6 @@ commandname="WIPE" |
|
|
|
commandaction="Wiping" |
|
|
|
functionselfname="$(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 -e "server data wiped" |
|
|
|
fn_script_log "server data wiped" |
|
|
|
} |
|
|
|
|
|
|
|
# Provides an exit code upon error. |
|
|
|
fn_wipe_exit_code(){ |
|
|
|
((exitcode=$?)) |
|
|
@ -41,12 +21,12 @@ fn_wipe_exit_code(){ |
|
|
|
} |
|
|
|
|
|
|
|
# Removes files to wipe server. |
|
|
|
fn_wipe_server_remove_files(){ |
|
|
|
# Rust Wipe. |
|
|
|
if [ "${shortname}" == "rust" ]; then |
|
|
|
# Wipe pocedural map. |
|
|
|
fn_wipe_server_files(){ |
|
|
|
fn_print_start_nl "Wiping server" |
|
|
|
fn_script_log_info "Wiping server" |
|
|
|
# Wipe procedural map. |
|
|
|
if [ "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.map")" ]; then |
|
|
|
currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.map" |
|
|
|
currentaction="removing map file(s): ${serveridentitydir}/proceduralmap.*.map" |
|
|
|
echo -en "Removing procedural map proceduralmap.*.map file(s)..." |
|
|
|
fn_sleep_time |
|
|
|
fn_script_log "${currentaction}" |
|
|
@ -175,8 +155,6 @@ fn_wipe_server_remove_files(){ |
|
|
|
fn_sleep_time |
|
|
|
# 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 |
|
|
|
} |
|
|
|
|
|
|
|
fn_stop_warning(){ |
|
|
@ -194,18 +172,40 @@ fn_stop_warning(){ |
|
|
|
fn_print_warn_nl "${selfname} will be stopped during wipe" |
|
|
|
} |
|
|
|
|
|
|
|
# Check if there is something to wipe, prompt the user, and call appropriate functions. |
|
|
|
# Rust Wipe. |
|
|
|
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")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then |
|
|
|
fn_print_warning_nl "Any user, storage, log and map data from ${serveridentitydir} will be erased" |
|
|
|
fn_wipe_warning(){ |
|
|
|
fn_print_warn "${selfname} wipe is about to start" |
|
|
|
fn_script_log_warn "${selfname} wipe is about to start" |
|
|
|
totalseconds=3 |
|
|
|
for seconds in {3..1}; do |
|
|
|
fn_print_warn "${selfname} wipe is about to start: ${totalseconds}" |
|
|
|
totalseconds=$((totalseconds - 1)) |
|
|
|
sleep 1 |
|
|
|
if [ "${seconds}" == "0" ]; then |
|
|
|
break |
|
|
|
fi |
|
|
|
done |
|
|
|
fn_print_warn "${selfname} wipe is about to start" |
|
|
|
} |
|
|
|
|
|
|
|
fn_print_dots "Wiping server" |
|
|
|
check.sh |
|
|
|
|
|
|
|
# Check if there is something to wipe. |
|
|
|
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")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then |
|
|
|
fn_wipe_warning |
|
|
|
fn_script_log_info "User selects to erase any user, storage, log and map data from ${serveridentitydir}" |
|
|
|
fn_sleep_time |
|
|
|
fn_wipe_server_process |
|
|
|
check_status.sh |
|
|
|
if [ "${status}" != "0" ]; then |
|
|
|
fn_stop_warning |
|
|
|
exitbypass=1 |
|
|
|
command_stop.sh |
|
|
|
fn_wipe_server_files |
|
|
|
exitbypass=1 |
|
|
|
command_start.sh |
|
|
|
else |
|
|
|
fn_print_information_nl "No data to wipe was found" |
|
|
|
fn_script_log_info "No data to wipe was found" |
|
|
|
core_exit.sh |
|
|
|
fn_wipe_server_files |
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|
fn_print_info_nl "No data to wipe was found" |
|
|
|
fn_script_log_info "No data to wipe was found" |
|
|
|
fi |
|
|
|
core_exit.sh |
|
|
|