summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Busby <noreply+git@benbusby.com>2021-11-15 16:44:26 -0700
committerBen Busby <noreply+git@benbusby.com>2021-11-15 16:44:26 -0700
commit8ce5b04f510333b5e8552d30e84276e08c29ecb2 (patch)
treef634bdcad7d2813f7be2d5c93dff34c13d571871
parentc627f4d402c396663f1a4ca9d63a54299ac0fe57 (diff)
downloadfarside-8ce5b04f510333b5e8552d30e84276e08c29ecb2.tar.gz
Install crontab w/ script
This adds a couple of new scripts: install-crontab.sh and update.sh. The install-crontab script does exactly that -- it installs a new crontab that runs the update script every 5 minutes. An update script was added to simplify the crontab a bit and to ensure the Elixir update script is executed from the correct directory.
-rwxr-xr-xinstall-crontab.sh6
-rw-r--r--update.exs2
-rwxr-xr-xupdate.sh6
3 files changed, 13 insertions, 1 deletions
diff --git a/install-crontab.sh b/install-crontab.sh
new file mode 100755
index 0000000..47c220c
--- /dev/null
+++ b/install-crontab.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Install crontab to run update script
+
+SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
+
+(crontab -l 2>/dev/null; echo "*/5 * * * * $SCRIPT_DIR/update.sh") | crontab -
diff --git a/update.exs b/update.exs
index e0c367a..bc9ba0d 100644
--- a/update.exs
+++ b/update.exs
@@ -6,7 +6,7 @@ defmodule Instances do
def init() do
File.rename(@update_file, "#{@update_file}-prev")
- update
+ update()
end
def request(url) do
diff --git a/update.sh b/update.sh
new file mode 100755
index 0000000..1ab0d52
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
+
+cd "$SCRIPT_DIR"
+mix run update.exs