#!/bin/bash set -euo pipefail ENV_FILE="$1" if [ ! -f "$ENV_FILE" ]; then echo "Error: Environment file not found: $ENV_FILE" exit 1 fi echo "Current Gotify configuration:" grep -E "^GOTIFY_(URL|TOKEN)=" "$ENV_FILE" || echo "No Gotify configuration found" echo read -rp "Enter new Gotify URL (no trailing slash, e.g. https://gotify.example.com): " GOTIFY_URL if [ -n "$GOTIFY_URL" ]; then # Validate URL format if [[ ! "$GOTIFY_URL" =~ ^https?:// ]]; then echo "Error: Invalid URL format (must start with http:// or https://)" exit 1 fi # Test URL reachability echo "Testing Gotify server connectivity..." if ! curl -s --connect-timeout 10 "$GOTIFY_URL/health" >/dev/null 2>&1; then echo "Warning: Cannot reach Gotify server at $GOTIFY_URL" echo "This might be due to network issues or incorrect URL." read -rp "Continue anyway? [y/N]: " continue_anyway if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then echo "Aborted." exit 1 fi else echo "✓ Gotify server is reachable" fi read -rp "Enter new Gotify token: " GOTIFY_TOKEN # Test token if both URL and token are provided if [ -n "$GOTIFY_TOKEN" ]; then echo "Testing Gotify token..." if curl -sS "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" \ -F "title=DRestic Config Test ($(whoami)@$(hostname))" \ -F "message=Testing Gotify configuration from $(whoami)@$(hostname) - you can ignore this message" \ -F "priority=1" >/dev/null 2>&1; then echo "✓ Test notification sent successfully!" else echo "Warning: Failed to send test notification. Please verify your token." read -rp "Continue anyway? [y/N]: " continue_anyway if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then echo "Aborted." exit 1 fi fi fi else GOTIFY_TOKEN="" fi # Update or add Gotify settings sed -i '/^GOTIFY_URL=/d' "$ENV_FILE" sed -i '/^GOTIFY_TOKEN=/d' "$ENV_FILE" echo "GOTIFY_URL=\"$GOTIFY_URL\"" >>"$ENV_FILE" echo "GOTIFY_TOKEN=\"$GOTIFY_TOKEN\"" >>"$ENV_FILE" echo "✓ Gotify configuration updated!" if [ -n "$GOTIFY_URL" ]; then echo "Test with: make test-remote-gotify" else echo "Gotify notifications disabled" fi e='committer'>committer
path: root/update.sh
blob: ab0562d1886ecd4047f98459f3bb0de729f43839 (plain)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189