RC_SUBR-ize
PR: ports/68787 Submitted by: maintainer
This commit is contained in:
parent
fcd42c3e27
commit
f00bff1604
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=113286
@ -7,7 +7,7 @@
|
||||
|
||||
PORTNAME= arpwatch
|
||||
PORTVERSION= 2.1.a11
|
||||
PORTREVISION= 3
|
||||
PORTREVISION= 4
|
||||
CATEGORIES= net-mgmt
|
||||
MASTER_SITES= http://www.Awfulhak.org/arpwatch/ \
|
||||
ftp://ftp.ee.lbl.gov/
|
||||
@ -25,8 +25,15 @@ CONFIGURE_ARGS= --quiet
|
||||
INSTALL_TARGET= install install-man
|
||||
MAN8= arpwatch.8 arpsnmp.8
|
||||
|
||||
USE_RC_SUBR= yes
|
||||
RC_SCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
|
||||
|
||||
MAKE_ENV= PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" PTHREAD_LIBS="${PTHREAD_LIBS}"
|
||||
|
||||
post-patch:
|
||||
@${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
|
||||
${FILESDIR}/arpwatch.sh > ${WRKDIR}/arpwatch.sh
|
||||
|
||||
post-install:
|
||||
if [ ! -d ${PREFIX}/arpwatch ]; then \
|
||||
${MKDIR} ${PREFIX}/arpwatch; \
|
||||
@ -41,6 +48,7 @@ post-install:
|
||||
${INSTALL_DATA} ${WRKSRC}/$$file ${PREFIX}/arpwatch/.; \
|
||||
done
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/arp2ethers ${PREFIX}/arpwatch/.
|
||||
${INSTALL_SCRIPT} ${FILESDIR}/arpwatch.sh ${PREFIX}/etc/rc.d/arpwatch.sh.sample
|
||||
${INSTALL_SCRIPT} ${WRKDIR}/arpwatch.sh ${PREFIX}/etc/rc.d/arpwatch.sh
|
||||
@${CAT} ${PKGMESSAGE}
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,60 +1,31 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
if [ -r /etc/defaults/rc.conf ]; then
|
||||
. /etc/defaults/rc.conf
|
||||
source_rc_confs
|
||||
elif [ -r /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
fi
|
||||
# PROVIDE: arpwatch
|
||||
# REQUIRE: NETWORKING SERVERS
|
||||
# BEFORE: DAEMON
|
||||
# KEYWORD: FreeBSD shutdown
|
||||
|
||||
prog=$(realpath $0) || exit 1
|
||||
dir=${prog%/*}
|
||||
PREFIX=${dir%/etc/rc.d}
|
||||
#
|
||||
# Add the following lines to /etc/rc.conf to enable arpwatch:
|
||||
# arpwatch_enable (bool): Set to "NO" by default.
|
||||
# Set it to "YES" to enable arpwatch
|
||||
# arpwatch_flags (str): Set to "-N" by default.
|
||||
# Extra flags passed to start command
|
||||
#
|
||||
. %%RC_SUBR%%
|
||||
|
||||
if [ ."$dir" = ."$prog" -o ."$PREFIX" = ."$dir" ]
|
||||
then
|
||||
echo "$0: Cannot determine the PREFIX" >&2
|
||||
exit 1
|
||||
fi
|
||||
name="arpwatch"
|
||||
rcvar=`set_rcvar`
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
if [ ! -e "$PREFIX"/arpwatch/arp.dat ]; then
|
||||
if [ -e "$PREFIX"/arpwatch/arp.dat- ]; then
|
||||
cp "$PREFIX"/arpwatch/arp.dat- "$PREFIX"/arpwatch/arp.dat
|
||||
else
|
||||
touch "$PREFIX"/arpwatch/arp.dat
|
||||
fi
|
||||
fi
|
||||
command="%%PREFIX%%/sbin/arpwatch"
|
||||
|
||||
if [ ! -e "$PREFIX"/arpwatch/ether.dat ]; then
|
||||
if [ -e "$PREFIX"/arpwatch/ether.dat- ]; then
|
||||
cp "$PREFIX"/arpwatch/ether.dat- "$PREFIX"/arpwatch/ether.dat
|
||||
else
|
||||
touch "$PREFIX"/arpwatch/ether.dat
|
||||
fi
|
||||
fi
|
||||
[ -z "$arpwatch_enable" ] && arpwatch_enable="NO"
|
||||
[ -z "$arpwatch_flags" ] && arpwatch_flags="-N"
|
||||
|
||||
case ${arpwatch_interfaces} in
|
||||
'')
|
||||
if [ -x "$PREFIX"/sbin/arpwatch -a -d "$PREFIX"/arpwatch ]; then
|
||||
"$PREFIX"/sbin/arpwatch ${arpwatch_flags} && echo -n ' arpwatch'
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
for interface in ${arpwatch_interfaces}; do
|
||||
"$PREFIX"/sbin/arpwatch -i "${interface}" && echo -n " arpwatch(${interface})"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
killall arpwatch && echo -n ' arpwatch'
|
||||
;;
|
||||
*)
|
||||
echo "Usage: `basename $0` {start|stop}" >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
load_rc_config $name
|
||||
|
||||
run_rc_command "$1"
|
||||
|
||||
exit 0
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- arpwatch.c.orig Sat Oct 14 04:07:35 2000
|
||||
+++ arpwatch.c Tue Jan 20 00:22:23 2004
|
||||
--- arpwatch.c.orig Fri Oct 13 22:07:35 2000
|
||||
+++ arpwatch.c Wed Jul 7 17:08:21 2004
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
@ -85,7 +85,7 @@
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
@@ -213,19 +230,23 @@
|
||||
@@ -213,50 +230,107 @@
|
||||
net = 0;
|
||||
netmask = 0;
|
||||
} else {
|
||||
@ -121,16 +121,26 @@
|
||||
}
|
||||
|
||||
/* Drop into the background if not debugging */
|
||||
@@ -238,7 +259,7 @@
|
||||
exit(0);
|
||||
(void)close(fileno(stdin));
|
||||
(void)close(fileno(stdout));
|
||||
if (!debug) {
|
||||
- pid = fork();
|
||||
- if (pid < 0) {
|
||||
- syslog(LOG_ERR, "main fork(): %m");
|
||||
- exit(1);
|
||||
- } else if (pid != 0)
|
||||
- exit(0);
|
||||
- (void)close(fileno(stdin));
|
||||
- (void)close(fileno(stdout));
|
||||
- (void)close(fileno(stderr));
|
||||
+
|
||||
#ifdef TIOCNOTTY
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd >= 0) {
|
||||
@@ -251,12 +272,82 @@
|
||||
-#ifdef TIOCNOTTY
|
||||
- fd = open("/dev/tty", O_RDWR);
|
||||
- if (fd >= 0) {
|
||||
- (void)ioctl(fd, TIOCNOTTY, 0);
|
||||
- (void)close(fd);
|
||||
- }
|
||||
-#else
|
||||
- (void) setsid();
|
||||
-#endif
|
||||
+ daemon(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +224,7 @@
|
||||
|
||||
if (rfilename != NULL) {
|
||||
pd = pcap_open_offline(rfilename, errbuf);
|
||||
@@ -306,27 +397,7 @@
|
||||
@@ -306,27 +380,7 @@
|
||||
if (rfilename == NULL)
|
||||
syslog(LOG_INFO, "listening on %s", interface);
|
||||
|
||||
@ -242,7 +252,7 @@
|
||||
|
||||
switch (linktype) {
|
||||
|
||||
@@ -347,9 +418,7 @@
|
||||
@@ -347,9 +401,7 @@
|
||||
exit(1);
|
||||
}
|
||||
pcap_close(pd);
|
||||
@ -253,7 +263,7 @@
|
||||
}
|
||||
|
||||
/* Process an ethernet arp/rarp packet */
|
||||
@@ -362,6 +431,8 @@
|
||||
@@ -362,6 +414,8 @@
|
||||
register u_char *sea, *sha;
|
||||
register time_t t;
|
||||
u_int32_t sia;
|
||||
@ -262,7 +272,7 @@
|
||||
|
||||
eh = (struct ether_header *)p;
|
||||
ea = (struct ether_arp *)(eh + 1);
|
||||
@@ -400,9 +471,16 @@
|
||||
@@ -400,9 +454,16 @@
|
||||
/* Got a live one */
|
||||
t = h->ts.tv_sec;
|
||||
can_checkpoint = 0;
|
||||
@ -280,7 +290,7 @@
|
||||
can_checkpoint = 1;
|
||||
}
|
||||
|
||||
@@ -507,6 +585,8 @@
|
||||
@@ -507,6 +568,8 @@
|
||||
register u_char *sea, *sha;
|
||||
register time_t t;
|
||||
u_int32_t sia;
|
||||
@ -289,7 +299,7 @@
|
||||
|
||||
fh = (struct fddi_header *)p;
|
||||
ea = (struct ether_arp *)(fh + 1);
|
||||
@@ -549,7 +629,13 @@
|
||||
@@ -549,7 +612,13 @@
|
||||
/* Got a live one */
|
||||
t = h->ts.tv_sec;
|
||||
can_checkpoint = 0;
|
||||
@ -304,7 +314,7 @@
|
||||
syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed",
|
||||
intoa(sia), e2str(sea), t);
|
||||
can_checkpoint = 1;
|
||||
@@ -750,7 +836,7 @@
|
||||
@@ -750,7 +819,7 @@
|
||||
extern char version[];
|
||||
|
||||
(void)fprintf(stderr, "Version %s\n", version);
|
||||
|
12
net-mgmt/arpwatch-devel/pkg-message
Normal file
12
net-mgmt/arpwatch-devel/pkg-message
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
*** ATTENTION ***
|
||||
|
||||
To run arpwatch from startup, add
|
||||
arpwatch_enable="YES" to /etc/rc.conf
|
||||
|
||||
Available variables you add/set to /etc/rc.conf.
|
||||
- arpwatch_enable (bool): Set to "NO" by default.
|
||||
Set it to "YES" to enable arpwatch.
|
||||
- arpwatch_flags (str): Set to "-N" by default.
|
||||
Extra flags passed to start command.
|
||||
|
@ -5,7 +5,7 @@ arpwatch/ethercodes.dat
|
||||
arpwatch/d.awk
|
||||
arpwatch/e.awk
|
||||
arpwatch/p.awk
|
||||
etc/rc.d/arpwatch.sh.sample
|
||||
etc/rc.d/arpwatch.sh
|
||||
@unexec test -f %D/arpwatch/arp.dat && test -s %D/arpwatch/arp.dat || rm -f %D/arpwatch/arp.dat
|
||||
@unexec test -f %D/arpwatch/ether.dat && test -s %D/arpwatch/ether.dat || rm -f %D/arpwatch/ether.dat
|
||||
@exec test -f %D/arpwatch/arp.dat || touch %D/arpwatch/arp.dat
|
||||
|
Loading…
Reference in New Issue
Block a user