From e59478635a4d2ca530309f043d80d61cdedf9b81 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Wed, 26 Feb 2020 11:09:40 +0100 Subject: [PATCH] Added code to run a script once each time it is altered --- deployment-script.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deployment-script.sh b/deployment-script.sh index ffe2e0c..c95e993 100755 --- a/deployment-script.sh +++ b/deployment-script.sh @@ -7,5 +7,11 @@ echo -n "`find -name "*.php" -or -name "*.html" | sed 's/^/python variable_grabb echo -n "`find -name "*.php" -or -name "*.html" | sed 's/^/python variable_grabbler.py /;s/$/ variable_grabbler.pass1.json/'`" | bash - echo -n "`find -name "*.php" -or -name "*.html" | sed 's/^/python variable_grabbler.py /;s/$/ variable_grabbler.pass2.json/'`" | bash - +echo "Checking run-once script..." +echo "Setting permissions." +chmod +x run-once-script.sh +echo -ne "import os, sys\nif \"`sha256sum run-once-script.sh`\" == \"`cat ../run-once`\":\n print \"File has not changed. Aborting.\"\n sys.exit()\nelse:\n print \"File has changed. Calculating checksum...\"\n os.system(\"sha256sum run-once-script.sh > ../run-once\")\n print \"\"\"Executing...\n==========\"\"\"\n os.system(\"./run-once-script.sh\")\n print \"\"\"==========\nDone.\"\"\"" | python + + echo "============================================================================== Done."