-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·49 lines (37 loc) · 1.23 KB
/
deploy.sh
File metadata and controls
executable file
·49 lines (37 loc) · 1.23 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
45
46
47
48
49
#!/usr/bin/env bash
# Build, package, and deploy wirepf to a Debian server over SSH.
#
# Usage:
# ./deploy.sh user@host # ssh target
# WIREPF_HOST=user@host ./deploy.sh
set -euo pipefail
HOST="${1:-${WIREPF_HOST:-}}"
if [[ -z "$HOST" ]]; then
echo "usage: $0 <user@host> (or set WIREPF_HOST)" >&2
exit 2
fi
TARGET="x86_64-unknown-linux-musl"
PKG="wirepf-daemon"
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
echo "==> Building release binary ($TARGET)"
cargo build -p "$PKG" --release --target "$TARGET"
echo "==> Packaging .deb"
cargo deb -p "$PKG" --no-build --target "$TARGET"
DEB=$(ls -t "target/$TARGET/debian/"wirepf_*.deb | head -1)
echo "==> Built: $DEB"
REMOTE="/tmp/$(basename "$DEB")"
echo "==> Uploading to $HOST:$REMOTE"
scp "$DEB" "$HOST:$REMOTE"
echo "==> Installing on $HOST"
ssh -t "$HOST" "sudo apt-get install -y --reinstall $REMOTE && rm -f $REMOTE && sudo systemctl status wirepf --no-pager -l"
cat <<EOF
==> Done.
Next steps on $HOST:
sudo nano /etc/wirepf/config.json # set auth_token
sudo systemctl restart wirepf
sudo journalctl -u wirepf -f # tail logs
API:
curl -s http://<host>:1204/health
curl -s -H "Authorization: Bearer <token>" http://<host>:1204/interfaces
EOF