File tree 3 files changed +61
-2
lines changed
3 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 24
24
package main
25
25
26
26
import (
27
+ "encoding/json"
27
28
"fmt"
29
+ "net/url"
28
30
"os"
29
31
"os/signal"
30
32
"syscall"
45
47
configURL string
46
48
versionFlag bool
47
49
debugFlag bool
50
+ decryptFlag bool
48
51
)
49
52
50
53
func main () {
@@ -67,6 +70,12 @@ func main() {
67
70
Value : false ,
68
71
Desc : "Turn on debugging" ,
69
72
},
73
+ {
74
+ V : & decryptFlag ,
75
+ Name : "decrypt" ,
76
+ Value : false ,
77
+ Desc : "Decrypt and print the configuration file" ,
78
+ },
70
79
})
71
80
72
81
// Parse command-line args for all registered bees
@@ -77,6 +86,10 @@ func main() {
77
86
os .Exit (0 )
78
87
}
79
88
89
+ if decryptFlag {
90
+ decryptConfig (configURL )
91
+ }
92
+
80
93
api .Run ()
81
94
82
95
if debugFlag {
@@ -164,6 +177,32 @@ func main() {
164
177
}
165
178
}
166
179
180
+ func decryptConfig (u string ) {
181
+ b := cfg.AESBackend {}
182
+
183
+ pu , err := url .Parse (u )
184
+ if err != nil {
185
+ log .Fatal ("Invalid configuration URL. err: " , err )
186
+ }
187
+
188
+ _ , err = os .Stat (pu .Path )
189
+ if err != nil {
190
+ log .Fatalf ("Invalid configuration file %s" , pu .Path )
191
+ }
192
+
193
+ config , err := b .Load (pu )
194
+ if err != nil {
195
+ log .Fatal ("Error decrypting the configuration file. err: " , err )
196
+ }
197
+
198
+ j , err := json .MarshalIndent (config , "" , " " )
199
+ if err != nil {
200
+ log .Fatal ("Error encoding the configuraiton file. err: " , err )
201
+ }
202
+ fmt .Println (string (j ))
203
+ os .Exit (0 )
204
+ }
205
+
167
206
func init () {
168
207
log .SetFormatter (& log.TextFormatter {ForceColors : true })
169
208
log .SetOutput (colorable .NewColorableStdout ())
Original file line number Diff line number Diff line change @@ -33,6 +33,26 @@ A sample wrapper script (Linux only) is provided in [tools/encrypted-config-wrap
33
33
34
34
Something similar could be written to do it on macOS using Keychain and its ` security(1) ` CLI.
35
35
36
+ ## Decrypting the configuration
37
+
38
+ Use ` --decrypt ` with a valid password:
39
+
40
+ ```
41
+ beehive --decrypt --config crypto://mysecret@/path/to/config/file
42
+ ```
43
+
44
+ or using an environment variable:
45
+
46
+ ```
47
+ BEEHIVE_CONFIG_PASSWORD=mysecret beehive --decrypt --config crypto:///path/to/config/file
48
+ ```
49
+
50
+ You can also use omit ` --config ` when using the default configuration path:
51
+
52
+ ```
53
+ BEEHIVE_CONFIG_PASSWORD=mysecret beehive --decrypt
54
+ ```
55
+
36
56
## Troubleshooting
37
57
38
58
```
Original file line number Diff line number Diff line change @@ -22,14 +22,14 @@ func init() {
22
22
// returns the configured WatchdogSec in the service unit as time.Duration
23
23
interval , err := daemon .SdWatchdogEnabled (false )
24
24
if err != nil || interval == 0 {
25
- log .Printf ("Systemd watchdog not enabled" )
25
+ log .Debug ("Systemd watchdog not enabled" )
26
26
return
27
27
}
28
28
29
29
// We want to notify the watchdog every WatchdogSec/3, that is, if WatchdogSec is
30
30
// set to 30 seconds, we'll send a notification to systemd every 10 seconds.
31
31
runEvery := interval / 3
32
- log .Printf ("Systemd watchdog notifications every %.2f seconds" , runEvery .Seconds ())
32
+ log .Debugf ("Systemd watchdog notifications every %.2f seconds" , runEvery .Seconds ())
33
33
34
34
go func () {
35
35
for {
You can’t perform that action at this time.
0 commit comments