Manual page install function

Function to install man page.
Verifies that man pages are installed, and correct directory for the pihole manpage is present.
Copies file, and runs man-db to update man page database.

Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
Rob Gill 2018-06-02 09:45:04 +10:00 committed by GitHub
parent ef17f4913b
commit a8103ca22d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1193,6 +1193,37 @@ installConfigs() {
fi
}
install_manpage() {
# Copy Pi-hole man page and call mandb to update man page database
# Default location for man files for /usr/local/bin is /usr/local/share/man
# on lightweight systems may not be present, so check before copying.
echo -en " ${INFO} Testing man page installation"
if ! command -v mandb; then
# if mandb is not present, no manpage support
echo -e "${OVER} ${INFO} man not installed"
return
elif [[ ! -d "/usr/local/share/man" ]]; then
# appropriate directory for Pi-hole's man page is not present
echo -e "${OVER} ${INFO} man page not installed"
return
elif [[ ! -d "/usr/local/share/man/man8"]]; then
# if not present, create man8 directory
mkdir /usr/local/share/man/man8
fi
# Testing complete, copy the file & update the man db
cp ${PI_HOLE_LOCAL_REPO}/pihole.8 /usr/local/share/man/man8/pihole.8
if mandb -q &>/dev/null; then
# Updated successfully
echo -e "${OVER} ${TICK} man page installed and database updated"
return
else
# Something is wrong with the system's man installation, clean up
# our file, (leave everything how we found it).
rm /usr/local/share/man/man8/pihole.8
echo -e "${OVER} ${INFO} man page db not updated, man page not installed"
fi
}
stop_service() {
# Stop service passed in as argument.
# Can softfail, as process may not be installed when this is called
@ -1695,6 +1726,9 @@ installPihole() {
configureFirewall
fi
# install a man page entry for pihole
install_manpage
# Update setupvars.conf with any variables that may or may not have been changed during the install
finalExports
}