f-42: vpc: br-public du netns fermé, br_netfilter coupé dans le netns #42
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
74e8c6220e
commit
1df0d2dad6
8 changed files with 128 additions and 0 deletions
|
|
@ -1,7 +1,9 @@
|
|||
package sysctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -21,3 +23,13 @@ func Set(key, value string) error {
|
|||
}
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func SetIfPresent(key, value string) (bool, error) {
|
||||
path := filepath.Join(root, strings.ReplaceAll(key, ".", "/"))
|
||||
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
return false, fmt.Errorf("sysctl %s: %w", key, err)
|
||||
}
|
||||
return true, Set(key, value)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue