-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·44 lines (39 loc) · 1.39 KB
/
install
File metadata and controls
executable file
·44 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -eo pipefail
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case "$(uname -m)" in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
*)
echo "dokkufile: unsupported architecture $(uname -m)" >&2
exit 1
;;
esac
URL="https://github.com/deanmarano/dokkufile/releases/download/latest/dokkufile-linux-${ARCH}"
TMPFILE=$(mktemp "$PLUGIN_DIR/dokkufile-bin.XXXXXX")
trap "rm -f '$TMPFILE'" EXIT
if [[ -x "$PLUGIN_DIR/dokkufile-bin" ]]; then
# -z only downloads if remote is newer than local file
HTTP_CODE=$(curl -fsSL -z "$PLUGIN_DIR/dokkufile-bin" -o "$TMPFILE" -w "%{http_code}" "$URL" 2>/dev/null || echo "000")
if [[ "$HTTP_CODE" == "304" ]]; then
:
elif [[ "$HTTP_CODE" == "200" ]]; then
mv "$TMPFILE" "$PLUGIN_DIR/dokkufile-bin"
chmod +x "$PLUGIN_DIR/dokkufile-bin"
chown dokku:dokku "$PLUGIN_DIR/dokkufile-bin"
echo "dokkufile: updated successfully"
else
echo "dokkufile: update check failed (HTTP ${HTTP_CODE}), keeping existing binary" >&2
fi
else
echo "dokkufile: downloading binary for linux/${ARCH}..."
if curl -fsSL -o "$TMPFILE" "$URL"; then
mv "$TMPFILE" "$PLUGIN_DIR/dokkufile-bin"
chmod +x "$PLUGIN_DIR/dokkufile-bin"
chown dokku:dokku "$PLUGIN_DIR/dokkufile-bin"
echo "dokkufile: installed successfully"
else
echo "dokkufile: download failed, is GitHub reachable?" >&2
exit 1
fi
fi