#! /bin/sh # $FreeBSD$ if [ "$2" != "POST-INSTALL" ]; then exit 0 fi OPENACSBASE="%%OPENACSBASE%%" openacs_user="%%OPENACS_USER%%" openacs_uid="%%OPENACS_UID%%" openacs_group="%%OPENACS_GROUP%%" openacs_gid="%%OPENACS_GID%%" openacs_gecos="%%OPENACS_GECOS%%" openacs_home="%%OPENACS_HOME%%" openacs_shell="%%OPENACS_SHELL%%" CHMOD=%%CHMOD%% CHOWN=%%CHOWN%% PW=%%PW%% create_group() { local group gid group=$1 gid=$2 if ${PW} group show -n $group >/dev/null 2>&1 ; then echo "===> Using existing group $group" else if ${PW} groupadd -n $group -g $gid ; then echo "===> Created group $group" else cat <<-EOERRORMSG *** Failed to create group $group. Please add user $user and group $group manually with the following commands: ${PW} groupadd -n $group -g $gid ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\ -d $home -s $shell -h - and retry installing this package. EOERRORMSG exit 1 fi fi } create_user() { local user uid group gecos home shell user=$1 uid=$2 group=$3 gecos=$4 home=$5 shell=$6 if ${PW} user show -n $user >/dev/null 2>&1 ; then echo "===> Using existing user $user" else if ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \ -d "$home" -s "$shell" -h - ; then echo "===> Created user $user" else cat <<-EOERRORMSG *** Failed to create user $user. Please add user $user manually with the following command: ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\ -d $home -s $shell -h - and retry installing this package. EOERRORMSG exit 1 fi fi } create_group $openacs_group $openacs_gid create_user $openacs_user $openacs_uid $openacs_group \ "$openacs_gecos" "$openacs_home" "$openacs_shell" echo "===> Changing ownership of ${OPENACSBASE}" ${CHOWN} -R ${openacs_user}:${openacs_group} ${OPENACSBASE} echo "===> Changing permissions of ${OPENACSBASE}" ${CHMOD} -R 770 ${OPENACSBASE}