#!/bin/sh
#
# $NetBSD: header,v 1.3 2014/12/30 15:13:20 wiz Exp $

SELF="$0"
PKGNAME="$1"
STAGE="$2"
shift 2

AWK="/usr/bin/awk"
BASENAME="/usr/bin/basename"
CAT="/bin/cat"
CHGRP="/usr/bin/chgrp"
CHMOD="/bin/chmod"
CHOWN="/usr/sbin/chown"
CMP="/usr/bin/cmp"
CP="/bin/cp"
DIRNAME="/usr/bin/dirname"
ECHO="echo"
ECHO_N="echo -n"
EGREP="/usr/bin/egrep"
EXPR="/bin/expr"
FALSE="false"
FIND="/usr/bin/find"
GREP="/usr/bin/grep"
GTAR=""
HEAD="/usr/bin/head"
ID="/usr/bin/id"
LINKFARM="/usr/sbin/linkfarm"
LN="/bin/ln"
LS="/bin/ls"
MKDIR="/bin/mkdir -p"
MV="mv -f"
PERL5="/usr/pkg/bin/perl"
PKG_ADMIN="/usr/sbin/pkg_admin"
PKG_INFO="/usr/sbin/pkg_info"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SETENV="/usr/bin/env"
SH="/bin/sh"
SORT="/usr/bin/sort"
SU="/usr/bin/su"
TEST="test"
TOUCH="/usr/bin/touch"
TR="/usr/bin/tr"
TRUE="true"
XARGS="/usr/bin/xargs"

CURDIR=`${PWD_CMD}`
: ${PKG_METADATA_DIR=${CURDIR}}
PKGBASE="xymon"

LOCALBASE="/usr/pkg"
X11BASE="/usr/X11R7"
PREFIX="/usr/pkg"

PKG_SYSCONFBASE="/usr/pkg/etc"
PKG_SYSCONFBASEDIR="/usr/pkg/etc/xymon"
PKG_SYSCONFDIR="/usr/pkg/etc/xymon"
CONF_DEPENDS=""

CONF_IGNORE_FILES="*[~#] *.OLD *.orig *,v .pkgsrc */.pkgsrc"

case "${PKG_CONFIG:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_CONFIG=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_CONFIG=yes
	;;
esac

#! /bin/sh
#
# $NetBSD: DEINSTALL,v 1.3 2022/08/22 15:22:14 tnn Exp $
#

# xymons user/group

EXAMPLEDIR=/usr/pkg/share/examples/xymon
XYMONHOME=/usr/pkg/share/xymon/xymonhome
XYMONVAR=/var/xymon
XYMONLOGDIR=/var/log/xymon

XYBINDIR=/usr/pkg/libexec/xymon
XYETCDIR=/usr/pkg/etc/xymon
XYEXTDIR=/usr/pkg/libexec/xymon/ext
XYTMPDIR=/var/xymon/tmp
XYWEBDIR=/usr/pkg/share/xymon/web
XYWWWDIR=/var/xymon/www

