xref: /illumos-gate/usr/src/cmd/man/update-man-index (revision 2b77347c)
1*2b77347cSAndy Fiddaman#!/bin/ksh
2*2b77347cSAndy Fiddaman#
3*2b77347cSAndy Fiddaman# This file and its contents are supplied under the terms of the
4*2b77347cSAndy Fiddaman# Common Development and Distribution License ("CDDL"), version 1.0.
5*2b77347cSAndy Fiddaman# You may only use this file in accordance with the terms of version
6*2b77347cSAndy Fiddaman# 1.0 of the CDDL.
7*2b77347cSAndy Fiddaman#
8*2b77347cSAndy Fiddaman# A full copy of the text of the CDDL should have accompanied this
9*2b77347cSAndy Fiddaman# source. A copy of the CDDL is also available via the Internet at
10*2b77347cSAndy Fiddaman# http://www.illumos.org/license/CDDL.
11*2b77347cSAndy Fiddaman#
12*2b77347cSAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
13*2b77347cSAndy Fiddaman#
14*2b77347cSAndy Fiddaman
15*2b77347cSAndy Fiddaman[ -f /lib/svc/share/smf_include.sh ] || exit 1
16*2b77347cSAndy Fiddaman
17*2b77347cSAndy Fiddaman. /lib/svc/share/smf_include.sh
18*2b77347cSAndy Fiddaman
19*2b77347cSAndy Fiddaman# Associative array to hold unique components for manpath
20*2b77347cSAndy Fiddamantypeset -A manpath
21*2b77347cSAndy Fiddaman
22*2b77347cSAndy Fiddamandefault_system_path=
23*2b77347cSAndy Fiddamanif [ -f /etc/default/login ]; then
24*2b77347cSAndy Fiddaman	default_system_path="`grep '^PATH=' /etc/default/login | sed -n '
25*2b77347cSAndy Fiddaman	    s/PATH=//
26*2b77347cSAndy Fiddaman	    p
27*2b77347cSAndy Fiddaman	    q
28*2b77347cSAndy Fiddaman	    '`"
29*2b77347cSAndy Fiddamanfi
30*2b77347cSAndy Fiddaman
31*2b77347cSAndy FiddamanoIFS="$IFS"; IFS=":"
32*2b77347cSAndy Fiddaman# The config/manpath property from the service will have been passed as
33*2b77347cSAndy Fiddaman# arguments to this method script.
34*2b77347cSAndy Fiddamanfor p in $@; do
35*2b77347cSAndy Fiddaman	manpath["$p"]=1
36*2b77347cSAndy Fiddamandone
37*2b77347cSAndy Fiddaman
38*2b77347cSAndy Fiddaman# Add any additional man directories from the default system path
39*2b77347cSAndy Fiddamanfor p in $default_system_path; do
40*2b77347cSAndy Fiddaman	dir="`dirname "$p"`"
41*2b77347cSAndy Fiddaman	for suffix in man share/man; do
42*2b77347cSAndy Fiddaman		[ -d "$dir/$suffix" ] && manpath["$dir/$suffix"]=1
43*2b77347cSAndy Fiddaman	done
44*2b77347cSAndy Fiddamandone
45*2b77347cSAndy FiddamanIFS="$oIFS"
46*2b77347cSAndy Fiddaman
47*2b77347cSAndy FiddamanMANPATH=
48*2b77347cSAndy Fiddamanfor p in "${!manpath[@]}"; do
49*2b77347cSAndy Fiddaman	MANPATH+="${MANPATH:+:}$p"
50*2b77347cSAndy Fiddamandone
51*2b77347cSAndy Fiddaman
52*2b77347cSAndy Fiddamanecho "Rebuilding man page index using $MANPATH"
53*2b77347cSAndy Fiddamanexport MANPATH
54*2b77347cSAndy Fiddaman/usr/bin/man -w
55*2b77347cSAndy Fiddaman
56*2b77347cSAndy Fiddamanexit 0
57