mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-02 01:26:43 +00:00
Remove entries on install (#213)
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -527,3 +528,31 @@ func UkiBootMode() state.Boot {
|
||||
}
|
||||
return state.Unknown
|
||||
}
|
||||
|
||||
// SystemdBootConfReader reads a systemd-boot conf file and returns a map with the key/value pairs
|
||||
func SystemdBootConfReader(filePath string) (map[string]string, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
result := make(map[string]string)
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.SplitN(line, " ", 2)
|
||||
if len(parts) == 2 {
|
||||
result[parts[0]] = parts[1]
|
||||
}
|
||||
if len(parts) == 1 {
|
||||
result[parts[0]] = ""
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user