This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-helper.sh
executable file
·67 lines (60 loc) · 1.82 KB
/
update-helper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
function help() {
echo "update trigger helper"
echo "usage: update-helper [options] [PATH]"
echo ""
echo " PATH: Run update scripts in a chroot located at PATH (does not use systemd)"
echo ""
echo "options:"
echo " --reexec -r: Will run daemon-reexec instead of daemon-reload (only used with systemctl)"
echo " --no-block -n: Will run the update hooks in the background"
echo " --help -h: display this menu"
echo ""
}
update() {
local block_flag=""
local reexec=
local prefix="/"
for var in "$@"; do
case "$var" in
"--help"|"-h")
help
exit 0
;;
"--no-block"|"-n")
block_flag="--no-block"
;;
"--reexec"|"-r")
reexec=1
;;
*)
if [ "$prefix" != "/" ]; then
help
exit -1
fi
prefix="$var"
;;
esac
done
systemctl &> /dev/null
# Check if systemd is init and not being run for a chroot update
if [ $? -eq 0 ] && [ "${prefix}" = "/" ]; then
if [ ! -z "${reexec}" ]; then
systemctl daemon-reexec
else
systemctl daemon-reload
fi
# make sure daemons are restarted if needed, first
if [ -x /usr/bin/clr-service-restart ]; then
/usr/bin/clr-service-restart
fi
systemctl restart "${block_flag}" update-triggers.target
else # Not using systemd as init, run the trigger scripts
if [ -z "${block_flag}" ]; then
"${prefix}/usr/libexec/updater/update-trigger.sh" "${prefix}"
else
"${prefix}/usr/libexec/updater/update-trigger.sh" "${prefix}" &
fi
fi
}
update "$@"