summaryrefslogtreecommitdiffstats
path: root/net/nut/files/nut-upsmon.default
blob: 3eda299188acb36d21bb36732d63e59f6fbb7aea (plain)
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
#!/bin/sh
# In recent (relevant) versions of shellcheck busybox is a valid shell type
# shellcheck shell=busybox

# uci-defaults script to setup nut-upsmon package
#  * create (if not present) shared group for directories shared with nut-server
#  * install/create NSS certificate/key database

# IPKG_INSTROOT is intentionally only set when building an image and
# is intentionally empty on a live OpenWrt device

# Shellcheck source paths intentionally point to the location of files of
# the scripts in the development environment (where shellcheck is used), not
# on the live OpenWrt device.

# This script lives in nut-upsmon package, which is independent of the
# nut-server package in which nut-server.default lives

# The separate packages limit the opportunities for code-sharing across the
# scripts.

# Only run this uci-defaults script on a live OpenWrt device
[ -z "${IPKG_INSTROOT}" ] || exit 0

# shellcheck source=net/nut/files/functions.sh.functions
. /lib/functions.sh || {
	# As the uci-defaults environment in which this runs does not have logging
	# available, nor is stderr captured or displayed on the console, these messages
	# exist only to assist when debugging manual runs of the script.
	printf "'%s': '%s'" "nut-upsmon.default" "FATAL: Unable to source 'functions.sh'" || true
	exit 1
}

if ! group_exists "nutgrp"; then
	group_add_next "nutgrp"
fi

group_add_user "nutgrp" "nutmon"