Index: comms/aprsd/Makefile =================================================================== --- comms/aprsd/Makefile +++ comms/aprsd/Makefile @@ -12,35 +12,42 @@ COMMENT= Server daemon providing Internet access to APRS packet data 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 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 Index: comms/aprsd/files/aprsd =================================================================== --- comms/aprsd/files/aprsd +++ comms/aprsd/files/aprsd @@ -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 -# Modified: Diane Bruce - -# 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" Index: comms/aprsd/files/aprsd.in =================================================================== --- comms/aprsd/files/aprsd.in +++ comms/aprsd/files/aprsd.in @@ -1,7 +1,10 @@ #!/bin/sh # +# $FreeBSD$ +# # PROVIDE: aprsd # REQUIRE: NETWORKING +# KEYWORD: shutdown # # Add the following lines to /etc/rc.conf # aprsd_enable="YES" @@ -9,62 +12,32 @@ . /etc/rc.subr -name="aprsd" +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 +: ${aprsd_enable=NO} +: ${aprsd_root=NO} +: ${aprsd_user=%%APRSD_RC_USER%%} +: ${aprsd_group=%%APRSD_RC_GROUP%%} -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 -# Modified: Diane Bruce +command=%%LOCALBASE%%/bin/aprsd +start_precmd=aprsd_pre +stop_cmd=aprsd_stop +pidfile=/var/run/aprsd.pid -# Source function library. -#. /etc/rc.d/init.d/functions -# See how we were called. -aprsd_start() +aprsd_pre() { - 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" + 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." - chown root:wheel ${PIDFILE} - chown root:wheel /var/log/aprsd - chown root:wheel /var/log/aprsd/* - - ${command} -d + install -o root -g wheel /dev/null ${pidfile} + chown -R root:wheel /var/log/aprsd fi return 0 } -aprsd_stop() -{ - echo "Stopping aprs server daemon. " - kill -INT `cat ${PIDFILE}` - return 0 -} run_rc_command "$1" Index: comms/aprsd/files/pkg-deinstall.in =================================================================== --- comms/aprsd/files/pkg-deinstall.in +++ comms/aprsd/files/pkg-deinstall.in @@ -1,16 +1,8 @@ #!/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< /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< /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<