#!/bin/sh # $FreeBSD$ PATH=/bin:/usr/bin:/usr/sbin USER="%%REDIS_USER%%" USER_ID="%%REDIS_UID%%" GROUP="%%REDIS_GROUP%%" GROUP_ID="%%REDIS_GID%%" RUNTIME_DIRS="%%REDIS_LOGDIR%% %%REDIS_DBDIR%% %%REDIS_RUNDIR%%" case $2 in PRE-INSTALL) if [ `id -u` -ne 0 ]; then echo; echo "You must be root to run this step!"; echo; echo exit 1 fi RES=`pw groupshow -n ${GROUP} 2>/dev/null` if [ $? -eq 0 ]; then echo "You already have a group \"${GROUP}\", so we will use it." else RES=`pw groupshow -g ${GROUP_ID} 2>/dev/null` if [ $? -ne 0 ]; then _GID="-g ${GROUP_ID}" else _GID='' fi if pw groupadd -n ${GROUP} ${_GID}; then echo "Added group \"${GROUP}\"." else echo "Adding group \"${GROUP}\" failed..." exit 1 fi fi RES=`id -u ${USER} 2>/dev/null` if [ $? -ne 0 ]; then RES=`id -un ${USER_ID} 2>/dev/null` if [ $? -ne 0 ]; then _UID="-u ${USER_ID}" else _UID='' fi if pw useradd -n ${USER} ${_UID} -g ${GROUP} \ -w no -s /usr/sbin/nologin; then echo "Added user \"${USER}\"." else echo "Adding user \"${USER}\" failed..." exit 1 fi fi ;; POST-INSTALL) for DIR in ${RUNTIME_DIRS}; do mkdir -p ${DIR} chown -R ${USER}:${GROUP} ${DIR} chmod -R 755 ${DIR} done ;; DEINSTALL) if [ -z ${UPGRADE_PORT} ] ; then echo echo "If you do not intend to reinstall \"%%PORTNAME%%\" you should manually" echo "remove user '${USER}' (uid='${USER_ID}') and group '${GROUP}' (gid='${USER_ID}')." echo echo "Also you may want to remove the no longer required directoris:" echo ${RUNTIME_DIRS} echo fi esac