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
|
||||
|
||||
# Temp file to monitor
|
||||
readonly APT_TMP_FILE="/tmp/.apt.upgrade"
|
||||
|
||||
## Colors
|
||||
readonly PURPLE='\033[1;35m'
|
||||
readonly RED='\033[0;31m'
|
||||
|
@ -65,24 +68,16 @@ debug_message() { # {{{
|
|||
# }}}
|
||||
is_apt_upgrade_absent() { # {{{
|
||||
|
||||
## Count the number of upgradable packages and substract 1 for the header
|
||||
#local_apt_upgrade_number="$(apt list --upgradable \
|
||||
#| wc -l \
|
||||
#| awk '{print $1-1}')"
|
||||
local_apt_upgrade_number="5"
|
||||
|
||||
case "${local_apt_upgrade_number}" in
|
||||
0 ) ## No available upgrade
|
||||
return_apt_upgrade_absent="0"
|
||||
;;
|
||||
* ) ## 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}."
|
||||
## Check if temp APT upgrade file is absent
|
||||
if [ ! -f "${APT_TMP_FILE}" ]; then
|
||||
return_apt_upgrade_absent="0"
|
||||
debug_message "is_apt_upgrade_absent − \
|
||||
NO APT upgrade available for this system."
|
||||
else
|
||||
return_apt_upgrade_absent="1"
|
||||
debug_message "is_apt_upgrade_absent − \
|
||||
APT upgrade seems available for this system."
|
||||
fi
|
||||
|
||||
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() { # {{{
|
||||
|
||||
## Count the number of upgradable packages and substract 1 for the header
|
||||
local_apt_upgrade_number="$(apt list --upgradable \
|
||||
| wc -l \
|
||||
| awk '{print $1-1}')"
|
||||
|
||||
case "${local_apt_upgrade_number}" in
|
||||
0 ) ## No available upgrade
|
||||
return_apt_upgrade_present="1"
|
||||
;;
|
||||
* ) ## Upgrade seems available
|
||||
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}."
|
||||
## Check if temp APT upgrade file exists
|
||||
if [ -f "${APT_TMP_FILE}" ]; then
|
||||
return_apt_upgrade_present="0"
|
||||
debug_message "is_apt_upgrade_absent − \
|
||||
APT upgrade seems available for this system."
|
||||
else
|
||||
return_apt_upgrade_present="1"
|
||||
debug_message "is_apt_upgrade_absent − \
|
||||
NO APT upgrade available for this system."
|
||||
fi
|
||||
|
||||
return "${return_apt_upgrade_present}"
|
||||
|
||||
|
@ -221,7 +209,7 @@ main() { # {{{
|
|||
is_job_running "${sge_hostname}" \
|
||||
&& exit 0
|
||||
|
||||
## If anything to maco is currently running
|
||||
## If anything related to maco is currently running
|
||||
### Exit
|
||||
is_proc_running "${maco_proc_pattern}" \
|
||||
&& exit 0
|
||||
|
|
Loading…
Reference in New Issue