Create a temp file if APT upgrade is available

This commit is contained in:
Jeremy Gardais 2020-06-18 08:45:28 +02:00
parent 448f71d4cc
commit 6a84224f8a
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 8 additions and 1 deletions

View File

@ -2,7 +2,8 @@
# This script will check if any APT upgrade is available and # This script will check if any APT upgrade is available and
# will prepare the host in order to apply upgrade with another script # will prepare the host in order to apply upgrade with another script
# 1. Disable SGE queue # 1. Create a temp file
# 2. Disable SGE queue
# This script can be call by a cronjob (eg. weekly) # This script can be call by a cronjob (eg. weekly)
# Another script should try to apply upgrades also with cron (eg. hourly) # Another script should try to apply upgrades also with cron (eg. hourly)
@ -16,6 +17,8 @@ readonly NBARGS="${#}"
## Export DEBUG for sub-script ## Export DEBUG for sub-script
export DEBUG export DEBUG
readonly APT_TMP_FILE="/tmp/.apt.upgrade"
## Colors ## Colors
readonly PURPLE='\033[1;35m' readonly PURPLE='\033[1;35m'
readonly RED='\033[0;31m' readonly RED='\033[0;31m'
@ -118,13 +121,17 @@ main() { # {{{
disable_host_queue_script="${PROGDIR}/disable.host.queue.sh" disable_host_queue_script="${PROGDIR}/disable.host.queue.sh"
## If NO APT package upgrade is available ## If NO APT package upgrade is available
### Ensure to remove any temp file related to APT upgrades
### Exit ### Exit
is_apt_upgrade_absent \ is_apt_upgrade_absent \
&& rm -f -- "${APT_TMP_FILE}" \
&& exit 0 && exit 0
## If APT package upgrade is available ## If APT package upgrade is available
### Create a temp file
### Disable SGE queue ### Disable SGE queue
is_apt_upgrade_present \ is_apt_upgrade_present \
&& touch "${APT_TMP_FILE}" && echo "APT upgrade is available." >> "${APT_TMP_FILE}" \
&& sh "${disable_host_queue_script}" \ && sh "${disable_host_queue_script}" \
&& exit 0 && exit 0