-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathatrain.sh
108 lines (90 loc) · 2.28 KB
/
atrain.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# https://github.com/maximuskowalski/maxmisc/blob/master/atrain.sh
# an A-Train installer
set -Eeuo pipefail
IFS=$'\n\t'
#________ VARS
APP=atrain
APPDIR=/opt
NETWORK=saltbox
#________ DONT CHANGE
DOCKTAG=latest
MNTPNT=${APPDIR}/${APP}
CONFIGUS="${MNTPNT}/a-train.toml"
#________ FUNCTIONS
checkoff() {
([ -d "${MNTPNT}" ] || dirmkr)
([ -e ${CONFIGUS} ] || configo)
}
dirmkr() {
sudo mkdir -p "${MNTPNT}" && sudo chown "${USER}":"${USER}" "${MNTPNT}"
}
# let user complete - no var replacing
# use heredoc instead of var
configo() {
cat >"${CONFIGUS}" <<EOF
# a-train.toml
[autoscan]
# Replace the URL with your Autoscan URL.
url = "http://localhost:3030"
username = "hello there"
password = "general kenobi"
[drive]
# Path to the Service Account key file,
# relative to the current working directory ('/data' on Docker).
account = "./account.json"
# One or more Shared Drive IDs
drives = ["0A1xxxxxxxxxUk9PVA", "0A2xxxxxxxxxUk9PVA"]
EOF
}
tugger() {
docker image pull ghcr.io/m-rots/a-train:${DOCKTAG}
}
dockery() {
docker run -d \
--name "${APP}" \
--volume "${MNTPNT}":/data \
--user $UID \
--network="${NETWORK}" \
--network-alias="${APP}" \
--restart unless-stopped \
ghcr.io/m-rots/a-train
}
dockstop() {
docker stop "${APP}"
echo "...A-Train docker has been stopped for configuration"
}
messaging() {
echo
echo " You must be running the cloudb0x/autoscan:bernard-rs docker image"
echo " for A-Train events to be accepted as triggers"
echo
echo " A-Train initial documentation:"
echo " https://gist.github.com/m-rots/f345fd2cfc44585266b620feb9fbd612"
echo
echo " A-Train Autoscan documentation:"
echo " https://github.com/Cloudbox/autoscan/tree/bernard-rs#a-train"
echo
echo " your configuration is files is located here"
echo " ${MNTPNT}/a-train.toml"
echo " remember to add a service account"
echo
echo " to start A-Train after configuration is completed..."
echo " docker start ${APP}"
}
fin() {
echo
echo " **************************"
echo " * ---------------------- *"
echo " * - install completed! - *"
echo " * ---------------------- *"
echo " **************************"
echo
}
#________ RUNLIST
checkoff
tugger
dockery
dockstop
messaging
fin