deploy/install.sh

88fc476788ab9c640649427d815217360569b4d9
gitbay/deploy/install.sh history · blame · raw

20 lines · 749 bytes · executable

 1#!/bin/sh
 2# Push the gitbayd binary to a freshly cloud-inited host and start it.
 3# Usage: deploy/install.sh <host-or-ip> [ssh-port]
 4set -eu
 5host=${1:?usage: install.sh <host-or-ip> [ssh-port]}
 6port=${2:-2222}
 7bin=dist/gitbayd-linux-amd64
 8
 9[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; }
10
11"$(dirname "$0")/copy.sh" "$host" "$port" "$bin" /usr/local/bin/gitbayd.new
12ssh -p "$port" "root@$host" '
13  set -eu
14  chmod 755 /usr/local/bin/gitbayd.new
15  mv /usr/local/bin/gitbayd.new /usr/local/bin/gitbayd
16  /usr/local/bin/gitbayd --config /etc/gitbay/config.toml check-config --no-host-checks
17  systemctl restart gitbayd
18  sleep 1
19  systemctl --no-pager --lines=5 status gitbayd
20'