mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-24 04:33:24 +00:00
- Use USE_RC_SUBR properly
- Use SUB_LIST/SUB_FILES rather than a bunch of seds - Tidy whitespace in pkg-install and pkg-deinstall scripts - Tidy up rc script and improve tests using ps Approved by: clement (mentor)
This commit is contained in:
parent
2e13905eea
commit
3369145c11
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=153123
@ -7,7 +7,7 @@
|
||||
|
||||
PORTNAME= dnetc
|
||||
PORTVERSION= ${VERSION}
|
||||
PORTREVISION= 1
|
||||
PORTREVISION= 2
|
||||
PORTEPOCH= 1
|
||||
CATEGORIES= misc
|
||||
MASTER_SITES= ftp://ftp.distributed.net/pub/dcti/%SUBDIR%/ \
|
||||
@ -25,7 +25,7 @@ MD5_FILE= ${MASTERDIR}/distinfo.${ARCH}
|
||||
|
||||
ONLY_FOR_ARCHS= i386 alpha sparc64 amd64
|
||||
|
||||
USE_RC_SUBR= yes
|
||||
USE_RC_SUBR= dnetc.sh
|
||||
NO_BUILD= yes
|
||||
|
||||
BINDIR= ${PREFIX}/distributed.net
|
||||
@ -34,14 +34,18 @@ CLIENTUSER= dnetc
|
||||
CLIENTGROUP= ${CLIENTUSER}
|
||||
CLIENTUID= 105
|
||||
|
||||
BINMODE= 700
|
||||
|
||||
PKGINSTALL= ${WRKDIR}/pkg-install
|
||||
PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
|
||||
PKGMESSAGE= ${WRKDIR}/pkg-message
|
||||
|
||||
MAN1= dnetc.1
|
||||
|
||||
SUB_FILES= pkg-install pkg-deinstall pkg-message
|
||||
SUB_LIST= BINDIR="${BINDIR}" \
|
||||
CLIENTUSER="${CLIENTUSER}" \
|
||||
CLIENTGROUP="${CLIENTGROUP}" \
|
||||
CLIENTUID="${CLIENTUID}"
|
||||
|
||||
.include <bsd.port.pre.mk>
|
||||
|
||||
.if ${ARCH} == sparc64 || ${ARCH} == alpha
|
||||
@ -61,17 +65,6 @@ MASTER_SITE_SUBDIR= prerelease/rc
|
||||
DISTNAME= dnetc${PORTVERSION:E}-freebsd5-${ARCH:S/i386/x86/}-elf
|
||||
.endif
|
||||
|
||||
post-extract:
|
||||
@${SED} -e 's#%%CLIENTUSER%%#${CLIENTUSER}#g' -e 's#%%CLIENTGROUP%%#${CLIENTGROUP}#' \
|
||||
-e 's#%%CLIENTUID%%#${CLIENTUID}#g' ${MASTERDIR}/pkg-install > ${PKGINSTALL}
|
||||
@${SED} -e 's#%%CLIENTUSER%%#${CLIENTUSER}#g' -e 's#%%CLIENTGROUP%%#${CLIENTGROUP}#' \
|
||||
${MASTERDIR}/pkg-deinstall > ${PKGDEINSTALL}
|
||||
@${SED} -e 's#%%BINDIR%%#${BINDIR}#' ${MASTERDIR}/pkg-message > ${PKGMESSAGE}
|
||||
@${SED} -e 's#%%BINDIR%%#${BINDIR}#' \
|
||||
-e 's#%%CLIENTUSER%%#${CLIENTUSER}#g' \
|
||||
-e 's#%%RC_SUBR%%#${RC_SUBR}#g' \
|
||||
${FILESDIR}/dnetc.sh > ${WRKDIR}/dnetc.sh
|
||||
|
||||
do-configure:
|
||||
@if [ ! -f ${PREFIX}/dnetc.ini ]; then \
|
||||
${INSTALL} -c -m 644 ${FILESDIR}/dnetc.ini ${WRKSRC}; \
|
||||
@ -88,12 +81,10 @@ do-install:
|
||||
${CHOWN} ${CLIENTUSER}:${CLIENTGROUP} ${BINDIR}
|
||||
${CHMOD} 775 ${BINDIR}
|
||||
|
||||
${INSTALL} -c -m ${BINMODE} -o ${CLIENTUSER} -g ${CLIENTGROUP} ${WRKSRC}/dnetc ${BINDIR}
|
||||
${INSTALL} -c -m 755 -o ${CLIENTUSER} -g ${CLIENTGROUP} ${WRKSRC}/dnetc ${BINDIR}
|
||||
|
||||
${INSTALL_MAN} ${WRKSRC}/${MAN1} ${PREFIX}/man/man1
|
||||
|
||||
${INSTALL_SCRIPT} ${WRKDIR}/dnetc.sh ${PREFIX}/etc/rc.d/dnetc.sh
|
||||
|
||||
${INSTALL} -c -m 644 -o ${CLIENTUSER} -g ${CLIENTGROUP} ${WRKSRC}/dnetc.ini ${BINDIR}/dnetc.ini.sample
|
||||
.if !exists(${BINDIR}/dnetc.ini)
|
||||
${INSTALL} -c -m 644 -o ${CLIENTUSER} -g ${CLIENTGROUP} ${WRKSRC}/dnetc.ini ${BINDIR}/dnetc.ini
|
||||
|
@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: dnetc
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: FreeBSD shutdown
|
||||
|
||||
dnetc_enable=${dnetc_enable:-"NO"}
|
||||
|
||||
dir="%%BINDIR%%"
|
||||
user="%%CLIENTUSER%%"
|
||||
|
||||
. %%RC_SUBR%%
|
||||
|
||||
name="dnetc"
|
||||
rcvar=`set_rcvar`
|
||||
|
||||
required_files=${dir}/${name}.ini
|
||||
|
||||
start_cmd="${name}_start"
|
||||
stop_cmd="${name}_stop"
|
||||
|
||||
extra_commands="flush fetch update"
|
||||
|
||||
flush_cmd="${name}_flush"
|
||||
fetch_cmd="${name}_fetch"
|
||||
update_cmd="${name}_update"
|
||||
|
||||
dnetc_start()
|
||||
{
|
||||
if ps -U${user} >/dev/null; then
|
||||
echo "${name} already running?"
|
||||
else
|
||||
su -m ${user} -c "${dir}/${name} -quiet" >/dev/null 2>&1
|
||||
echo -n " ${name}"
|
||||
fi
|
||||
}
|
||||
|
||||
dnetc_stop()
|
||||
{
|
||||
if ps -U${user} >/dev/null; then
|
||||
su -m ${user} -c "${dir}/${name} -shutdown" >/dev/null 2>&1
|
||||
echo -n " ${name}"
|
||||
else
|
||||
echo "${name} not running?"
|
||||
fi
|
||||
}
|
||||
|
||||
dnetc_flush()
|
||||
{
|
||||
su -m ${user} -c "${dir}/${name} -flush" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
dnetc_fetch()
|
||||
{
|
||||
su -m ${user} -c "${dir}/${name} -fetch" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
dnetc_update()
|
||||
{
|
||||
su -m ${user} -c "${dir}/${name} -update" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
76
misc/dnetc/files/dnetc.sh.in
Normal file
76
misc/dnetc/files/dnetc.sh.in
Normal file
@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: dnetc
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: FreeBSD shutdown
|
||||
|
||||
#
|
||||
# Add the following lines to /etc/rc.conf to enable dnetc:
|
||||
# dnetc_enable (bool): Set to "NO" by default.
|
||||
# Set to "YES" to enable dnetc.
|
||||
# dnetc_dir (path): Set to "%%BINDIR%%" by default.
|
||||
# dnetc_user (user): Set to "%%CLIENTUSER%%" by default.
|
||||
#
|
||||
|
||||
. %%RC_SUBR%%
|
||||
|
||||
name="dnetc"
|
||||
rcvar=`set_rcvar`
|
||||
|
||||
load_rc_config $name
|
||||
|
||||
: ${dnetc_enable="NO"}
|
||||
: ${dnetc_dir="%%BINDIR%%"}
|
||||
: ${dnetc_user="%%CLIENTUSER%%"}
|
||||
|
||||
required_files=${dnetc_dir}/${name}.ini
|
||||
|
||||
start_cmd="${name}_start"
|
||||
stop_cmd="${name}_stop"
|
||||
|
||||
extra_commands="flush fetch update"
|
||||
|
||||
flush_cmd="${name}_flush"
|
||||
fetch_cmd="${name}_fetch"
|
||||
update_cmd="${name}_update"
|
||||
|
||||
dnetc_start()
|
||||
{
|
||||
if ps -x -o ucomm -U${dnetc_user} | grep ${name} >/dev/null; then
|
||||
echo "${name} already running?"
|
||||
else
|
||||
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -quiet" >/dev/null 2>&1
|
||||
echo -n " ${name}"
|
||||
fi
|
||||
}
|
||||
|
||||
dnetc_stop()
|
||||
{
|
||||
if ps -x -o ucomm -U${dnetc_user} | grep ${name} >/dev/null; then
|
||||
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -shutdown" >/dev/null 2>&1
|
||||
# wait for dnetc to stop
|
||||
sleep 2
|
||||
echo -n " ${name}"
|
||||
else
|
||||
echo "${name} not running?"
|
||||
fi
|
||||
}
|
||||
|
||||
dnetc_flush()
|
||||
{
|
||||
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -flush" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
dnetc_fetch()
|
||||
{
|
||||
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -fetch" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
dnetc_update()
|
||||
{
|
||||
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -update" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
@ -1,4 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
if [ "$2" != "POST-DEINSTALL" ]; then
|
||||
exit 0
|
||||
@ -8,21 +10,21 @@ CLIENTUSER=%%CLIENTUSER%%
|
||||
CLIENTGROUP=%%CLIENTGROUP%%
|
||||
|
||||
if /usr/sbin/pw usershow "$CLIENTUSER" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw userdel -n $CLIENTUSER; then
|
||||
echo "=> Removed user \"$CLIENTUSER\"."
|
||||
else
|
||||
echo "=> Removing user \"$CLIENTUSER\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
if /usr/sbin/pw userdel -n $CLIENTUSER; then
|
||||
echo "=> Removed user \"$CLIENTUSER\"."
|
||||
else
|
||||
echo "=> Removing user \"$CLIENTUSER\" failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if /usr/sbin/pw groupshow "$CLIENTGROUP" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw groupdel -n $CLIENTGROUP; then
|
||||
echo "=> Removed group \"$CLIENTGROUP\"."
|
||||
else
|
||||
echo "=> Removing group \"$CLIENTGROUP\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
echo "=> Removing group \"$CLIENTGROUP\" failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
35
misc/dnetc/files/pkg-install.in
Normal file
35
misc/dnetc/files/pkg-install.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
if [ "$2" != "PRE-INSTALL" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CLIENTUSER=%%CLIENTUSER%%
|
||||
CLIENTGROUP=%%CLIENTGROUP%%
|
||||
UID=%%CLIENTUID%%
|
||||
GID=$UID
|
||||
|
||||
if ! /usr/sbin/pw groupshow "$CLIENTGROUP" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw groupadd $CLIENTGROUP -g $GID; then
|
||||
echo "=> Added group \"$CLIENTGROUP\"."
|
||||
else
|
||||
echo "=> Adding group \"$CLIENTGROUP\" failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! /usr/sbin/pw usershow "$CLIENTUSER" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw useradd $CLIENTUSER -u $UID -g $CLIENTGROUP -h - \
|
||||
-s "/sbin/nologin" -d "/nonexistent" \
|
||||
-c "distributed.net client and proxy pseudo-user"; \
|
||||
then
|
||||
echo "=> Added user \"$CLIENTUSER\"."
|
||||
else
|
||||
echo "=> Adding user \"$CLIENTUSER\" failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$2" != "PRE-INSTALL" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CLIENTUSER=%%CLIENTUSER%%
|
||||
CLIENTGROUP=%%CLIENTGROUP%%
|
||||
UID=%%CLIENTUID%%
|
||||
GID=$UID
|
||||
|
||||
if ! /usr/sbin/pw groupshow "$CLIENTGROUP" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw groupadd $CLIENTGROUP -g $GID; then
|
||||
echo "=> Added group \"$CLIENTGROUP\"."
|
||||
else
|
||||
echo "=> Adding group \"$CLIENTGROUP\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! /usr/sbin/pw usershow "$CLIENTUSER" 2>/dev/null 1>&2; then
|
||||
if /usr/sbin/pw useradd $CLIENTUSER -u $UID -g $CLIENTGROUP -h - \
|
||||
-s "/sbin/nologin" -d "/nonexistent" \
|
||||
-c "distributed.net client pseudo-user"; \
|
||||
then
|
||||
echo "=> Added user \"$CLIENTUSER\"."
|
||||
else
|
||||
echo "=> Adding user \"$CLIENTUSER\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
exit 0
|
@ -2,5 +2,4 @@ distributed.net/dnetc
|
||||
@unexec if cmp -s %D/distributed.net/dnetc.ini %D/distributed.net/dnetc.ini.sample; then rm -f %D/distributed.net/dnetc.ini; fi
|
||||
distributed.net/dnetc.ini.sample
|
||||
@exec [ -f %B/dnetc.ini ] || cp %B/%f %B/dnetc.ini
|
||||
etc/rc.d/dnetc.sh
|
||||
@dirrm distributed.net
|
||||
|
Loading…
Reference in New Issue
Block a user