-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapt
68 lines (55 loc) · 1.56 KB
/
apt
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
#!/bin/bash
# apt jobs to run upon first login
# @example
# update, upgrade and autoremove
# RPI_APT_CMDS=( "update" "full-upgrade" "autoremove" )
# default options
RPI_APT_INTERACTIVE="${RPI_APT_INTERACTIVE:=false}"
RPI_APT_ON="${RPI_APT_ON:=login}"
to_array RPI_APT_CMDS
# load dependencies
plugin_load run || return 1
function run() {
case "${RPI_APT_ON}" in
"login")
rpi_run_on_first_login "$@"
;;
"boot")
rpi_run_on_first_boot "$@"
;;
?|*)
error "invalid RPI_APT_ON=${RPI_APT_ON}"
esac
}
rpi_apt_prerun() {
[[ -n "${RPI_APT_CMDS}" ]] || return 1
case "${RPI_APT_ON}" in
"login")
;;
"boot")
;;
?|*)
error "invalid RPI_APT_ON=${RPI_APT_ON} - valid: login, boot"
esac
return 0
}
rpi_apt_run() {
local cmd
for cmd in "${RPI_APT_CMDS[@]}" ; do
# run in interactive mode?
if [[ "${RPI_APT_INTERACTIVE}" == "true" ]] ; then
run "sudo apt ${cmd}" || error "apt"
# run in non-interactive mode
else
run "sudo DEBIAN_FRONTEND=noninteractive apt --assume-yes -o Dpkg::Options::=\"--force-confold\" --quiet ${cmd}" || error "install apt update"
fi
done
}
function rpi_apt_description() {
echo "run apt commands"
}
function rpi_apt_help_params() {
help_param "RPI_APT_CMDS" "array of apt commands to execute"
help_param "RPI_APT_INTERACTIVE" "run in interactive mode"
help_param "RPI_APT_ON" "login=run on login, boot=run on boot"
}