From: Frank Brehm Date: Wed, 31 Aug 2022 15:09:18 +0000 (+0200) Subject: Moving some often used functions into scripts/functions.rc X-Git-Tag: 0.4.4^2^2~1 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=36b04d0c0851be21ab34ff23a9f14eaa1e9017d8;p=pixelpark%2Fpp-admin-tools.git Moving some often used functions into scripts/functions.rc --- diff --git a/scripts/backup-pdns.sh b/scripts/backup-pdns.sh index 08c24c7..2ff8e53 100755 --- a/scripts/backup-pdns.sh +++ b/scripts/backup-pdns.sh @@ -223,54 +223,6 @@ get_options() { } -######################################### -# Some often used funktions - -#------------------------------------------------------------------------------ -MKDIR() { - local cmd="mkdir" - if [[ "${VERBOSE}" == "y" ]] ; then - cmd+=" --verbose" - fi - eval ${cmd} "$@" -} - -#------------------------------------------------------------------------------ -MV() { - local cmd="mv" - if [[ "${VERBOSE}" == "y" ]] ; then - cmd+=" --verbose" - fi - eval ${cmd} "$@" -} - -#------------------------------------------------------------------------------ -RMDIR() { - local cmd="rmdir" - if [[ "${VERBOSE}" == "y" ]] ; then - cmd+=" --verbose" - fi - eval ${cmd} "$@" -} - -#------------------------------------------------------------------------------ -empty_line() { -# if [[ "${QUIET}" == "y" ]] ; then -# return 0 -# fi - echo -} - -#------------------------------------------------------------------------------ -check_for_root() { - local my_id=$( id -u ) - if [[ "${my_id}" != "0" ]] ; then - error "You must be ${RED}root${NORMAL} to execute this script." - echo >&2 - exit 1 - fi -} - ################################################################################ prepare_dirs() { diff --git a/scripts/functions.rc b/scripts/functions.rc index 9fbbf1d..f44977d 100644 --- a/scripts/functions.rc +++ b/scripts/functions.rc @@ -323,6 +323,19 @@ check_for_root() { fi } +#------------------------------------------------------------------------------ +MV() { + local cmd="mv" + if [[ "${VERBOSE}" == "y" ]] ; then + cmd+=" --verbose" + fi + if [[ "${SIMULATE}" == "y" ]] ; then + info "Executing: ${cmd} $*" + return + fi + eval ${cmd} "$@" +} + #------------------------------------------------------------------------------ RM() { @@ -364,6 +377,19 @@ MKDIR_forced() { eval ${cmd} } +#------------------------------------------------------------------------------ +RMDIR() { + local cmd="rmdir" + if [[ "${VERBOSE}" == "y" ]] ; then + cmd+=" --verbose" + fi + if [[ "${SIMULATE}" == "y" ]] ; then + info "Executing: ${cmd} $*" + return + fi + eval ${cmd} "$@" +} + #------------------------------------------------------------------------------ CHOWN() {