Skip to content

Commit

Permalink
scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: smf_setDocLink(): c…
Browse files Browse the repository at this point in the history
…omplete the proposed SMF implementation [#722]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Dec 25, 2024
1 parent 449a658 commit c1e09d4
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -864,14 +864,40 @@ smf_setSavedDeviceName() {
smf_setSavedUniq "nut-driver:$1" "nut-driver-enumerator-generated-devicename" "DEVICE" astring "$2"
}
smf_setDocLink() {
# FIXME: experiment and implement
# Save device (config section) name $2 into service instance $1
# Save documentation links for driver of device (config section) named $2
# into service instance $1
[ -n "$1" ] || return # No-op for global section
__TARGET_FMRI="$1"
__TARGET_FMRI="nut-driver:$1"
__DRV="`upsconf_getDriver "$2"`"
#Documentation=man:${__DRV}(8)
#Documentation=${NUT_WEBSITE_BASE}/docs/man/${__DRV}.html
unset __DRV

### Sample:
#tm_common_name template
#tm_common_name/C ustring "physical network interface autoconfiguration"
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page template
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page/name astring "Network Auto-Magic OpenSolaris Project Page"
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page/uri astring http://hub.opensolaris.org/bin/view/Project+nwam/
#tm_man_nwamd8 template
#tm_man_nwamd8/manpath astring /usr/share/man
#tm_man_nwamd8/section astring 8
#tm_man_nwamd8/title astring nwamd

__PG="tm_doc_${__DRV}_Page"
/usr/sbin/svccfg -s "${__TARGET_FMRI}" delprop "${__PG}" 2>/dev/null || true
/usr/sbin/svccfg -s "${__TARGET_FMRI}" addpg "${__PG}" template && \
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/name" = "astring" "${__DRV} online" && \
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/uri" = "astring" "${NUT_WEBSITE_BASE}/docs/man/${__DRV}.html"
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the service property group ${__PG} for online docs">&2 ; return 1 ; }

# FIXME: Pass resolved $mandir if known
__PG="tm_man_${__DRV}8"
/usr/sbin/svccfg -s "${__TARGET_FMRI}" delprop "${__PG}" 2>/dev/null || true
/usr/sbin/svccfg -s "${__TARGET_FMRI}" addpg "${__PG}" template && \
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/manpath" = "astring" "/usr/share/man" && \
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/section" = "astring" "8" && \
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/titke" = "astring" "${__DRV}"
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the service property group ${__PG} for local docs">&2 ; return 1 ; }

unset __DRV __PG __TARGET_FMRI
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the device doc links">&2 ; return 1 ; }
}
smf_restart_upsd() {
Expand Down Expand Up @@ -1017,7 +1043,8 @@ EOF
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the device name">&2 ; return 1 ; }
}
systemd_setDocLink() {
# Save device (config section) name $2 into service instance $1
# Save documentation links for driver of device (config section) named $2
# into service instance $1
[ -n "$1" ] || return # No-op for global section
PROPFILE="${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-doclink.conf"
mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" && \
Expand Down

0 comments on commit c1e09d4

Please sign in to comment.