diff options
author | Charadon <dev@iotib.net> | 2022-08-08 21:46:40 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-08-08 21:46:40 -0400 |
commit | 71e7432979ff32478f942b153cfe75a31a2dd838 (patch) | |
tree | 7b183a1821a7bb9ce266f007a4eeddaf31f5edf7 | |
parent | 63f551f21fb77d25405cc74683e6dccab2ba192c (diff) | |
download | dscip-71e7432979ff32478f942b153cfe75a31a2dd838.tar.gz |
Added auto update feature, by default it's off.
-rwxr-xr-x | config.sh | 5 | ||||
-rwxr-xr-x | dscip | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/config.sh b/config.sh index 342ff83..683a67f 100755 --- a/config.sh +++ b/config.sh @@ -28,4 +28,7 @@ export DSCIP_SLEEP="60" # How many seconds before the daemon re-runs itself. # # etc # export DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even # # if upstream has not updated. # -export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is stdout. +export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is output.txt +# Automatically update DSCIP? +export DSCIP_AUTO_UPDATE="true" + diff --git a/dscip b/dscip index d27c9cc..99915ee 100755 --- a/dscip +++ b/dscip @@ -15,11 +15,30 @@ # See the License for the specific language governing permissions and # # limitations under the License. # ################################################################################ - set -eu + +# Grab checksum of DSCIP for use with updating. +DSCIP_CKSUM="$(cksum "$0")" + cd "$(dirname "$0")" . "$(pwd -P)/config.sh" +# Checking updates +if [ "$DSCIP_AUTO_UPDATE" = "true" ]; then + . "$WORKING_DIRECTORY/update.sh" + DSCIP_NEW_CKSUM="$(cksum "$0")" + # Rerun dscip if update was found. + if [ ! "$DSCIP_CKSUM" = "$DSCIP_NEW_CKSUM" ]; then + echo "Update found. Rerunning DSCIP..." + "$SHELL" "$0" "$@" + exit 0 + else + echo "No updates found. Continuing..." + fi +else + echo "Auto updates turned off. Continuing..." +fi + ################################################################################ # Move script to background if DSCIP_DAEMON_FORK is set to true # |