Browse Source

Merged feature/ultimatebyte-271 into develop

pull/1279/head
Daniel Gibbs 8 years ago
parent
commit
89e5f93cc7
  1. 2
      Rust/rustserver
  2. 2
      lgsm/functions/check.sh
  3. 86
      lgsm/functions/check_permissions.sh
  4. 4
      lgsm/functions/command_mods_remove.sh
  5. 134
      lgsm/functions/command_wipe.sh
  6. 4
      lgsm/functions/core_functions.sh
  7. 88
      lgsm/functions/core_getopt.sh
  8. 23
      lgsm/functions/mods_core.sh
  9. 2
      lgsm/functions/mods_list.sh

2
Rust/rustserver

@ -29,7 +29,7 @@ ip="0.0.0.0"
port="28015"
rconport="28016"
rconpassword="CHANGE_ME"
rconweb="1"
rconweb="1" # Value is: 1 for Facepunch's web panel; 0 for RCON tools like Rusty or Rustadmin
maxplayers="50"
# Advanced Start Settings
seed="" # default random; range : 1 to 2147483647 ; used to change or reproduce a procedural map

2
lgsm/functions/check.sh

@ -34,7 +34,7 @@ do
fi
done
local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh command_update.sh command_validate.sh command_update_functions.sh command_email_test.sh command_mods_install.sh command_mods_update.sh command_mods_remove.sh )
local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh command_update.sh command_validate.sh command_update_functions.sh command_email_test.sh command_mods_install.sh command_mods_update.sh command_mods_remove.sh command_wipe.sh )
for allowed_command in "${allowed_commands_array[@]}"
do
if [ "${allowed_command}" == "${function_selfname}" ]; then

86
lgsm/functions/check_permissions.sh

@ -126,5 +126,91 @@ fn_check_permissions(){
fi
}
## The following fn_sys_perm_* functions checks for permission errors in /sys directory
# Checks for permission errors in /sys directory
fn_sys_perm_errors_detect(){
# Reset test variables
sysdirpermerror="0"
classdirpermerror="0"
netdirpermerror="0"
# Check permissions
# /sys, /sys/class and /sys/class/net should be readable & executable
if [ ! -r "/sys" ]||[ ! -x "/sys" ]; then
sysdirpermerror="1"
fi
if [ ! -r "/sys/class" ]||[ ! -x "/sys/class" ]; then
classdirpermerror="1"
fi
if [ ! -r "/sys/class/net" ]||[ ! -x "/sys/class/net" ]; then
netdirpermerror="1"
fi
}
# Display a message on how to fix the issue manually
fn_sys_perm_fix_manually_msg(){
echo ""
fn_print_information_nl "This error causes servers to fail starting properly"
fn_script_log_info "This error causes servers to fail starting properly."
echo " * To fix this issue, run the following command as root:"
fn_script_log_info "To fix this issue, run the following command as root:"
echo " chmod a+rx /sys /sys/class /sys/class/net"
fn_script_log "chmod a+rx /sys /sys/class /sys/class/net"
sleep 1
core_exit.sh
}
# Attempt to fix /sys related permission errors if sudo is available, exits otherwise
fn_sys_perm_errors_fix(){
sudo -v > /dev/null 2>&1
if [ $? -eq 0 ]; then
fn_print_dots "Automatically fixing /sys permissions"
sleep 2
fn_script_log_info "Automatically fixing /sys permissions."
if [ "${sysdirpermerror}" == "1" ]; then
sudo chmod a+rx "/sys"
fi
if [ "${classdirpermerror}" == "1" ]; then
sudo chmod a+rx "/sys/class"
fi
if [ "${netdirpermerror}" == "1" ]; then
sudo chmod a+rx "/sys/class/net"
fi
# Run check again to see if it's fixed
fn_sys_perm_errors_detect
if [ "${sysdirpermerror}" == "1" ]||[ "${classdirpermerror}" == "1" ]||[ "${netdirpermerror}" == "1" ]; then
fn_print_error "Could not fix /sys permissions"
fn_script_log_error "Could not fix /sys permissions."
sleep 1
# Show the user how to fix
fn_sys_perm_fix_manually_msg
else
fn_print_ok_nl "Automatically fixing /sys permissions"
fn_script_log_pass "Permissions in /sys fixed"
sleep 1
fi
else
# Show the user how to fix
fn_sys_perm_fix_manually_msg
fi
}
# Processes to the /sys related permission errors check & fix/info
fn_sys_perm_error_process(){
fn_sys_perm_errors_detect
# If any error was found
if [ "${sysdirpermerror}" == "1" ]||[ "${classdirpermerror}" == "1" ]||[ "${netdirpermerror}" == "1" ]; then
fn_print_error_nl "Permission error(s) found in /sys"
fn_script_log_error "Permission error(s) found in /sys"
sleep 1
# Run the fix
fn_sys_perm_errors_fix
fi
}
# Run perm error detect & fix/alert functions on /sys directories
## Run checks
fn_check_ownership
fn_check_permissions
fn_sys_perm_error_process

