diff options
| author | Aiden Scandella <git@sca.ndella.com> | 2024-11-25 16:10:39 -0800 |
|---|---|---|
| committer | Aiden Scandella <git@sca.ndella.com> | 2024-11-25 21:40:13 -0800 |
| commit | 25e0b6064eed7a4ffeca7bacbba9dcca6fa8cc86 (patch) | |
| tree | 368f3bf51a5566b5eec38d70dbf3b5b8292063d4 /modules/system | |
| parent | 3c52583b99666a349a6219dc1f0dd07d75c82d6a (diff) | |
system: fix detection and ownership of /etc/synthetic.conf
This file is owned by root and mode 600 on my system, so the grep is
failing and it's adding a new entry every run.
```sh
-rw------- 1 root wheel 664 Nov 25 15:52 /etc/synthetic.conf
```
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/base.nix | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/system/base.nix b/modules/system/base.nix index f20e2b6..2374855 100644 --- a/modules/system/base.nix +++ b/modules/system/base.nix @@ -5,6 +5,16 @@ IFS="." read -r -a macOSVersion <<< "$(sw_vers -productVersion)" if [[ ''${macOSVersion[0]} -gt 10 || ( ''${macOSVersion[0]} -eq 10 && ''${macOSVersion[1]} -ge 15 ) ]]; then + if [[ $(stat -c '%a' /etc/synthetic.conf) != "644" ]]; then + echo "fixing permissions on /etc/synthetic.conf..." + sudo chmod 644 /etc/synthetic.conf + fi + + if [[ $(grep -c '^run\b' /etc/synthetic.conf) -gt 1 ]]; then + echo "found duplicate run entries in /etc/synthetic.conf, removing..." + sudo sed -i "" -e '/^run\tprivate\/var\/run$/d' /etc/synthetic.conf + fi + if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then echo "setting up /run via /etc/synthetic.conf..." printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null |
