#!/bin/sh
a= . install2-init-functions

osimageserver=$1
deployment_id=$2
computer_id=$3
rmqserver=$4
agent_server="$5"
curl http://$osimageserver/osimages/pefiles/agent/firsttime.sh -o  $destdir/usr/local/bin/colibri_postinstall.sh
chmod +x  $destdir/usr/local/bin/colibri_postinstall.sh
curl http://$osimageserver/osimages/pefiles/agent/colibri_runonce.service -o $destdir/etc/systemd/system/colibri_runonce.service
sed -i "s/PARAM1/$osimageserver/g" "$destdir/usr/local/bin/colibri_postinstall.sh"
sed -i "s/PARAM2/$deployment_id/g" "$destdir/usr/local/bin/colibri_postinstall.sh"
sed -i "s/PARAM3/$computer_id/g" "$destdir/usr/local/bin/colibri_postinstall.sh"
sed -i "s/PARAM4/$rmqserver/g" "$destdir/usr/local/bin/colibri_postinstall.sh"
sed -i "s!PARAM5!$agent_server!g" "$destdir/usr/local/bin/colibri_postinstall.sh"
chmod 664 $destdir/etc/systemd/system/colibri_runonce.service
run_chroot sh -c "systemctl enable colibri_runonce"