4
lgsm/functions/command_mods_remove.sh

@ -114,11 +114,11 @@ sleep 0.5
sed -i "/^${modcommand}$/d" "${modsinstalledlistfullpath}"
local exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_script_loga_fatal "Removing ${modcommand} from ${modsinstalledlist}"
fn_script_log_fatal "Removing ${modcommand} from ${modsinstalledlist}"
fn_print_fail_eol_nl
core_exit.sh
else
fn_script_loga_pass "Removing ${modcommand} from ${modsinstalledlist}"
fn_script_log_pass "Removing ${modcommand} from ${modsinstalledlist}"
fn_print_ok_eol_nl
fi

134
lgsm/functions/command_wipe.sh

@ -0,0 +1,134 @@
#!/bin/bash
# LGSM command_backup.sh function
# Author: Daniel Gibbs
# Contributor: UltimateByte
# Website: https://gameservermanagers.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
if [ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.sav")" ]; then
currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.sav"
echo -en "Removing map proceduralmap.*.sav file(s)..."
sleep 1
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 map file to remove"
fn_script_log_info "No map file to remove."
sleep 0.5
fi
if [ -d "${serveridentitydir}/user" ]; then
currentaction="Removing user directory: ${serveridentitydir}/user"
echo -en "Removing user directory..."
sleep 1
fn_script_log "${currentaction}"
rm -rf "${serveridentitydir}/user"
fn_wipe_exit_code
sleep 0.5
else
fn_print_information_nl "No user directory to remove"
fn_script_log_info "No user directory to remove."
sleep 0.5
fi
if [ -d "${serveridentitydir}/storage" ]; then
currentaction="Removing storage directory: ${serveridentitydir}/storage"
echo -en "Removing storage directory..."
sleep 1
fn_script_log "${currentaction}"
rm -rf "${serveridentitydir}/storage"
fn_wipe_exit_code
sleep 0.5
else
fn_print_information_nl "No storage directory to remove"
fn_script_log_info "No storage directory to remove."
sleep 0.5
fi
if [ -n "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]; then
currentaction="Removing log files: ${serveridentitydir}/Log.*.txt"
echo -en "Removing Log files..."
sleep 1
fn_script_log "${currentaction}"
find "${serveridentitydir}" -type f -name "Log.*.txt" -delete
fn_wipe_exit_code
sleep 0.5
else
fn_print_information_nl "No log files to remove"
fn_script_log_info "No log files to remove."
sleep 0.5
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 "Log.*.txt")" ]; then
fn_print_warning_nl "Any user, storage, log and map data from ${serveridentitydir} will be erased."
while true; do
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo Exiting; core_exit.sh;;
* ) echo "Please answer yes or no.";;
esac
done
fn_script_log_info "User selects to erase any user, storage, log and map data from ${serveridentitydir}"
sleep 1
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 1
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 1
core_exit.sh
fi
core_exit.sh

4
lgsm/functions/core_functions.sh

@ -217,6 +217,10 @@ functionfile="${FUNCNAME}"
fn_fetch_function
}
command_wipe.sh(){
functionfile="${FUNCNAME}"
fn_fetch_function
}
# Checks

88
lgsm/functions/core_getopt.sh

@ -648,6 +648,92 @@ case "${getopt}" in
esac
}
fn_getopt_rustserver(){
case "${getopt}" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
command_restart.sh;;
u|update)
command_update.sh;;
fu|force-update|update-restart)
forceupdate=1;
command_update.sh;;
uf|update-functions)
command_update_functions.sh;;
v|validate)
command_validate.sh;;
m|monitor)
command_monitor.sh;;
ta|test-alert)
command_test_alert.sh;;
dt|details)
command_details.sh;;
pd|postdetails)
command_postdetails.sh;;
b|backup)
command_backup.sh;;
c|console)
command_console.sh;;
d|debug)
command_debug.sh;;
dev|dev-debug)
command_dev_debug.sh;;
i|install)
command_install.sh;;
ai|auto-install)
fn_autoinstall;;
mi|mods-install)
command_mods_install.sh;;
mu|mods-update)
command_mods_update.sh;;
mr|mods-remove)
command_mods_remove.sh;;
wi|wipe)
command_wipe.sh;;
dd|detect-deps)
command_dev_detect_deps.sh;;
dg|detect-glibc)
command_dev_detect_glibc.sh;;
dl|detect-ldd)
command_dev_detect_ldd.sh;;
*)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "${lightyellow}Commands${default}"
{
echo -e "${blue}start\t${default}st |Start the server."
echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "${blue}details\t${default}dt |Displays useful information about the server."
echo -e "${blue}postdetails\t${default}pd |Post stripped details to pastebin (for support)"
echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "${blue}install\t${default}i |Install the server."
echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons."
echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons."
echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons."
echo -e "${blue}wipe\t${default}wi |Wipe your Rust server."
} | column -s $'\t' -t
esac
}
fn_getopt_unreal(){
case "${getopt}" in
st|start)
@ -873,6 +959,8 @@ elif [ "${gamename}" == "Mumble" ]; then
# Teamspeak 3
elif [ "${gamename}" == "TeamSpeak 3" ]; then
fn_getopt_teamspeak3
elif [ "${gamename}" == "Rust" ]; then
fn_getopt_rustserver
# Unreal 2 Engine
elif [ "${engine}" == "unreal2" ]; then
if [ "${gamename}" == "Unreal Tournament 2004" ]; then

