#!/bin/ksh93 # License: CDDL 1.0 (see http://opensource.org/licenses/cddl-1.0) # Copyright 2015 Jens Elkner. DIR_PROP='config/info_dirs' function getDirs { [[ -z ${SMF_FMRI} ]] && SMF_FMRI='texinfo-update2:default' typeset VAL="${ svcprop -p ${DIR_PROP} ${SMF_FMRI} 2>/dev/null ; }" [[ ${VAL} == '""' || -z ${VAL} ]] && VAL='/local/usr/share/info' print -- "${VAL//,/ }" } function updateDirs { typeset F X DIRS FILES \ INSTALL='/usr/bin/install-info' ND=${ mktemp /tmp/tu2.XXXXXX ; } integer I=0 if [[ -z ${ND} ]]; then print -u2 'Unable to create a temp file - exiting.' return 1 fi trap "rm -f ${ND}" EXIT [[ -x ${INSTALL} ]] || INSTALL=${ whence install-info ; } if [[ -z ${INSTALL} ]]; then print -u2 'install-info not found - exiting' return 2 fi for D in ${ getDirs ; } ; do [[ ${D:0:1} == '/' ]] || D="/$D" cd $D 2>/dev/null || continue # We insist on a file. symlink stuff gets usually handled by the # texinfo-update:default svc from the Solaris texinfo package. Also # -ot test works for real files, only (stats the entry, not dst ...). # However, we "record" symlinks and invoke svc-texinfo-update:default # atthe end if any have been found. This makes packaging/transforming # easier, since we can always use this svc ... [[ -h dir ]] && (( I++ )) && continue [[ -e dir && ! -f dir ]] && continue [[ dir -ot . ]] || continue # no dir modification so nothing to do FILES='' for F in ~(N)*.info ~(N)*.info.gz ; do FILES+=" $F" done printf \ 'This is the file .../info/dir, which contains the topmost node of the Info hierarchy, called (dir)Top. The first time you invoke Info you start off looking at this node. \x{1F} File: dir, Node: Top This is the top of the INFO tree This (the Directory node) gives a menu of major topics. Typing "q" exits, "?" lists all Info commands, "d" returns here, "h" gives a primer for first-timers, "mEmacs" visits the Emacs manual, etc. In Emacs, you can click mouse button 2 on a menu item or cross reference to select it. * Menu: ' >${ND} if [[ -z ${FILES} ]]; then [[ -e dir ]] || continue else for F in ${FILES} ; do ${INSTALL} $D/$F --dir-file=${ND} done fi cp ${ND} dir && chmod 0644 dir done if (( I )); then X=${ svcs -H -o STA texinfo-update:default 2>/dev/null ; } [[ $X == 'ON' ]] && svcadm refresh -s texinfo-update:default fi return 0 } # Allow manual invocation [[ -z $1 ]] && METHOD='refresh' || METHOD="$1" case "$1" in start|refresh) updateDirs || exit $? ;; stop) ;; *) print -u2 "Usage: ${0##*/} {start|refresh}" && exit 11 ;; esac exit ${SMF_EXIT_OK}