public
anonymous / INSTALL.txt
Created

INSTALL

  • Download Gist
INSTALL.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#!/bin/sh
# $NetBSD$
 
PATH=/bin:/usr/sbin
USER=PACKAGE_NAME
GROUP=PACKAGE_NAME
HOME=/usr/pkg/PACKAGE_NAME
DAEMON=${HOME}/agent
 
case ${STAGE} in
PRE-INSTALL)
if groupinfo ${GROUP} 2> /dev/null; then
echo "Group \"${GROUP}\" alredy exists, leaving as is."
else
if groupadd ${GROUP} 2> /dev/null
then
echo "Created agent's \"${GROUP}\" group."
else
echo "Creating agent's group \"${GROUP}\" has failed."
exit 1
fi
fi
 
if /usr/bin/id ${USER} 2> /dev/null; then
echo "User \"${USER}\" already exists."
else
if useradd -g ${GROUP} \
-d ${HOME} -s /sbin/nologin -c "PACKAGE_NAME" ${USER} 2> /dev/null
then
echo "Added agent's user \"${USER}\"."
else
echo "Adding agent's \"${USER}\" user has failed."
exit 1
fi
fi
 
;;
POST-INSTALL)
if cat /etc/rc.conf | /usr/bin/grep PACKAGE_NAME 2>&1 > /dev/null; then
echo "Agent's service was found rc.conf, leaving as is"
else
echo 'PACKAGE_NAME=YES' >> /etc/rc.conf
echo "Agent's service enabled in rc.conf."
fi
 
chown -R ${USER}:${GROUP} ${HOME}
chmod 770 ${HOME}
chmod 770 ${DAEMON}
/usr/pkg/bin/perl ${DAEMON} register
 
;;
 
esac

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.