#!/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 < /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<