case ${STAGE} in
DEINSTALL)

	GIFS="README arrow.gif bkg-blue.gif bkg-clear.gif		\
		bkg-green.gif bkg-purple.gif bkg-red.gif bkg-yellow.gif	\
		blue-ack.gif blue-recent.gif blue.gif clear-recent.gif	\
		clear.gif favicon-blue.ico favicon-clear.ico		\
		favicon-green.ico favicon-purple.ico favicon-red.ico	\
		favicon-unknown.ico favicon-yellow.ico green-recent.gif	\
		green.gif purple-ack.gif purple-recent.gif purple.gif	\
		red-ack.gif red-recent.gif red.gif unknown-recent.gif	\
		unknown.gif xymonbody.css yellow-ack.gif		\
		yellow-recent.gif yellow.gif zoom.gif"
	for file in ${GIFS}; do
		${RM} ${XYWWWDIR}/gifs/${file}
	done

	MENUFILES="b2t-blue.gif b2t-grey.gif t2b-blue.gif t2b-grey.gif	\
			xymonmenu-blue.css xymonmenu-grey.css"
	for file in ${MENUFILES}; do
		${RM} ${XYWWWDIR}/menu/${file}
	done

	DOCFILES="Renaming-430.txt about.html bb-to-xymon.html		\
			clonewarn.jpg configure.txt			\
			criticalsystems.html critview-detail-acked.jpg	\
			critview-detail-ackform.jpg			\
			critview-detail.jpg critview-disk.jpg		\
			critview-green.jpg editor-clonemaster.jpg	\
			editor-diskchanged.jpg editor-disksetup.jpg	\
			editor-main.jpg editor-makeclone.jpg		\
			editor-nohost.jpg editor-showclone.jpg		\
			howtograph.html install.html known-issues.html	\
			mainview-acked.jpg mainview.jpg			\
			manpages/index.html				\
			manpages/man1/ackinfo.cgi.1.html		\
			manpages/man1/acknowledge.cgi.1.html		\
			manpages/man1/clientupdate.1.html		\
			manpages/man1/combostatus.1.html		\
			manpages/man1/confreport.cgi.1.html		\
			manpages/man1/criticaleditor.cgi.1.html		\
			manpages/man1/criticalview.cgi.1.html		\
			manpages/man1/csvinfo.cgi.1.html		\
			manpages/man1/datepage.cgi.1.html		\
			manpages/man1/eventlog.cgi.1.html		\
			manpages/man1/findhost.cgi.1.html		\
			manpages/man1/ghostlist.cgi.1.html		\
			manpages/man1/history.cgi.1.html		\
			manpages/man1/hostgraphs.cgi.1.html		\
			manpages/man1/logfetch.1.html			\
			manpages/man1/orcaxymon.1.html			\
			manpages/man1/report.cgi.1.html			\
			manpages/man1/reportlog.cgi.1.html		\
			manpages/man1/showgraph.cgi.1.html		\
			manpages/man1/snapshot.cgi.1.html		\
			manpages/man1/statusreport.cgi.1.html		\
			manpages/man1/svcstatus.cgi.1.html		\
			manpages/man1/xymon.1.html			\
			manpages/man1/xymoncfg.1.html			\
			manpages/man1/xymoncmd.1.html			\
			manpages/man1/xymondigest.1.html		\
			manpages/man1/xymongen.1.html			\
			manpages/man1/xymongrep.1.html			\
			manpages/man1/xymonnet-again.sh.1.html		\
			manpages/man1/xymonnet.1.html			\
			manpages/man1/xymonpage.cgi.1.html		\
			manpages/man1/xymonping.1.html			\
			manpages/man5/alerts.cfg.5.html			\
			manpages/man5/analysis.cfg.5.html		\
			manpages/man5/cgioptions.cfg.5.html		\
			manpages/man5/client-local.cfg.5.html		\
			manpages/man5/clientlaunch.cfg.5.html		\
			manpages/man5/combo.cfg.5.html			\
			manpages/man5/critical.cfg.5.html		\
			manpages/man5/graphs.cfg.5.html			\
			manpages/man5/hosts.cfg.5.html			\
			manpages/man5/protocols.cfg.5.html		\
			manpages/man5/tasks.cfg.5.html			\
			manpages/man5/xymon-xmh.5.html			\
			manpages/man5/xymonclient.cfg.5.html		\
			manpages/man5/xymonserver.cfg.5.html		\
			manpages/man5/xymonweb.5.html			\
			manpages/man7/xymon.7.html			\
			manpages/man8/enadis.cgi.8.html			\
			manpages/man8/msgcache.8.html			\
			manpages/man8/trimhistory.8.html		\
			manpages/man8/xymon-mailack.8.html		\
			manpages/man8/xymoncgimsg.cgi.8.html		\
			manpages/man8/xymond.8.html			\
			manpages/man8/xymond_alert.8.html		\
			manpages/man8/xymond_capture.8.html		\
			manpages/man8/xymond_channel.8.html		\
			manpages/man8/xymond_client.8.html		\
			manpages/man8/xymond_filestore.8.html		\
			manpages/man8/xymond_history.8.html		\
			manpages/man8/xymond_hostdata.8.html		\
			manpages/man8/xymond_rrd.8.html			\
			manpages/man8/xymond_sample.8.html		\
			manpages/man8/xymonfetch.8.html			\
			manpages/man8/xymonlaunch.8.html		\
			manpages/man8/xymonproxy.8.html			\
			stdview-detail-acked.jpg			\
			upgrade-to-430.txt				\
			xymon-alerts.html				\
			xymon-apacheconf.txt				\
			xymon-clients.png				\
			xymon-config.html				\
			xymon-hosts.png					\
			xymon-mrtg.html					\
			xymon-tips.html					\
			xymonmain.png					\
			xymonprocs.png					\
		"
	DOCDIRS="manpages/man8 manpages/man7 manpages/man5 	\
			manpages/man1 manpages"
	for file in ${DOCFILES}; do
		${RM} ${XYWWWDIR}/help/${file}
	done
	for dir in ${DOCDIRS}; do
		${RMDIR} ${XYWWWDIR}/help/${dir}
	done

	if [ -h ${XYMONHOME}/bin ]; then
		${RM} ${XYMONHOME}/bin
	fi
	if [ -h ${XYMONHOME}/etc ]; then
		${RM} ${XYMONHOME}/etc
	fi
	if [ -h ${XYMONHOME}/ext ]; then
		${RM} ${XYMONHOME}/ext
	fi
	if [ -h ${XYMONHOME}/tmp ]; then
		${RM} ${XYMONHOME}/tmp
	fi
	if [ -h ${XYMONHOME}/web ]; then
		${RM} ${XYMONHOME}/web
	fi
	if [ -h ${XYMONHOME}/www ]; then
		${RM} ${XYMONHOME}/www
	fi
	if [ -h ${XYMONHOME}/download ]; then
		${RM} ${XYMONHOME}/download
	fi
	if [ -h ${XYMONHOME}/logs ]; then
		${RM} ${XYMONHOME}/logs
	fi

	;;
