From: Frank Brehm Date: Sun, 18 Apr 2021 12:33:41 +0000 (+0200) Subject: Renaming X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=6d5b48e917cbfeb2b24c1ffa1a7e3c20acbe8db4;p=pixelpark%2Fadmin-tools.git Renaming --- diff --git a/bin/update-minecraft-server-jar b/bin/update-minecraft-server-jar new file mode 100755 index 0000000..04a9cdb --- /dev/null +++ b/bin/update-minecraft-server-jar @@ -0,0 +1,140 @@ +#!/bin/bash + +set -e +set -u + +BASE_NAME="$( basename ${0} )" +MY_REAL_NAME=$( readlink -f $0 ) +BIN_DIR=$( dirname "${MY_REAL_NAME}" ) +BASE_DIR=$( dirname "${BIN_DIR}" ) +LIB_DIR="${BASE_DIR}/lib" +CONF_DIR="${BASE_DIR}/etc" + +if [[ -f "${LIB_DIR}/functions.rc" ]] ; then + . "${LIB_DIR}/functions.rc" +else + echo "Bash resource file '${LIB_DIR}/functions.rc' not found" >&2 + exit 5 +fi + + +MC_ROOT_DIR="/home/minecraft" +MC_BACKUP_DIR="${MC_ROOT_DIR}/backup" +MC_SERVER_DIR="${MC_ROOT_DIR}/server" +SERVER_JAR="${MC_SERVER_DIR}/minecraft_server.jar" + +VERSION_MANIFEST='https://launchermeta.mojang.com/mc/game/version_manifest.json' + +CURRENT_VERSION= +UPSTREAM_VERSION= + +DESCRIPTION=$( cat <<-EOF + Update Micraft server .jar file. + + EOF +) + +#------------------------------------------------------------------------------ +usage() { + cat <<-EOF + Usage: ${BASE_NAME} [Common Options] + ${BASE_NAME} [-h|--help] + ${BASE_NAME} [-V|--version] + + Common Options: + ${STD_USAGE_MSG} + EOF + +} + +#------------------------------------------------------------------------------ +get_options() { + + local tmp= + local base_dir= + + set +e + tmp=$( getopt -o ${STD_SHORT_OPTIONS} --long ${STD_LONG_OPTIONS} -n "${BASE_NAME}" -- "$@" ) + if [[ $? != 0 ]] ; then + echo "" >&2 + usage >&2 + exit 1 + fi + set -e + + # Note the quotes around `$TEMP': they are essential! + eval set -- "${tmp}" + eval_common_options "$@" + if [[ "${DEBUG}" == 'y' ]] ; then + declare -p REMAINING_OPTS + declare -p REMAINING_ARGS + fi + + if [[ "${#REMAINING_OPTS[@]}" -gt 0 ]] ; then + error "Unknown options: ${REMAINING_OPTS[*]}" + echo >&2 + usage >&2 + exit 2 + fi + + if [[ "${#REMAINING_ARGS[@]}" -gt 0 ]] ; then + error "Invalid arguments: ${REMAINING_ARGS[*]}" + echo >&2 + usage >&2 + exit 2 + fi + + check_for_root + + LOGFILE="/var/log/${BASE_NAME}.log" + +} + +#------------------------------------------------------------------------------ +check_preferences() { + + info "Checking preferences ..." + local all_ok="y" + + local -a tools=('curl' 'jq') + local tool= + local folder= + + for tool in "${tools[@]}" ; do + debug "Checking for '${CYAN}${tool}${NORMAL}' ..." + if type -p ${tool} >/dev/null ; then + : + else + all_ok="n" + error "Did not found '${RED}${tool}${NORMAL}'. Maybe not installed?" + fi + done + + for folder in "${MC_BACKUP_DIR}" "${MC_SERVER_DIR}" ; do + debug "Checking for directory '${folder}' ..." + if [[ ! -d "${folder}" ]]; then + all_ok="n" + error "Did not found directory '${RED}${folder}${NORMAL}'." + fi + done + + if [[ "${all_ok}" != "y" ]] ; then + exit 5 + fi + +} + +#------------------------------------------------------------------------------ +main() { + + get_options "$@" + umask 0022 + + check_preferences +} + +main "$@" + +exit 0 + +# vim: et list diff --git a/bin/update-minecraft-server-jar.sh b/bin/update-minecraft-server-jar.sh deleted file mode 100755 index 2c309bd..0000000 --- a/bin/update-minecraft-server-jar.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/bash - -set -e -set -u - -BASE_NAME="$( basename ${0} )" -MY_REAL_NAME=$( readlink -f $0 ) -BIN_DIR=$( dirname "${MY_REAL_NAME}" ) -BASE_DIR=$( dirname "${BIN_DIR}" ) -LIB_DIR="${BASE_DIR}/lib" -CONF_DIR="${BASE_DIR}/etc" - -if [[ -f "${LIB_DIR}/functions.rc" ]] ; then - . "${LIB_DIR}/functions.rc" -else - echo "Bash resource file '${LIB_DIR}/functions.rc' not found" >&2 - exit 5 -fi - - -MC_ROOT_DIR="/home/minecraft" -MC_BACKUP_DIR="${MC_ROOT_DIR}/backup" -MC_SERVER_DIR="${MC_ROOT_DIR}/server" -SERVER_JAR="${MC_SERVER_DIR}/minecraft_server.jar" - -VERSION_MANIFEST='https://launchermeta.mojang.com/mc/game/version_manifest.json' - -CURRENT_VERSION= -UPSTREAM_VERSION= - -DESCRIPTION=$( cat <<-EOF - Update Micraft server .jar file. - - EOF - -#------------------------------------------------------------------------------ -usage() { - cat <<-EOF - Usage: ${BASE_NAME} [Common Options] - ${BASE_NAME} [-h|--help] - ${BASE_NAME} [-V|--version] - - Common Options: - ${STD_USAGE_MSG} - EOF - -} - -#------------------------------------------------------------------------------ -get_options() { - - local tmp= - local base_dir= - - set +e - tmp=$( getopt -o ${STD_SHORT_OPTIONS} --long ${STD_LONG_OPTIONS} -n "${BASE_NAME}" -- "$@" ) - if [[ $? != 0 ]] ; then - echo "" >&2 - usage >&2 - exit 1 - fi - set -e - - # Note the quotes around `$TEMP': they are essential! - eval set -- "${tmp}" - eval_common_options "$@" - if [[ "${DEBUG}" == 'y' ]] ; then - declare -p REMAINING_OPTS - declare -p REMAINING_ARGS - fi - - if [[ "${#REMAINING_OPTS[@]}" -gt 0 ]] ; then - error "Unknown options: ${REMAINING_OPTS[*]}" - echo >&2 - usage >&2 - exit 2 - fi - - if [[ "${#REMAINING_ARGS[@]}" -gt 0 ]] ; then - error "Invalid arguments: ${REMAINING_ARGS[*]}" - echo >&2 - usage >&2 - exit 2 - fi - - check_for_root - - LOGFILE="/var/log/${BASE_NAME}.log" - -} - -#------------------------------------------------------------------------------ -check_preferences() { - - info "Checking preferences ..." - local all_ok="y" - - local -a tools=('curl' 'jq') - local tool= - local folder= - - for tool in "${tools[@]}" ; do - debug "Checking for '${CYAN}${tool}${NORMAL}' ..." - if type -p ${tool} >/dev/null ; then - : - else - all_ok="n" - error "Did not found '${RED}${tool}${NORMAL}'. Maybe not installed?" - fi - done - - for folder in "${MC_BACKUP_DIR}" "${MC_SERVER_DIR}" ; do - debug "Checking for directory '${folder}' ..." - if [[ ! -d "${folder}" ]]; then - all_ok="n" - error "Did not found directory '${RED}${folder}${NORMAL}'." - fi - done - - if [[ "${all_ok}" != "y" ]] ; then - exit 5 - fi - -} - -#------------------------------------------------------------------------------ -main() { - - get_options "$@" - umask 0022 - - check_preferences -} - -main "$@" - -exit 0 - -# vim: et list