aboutsummaryrefslogtreecommitdiffstats
path: root/comms/aprsd
diff options
context:
space:
mode:
authorfeld <feld@FreeBSD.org>2015-07-30 23:48:52 +0800
committerfeld <feld@FreeBSD.org>2015-07-30 23:48:52 +0800
commit8ecf9e9965ae1d53ed0944a54483afaa58ae34d0 (patch)
tree1fa2326c024beb65960c5b3a2f4bb3b259954fed /comms/aprsd
parentedb735eb30858458c9c947c67742082f6a054c71 (diff)
downloadfreebsd-ports-gnome-8ecf9e9965ae1d53ed0944a54483afaa58ae34d0.tar.gz
freebsd-ports-gnome-8ecf9e9965ae1d53ed0944a54483afaa58ae34d0.tar.zst
freebsd-ports-gnome-8ecf9e9965ae1d53ed0944a54483afaa58ae34d0.zip
comms/aprsd: Modernize port
USE_RC_SUBR USERS and GROUPS instead of custom script Unmute some install steps LICENSE The rc script now passes rclint Approved by: db Differential Revision: https://reviews.freebsd.org/D3104
Diffstat (limited to 'comms/aprsd')
-rw-r--r--comms/aprsd/Makefile33
-rw-r--r--comms/aprsd/files/aprsd70
-rw-r--r--comms/aprsd/files/aprsd.in43
-rw-r--r--comms/aprsd/files/pkg-deinstall.in8
-rw-r--r--comms/aprsd/pkg-deinstall16
-rw-r--r--comms/aprsd/pkg-install142
-rw-r--r--comms/aprsd/pkg-plist1
7 files changed, 72 insertions, 241 deletions
diff --git a/comms/aprsd/Makefile b/comms/aprsd/Makefile
index 575935f30eec..7fc241025688 100644
--- a/comms/aprsd/Makefile
+++ b/comms/aprsd/Makefile
@@ -11,36 +11,45 @@ DISTNAME= aprsd-2.2.5-15
MAINTAINER= hamradio@FreeBSD.org
COMMENT= Server daemon providing Internet access to APRS packet data
+LICENSE= GPLv2
+
GNU_CONFIGURE= yes
-SUB_FILES= pkg-message
+SUB_FILES= pkg-message pkg-deinstall
+USE_RC_SUBR= aprsd
+
+USERS= aprsd tnc
+GROUPS= aprsd tnc
+APRSD_RC_USER= aprsd
+APRSD_RC_GROUP= aprsd
+
+RC_SUB_LIST= LOCALBASE=${LOCALBASE} APRSD_RC_USER=${APRSD_RC_USER} \
+ APRSD_RC_GROUP=${APRSD_RC_GROUP}
OPTIONS_DEFINE= DOCS EXAMPLES
.include <bsd.port.pre.mk>
post-patch:
- @${REINPLACE_CMD} -e 's|%%CONFPATH%%|${PREFIX}/etc/aprsd/|' \
+ ${REINPLACE_CMD} -e 's|%%CONFPATH%%|${PREFIX}/etc/aprsd/|' \
-e 's|%%LOGPATH%%|/var/log/aprsd/|' \
${WRKSRC}/src/aprsd.cpp
- @${REINPLACE_CMD} -e 's|%%LOGPATH%%|/var/log/aprsd/|' \
+ ${REINPLACE_CMD} -e 's|%%LOGPATH%%|/var/log/aprsd/|' \
${WRKSRC}/src/utils.cpp
pre-install:
- @${MKDIR} ${STAGEDIR}${PREFIX}/etc/aprsd
- @${MKDIR} ${STAGEDIR}"/var/log/aprsd"
- @${SETENV} "PKG_PREFIX=${STAGEDIR}${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+ ${MKDIR} ${STAGEDIR}${PREFIX}/etc/aprsd
+ ${MKDIR} ${STAGEDIR}"/var/log/aprsd"
post-install:
@cd ${WRKSRC}/admin
.for f in INIT.TNC RESTORE.TNC aprsd.conf welcome.txt user.deny
- @${INSTALL_DATA} ${WRKSRC}/admin/$f ${STAGEDIR}${PREFIX}/etc/aprsd/$f.samp
+ ${INSTALL_DATA} ${WRKSRC}/admin/$f ${STAGEDIR}${PREFIX}/etc/aprsd/$f.samp
.endfor
- @${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
+ ${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
.for f in chkaprsd udp_example
- @${INSTALL_DATA} ${WRKSRC}/admin/$f ${STAGEDIR}${EXAMPLESDIR}
+ ${INSTALL_DATA} ${WRKSRC}/admin/$f ${STAGEDIR}${EXAMPLESDIR}
.endfor
- @${INSTALL_SCRIPT} ${FILESDIR}/aprsd ${STAGEDIR}${LOCALBASE}/etc/rc.d
- @${MKDIR} ${STAGEDIR}${DOCSDIR}
- @${CP} ${WRKSRC}/doc/*.html ${STAGEDIR}${DOCSDIR}
+ ${MKDIR} ${STAGEDIR}${DOCSDIR}
+ ${CP} ${WRKSRC}/doc/*.html ${STAGEDIR}${DOCSDIR}
.include <bsd.port.post.mk>
diff --git a/comms/aprsd/files/aprsd b/comms/aprsd/files/aprsd
deleted file mode 100644
index 3f260afc9057..000000000000
--- a/comms/aprsd/files/aprsd
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-#
-# PROVIDE: aprsd
-# REQUIRE: NETWORKING
-#
-# Add the following lines to /etc/rc.conf
-# aprsd_enable="YES"
-# aprsd_root="YES" or aprsd_root="NO"
-
-. /etc/rc.subr
-
-name="aprsd"
-rcvar=aprsd_enable
-load_rc_config $name
-aprsd_enable=${aprsd_enable-"NO"}
-aprsd_root=${aprsd_root-"NO"}
-
-command="/usr/local/bin/aprsd"
-start_cmd=aprsd_start
-stop_cmd=aprsd_stop
-
-PIDFILE="/var/run/aprsd.pid"
-UID="aprsd"
-GID="aprsd"
-#
-# aprsd.init for version 2.1.5. starts or stops aprsd server.
-# This file should be placed in /usr/local/etc/rc.d/
-#
-#
-#
-# Author: Dale Heatherington <aprsd1@wa4dsy.net>
-# Modified: Diane Bruce <va3db@amsat.org>
-
-# Source function library.
-#. /etc/rc.d/init.d/functions
-# See how we were called.
-aprsd_start()
-{
- if [ -s ${PIDFILE} ] ; then
- kill -0 `cat ${PIDFILE}` >&- 2>&-
- if [ $? -eq 0 ]; then
- echo "aprs server is already running."
- return 0
- fi
- fi
- if [ ${aprsd_root} != "YES" ]; then
- echo "Starting aprs server as user ${UID}:${GID}."
- touch ${PIDFILE}
- chown ${UID}:${GID} ${PIDFILE}
- chown ${UID}:${GID} /var/log/aprsd
- chown ${UID}:${GID} /var/log/aprsd/*
- su ${UID} -m -c "${command} -d"
- else
- echo "Starting aprs server as root."
- chown root:wheel ${PIDFILE}
- chown root:wheel /var/log/aprsd
- chown root:wheel /var/log/aprsd/*
-
- ${command} -d
- fi
- return 0
-}
-aprsd_stop()
-{
- echo "Stopping aprs server daemon. "
- kill -INT `cat ${PIDFILE}`
- return 0
-}
-
-run_rc_command "$1"
diff --git a/comms/aprsd/files/aprsd.in b/comms/aprsd/files/aprsd.in
new file mode 100644
index 000000000000..8b2726fdba1f
--- /dev/null
+++ b/comms/aprsd/files/aprsd.in
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: aprsd
+# REQUIRE: NETWORKING
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf
+# aprsd_enable="YES"
+# aprsd_root="YES" or aprsd_root="NO"
+
+. /etc/rc.subr
+
+name=aprsd
+rcvar=aprsd_enable
+load_rc_config $name
+
+: ${aprsd_enable=NO}
+: ${aprsd_root=NO}
+: ${aprsd_user=%%APRSD_RC_USER%%}
+: ${aprsd_group=%%APRSD_RC_GROUP%%}
+
+command=%%LOCALBASE%%/bin/aprsd
+start_precmd=aprsd_pre
+stop_cmd=aprsd_stop
+pidfile=/var/run/aprsd.pid
+
+aprsd_pre()
+{
+ if [ ${aprsd_root} != "YES" ]; then
+ echo "Starting aprs server as user ${APRSD_RC_USER}:${APRSD_RC_GROUP}."
+ install -o ${APRSD_RC_USER} -g ${APRSD_RC_GROUP} /dev/null ${pidfile}
+ chown -R ${APRSD_RC_USER}:${APRSD_RC_GROUP} /var/log/aprsd
+ else
+ echo "Starting aprs server as root."
+ install -o root -g wheel /dev/null ${pidfile}
+ chown -R root:wheel /var/log/aprsd
+ fi
+ return 0
+}
+
+run_rc_command "$1"
diff --git a/comms/aprsd/files/pkg-deinstall.in b/comms/aprsd/files/pkg-deinstall.in
new file mode 100644
index 000000000000..ce7c22ec7e39
--- /dev/null
+++ b/comms/aprsd/files/pkg-deinstall.in
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cat<<EOF
+If you really want to remove this package completely
+remove what is left in %%LOCALBASE%%/etc/aprsd /var/log/aprsd.
+Also be sure to remove user and groups aprsd and tnc
+and remember to remove aprsd from dialer group.
+EOF
diff --git a/comms/aprsd/pkg-deinstall b/comms/aprsd/pkg-deinstall
deleted file mode 100644
index 45108ced6931..000000000000
--- a/comms/aprsd/pkg-deinstall
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-if [ "x$2" != "xPOST-DEINSTALL" ]; then
- exit 0;
-fi
-
-echo "Killing aprsd if running"
-kill -9 `cat /var/run/aprsd.pid`
-rm -f /var/run/aprsd.pid
-
-cat<<EOF
-If you really want to remove this package completely
-remove what is left in /usr/local/etc/aprsd /var/log/aprsd.
-Also be sure to remove user and groups aprsd and tnc
-and remember to remove aprsd from dialer group.
-EOF
diff --git a/comms/aprsd/pkg-install b/comms/aprsd/pkg-install
deleted file mode 100644
index 2d0dee30332e..000000000000
--- a/comms/aprsd/pkg-install
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/bin/sh
-
-UID=240
-GID=${UID}
-DAEMON_NAME="aprsd"
-UID_NAME=${DAEMON_NAME}
-GID_NAME=${DAEMON_NAME}
-
-TNC_UID=241
-TNC_GID=${TNC_UID}
-TNC_UID_NAME="tnc"
-TNC_GID_NAME="tnc"
-
-if [ "x$2" != "xPRE-INSTALL" ]; then
- exit 0;
-fi
-
-ask() {
- local question default answer
-
- question=$1
- default=$2
- if [ -z "${PACKAGE_BUILDING}" ]; then
- read -p "${question} [${default}]? " answer
- fi
- if [ x${answer} = x ]; then
- answer=${default}
- fi
- echo ${answer}
-}
-
-yesno() {
- local dflt question answer
-
- question=$1
- dflt=$2
- while :; do
- answer=$(ask "${question}" "${dflt}")
- case "${answer}" in
- [Yy]*) return 0;;
- [Nn]*) return 1;;
- esac
- echo "Please answer yes or no."
- done
-}
-
-adduser() {
- local uid gid uid_name gid_name daemon_name
-
- uid=$1
- gid=$2
- uid_name=$3
- gid_name=$4
- daemon_name=$5
- if which -s pw ; then
- :
- else
- cat <<EOF
-Your system does not include the "pw" utility. You should upgrade
-to a newer version of FreeBSD. Without "pw" this script will not
-run.
-EOF
- exit 1
- fi
-
- echo ""
- if pw groupshow ${gid_name} 2> /dev/null ; then
- echo "You already have a group \"${gid_name}\", so I will use it."
- else
- if pw groupshow ${gid} 2> /dev/null ; then
- echo "You already have a gid \"${gid}\". Please create a user ${gid_name}"
- echo "with a default group of \"${gid_name}\"."
- exit 1
- fi
- echo "You need a group \"${gid_name}\"."
- if which -s pw && yesno "Would you like me to create it" y; then
- pw groupadd ${gid_name} -g ${gid} || exit
- echo "Done."
- else
- echo "Please create it, and try again."
- if ! pw usershow ${uid_name} 2> /dev/null ; then
- echo "While you're at it, please create a user \"${uid_name}\""
- echo 'too, with a default group of "${gid_name}".'
- fi
- exit 1
- fi
- fi
-
- if pw usershow ${uid_name} 2> /dev/null ; then
- echo "You already have a user \"${uid_name}\", so I will use it."
- else
- if pw usershow ${uid} 2> /dev/null ; then
- echo "You already have a uid \"${uid}\". Please create a user \"${uid_name}\""
- echo "with a default group of \"${gid_name}\"."
- exit 1
- fi
- echo "You need a user \"${uid_name}\"."
- if which -s pw && yesno "Would you like me to create it" y; then
- pw useradd ${uid_name} -g ${gid_name} -u ${uid} -h - -d /nonexistent \
- -s /bin/sh -c "${daemon_name}" || exit
- echo "Done."
- else
- echo "Please create it, and try again."
- exit 1
- fi
- fi
-}
-
-(adduser ${UID} ${GID} ${UID_NAME} ${GID_NAME} ${DAEMON_NAME})
-
-echo `pw groupshow dialer`|grep -q ${UID_NAME}
-if [ $? -eq 0 ]; then
- echo "You already have \"${UID_NAME}\" in the dialer group, so I will use this."
-else
-cat<<EOF
-${DAEMON_NAME} needs access to serial ports to talk to an
-external tnc. You will be asked if you wish to add ${DAEMON_NAME}
-to the dialer group for that purpose.
-EOF
- if pw usershow ${UID_NAME} 2> /dev/null ; then
- if which -s pw && yesno "Would you like to add \"${UID_NAME}\" to the dialer group?" y; then
- pw groupmod -n "dialer" -m ${UID_NAME} || exit
- echo "Done."
- fi
- fi
-fi
-
-if ! pw usershow ${TNC_UID_NAME} 2> /dev/null ; then
-cat<<EOF
-"${DAEMON_NAME}" has an optional login "${TNC_UID_NAME}",
-(This is described in the aprsd docs.) if you
-wish to allow remote logins. "${DAEMON_NAME}" needs to run as
-root for this to work, if you do not plan to run
-"${DAEMON_NAME}" ever as root, you can skip this step.
-You can always add it manually later if you change your mind.
-EOF
- if which -s pw && yesno "Would you like to add a ${TNC_UID_NAME} login" y; then
- (adduser ${TNC_UID} ${TNC_GID} ${TNC_UID_NAME} ${TNC_GID_NAME} ${DAEMON_NAME})
- fi
-else
- echo "You already have an user \"${TNC_UID_NAME}\" so I will use it."
-fi
diff --git a/comms/aprsd/pkg-plist b/comms/aprsd/pkg-plist
index 7647773e8fae..154935a98f4f 100644
--- a/comms/aprsd/pkg-plist
+++ b/comms/aprsd/pkg-plist
@@ -5,7 +5,6 @@ etc/aprsd/RESTORE.TNC.samp
etc/aprsd/aprsd.conf.samp
etc/aprsd/user.deny.samp
etc/aprsd/welcome.txt.samp
-etc/rc.d/aprsd
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/chkaprsd
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/udp_example
%%PORTDOCS%%%%DOCSDIR%%/aprsddoc.html