-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-pkg
executable file
·84 lines (77 loc) · 1.52 KB
/
update-pkg
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
pkg upgrade
pkg autoremove
pkg clean -qay
pkg version -qo -Rl '?'
pkg annotate -a -S deprecated
pkg annotate -a -S expiration_date
pkg audit
jail_update() {
jail="${1}"
name="${jail##*/}"
printf "\n%s:\n" "${name}"
jexec "${name}" pkg upgrade
jexec "${name}" pkg autoremove
jexec "${name}" pkg clean -qay
jexec "${name}" pkg version -qo -Rl '?'
jexec "${name}" pkg annotate -a -S deprecated
jexec "${name}" pkg annotate -a -S expiration_date
jexec "${name}" pkg audit
}
chroot_update() {
jail="${1}"
name="${jail##*/}"
printf "\n%s:\n" "${name}"
chroot "${jail}" pkg upgrade
chroot "${jail}" pkg autoremove
chroot "${jail}" pkg clean -qay
chroot "${jail}" pkg version -qo -Rl '?'
chroot "${jail}" pkg annotate -a -S deprecated
chroot "${jail}" pkg annotate -a -S expiration_date
chroot "${jail}" pkg audit
}
find_jail() {
name=`jls -n | fgrep " path=${jail} " | tr ' ' '\n' | grep "^name="`
name="${name#name=}"
case "${name}" in
'')
chroot_update "${jail}"
;;
*)
jail_update "${name}"
;;
esac
}
list=""
case "${1}" in
'')
ARCH=`make -V MACHINE_ARCH`
HOST=`hostname -s`"-${ARCH}"
list=""
for listfile in \
"/usr/local/etc/jails.pkg.txt" \
"/usr/local/etc/jails.txt" \
"/usr/src/jails-${HOST}.pkg.txt" \
"/usr/src/jails-${HOST}.txt"
do
if test ! -f "${listfile}"
then
continue
fi
list=`grep -v "^#" "${listfile}"`
break
done
;;
*)
list="${@}"
;;
esac
for jail in ${list}
do
if test ! -f "${jail}/var/db/pkg/local.sqlite"
then
continue
fi
find_jail "${jail}"
done
# eof