-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.sh
173 lines (162 loc) · 4.64 KB
/
services.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh -e
all="\
avahi-daemon,\
qemu-guest-agent,\
i2pd,\
tor,\
{{ firewall_role }},\
{{ reverse_proxy_role }},\
bitcoind,\
electrum,\
btc-rpc-explorer,\
mempool,\
public-pool,\
{{ lightning_role }},\
thunderhub, \
nostr-rs-relay,\
umbrel-nostr-relay,\
"
usage() {
cat <<EOF
Usage: ${0##*/} [actions] [enable|disable] -s|--service [services]
Options:
-s, --service Comma-separated list of services to manage
-h, --help Display this help message
Actions:
start Start services
stop Stop services
reload Reload services
restart Restart services
Services:
all Manage all services (default)
avahi-daemon, avahi Manage the avahi-daemon service
qemu-guest-agent Manage the qemu-guest-agent service
qemu, qm, qmga
i2p, i2pd Manage the i2pd service
tor Manage the tor service
firewall, awall, ufw Manage the firewall service (awall, ufw)
reverse-proxy Manage the reverse proxy service (caddy, nginx)
caddy, nginx
bitcoin Manage the bitcoind service
bitcoind, knots, core
electrum Manage the electrum service
fulcrum, electrs
btc-rpc-explorer Manage the btc-rpc-explorer service
btc-rpc-expl, btc-rpc,
btcrpcexplorer, btcrpcexpl,
btcexplorer, btcexpl
mempool Manage the mempool service
mempool.space
public-pool Manage the public-pool service
publicpool, pool
lightning, lnd Manage the lightning service
thunderhub Manage the thunderhub service
nostr-relay Manage the nostr-rs-relay service
nostr-rs-relay
nostr-relay-only
nostr Manage the umbrel-nostr-relay service
nostr-webapp, nostr-webgui,
nostr-webui, nostr-umbrel,
umbrel-nostr
Examples:
${0##*/} start enable
${0##*/} start --service bitcoin,fulcrum,nginx
${0##*/} stop --service all
EOF
}
[ "$#" -eq 0 ] && {
usage; exit 0
}
while [ "$1" ]; do case "$1" in
start|reload|restart)
action="${1}ed"; shift 1
;;
stop)
action="${1}ped"; shift 1
;;
enable)
enable=true; shift 1
;;
disable)
enable=false; shift 1
;;
-s|--service)
in_services="$2"; shift 2
;;
-h|--help)
usage; exit 0
;;
*)
printf "invalid option: %s\n\n" "$1"
usage; exit 1
;;
esac; done
[ -z "$action" ] && [ -z "$enable" ] && {
printf "missing action: start, stop, reload, restart, enable, disable\n\n"
usage; exit 1
}
IFS=,; for service in $in_services; do
case "$service" in
all|""|" ")
services="$all"; break
;;
avahi-daemon|avahi)
services="${services}avahi-daemon,"
;;
qemu-guest-agent|qemu|qm|qmga)
services="${services}qemu-guest-agent,"
;;
i2p|i2pd)
services="${services}i2pd,"
;;
tor)
services="${services}$service,"
;;
firewall|awall|ufw)
services="${services}{{ firewall_role }},"
;;
reverse-proxy|caddy|nginx)
services="${services}{{ reverse_proxy_role }},"
;;
bitcoin|bitcoind|knots|core)
services="${services}bitcoind,"
;;
electrum|fulcrum|electrs)
services="${services}electrum,"
;;
btc-rpc-explorer|btc-rpc-expl|btc-rpc|btcrpcexplorer|btcrpcexpl|btcexplorer|btcexpl)
services="${services}btc-rpc-explorer,"
;;
mempool|mempool.space)
services="${services}mempool,"
;;
public-pool|publicpool|pool)
services="${services}public-pool,"
;;
lightning|lnd)
services="${services}{{ lightning_role }},"
;;
thunderhub)
services="${services}thunderhub,"
;;
nostr-relay|nostr-rs-relay|nostr-relay-only)
services="${services}nostr-rs-relay,"
;;
nostr|nostr-webapp|nostr-webgui|nostr-webui|nostr-umbrel|umbrel-nostr)
services="${services}umbrel-nostr-relay,"
;;
*)
printf "invalid service: %s\n\n" "$service"
usage; exit 1
;;
esac
done
services="${services%,}"
ANSIBLE_CONFIG=./ansible.cfg \
ansible-playbook manager.yaml \
--extra-vars "\
service_state=${action:-} \
service_enabled=${enable:-} \
service_list=${services:-} \
" \
"$@"