lixonet-ee/run.sh

22 lines
648 B
Bash
Raw Normal View History

2021-05-18 17:38:32 -06:00
#!/bin/ash
delay=900
version_file=/etc/lixonet/version
while true
do
{
2021-05-18 17:48:02 -06:00
current_version=`cat $version_file || echo 0` &&
git fetch &&
latest_commit=`git log "--format=%G? %H" | grep ^G | head -n 1 | cut -d' ' -f2` &&
git checkout $latest_commit &&
checkout_version=`cat version` &&
2021-05-18 17:38:32 -06:00
if [ "$checkout_version" -gt "$current_version" ]; then
2021-05-18 17:48:02 -06:00
echo "Updating to version $checkout_version..." &&
chmod +x build.sh && ./build.sh &&
echo "Updated to version $checkout_version." &&
2021-05-18 17:38:32 -06:00
echo $checkout_version > $version_file
fi
} || {
echo "Failed to update repository. Trying again in $delay seconds."
}
sleep $delay
done