23
lgsm/functions/mods_core.sh

@ -121,7 +121,7 @@ fn_mod_tidy_files_list(){
sleep 0.5
fn_script_log_info "Tidy up ${modcommand}-files.txt"
# Lines/files to remove from file list (end with ";" separator)
removefromlist="cfg;addons;"
removefromlist="cfg;addons;RustDedicated_Data;RustDedicated_Data\/Managed;RustDedicated_Data\/Managed\/x86;RustDedicated_Data\/Managed\/x64;"
# Loop through files to remove from file list,
# generate elements to remove from list
removefromlistamount="$(echo "${removefromlist}" | awk -F ';' '{ print NF }')"
@ -344,6 +344,21 @@ fn_mod_compatible_test(){
# Create mods files and directories if it doesn't exist
fn_create_mods_dir(){
# Create lgsm data modsdir
if [ ! -d "${modsdir}" ];then
echo "creating lgsm mods data directory ${modsdir}..."
mkdir -p "${modsdir}"
exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Creating mod download dir ${modsdir}"
core_exit.sh
else
fn_print_ok_eol_nl
fn_script_log_pass "Creating mod download dir ${modsdir}"
fi
sleep 0.5
fi
# Create mod install directory
if [ ! -d "${modinstalldir}" ]; then
echo "creating mods install directory ${modinstalldir}..."
@ -351,11 +366,11 @@ fn_create_mods_dir(){
exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Creating mod download dir ${modinstalldir}"
fn_script_log_fatal "Creating mod install directory ${modinstalldir}"
core_exit.sh
else
fn_print_ok_eol_nl
fn_script_log_pass "Creating mod download dir ${modinstalldir}"
fn_script_log_pass "Creating mod install directory ${modinstalldir}"
fi
sleep 0.5
fi
@ -424,7 +439,7 @@ fn_mods_check_installed(){
echo ""
fn_print_failure_nl "No installed mods or addons were found"
echo " * Install mods using LGSM first with: ./${selfname} mods-install"
fn_script_log_fail "No installed mods or addons were found."
fn_script_log_error "No installed mods or addons were found."
core_exit.sh
fi
}

2
lgsm/functions/mods_list.sh

@ -61,7 +61,7 @@ mod_info_utime=( MOD "utime" "UTime" "https://github.com/TeamUlysses/utime/archi
mod_info_uclip=( MOD "uclip" "UClip" "https://github.com/TeamUlysses/uclip/archive/master.zip" "uclip-master.zip" "0" "LowercaseOff" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://ulyssesmod.net" "An alternative to noclip" )
mod_info_acf=( MOD "acf" "Armoured Combat Framework" "https://github.com/nrlulz/ACF/archive/master.zip" "acf-master.zip" "0" "LowercaseOn" "${systemdir}/addons" "acf-master/lua/acf/shared/guns;" "ENGINES" "Garry's Mod;" "NOTGAMES" "https://github.com/nrlulz/ACF" "Realistic Wepons & Engines" )
mod_info_acf_missiles=( MOD "acfmissiles" "ACF Missiles" "https://github.com/Bubbus/ACF-Missiles/archive/master.zip" "acf-missiles-master.zip" "0" "LowercaseOn" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "https://github.com/Bubbus/ACF-Missiles" "More missiles for ACF" )
mod_info_acf_advdupe2=( MOD "advdupe2" "Advanced Duplicator 2" "https://github.com/wiremod/advdupe2/archive/master.zip" "advdupe2-master.zip" "0" "LowercaseOn" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://www.wiremod.com" "Save your constructions" )
mod_info_advdupe2=( MOD "advdupe2" "Advanced Duplicator 2" "https://github.com/wiremod/advdupe2/archive/master.zip" "advdupe2-master.zip" "0" "LowercaseOn" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://www.wiremod.com" "Save your constructions" )
mod_info_darkrp=( MOD "darkrp" "DarkRP" "https://github.com/FPtje/DarkRP/archive/master.zip" "darkrp-master.zip" "0" "LowercaseOn" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://darkrp.com" "Most popular gamemode" )
mod_info_darkrpmodification=( MOD "darkrpmodification" "DarkRP Modification" "https://github.com/FPtje/darkrpmodification/archive/master.zip" "darkrpmodification-master.zip" "0" "LowercaseOff" "${systemdir}/addons" "NOUPDATE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://darkrp.com" "Customize DarkRP settings" )
# Oxidemod

Loading…
Cancel
Save