sysupdate: minor fixes
This commit is contained in:
parent
0929ce279e
commit
496e0572bb
1 changed files with 11 additions and 10 deletions
|
|
@ -8,8 +8,8 @@ lock_file="$TMPDIR/sysupdate.lock"
|
||||||
|
|
||||||
get_running_programs()
|
get_running_programs()
|
||||||
{
|
{
|
||||||
echo "$1" | tr '-' '_' | grep -qwE "$(echo "$linuxpkgnames" | tr '-' '_')" && echo linux
|
echo "$*" | tr '-' '_' | grep -qwE "$(echo "$linuxpkgnames" | tr '-' '_')" && echo linux
|
||||||
for I in $1
|
for I in $*
|
||||||
do
|
do
|
||||||
pgrep -xi "$I" >/dev/null && echo $I
|
pgrep -xi "$I" >/dev/null && echo $I
|
||||||
done
|
done
|
||||||
|
|
@ -23,24 +23,25 @@ stop()
|
||||||
|
|
||||||
fetch_error()
|
fetch_error()
|
||||||
{
|
{
|
||||||
echo "Error: Could not fetch packages" > /dev/stderr
|
echo "Error: Could not fetch packages" >&2
|
||||||
znotif -T "System updates" -t 120 -m "Error during system updates: could not fetch packages"
|
znotif -T "System updates" -t 120 -m "Error during system updates: could not fetch packages"
|
||||||
stop 3
|
stop 3
|
||||||
}
|
}
|
||||||
|
|
||||||
update_error()
|
update_error()
|
||||||
{
|
{
|
||||||
echo "Error: Could not upgrade system" > /dev/stderr
|
echo "Error: Could not upgrade system" >&2
|
||||||
znotif -T "System updates" -t 120 -m "Error during system updates: could not upgrade"
|
znotif -T "System updates" -t 120 -m "Error during system updates: could not upgrade"
|
||||||
stop 3
|
stop 3
|
||||||
}
|
}
|
||||||
|
|
||||||
which zupdate >/dev/null || { echo "zupdate not installed" >&2; exit 4; }
|
which zupdate >/dev/null 2>&1 || { echo "zupdate not installed" >&2; exit 4; }
|
||||||
|
which znotif >/dev/null 2>&1 || { echo "znotif not installed" >&2; exit 4; }
|
||||||
|
|
||||||
# Check if another process is running
|
# Check if another process is running
|
||||||
if [ -n "$(pgrep zupdate)" ] || [ -f "$lock_file" ]
|
if [ -n "$(pgrep zupdate)" ] || [ -f "$lock_file" ]
|
||||||
then
|
then
|
||||||
echo "Updates are already running" > /dev/stderr
|
echo "Updates are already running" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
touch "$lock_file"
|
touch "$lock_file"
|
||||||
|
|
@ -48,12 +49,12 @@ touch "$lock_file"
|
||||||
# package manager specific variables
|
# package manager specific variables
|
||||||
if which apt >/dev/null 2>&1
|
if which apt >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
linuxpkgnames="linux-image-*"
|
linuxpkgnames="linux-image-.*"
|
||||||
elif which pacman > /dev/null 2>&1
|
elif which pacman > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
linuxpkgnames="linux|linux-hardened|linux-lts|linux-zen|linux-mainline|linux-rt|linux-git|linux-next"
|
linuxpkgnames="linux|linux-hardened|linux-lts|linux-zen|linux-mainline|linux-rt|linux-git|linux-next"
|
||||||
else
|
else
|
||||||
echo "Unsupported package manager" > /dev/stderr
|
echo "Unsupported package manager" >&2
|
||||||
stop 2
|
stop 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -75,8 +76,8 @@ if [ -n "$running_programs" ]
|
||||||
then
|
then
|
||||||
if ! znotif -T "System Updates" -y -m "The following running programs have recieved updates: \n$(echo "$running_programs" | sed 's|^| - |g')\nProceed?"
|
if ! znotif -T "System Updates" -y -m "The following running programs have recieved updates: \n$(echo "$running_programs" | sed 's|^| - |g')\nProceed?"
|
||||||
then
|
then
|
||||||
echo "Update cancelled" > /dev/stderr
|
echo "Update cancelled" >&2
|
||||||
stop 3
|
stop 5
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue