-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·47 lines (31 loc) · 945 Bytes
/
deploy.sh
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
#!/usr/bin/env bash
set -eo pipefail
export BELT_ENV_TOOLBOX_TOOLS="caddy"
source /dev/stdin <<< "$(curl -Lsm 2 https://get.belt.sh)"
ARCHIVE_FILE="/tmp/toolshed.tar.gz"
main() {
local host="$1"
[[ -z "$host" ]] && echo "Error: missing argument host" && exit 1
[[ ! -e "$ARCHIVE_FILE" ]] && echo "Error: missing archive $ARCHIVE_FILE" && exit 1
belt_begin_session "root" "$host"
echo "Uploading app archive"
app_upload "$ARCHIVE_FILE"
echo "Stopping process"
systemd_unit_stop "toolshed"
echo "Setting up user"
user_add "toolshed"
echo "Copying files"
app_copy_file "dist/toolshed"
echo "Setting up permissions"
app_set_permissions "toolshed:toolshed"
echo "Copying unit file"
systemd_add_unit "toolshed.service"
echo "Starting process"
systemd_unit_start "toolshed"
echo "Adding caddy vhost"
caddy_add_vhost
echo "Restarting caddy"
caddy_restart
}
echo "Deploying toolshed"
main "$1"