#!/bin/bash

# We are in the docker. We need to kill the current launch file and the current running application
# We send a SIGABRT since is more effective. In the future this may change
pkill -6 -f launch.sh
pkill -6 -f CinePlayout
pkill -6 -f DeviceManager

# let's wait a little bit. If necessary we need to wait on a process exit with a loop
sleep 5

cd /var/opt/cineplayer/bin/

rm launch.sh

# We download the new software
curl -O http://software.bitonlive.net/cinema/Setup/InstallDatastore/dockers/CinePlayout/launch-cineplayout.sh
curl -O http://software.bitonlive.net/cinema/Setup/InstallDatastore/dockers/CinePlayout/DeviceManager
curl -O http://software.bitonlive.net/beta/cinema/CinePlayout

mv launch-cineplayout.sh launch.sh

chmod +x launch.sh
chmod +x DeviceManager
chmod +x CinePlayout