Files

21 lines
789 B
Bash

#!/bin/ash
#Get and update ID
if [ ! -f "/opt/VouchTemplates/.vouchID" ]; then ID=0; else source /opt/VouchTemplates/.vouchID; fi
if [ -z ${ID+x} ]; then ID=0; fi
ID=$(($ID+1))
echo "ID=$ID" > /opt/VouchTemplates/.vouchID
#Settign up config
mkdir "/etc/vouch-proxy$ID"
cp -r /usr/share/webapps/vouch-proxy "/usr/share/webapps/vouch-proxy$ID"
rm "/usr/share/webapps/vouch-proxy$ID/config"
ln -s "/etc/vouch-proxy$ID" "/usr/share/webapps/vouch-proxy$ID/config"
cp /opt/VouchTemplates/Vouch-Config "/etc/vouch-proxy$ID/config.yml"
sed -i "s/VID/$ID/" "/etc/vouch-proxy$ID/config.yml"
#Setting up service
cp /opt/VouchTemplates/Vouch-Service "/etc/init.d/vouch-proxy$ID"
sed -i "s/VID/$ID/" "/etc/init.d/vouch-proxy$ID"
chmod +x "/etc/init.d/vouch-proxy$ID"
rc-update add "vouch-proxy$ID"