-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystemctl
More file actions
51 lines (38 loc) · 1.12 KB
/
systemctl
File metadata and controls
51 lines (38 loc) · 1.12 KB
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
#!/bin/bash
# run systemctl commands
# @example
# disable avahi-daemon
# RPI_SYSTEMCTL_CMDS=( "disable avahi-daemon avahi-daemon.socket" )
# default options
RPI_SYSTEMCTL_ON="${RPI_SYSTEMCTL_ON:=login}"
to_array RPI_SYSTEMCTL_CMDS
# load dependencies
plugin_load run || return 1
function run() {
case "${RPI_SYSTEMCTL_ON}" in
"login")
rpi_run_on_first_login "$@"
;;
"boot")
rpi_run_on_first_boot "$@"
;;
?|*)
error "invalid RPI_SYSTEMCTL_ON=${RPI_SYSTEMCTL_ON}"
esac
}
function rpi_systemctl_prerun() {
[[ -n "${RPI_SYSTEMCTL_CMDS}" ]] || { warn "RPI_SYSTEMCTL_CMDS must be set" ; return 1 ; }
return 0
}
function rpi_systemctl_run() {
for cmd in "${RPI_SYSTEMCTL_CMDS[@]}" ; do
run "sudo systemctl ${cmd}" || error "install systemctl ${cmd}"
done
}
function rpi_systemctl_description() {
echo "run systemctl commands once"
}
function rpi_systemctl_help_params() {
help_param "RPI_SYSTEMCTL_CMDS" "array of systemctl commands"
help_param "RPI_SYSTEMCTL_ON" "run on first \"boot\" or first \"login\""
}