mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
commit
c861f0f8b6
2 changed files with 3 additions and 3 deletions
|
@ -20,7 +20,7 @@ func (*WindowsPIDError) Error() string {
|
||||||
// SavePID - saves the pid of running program to disk
|
// SavePID - saves the pid of running program to disk
|
||||||
func SavePID() error {
|
func SavePID() error {
|
||||||
if IsWindows() {
|
if IsWindows() {
|
||||||
return &WindowsPIDError{}
|
return nil
|
||||||
}
|
}
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
if err := os.WriteFile(PIDFILE, []byte(fmt.Sprintf("%d", pid)), 0644); err != nil {
|
if err := os.WriteFile(PIDFILE, []byte(fmt.Sprintf("%d", pid)), 0644); err != nil {
|
||||||
|
@ -32,7 +32,7 @@ func SavePID() error {
|
||||||
// ReadPID - reads a previously saved pid from disk
|
// ReadPID - reads a previously saved pid from disk
|
||||||
func ReadPID() (int, error) {
|
func ReadPID() (int, error) {
|
||||||
if IsWindows() {
|
if IsWindows() {
|
||||||
return 0, &WindowsPIDError{}
|
return 0, nil
|
||||||
}
|
}
|
||||||
bytes, err := os.ReadFile(PIDFILE)
|
bytes, err := os.ReadFile(PIDFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -151,7 +151,7 @@ func deleteInterface(iface string, realIface string) error {
|
||||||
os.Remove("/var/run/wireguard/" + iface + ".name")
|
os.Remove("/var/run/wireguard/" + iface + ".name")
|
||||||
}
|
}
|
||||||
out, err = ncutils.RunCmd("ifconfig "+realIface+" down", false)
|
out, err = ncutils.RunCmd("ifconfig "+realIface+" down", false)
|
||||||
if strings.Contains(err.Error(), "does not exist") {
|
if err != nil && strings.Contains(err.Error(), "does not exist") {
|
||||||
err = nil
|
err = nil
|
||||||
} else if err != nil && out != "" {
|
} else if err != nil && out != "" {
|
||||||
err = errors.New(out)
|
err = errors.New(out)
|
||||||
|
|
Loading…
Reference in a new issue