#!/bin/sh

set -x

FRR_OWNER="%%FRR_OWNER%%"
FRR_GROUP="%%FRR_GROUP%%"
FRR_OWNER_ID="%%FRR_OWNER_ID%%"
FRR_GROUP_ID="%%FRR_GROUP_ID%%"

RUN_DIR="%%RUN_DIR%%"
LOG_DIR="%%LOG_DIR%%"
CONF_DIR="%%CONF_DIR%%"

PKG_PREFIX="/notexist"

case $2 in 
    PRE-INSTALL)
	pw group add ${FRR_GROUP} -g ${FRR_GROUP_ID} 
	pw user add ${FRR_OWNER}  -g ${FRR_GROUP} \
	    -d ${PKG_PREFIX} -s /usr/sbin/nologin -u ${FRR_OWNER_ID} \
	    -c "quagga"
	pw group mod ${FRR_GROUP} -M ${FRR_OWNER}
	pw group show ${FRR_GROUP}
	pw user show ${FRR_OWNER}
	mkdir -p ${RUN_DIR} 
	chown ${FRR_OWNER}:${FRR_GROUP} ${RUN_DIR} 
	chmod 0750 ${RUN_DIR} 

	mkdir -p ${LOG_DIR} 
	chown ${FRR_OWNER}:${FRR_GROUP} ${LOG_DIR} 
	chmod 0750 ${LOG_DIR} 

	mkdir -p ${CONF_DIR} 
	chown ${FRR_OWNER}:${FRR_GROUP} ${CONF_DIR} 
	chmod 0750 ${CONF_DIR} 
	;;
    POST-INSTALL)
	;;
esac
#EOF
