Skip to content

Commit c1e09d4

Browse files
committed
scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: smf_setDocLink(): complete the proposed SMF implementation [#722]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 449a658 commit c1e09d4

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,40 @@ smf_setSavedDeviceName() {
864864
smf_setSavedUniq "nut-driver:$1" "nut-driver-enumerator-generated-devicename" "DEVICE" astring "$2"
865865
}
866866
smf_setDocLink() {
867-
# FIXME: experiment and implement
868-
# Save device (config section) name $2 into service instance $1
867+
# Save documentation links for driver of device (config section) named $2
868+
# into service instance $1
869869
[ -n "$1" ] || return # No-op for global section
870-
__TARGET_FMRI="$1"
870+
__TARGET_FMRI="nut-driver:$1"
871871
__DRV="`upsconf_getDriver "$2"`"
872-
#Documentation=man:${__DRV}(8)
873-
#Documentation=${NUT_WEBSITE_BASE}/docs/man/${__DRV}.html
874-
unset __DRV
872+
873+
### Sample:
874+
#tm_common_name template
875+
#tm_common_name/C ustring "physical network interface autoconfiguration"
876+
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page template
877+
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page/name astring "Network Auto-Magic OpenSolaris Project Page"
878+
#tm_doc_Network_Auto-Magic_OpenSolaris_Project_Page/uri astring http://hub.opensolaris.org/bin/view/Project+nwam/
879+
#tm_man_nwamd8 template
880+
#tm_man_nwamd8/manpath astring /usr/share/man
881+
#tm_man_nwamd8/section astring 8
882+
#tm_man_nwamd8/title astring nwamd
883+
884+
__PG="tm_doc_${__DRV}_Page"
885+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" delprop "${__PG}" 2>/dev/null || true
886+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" addpg "${__PG}" template && \
887+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/name" = "astring" "${__DRV} online" && \
888+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/uri" = "astring" "${NUT_WEBSITE_BASE}/docs/man/${__DRV}.html"
889+
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the service property group ${__PG} for online docs">&2 ; return 1 ; }
890+
891+
# FIXME: Pass resolved $mandir if known
892+
__PG="tm_man_${__DRV}8"
893+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" delprop "${__PG}" 2>/dev/null || true
894+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" addpg "${__PG}" template && \
895+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/manpath" = "astring" "/usr/share/man" && \
896+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/section" = "astring" "8" && \
897+
/usr/sbin/svccfg -s "${__TARGET_FMRI}" setprop "${__PG}/titke" = "astring" "${__DRV}"
898+
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the service property group ${__PG} for local docs">&2 ; return 1 ; }
899+
900+
unset __DRV __PG __TARGET_FMRI
875901
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the device doc links">&2 ; return 1 ; }
876902
}
877903
smf_restart_upsd() {
@@ -1017,7 +1043,8 @@ EOF
10171043
[ $? = 0 ] && echo "OK" || { echo "FAILED to stash the device name">&2 ; return 1 ; }
10181044
}
10191045
systemd_setDocLink() {
1020-
# Save device (config section) name $2 into service instance $1
1046+
# Save documentation links for driver of device (config section) named $2
1047+
# into service instance $1
10211048
[ -n "$1" ] || return # No-op for global section
10221049
PROPFILE="${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-doclink.conf"
10231050
mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" && \

0 commit comments

Comments
 (0)