summaryrefslogblamecommitdiff
path: root/net/vserver/files/pkg-install.in
blob: e677774c5ee9199eb61df137bf8cdd2ee0cd353e (plain) (tree)




























































































                                                                                         
#! /bin/sh

PREFIX=${PKG_PREFIX:-%%PREFIX%%}

VCHATUSER=%%VCHATUSER%%
VCHATGROUP=%%VCHATGROUP%%
UID=128
GID=128

if [ -n "%%DESTDIR%%" ]; then

	PW="/usr/sbin/chroot %%DESTDIR%% pw"
	CHOWN="/usr/sbin/chroot %%DESTDIR%% chown"
	CHMOD="/usr/sbin/chroot %%DESTDIR%% chmod"
	MKDIR="/usr/sbin/chroot %%DESTDIR%% mkdir -p"

else

	PW="pw"
	CHOWN="chown"
	CHMOD="chmod"
	MKDIR="mkdir"


fi


if [ "$2" = "PRE-INSTALL" ]; then

	if ! ${PW} groupshow ${VCHATGROUP} 2>/dev/null 1>&2; then

		if ${PW} groupadd ${VCHATGROUP} -g $GID; then
			echo "=> Added group \"${VCHATGROUP}\"."
		else
			echo "=> Adding group \"${VCHATGROUP}\" failed."
			exit 1
		fi
	fi

	if ! ${PW} usershow ${VCHATUSER} 2>/dev/null 1>&2; then

		if ${PW} useradd ${VCHATUSER} -u $UID -g ${VCHATGROUP} -h - \
			-s "/sbin/nologin" -d "/nonexistent" \
			-c "VChat Conferencing System"; \
		then

			echo "=> Added user \"${VCHATUSER}\"."

		else

			echo "=> Adding user \"${VCHATUSER}\" failed."
			exit 1

		fi
	fi

elif [ "$2" = "POST-INSTALL" ]; then

	if [ ! -d "${PREFIX}/etc/vchat" ]; then
		${MKDIR} ${PREFIX}/etc/vchat || exit 1
	fi

	${CHOWN} ${VCHATUSER}:${VCHATGROUP} ${PREFIX}/etc/vchat
	${CHMOD} 755 ${PREFIX}/etc/vchat

	if [ ! -f "${PREFIX}/etc/vchat/user.db" ]; then


cat << -EOT-

****************************** IMPORTANT NOTE *******************************

Before starting vserver into normal operations for the first time, you
need to create an initial user database file "${PREFIX}/etc/vchat/user.db".

This is accomplished by running the following command sequence:

su -f -m ${VCHATUSER} -c "${PREFIX}/sbin/vserver /BASEDIR=${PREFIX}/etc/vchat /CREATEUDB"

*****************************************************************************

-EOT-

	else

		${CHOWN} ${VCHATUSER}:${VCHATGROUP} ${PREFIX}/etc/vchat/user.db
		${CHMOD} 600 ${PREFIX}/etc/vchat/user.db

	fi

fi

exit 0