3 # Trivial (better is yet to come) SMF method script to start nut services
4 # Adapted for OpenIndiana userland from init.d script template in NUT sources
5 # Adaptation copyright (C) 2016 Jim Klimov
7 if [ -z "$SMF_FMRI" ]; then
8 echo "$0 must be called in SMF context!" &>2
13 .
/lib
/svc
/share
/smf_include.sh ||
exit
16 NUT_SBIN_DIR
="$NUT_DIR/sbin"
17 #NUT_SBIN_DIR="$NUT_DIR/sbin/@MACH64@"
18 NUT_RUN_DIR
="/@NUTRUNDIR@"
21 CONFIG
="/@NUTETCDIR@/nut.conf"
23 if [ -f "$CONFIG" ] ; then
30 "${NUT_SBIN_DIR}"/upsdrvctl stop
> /dev
/null
2>&1
34 if [ "$MODE" = "none" ];then
35 echo "No NUT mode set" >&2
36 exit $SMF_EXIT_ERR_CONFIG
39 # Default rights inspired by NUT scripts/Solaris/postinstall.in
40 mkdir
-p "$NUT_RUN_DIR" && \
41 chown
"root:$NUTGROUP" "$NUT_RUN_DIR" && \
42 chmod 770 "$NUT_RUN_DIR" \
43 ||
exit $SMF_EXIT_ERR_FATAL
45 if [ ! "$MODE" = "netclient" ];then
46 "${NUT_SBIN_DIR}"/upsdrvctl start
#> /dev/null 2>&1
47 "${NUT_SBIN_DIR}"/upsd
#> /dev/null 2>&1
49 "${NUT_SBIN_DIR}"/upsmon
#> /dev/null 2>&1
63 while pgrep upsd
> /dev
/null
70 "${NUT_SBIN_DIR}"/upsmon
-K >/dev
/null
2>&1
72 echo "Shutting down the UPS ..."
73 #"${NUT_SBIN_DIR}"/upsdrvctl shutdown
78 echo "Usage: '$0' {start | stop | restart }"
80 exit $SMF_EXIT_ERR_CONFIG