Bug 70390 - [update]net/dictd: fix overwrite config file
Summary: [update]net/dictd: fix overwrite config file
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: dd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-13 03:20 UTC by Dryice Liu
Modified: 2004-08-29 08:11 UTC (History)
1 user (show)

See Also:


Attachments
dictd.diff (1.89 KB, patch)
2004-08-13 03:20 UTC, Dryice Liu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dryice Liu 2004-08-13 03:20:18 UTC
	Problem:
		I'm using net/dictd and I found if I deinstall -
		install it, or portupgrade it, it will overwrite my
		/usr/local/etc/dictd.conf with a default one.
	Changes:
		- install a sample config file by default and try to
	keep user config file
		- new file: pkg-install
		- new file: pkg-deinstall

How-To-Repeat: 	cd /usr/ports/net/dictd
	make install clean
	make some change on /usr/local/etc/dictd.conf
	cd /usr/ports/net/dictd
	make deinstall install
	The changes are lost
Comment 1 Volker Stolz freebsd_committer freebsd_triage 2004-08-13 08:17:17 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dd

Over to maintainer
Comment 2 clive 2004-08-22 05:26:29 UTC
On Fri, Aug 13, 2004 at 10:16:40AM +0800, Dryice Liu wrote:
> >Synopsis:       [update]net/dictd: fix overwrite config file

    Here is a slightly modified version plus rc.subr support. Rc.subr
part is originally submitted to MAINTAINER by Andy Miller, and sitting
in my tree about 6 months.

    Dima: would you like to review and commit this?

Clive

Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/net/dictd/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- Makefile	4 Jun 2004 17:29:27 -0000	1.25
+++ Makefile	22 Aug 2004 04:18:09 -0000
@@ -20,6 +20,7 @@
 MAN8=		dictd.8
 
 USE_LIBLTDL=	yes
+USE_RC_SUBR=	yes
 USE_REINPLACE=	yes
 USE_BISON=	yes
 USE_LIBTOOL_VER=13
@@ -47,7 +48,8 @@
 .for i in example.conf example.dictrc example.site example2.conf example3.conf
 	${INSTALL_DATA} ${WRKSRC}/$i ${DATADIR}
 .endfor
-	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${FILESDIR}/${PORTNAME}.conf > ${PREFIX}/etc/${PORTNAME}.conf
+	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${FILESDIR}/${PORTNAME}.conf > ${PREFIX}/etc/${PORTNAME}.conf.sample
+	@[ -f ${PREFIX}/etc/${PORTNAME}.conf ] || cp ${PREFIX}/etc/${PORTNAME}.conf.sample ${PREFIX}/etc/${PORTNAME}.conf 
 	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${FILESDIR}/${PORTNAME}.sh > ${PREFIX}/etc/rc.d/${PORTNAME}.sh
 	@${CHMOD} +x ${PREFIX}/etc/rc.d/${PORTNAME}.sh
 	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${PKGMESSAGE}
Index: pkg-plist
===================================================================
RCS file: /home/pcvs/ports/net/dictd/pkg-plist,v
retrieving revision 1.3
diff -u -r1.3 pkg-plist
--- pkg-plist	28 Jan 2001 21:23:04 -0000	1.3
+++ pkg-plist	22 Aug 2004 04:18:09 -0000
@@ -5,6 +5,8 @@
 share/dictd/example.site
 share/dictd/example2.conf
 share/dictd/example3.conf
-etc/dictd.conf
+@unexec if cmp -s %D/etc/dictd.conf %D/etc/dictd.conf.sample; then rm -f %D/etc/dictd.conf; fi
+etc/dictd.conf.sample
+@exec [ -f %B/dictd.conf ] || cp %B/%f %B/dictd.conf
 etc/rc.d/dictd.sh
 @dirrm share/dictd
Index: files/dictd.sh
===================================================================
RCS file: /home/pcvs/ports/net/dictd/files/dictd.sh,v
retrieving revision 1.3
diff -u -r1.3 dictd.sh
--- files/dictd.sh	17 Feb 2004 09:51:18 -0000	1.3
+++ files/dictd.sh	22 Aug 2004 04:18:09 -0000
@@ -1,44 +1,20 @@
 #!/bin/sh
-# $FreeBSD: ports/net/dictd/files/dictd.sh,v 1.3 2004/02/17 09:51:18 clive Exp $
+# $FreeBSD$
+#
+# PROVIDE: dictd
+# REQUIRE: DAEMON
+# KEYWORD: FreeBSD
+#
+# Add the following line to /etc/rc.conf to enable dictd:
+#
+# dictd_enable="YES"
+#
+
+. /etc/rc.subr
+
+name=dictd
+rcvar=`set_rcvar`
+command=%%PREFIX%%/sbin/dictd
 
-SOCKSTAT=/usr/bin/sockstat
-GREP=/usr/bin/grep
-AWK=/usr/bin/awk
-ECHO=/bin/echo
-CAT=/bin/cat
-KILL=/bin/kill
-RM=/bin/rm
-
-DICTD=%%PREFIX%%/sbin/dictd
-
-# DICTD_OPTIONS="-put -command_line -options -for -dictd -here"
-DICTD_OPTIONS=""
-
-DICTD_PID_FILE=/var/run/dictd.pid
-
-case "$1" in
-	start)
-		if [ -x $DICTD ]; then
-			${ECHO} -n " dictd"
-			$DICTD $DICTD_OPTIONS
-			${ECHO} `${SOCKSTAT} | ${GREP} dictd | ${AWK} '{print $3}'` > ${DICTD_PID_FILE}
-		else
-			${ECHO} "dictd.sh: cannot find $DICTD or it's not executable"
-		fi
-		;;
-
-	stop)
-		if [ ! -f $DICTD_PID_FILE ]; then
-			exit 0
-		fi
-		dictdpid=`${CAT} $DICTD_PID_FILE`
-		if [ "$dictdpid" -gt 0 ]; then
-			${ECHO} -n " dictd"
-			${KILL} -15 $dictdpid 2>&1 > /dev/null
-		fi
-		${RM} -f $DICTD_PID_FILE
-		;;
-	*)
-		echo "Usage: dictd.sh { start | stop }"
-		;;
-esac
+load_rc_config $name
+run_rc_command "$1"


-- 
Clive Tong-I Lin <clive@tongi.org> | http://tongi.org | PGP KeyID: A008C03E
Comment 3 Clive Lin freebsd_committer freebsd_triage 2004-08-29 08:10:31 UTC
State Changed
From-To: open->closed

Committed, thanks.