-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-packages
executable file
·53 lines (43 loc) · 1.21 KB
/
install-packages
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
#!/bin/bash -eu
_mode="$(
_self="${0##*/}"
case "$_self" in
'install-packages' | 'upgrade-packages')
: "${_self%%-*}"
;;
*)
:
;;
esac
printf '%s\n' "$_" # Return value
)"
test "$_mode" == ':' && printf '%s\n' 'Invalid mode' && exit 1
if test "$_mode" == 'install' && [ $# = 0 ]; then
echo >&2 "No packages specified"
exit 1
fi
# Block users from running this unless they're root.
if [[ $EUID != 0 ]]; then
echo >&2 "Run this script again as root to $_mode packages."
exit 1
fi
# Set a runlevel to avoid invoke-rc.d warnings
# http://manpages.ubuntu.com/manpages/focal/man8/runlevel.8.html#environment
# shellcheck disable=SC2034
RUNLEVEL=1
DAZZLE_MARKS="/var/lib/apt/dazzle-marks/"
TIMESTAMP=$(date +%s)
if [ ! -d "${DAZZLE_MARKS}" ]; then
mkdir -p "${DAZZLE_MARKS}"
fi
debconf-set-selections <<<'debconf debconf/frontend select Noninteractive'
apt-get update
apt-get "$_mode" -yq --no-install-recommends "$@"
debconf-set-selections <<<'debconf debconf/frontend select Readline'
cp /var/lib/dpkg/status "${DAZZLE_MARKS}/${TIMESTAMP}.status"
apt-get clean -y
rm -rf \
/var/cache/debconf/* \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*