File: //var/packages/ProxyServer/scripts/postinst
#!/bin/sh
PRIVATE_LOCATION="/var/packages/ProxyServer/target"
BinDir="/var/packages/ProxyServer/target/bin"
VOLUME=`/usr/bin/readlink ${PRIVATE_LOCATION} | /usr/bin/cut -d '/' -f2`
chmod a+s ${PRIVATE_LOCATION}/bin/basic_pam_auth #chmod for pam local auth
chown -R nobody:nobody ${PRIVATE_LOCATION}/squid/var/logs/ #chown the cache_log directory
#create default cache dir
CACHE_DIR="/${VOLUME}/@squid"
mkdir ${CACHE_DIR}
chown -R nobody:nobody ${CACHE_DIR}
#write it into default conf file
#ex: cache_dir ufs /volume1/@squid 10240 16 256
/usr/syno/bin/synosetkeyvalue ${PRIVATE_LOCATION}/squid/etc/squid.syno cachedir_path ${CACHE_DIR}
$PRIVATE_LOCATION/tools/synoconftool --json-conf-set cache cache_dir_path ${CACHE_DIR}
cp ${PRIVATE_LOCATION}/squid/etc/setting_syno.json ${PRIVATE_LOCATION}/etc/default/setting_syno.json.default #keep default json setting
$PRIVATE_LOCATION/tools/synoconftool --squid-conf-dump cache
#use tool to dump conf
for i in `ls ${PRIVATE_LOCATION}/etc/default/`
do
cp ${PRIVATE_LOCATION}/etc/default/$i ${PRIVATE_LOCATION}/squid/etc/`echo $i | sed "s/\.default//g"`
done
${BinDir}/squid -z
exit 0