esac
# $NetBSD: deinstall,v 1.5 2017/06/14 16:23:09 prlw1 Exp $

case ${STAGE} in
DEINSTALL)
  #
  # Unregister package from ocaml-findlib.
  #
  ${TEST} ! -x ./+OCAML_FINDLIB_REGISTER ||
    ./+OCAML_FINDLIB_REGISTER REMOVE ${OCAML_FINDLIB_DIR}

	#
	# Unregister info files.
	#
	${TEST} ! -x ./+INFO_FILES ||
		./+INFO_FILES REMOVE ${PKG_METADATA_DIR}
	#
	# Remove any icon theme caches.
	#
	${TEST} ! -x ./+ICON_THEMES ||
		./+ICON_THEMES REMOVE ${PKG_METADATA_DIR}
	#
	# Remove shells from /etc/shells.
	#
	${TEST} ! -x ./+SHELL ||
		./+SHELL REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+SHELL ||
		./+SHELL CHECK-REMOVE ${PKG_METADATA_DIR}

	# Remove configuration files if they don't differ from the default
	# config file.
	#
	${TEST} ! -x ./+FILES ||
		./+FILES REMOVE ${PKG_METADATA_DIR}
	;;

POST-DEINSTALL)
	#
	# Update any fonts databases.
	#
	${TEST} ! -x ./+FONTS ||
		./+FONTS ${PKG_METADATA_DIR}
	#
	# Update any icon theme caches.
	#
	${TEST} ! -x ./+ICON_THEMES ||
		./+ICON_THEMES UPDATE ${PKG_METADATA_DIR}
	#
	# Rebuild the system run-time library search path database.
	#
	${TEST} ! -x ./+SHLIBS ||
		./+SHLIBS REMOVE ${PKG_METADATA_DIR}
	#
	# Remove empty directories and unused users/groups.
	#
	${TEST} ! -x ./+DIRS ||
		./+DIRS REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+USERGROUP ||
		./+USERGROUP REMOVE ${PKG_METADATA_DIR}
	#
	# Check for any existing bits after we're finished de-installing.
	#
	${TEST} ! -x ./+USERGROUP ||
		./+USERGROUP CHECK-REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+FILES ||
		./+FILES CHECK-REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+DIRS ||
		./+DIRS CHECK-REMOVE ${PKG_METADATA_DIR}
	;;
esac

# $NetBSD: footer,v 1.1 2006/05/21 23:50:15 jlam Exp $

exit 0

