-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network: ensure we do not clean ipam leases cache during an update of…
… networkd
- Loading branch information
Showing
5 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package app | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
const bootedPath = "/var/run/modules" | ||
|
||
// MarkBooted creates a file in a memory | ||
// this file then can be used to check if "something" has been restared | ||
// if its the first time it starts | ||
func MarkBooted(name string) error { | ||
if err := os.MkdirAll(bootedPath, 0770); err != nil { | ||
return err | ||
} | ||
path := filepath.Join(bootedPath, name) | ||
_, err := os.OpenFile(path, os.O_RDONLY|os.O_CREATE|os.O_TRUNC|os.O_EXCL, 0666) | ||
return err | ||
} | ||
|
||
// IsFirstBoot checks if the a file has been created by MarkBooted function | ||
func IsFirtBoot(name string) bool { | ||
path := filepath.Join(bootedPath, name) | ||
_, err := os.Stat(path) | ||
return !(err == nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters