mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-09-13 01:44:29 +08:00
Always initialize notifications first
This commit is contained in:
parent
cf860e1dab
commit
178239f5b8
2 changed files with 6 additions and 12 deletions
|
@ -30,12 +30,13 @@ func runScript(c *Config) (err error) {
|
|||
|
||||
s := newScript(c)
|
||||
|
||||
if initErr := s.initNotifications(); initErr != nil {
|
||||
err = errwrap.Wrap(initErr, "error initializing notifications")
|
||||
return
|
||||
}
|
||||
|
||||
unlock, lockErr := s.lock("/var/lock/dockervolumebackup.lock")
|
||||
if lockErr != nil {
|
||||
if initErr := s.initNotificationsOnly(); initErr != nil {
|
||||
err = errwrap.Wrap(initErr, "error initializing notifications")
|
||||
return
|
||||
}
|
||||
err = errwrap.Wrap(lockErr, "error acquiring file lock")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -219,17 +219,10 @@ func (s *script) init() error {
|
|||
s.storages = append(s.storages, dropboxBackend)
|
||||
}
|
||||
|
||||
if err := s.initNotificationsOnly(); err != nil {
|
||||
return errwrap.Wrap(err, "error initializing configuration setup")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// initNotificationsOnly lives outside of the main init routine so that script
|
||||
// runs that fail early can try to send notifications without having to
|
||||
// invoke a full initialization
|
||||
func (s *script) initNotificationsOnly() error {
|
||||
func (s *script) initNotifications() error {
|
||||
if s.c.EmailNotificationRecipient != "" {
|
||||
emailURL := fmt.Sprintf(
|
||||
"smtp://%s:%s@%s:%d/?from=%s&to=%s",
|
||||
|
|
Loading…
Add table
Reference in a new issue