lixonet-ee/run.sh

30 lines
910 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:52:36 -06:00
(
set -e
current_version=`cat $version_file || echo 0`
2021-05-18 18:16:25 -06:00
gpg --import <trusted_signers
(echo 5; echo y; echo save) | gpg --command-fd 0 --no-tty --no-greeting -q --edit-key "$(gpg --list-packets <trusted_signers | awk '$1=="keyid:"{print$2;exit}')" trust
2021-05-18 18:01:35 -06:00
git fetch $GIT_URL
2021-05-18 17:52:36 -06:00
latest_commit=`git log "--format=%G? %H" | grep ^G | head -n 1 | cut -d' ' -f2`
2021-05-18 18:16:25 -06:00
if test -z $latest_commit; then
echo "No trusted commits found! Re-checking in 60 seconds..."
sleep 60
continue
fi
2021-05-18 17:52:36 -06:00
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:52:36 -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
2021-05-18 17:52:36 -06:00
)
2021-05-18 17:38:32 -06:00
sleep $delay
done