Watch for temp APT file if APT upgrade is available
This commit is contained in:
parent
6a84224f8a
commit
27ef7256a0
|
@ -16,6 +16,9 @@ readonly NBARGS="${#}"
|
||||||
## Export DEBUG for sub-script
|
## Export DEBUG for sub-script
|
||||||
export DEBUG
|
export DEBUG
|
||||||
|
|
||||||
|
# Temp file to monitor
|
||||||
|
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'
|
||||||
|
@ -65,24 +68,16 @@ debug_message() { # {{{
|
||||||
# }}}
|
# }}}
|
||||||
is_apt_upgrade_absent() { # {{{
|
is_apt_upgrade_absent() { # {{{
|
||||||
|
|
||||||
## Count the number of upgradable packages and substract 1 for the header
|
## Check if temp APT upgrade file is absent
|
||||||
#local_apt_upgrade_number="$(apt list --upgradable \
|
if [ ! -f "${APT_TMP_FILE}" ]; then
|
||||||
#| wc -l \
|
return_apt_upgrade_absent="0"
|
||||||
#| awk '{print $1-1}')"
|
debug_message "is_apt_upgrade_absent − \
|
||||||
local_apt_upgrade_number="5"
|
NO APT upgrade available for this system."
|
||||||
|
else
|
||||||
case "${local_apt_upgrade_number}" in
|
return_apt_upgrade_absent="1"
|
||||||
0 ) ## No available upgrade
|
debug_message "is_apt_upgrade_absent − \
|
||||||
return_apt_upgrade_absent="0"
|
APT upgrade seems available for this system."
|
||||||
;;
|
fi
|
||||||
* ) ## Upgrade seems available
|
|
||||||
return_apt_upgrade_absent="1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
## Simple debug message to valid current variable
|
|
||||||
debug_message "is_apt_upgrade_absent − \
|
|
||||||
APT upgrade available for this system: ${RED}${local_apt_upgrade_number:=/dev/null}${COLOR_DEBUG}."
|
|
||||||
|
|
||||||
return "${return_apt_upgrade_absent}"
|
return "${return_apt_upgrade_absent}"
|
||||||
|
|
||||||
|
@ -90,23 +85,16 @@ APT upgrade available for this system: ${RED}${local_apt_upgrade_number:=/dev/nu
|
||||||
# }}}
|
# }}}
|
||||||
is_apt_upgrade_present() { # {{{
|
is_apt_upgrade_present() { # {{{
|
||||||
|
|
||||||
## Count the number of upgradable packages and substract 1 for the header
|
## Check if temp APT upgrade file exists
|
||||||
local_apt_upgrade_number="$(apt list --upgradable \
|
if [ -f "${APT_TMP_FILE}" ]; then
|
||||||
| wc -l \
|
return_apt_upgrade_present="0"
|
||||||
| awk '{print $1-1}')"
|
debug_message "is_apt_upgrade_absent − \
|
||||||
|
APT upgrade seems available for this system."
|
||||||
case "${local_apt_upgrade_number}" in
|
else
|
||||||
0 ) ## No available upgrade
|
return_apt_upgrade_present="1"
|
||||||
return_apt_upgrade_present="1"
|
debug_message "is_apt_upgrade_absent − \
|
||||||
;;
|
NO APT upgrade available for this system."
|
||||||
* ) ## Upgrade seems available
|
fi
|
||||||
return_apt_upgrade_present="0"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
## Simple debug message to valid current variable
|
|
||||||
debug_message "is_apt_upgrade_present − \
|
|
||||||
APT upgrade available for this system: ${RED}${local_apt_upgrade_number:=/dev/null}${COLOR_DEBUG}."
|
|
||||||
|
|
||||||
return "${return_apt_upgrade_present}"
|
return "${return_apt_upgrade_present}"
|
||||||
|
|
||||||
|
@ -221,7 +209,7 @@ main() { # {{{
|
||||||
is_job_running "${sge_hostname}" \
|
is_job_running "${sge_hostname}" \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
|
|
||||||
## If anything to maco is currently running
|
## If anything related to maco is currently running
|
||||||
### Exit
|
### Exit
|
||||||
is_proc_running "${maco_proc_pattern}" \
|
is_proc_running "${maco_proc_pattern}" \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
|
|
Loading…
Reference in New Issue