|
@@ -1,4 +1,4 @@
|
|
|
-#!/bin/sh
|
|
|
|
|
|
|
+#!/bin/bash
|
|
|
#
|
|
#
|
|
|
# Copyright (c) 2019 Clementine Computing LLC.
|
|
# Copyright (c) 2019 Clementine Computing LLC.
|
|
|
#
|
|
#
|
|
@@ -37,10 +37,26 @@ function spawn_supervisor
|
|
|
# If we have a client supervisor binary to run
|
|
# If we have a client supervisor binary to run
|
|
|
#
|
|
#
|
|
|
if [ -f $BASEDIR/bin/client_supervisor ]; then
|
|
if [ -f $BASEDIR/bin/client_supervisor ]; then
|
|
|
|
|
+
|
|
|
|
|
+# # If we also have a config file for the UI
|
|
|
|
|
+# #
|
|
|
|
|
+# if [ -f $BASEDIR/config/menu.xml ]; then
|
|
|
|
|
+# rm $supervisor_pidfile
|
|
|
|
|
+#
|
|
|
|
|
+# # then run the whole shebang...
|
|
|
|
|
+# #
|
|
|
|
|
+# $BASEDIR/bin/client_supervisor $supervisor_args &
|
|
|
|
|
+# echo $! > $supervisor_pidfile
|
|
|
|
|
+# echo Spawned client_supervisor. PID = `cat $supervisor_pidfile`
|
|
|
|
|
+#
|
|
|
|
|
+# # if we DON'T have one, we still need to download a config before we're viable...
|
|
|
|
|
+# #
|
|
|
|
|
+# else
|
|
|
|
|
+# rm -f config.tgz.*
|
|
|
|
|
+# $BASEDIR/bin/showmessage -b "Downloading Config..."
|
|
|
|
|
+# fi
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- # If we also have a config file for the UI
|
|
|
|
|
- #
|
|
|
|
|
- if [ -f $BASEDIR/config/menu.xml ]; then
|
|
|
|
|
rm $supervisor_pidfile
|
|
rm $supervisor_pidfile
|
|
|
|
|
|
|
|
# then run the whole shebang...
|
|
# then run the whole shebang...
|
|
@@ -49,13 +65,6 @@ function spawn_supervisor
|
|
|
echo $! > $supervisor_pidfile
|
|
echo $! > $supervisor_pidfile
|
|
|
echo Spawned client_supervisor. PID = `cat $supervisor_pidfile`
|
|
echo Spawned client_supervisor. PID = `cat $supervisor_pidfile`
|
|
|
|
|
|
|
|
- # if we DON'T have one, we still need to download a config before we're viable...
|
|
|
|
|
- #
|
|
|
|
|
- else
|
|
|
|
|
- rm -f config.tgz.*
|
|
|
|
|
- $BASEDIR/bin/showmessage -b "Downloading Config..."
|
|
|
|
|
- fi
|
|
|
|
|
-
|
|
|
|
|
# If we DON'T have one, we are either a new system or just badly broken so...
|
|
# If we DON'T have one, we are either a new system or just badly broken so...
|
|
|
#
|
|
#
|
|
|
else
|
|
else
|
|
@@ -65,6 +74,8 @@ function spawn_supervisor
|
|
|
rm -f $BASEDIR/config/*.tgz.*
|
|
rm -f $BASEDIR/config/*.tgz.*
|
|
|
$BASEDIR/bin/showmessage -b "Wait (~ 15 min)"
|
|
$BASEDIR/bin/showmessage -b "Wait (~ 15 min)"
|
|
|
|
|
|
|
|
|
|
+ echo "..."
|
|
|
|
|
+
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -78,7 +89,7 @@ function check_update
|
|
|
else
|
|
else
|
|
|
echo -en "0"
|
|
echo -en "0"
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for file in `ls $checksum_path/*.checksum`; do
|
|
for file in `ls $checksum_path/*.checksum`; do
|
|
|
echo -en "\t`echo $file | sed -r 's/^.*\/(.*)\.checksum$/\1/'`=`cat $file`";
|
|
echo -en "\t`echo $file | sed -r 's/^.*\/(.*)\.checksum$/\1/'`=`cat $file`";
|
|
|
done;
|
|
done;
|
|
@@ -88,7 +99,9 @@ function check_update
|
|
|
|
|
|
|
|
|
|
|
|
|
while true; do
|
|
while true; do
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ echo "## heartbeat"
|
|
|
|
|
+
|
|
|
#See if we need to spawn our client supervisor
|
|
#See if we need to spawn our client supervisor
|
|
|
if [ ! -f $supervisor_pidfile ]; then
|
|
if [ ! -f $supervisor_pidfile ]; then
|
|
|
spawn_supervisor;
|
|
spawn_supervisor;
|
|
@@ -105,7 +118,7 @@ while true; do
|
|
|
check_update |
|
|
check_update |
|
|
|
(
|
|
(
|
|
|
while read client_file checksum file_size server_path file_version; do
|
|
while read client_file checksum file_size server_path file_version; do
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# If we've been asked to abort this update, do so before we start downloading if possible
|
|
# If we've been asked to abort this update, do so before we start downloading if possible
|
|
|
#
|
|
#
|
|
|
if [ -f $UPDATE_ABORT_DROPFILE ]; then
|
|
if [ -f $UPDATE_ABORT_DROPFILE ]; then
|
|
@@ -132,12 +145,12 @@ while true; do
|
|
|
# Initiate a secure download to fetch this package down from the server
|
|
# Initiate a secure download to fetch this package down from the server
|
|
|
#
|
|
#
|
|
|
scp -i $SSH_IDENTITY $SCP_OPTIONS -P $SSH_PORT $SSH_TARGET:$server_path /tmp/$client_file
|
|
scp -i $SSH_IDENTITY $SCP_OPTIONS -P $SSH_PORT $SSH_TARGET:$server_path /tmp/$client_file
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# If we've already downloaded when we get the abort message
|
|
# If we've already downloaded when we get the abort message
|
|
|
#
|
|
#
|
|
|
if [ -f $UPDATE_ABORT_DROPFILE ]; then
|
|
if [ -f $UPDATE_ABORT_DROPFILE ]; then
|
|
|
echo "Aborting update on request!";
|
|
echo "Aborting update on request!";
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Clean up after ourselves
|
|
# Clean up after ourselves
|
|
|
#
|
|
#
|
|
|
rm -f /tmp/$client_file.expected_size /tmp/$client_file.expected_md5
|
|
rm -f /tmp/$client_file.expected_size /tmp/$client_file.expected_md5
|
|
@@ -159,7 +172,7 @@ while true; do
|
|
|
# If we indeed _got_ a file to begin with...
|
|
# If we indeed _got_ a file to begin with...
|
|
|
#
|
|
#
|
|
|
if [ -f /tmp/$client_file ]; then
|
|
if [ -f /tmp/$client_file ]; then
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Start a subshell in which we...
|
|
# Start a subshell in which we...
|
|
|
#
|
|
#
|
|
|
(
|
|
(
|
|
@@ -174,7 +187,7 @@ while true; do
|
|
|
$BASEDIR/bin/apply_update.sh $client_file $checksum $file_size $server_path $file_version
|
|
$BASEDIR/bin/apply_update.sh $client_file $checksum $file_size $server_path $file_version
|
|
|
);
|
|
);
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Clean up after ourselves (removing our during-update dropfiles)
|
|
# Clean up after ourselves (removing our during-update dropfiles)
|
|
|
#
|
|
#
|
|
|
rm -f /tmp/$client_file.expected_size /tmp/$client_file.expected_md5
|
|
rm -f /tmp/$client_file.expected_size /tmp/$client_file.expected_md5
|