#!/bin/sh
SPK_ID='udpxy'
[ ${SYNOPKG_PKGDEST} ] || SYNOPKG_PKGDEST=`ls -l /var/packages/${SPK_ID}/target | cut -d\> -f2 | cut -d\  -f2`

# link DSM config/help/cgi
[ -L /usr/syno/synoman/webman/3rdparty/${SPK_ID} ] || ln -s "${SYNOPKG_PKGDEST}/dsmui" /usr/syno/synoman/webman/3rdparty/${SPK_ID}

# add help
pkgindexer_add ${SYNOPKG_PKGDEST}/dsmui/index.conf 1>/dev/null
pkgindexer_add ${SYNOPKG_PKGDEST}/dsmui/helptoc.conf 1>/dev/null

# add port preset
servicetool --install-configure-file --package ${SYNOPKG_PKGDEST}/etc/port.conf

# add system user
synouser --add "${SPK_ID}" `openssl rand 27 -base64 2>/dev/null` "${SPK_ID} daemon user" 1 "" ""
SPK_USERDIR=`grep "${SPK_ID} daemon user" /etc/passwd | cut -d: -f6`
if [ ! ${SPK_USERDIR} ]; then
        echo "Could not create user ${SPK_ID}, please check your accounts configuration." >${SYNOPKG_TEMP_LOGFILE}
        exit 1
fi
mkdir -p ${SPK_USERDIR}
chown -R ${SPK_ID} ${SPK_USERDIR} ${SYNOPKG_PKGDEST}/var/log



exit 0 

