Browse Source

Updated gamedata files to include options and commands instead of having them on core_getopt.sh as code. Added gamedata removal to update_functions.sh

pull/553/head
Jared Ballou 10 years ago
parent
commit
2e140ae357
  1. 438
      functions/core_getopt.sh
  2. 1
      functions/update_functions.sh
  3. 28
      gamedata/_default
  4. 2
      gamedata/_source
  5. 6
      gamedata/_steam
  6. 5
      gamedata/_unreal
  7. 5
      gamedata/_unreal_shared
  8. 2
      gamedata/mumbleserver
  9. 2
      gamedata/ts3server
  10. 2
      lgsm-core

438
functions/core_getopt.sh

@ -6,425 +6,33 @@ lgsm_version="070116"
# Description: getopt arguments.
fn_getopt_generic(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
u|update)
update_check.sh;;
fu|force-update|update-restart)
forceupdate=1;
update_check.sh;;
uf|update-functions)
update_functions.sh;;
v|validate)
command_validate.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.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;;
sm|sourcemod)
install_sourcemod.sh;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
echo -e "\e[34msourcemod\t\e[0mInstall SourceMod."
} | column -s $'\t' -t
esac
exit
}
# This now uses the gamedata files, it creates a settings file named scriptactions
# This is processed into the pieces needed to execute commands and display usage.
fn_getopt_teamspeak3(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
u|update)
update_check.sh;;
uf|update-functions)
update_functions.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.sh;;
b|backup)
command_backup.sh;;
pw|change-password)
command_ts3_server_pass.sh;;
dev|dev-debug)
command_dev_debug.sh;;
i|install)
command_install.sh;;
ai|auto-install)
fn_autoinstall;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from teamspeak.com."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mchange-password\t\e[0mChanges TS3 serveradmin password."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
} | column -s $'\t' -t
esac
exit
}
fn_getopt_mumble(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
uf|update-functions)
update_functions.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
b|backup)
command_backup.sh;;
dev|dev-debug)
command_dev_debug.sh;;
console)
command_console.sh;;
d|debug)
command_debug.sh;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
} | column -s $'\t' -t
esac
exit
}
fn_getopt_gmodserver(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
u|update)
update_check.sh;;
fu|force-update|update-restart)
forceupdate=1;
update_check.sh;;
uf|update-functions)
update_functions.sh;;
v|validate)
command_validate.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.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;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
} | column -s $'\t' -t
esac
exit
}
fn_getopt_unreal(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
uf|update-functions)
update_functions.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.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;;
mc|map-compressor)
compress_ut99_maps.sh;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
} | column -s $'\t' -t
esac
exit
}
fn_getopt_unreal2(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
u|update)
update_check.sh;;
fu|force-update|update-restart)
forceupdate=1;
update_check.sh;;
uf|update-functions)
update_functions.sh;;
v|validate)
command_validate.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.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;;
dd|depsdetect)
command_dev_detect_deps.sh;;
mc|map-compressor)
compress_unreal2_maps.sh;;
*)
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
} | column -s $'\t' -t
esac
exit
}
fn_getopt_ut2k4(){
case "$getopt" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
fn_restart;;
uf|update-functions)
update_functions.sh;;
m|monitor)
command_monitor.sh;;
et|email-test)
command_email_test.sh;;
d|details)
command_details.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;;
mc|map-compressor)
compress_unreal2_maps.sh;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
fn_getopt_generic(){
USAGE=()
while IFS='' read -r line || [[ -n "$line" ]]; do
IFS='|' read -ra field <<< "${line}"
for opt in ${field[0]}; do
if [ "${getopt}" == "${opt}" ]; then
eval "${field[1]}"
exit
fi
done
if [ -z $optlen ] || [ ${#opt} -gt $optlen ]; then
optlen=${#opt}
fi
USAGE+=("\e[34m${opt}|\e[0m${field[2]}")
done < <(sed -e 's/"//g' -e 's/=/ /g' "${settingsdir}/scriptactions")
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "http://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "\e[93mCommands\e[0m"
{
echo -e "\e[34mstart\t\e[0mStart the server."
echo -e "\e[34mstop\t\e[0mStop the server."
echo -e "\e[34mrestart\t\e[0mRestart the server."
echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
echo -e "\e[34memail-test\t\e[0mSends test monitor email."
echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
} | column -s $'\t' -t
esac
exit
for row in "${USAGE[@]}"; do
IFS='|' read -ra action <<< "${row}"
printf "%-$(($optlen+5))b %-$(($optlen+15))b\n" "${action[0]}" "${action[1]}"
done
exit
}
if [ "${gamename}" == "Mumble" ]; then
fn_getopt_mumble
elif [ "${gamename}" == "Teamspeak 3" ]; then
fn_getopt_teamspeak3
elif [ "${engine}" == "unreal2" ]; then
if [ "${gamename}" == "Unreal Tournament 2004" ]; then
fn_getopt_ut2k4
else
fn_getopt_unreal2
fi
elif [ "${engine}" == "unreal" ]; then
fn_getopt_unreal
else
fn_getopt_generic
fi
fn_getopt_generic

1
functions/update_functions.sh

@ -13,6 +13,7 @@ fn_scriptlog "Updating functions"
sleep 1
echo -ne "\n"
rm -rfv "${lgsmdir}/functions/"*
rm -rfv "${lgsmdir}/gamedata/"*
exitcode=$?
if [ "${exitcode}" == "0" ]; then
fn_printok "Updating functions"

28
gamedata/_default

@ -44,20 +44,20 @@ fn_set_game_params settings "servercfgdefault" "\${servercfgdir}/lgsm-default\${
fn_set_game_params settings "servercfgfullpath" "\${servercfgdir}/\${servercfg}" "Full path to server config"
# Script actions
fn_set_game_params scriptactions "st|start" "command_start.sh" "Start the server."
fn_set_game_params scriptactions "sp|stop" "command_stop.sh" "Stop the server."
fn_set_game_params scriptactions "r|restart" "fn_restart" "Restart the server."
fn_set_game_params scriptactions "dd|depsdetect" "command_dev_detect_deps.sh" "Detect Dependencies"
fn_set_game_params scriptactions "u|update" "update_check.sh" "Checks and applies updates from SteamCMD."
fn_set_game_params scriptactions "uf|update-functions" "update_functions.sh" "Removes all functions so latest can be downloaded."
fn_set_game_params scriptactions "m|monitor" "command_monitor.sh" "Checks that the server is running."
fn_set_game_params scriptactions "et|email-test" "command_email_test.sh" "Sends test monitor email."
fn_set_game_params scriptactions "d|details" "command_details.sh" "Displays useful infomation about the server."
fn_set_game_params scriptactions "d|debug" "command_debug.sh" "See the output of the server directly to your terminal."
fn_set_game_params scriptactions "dev|dev-debug" "command_dev_debug.sh" "Toggle Developer Debug mode"
fn_set_game_params scriptactions "i|install" "command_install.sh" "Install the server."
fn_set_game_params scriptactions "ai|auto-install" "fn_autoinstall" "Install the server, without prompts."
fn_set_game_params scriptactions "b|backup" "command_backup.sh" "Create archive of the server."
fn_set_game_params scriptactions "st" "start|command_start.sh|Start the server."
fn_set_game_params scriptactions "sp" "stop|command_stop.sh|Stop the server."
fn_set_game_params scriptactions "r" "restart|fn_restart|Restart the server."
fn_set_game_params scriptactions "dd" "depsdetect|command_dev_detect_deps.sh|Detect Dependencies"
fn_set_game_params scriptactions "u" "update|update_check.sh|Checks and applies updates from SteamCMD."
fn_set_game_params scriptactions "uf" "update-functions|update_functions.sh|Removes all functions so latest can be downloaded."
fn_set_game_params scriptactions "m" "monitor|command_monitor.sh|Checks that the server is running."
fn_set_game_params scriptactions "et" "email-test|command_email_test.sh|Sends test monitor email."
fn_set_game_params scriptactions "d" "details|command_details.sh|Displays useful infomation about the server."
fn_set_game_params scriptactions "debug" "|command_debug.sh|See the output of the server directly to your terminal."
fn_set_game_params scriptactions "dev" "dev-debug|command_dev_debug.sh|Toggle Developer Debug mode"
fn_set_game_params scriptactions "i" "install|command_install.sh|Install the server."
fn_set_game_params scriptactions "ai" "auto-install|fn_autoinstall|Install the server, without prompts."
fn_set_game_params scriptactions "b" "backup|command_backup.sh|Create archive of the server."
# Default fn_parms just loads the parms file. Still need to figure out how to handle "simple" parms.
fn_parms(){

2
gamedata/_source

@ -14,4 +14,4 @@ fn_set_game_params parms_plus "tv_port" "\${sourcetvport}"
# These are values that the script uses, they don't get used by the srcds server directly
fn_set_game_params settings "executable" "./srcds_linux"
fn_set_game_params scriptactions "sm|sourcemod" "install_sourcemod.sh" "Install SourceMod."
fn_set_game_params scriptactions "sm" "sourcemod|install_sourcemod.sh|Install SourceMod."

6
gamedata/_steam

@ -11,7 +11,7 @@ fn_set_game_params settings "steamuser" "anonymous" "Steam Username"
fn_set_game_params settings "updateonstart" "off" "Update game on start"
# Script actions
fn_set_game_params scriptactions "fu|force-update|update-restart" "forceupdate=1; update_check.sh" "Bypasses the check and applies updates from SteamCMD."
fn_set_game_params scriptactions "v|validate" "command_validate.sh" "Validate server files with SteamCMD."
fn_set_game_params scriptactions "c|console" "command_console.sh" "Console allows you to access the live view of a server."
fn_set_game_params scriptactions "fu" "update-restart force-update|forceupdate=1; update_check.sh|Bypasses the check and applies updates from SteamCMD."
fn_set_game_params scriptactions "v" "validate|command_validate.sh|Validate server files with SteamCMD."
fn_set_game_params scriptactions "c" "console|command_console.sh|Console allows you to access the live view of a server."

5
gamedata/_unreal

@ -5,7 +5,4 @@
# Import default settings
fn_import_game_settings _unreal_shared
# This is the way we create a script that collates and parses the parameters
fn_parms(){
parms=""
}
fn_set_game_params scriptactions "mc" "map-compressor|compress_ut99_maps.sh|Map Compressor."

5
gamedata/_unreal_shared

@ -15,6 +15,5 @@ fn_set_game_params settings "servercfgfullpath" "${servercfgdir}/${servercfg}"
fn_set_game_params settings "servercfgdefault" "${servercfgdir}/Default.ini"
fn_set_game_params settings "compressedmapsdir" "${rootdir}/Maps-Compressed" "Compressed Maps Directory"
fn_set_game_params scriptactions "c|console" "command_console.sh" "Console View."
fn_set_game_params scriptactions "mc|map-compressor" "compress_ut99_maps.sh" "Map Compressor."
fn_set_game_params scriptactions "c" "console|command_console.sh|Console View."
fn_set_game_params scriptactions "mc" "map-compressor|compress_unreal2_maps.sh|Map Compressor."

2
gamedata/mumbleserver

@ -15,5 +15,5 @@ fn_set_game_params settings "executable" "./murmur.x86"
fn_set_game_params settings "servercfg" "murmur.ini"
fn_set_game_params settings "servercfgdir" "\${filesdir}"
fn_set_game_params scriptactions "console" "command_console.sh" "Console View."
fn_set_game_params scriptactions "c" "console|command_console.sh|Console View."

2
gamedata/ts3server

@ -14,5 +14,5 @@ fn_set_game_params settings "servercfg" "\${servicename}.ini"
fn_set_game_params settings "servercfgdir" "\${filesdir}"
fn_set_game_params settings "servercfgdefault" "\${servercfgdir}/lgsm-default.ini"
fn_set_game_params scriptactions "pw|change-password" "command_ts3_server_pass.sh" "Change Password."
fn_set_game_params scriptactions "pw" "change-password|command_ts3_server_pass.sh|Change Password."

2
lgsm-core

@ -24,7 +24,7 @@ if [ "${BASH_SOURCE[0]}" != "" ]; then
# Name of this service (will return symlink name for multiple instance support)
servicename="$(basename $0)"
# Script root directory
rootdir="$(dirname "${scriptpath}")
rootdir="$(dirname "${scriptpath}")"
else
scriptpath="$(pwd)/${core_script}"
selfname="${core_script}"

Loading…
Cancel
Save