From 9549db7a170ea1ab46e298f5cac3a895f192e7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 24 Jun 2020 11:47:24 +0200 Subject: [PATCH] Prepare temp script during tests on physix*5 nodes To avoid two differents upgrades systems on some nodes. --- cluster/maco.remove.jobs.sh | 118 ++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 cluster/maco.remove.jobs.sh diff --git a/cluster/maco.remove.jobs.sh b/cluster/maco.remove.jobs.sh new file mode 100755 index 0000000..c3ad302 --- /dev/null +++ b/cluster/maco.remove.jobs.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +# Vars {{{ +readonly PROGNAME=$(basename "${0}") +readonly PROGDIR=$(readlink -m $(dirname "${0}")) +readonly ARGS="${*}" +readonly NBARGS="${#}" +[ -z "${DEBUG}" ] && DEBUG=1 + +## Colors +readonly PURPLE='\033[1;35m' +readonly RED='\033[0;31m' +readonly RESET='\033[0m' +readonly COLOR_DEBUG="${PURPLE}" +# }}} + +usage() { # {{{ + + cat <<- EOF +usage: $PROGNAME [--help] [-d|-h] + +Try to disable default Maco's cron (upgrades,…). + +EXAMPLES: + - Disable Maco's cron on the current host + ${PROGNAME} + +OPTIONS : + -d,--debug + Enable debug messages. + + -h,--help + Print this help message. +EOF + +} +# }}} +debug_message() { # {{{ + + local_message="${1}" + + ## Print message if DEBUG is enable (=0) + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG − ${PROGNAME}: ${local_message}" + +} +# }}} +remove_cron() { # {{{ + + debug_message "remove_cron − \ +Try to remove cron jobs (autoupdate, benchmark,…)." + + # Remove default Maco cron that check updates + rm -f /etc/cron.daily/ipr_autoupdate + + # and benchmark + rm -f /etc/cron.daily/ipr_benchmark + +} +# }}} +main() { # {{{ + + remove_cron + +} +# }}} + +# Manage arguments # {{{ +# This code can't be in a function due to arguments + +if [ ! "${NBARGS}" -eq "0" ]; then + + manage_arg="0" + + # Parse all options (start with a "-") one by one + while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do + + case "${1}" in + -d|--debug ) ## debug + DEBUG=0 + ;; + -h,--help ) ## help + usage + ## Exit after help informations + exit 0 + ;; + -- ) ## End of options list + ## End the while loop + break + ;; + * ) ## unknow option + printf '%b\n' "${RED}Invalid option: ${1}${RESET}" + printf '%b\n' "---" + usage + exit 1 + ;; + esac + + debug_message "Arguments management − \ +${RED}${1}${COLOR_DEBUG} option managed." + + ## Move to the next argument + shift + manage_arg=$((manage_arg+1)) + + done + + debug_message "Arguments management − \ +${RED}${manage_arg}${COLOR_DEBUG} argument(s) successfully managed." +else + debug_message "Arguments management − \ +No arguments/options to manage." +fi + +# }}} + +main + +exit 0