mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-15 17:51:01 +00:00
environment.etc: improve activation
This commit is contained in:
parent
6305c0675f
commit
e847283311
1 changed files with 14 additions and 10 deletions
|
@ -44,21 +44,25 @@ in
|
|||
|
||||
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
|
||||
|
||||
for link in $(ls /etc/static/); do
|
||||
if [ -e "/etc/$link" ]; then
|
||||
if [ ! -L "/etc/$link" ]; then
|
||||
echo "warning: not linking /etc/static/$link because /etc/$link exists, skipping..." >&2
|
||||
for f in $(find /etc/static/* -type l); do
|
||||
l="$(echo $f | sed 's,/etc/static/,/etc/,')"
|
||||
d="$(dirname $l)"
|
||||
if [ ! -e "$d" ]; then
|
||||
mkdir -p "$d"
|
||||
fi
|
||||
if [ -e "$l" ]; then
|
||||
if [ "$(readlink $l)" != "$f" ]; then
|
||||
echo "warning: not linking $l because $l exists, skipping..." >&2
|
||||
fi
|
||||
else
|
||||
ln -sfn "/etc/static/$link" "/etc/$link"
|
||||
ln -s "$f" "$l"
|
||||
fi
|
||||
done
|
||||
|
||||
for link in $(find /etc/ -maxdepth 1 -type l); do
|
||||
if [[ "$(readlink $link)" == /etc/static/* ]]; then
|
||||
if [ ! -e "$(readlink -f $link)" ]; then
|
||||
rm $link
|
||||
fi
|
||||
for l in $(find /etc/* -type l 2> /dev/null); do
|
||||
f="$(echo $l | sed 's,/etc/,/etc/static/,')"
|
||||
if [ "$(readlink $l)" = "$f" -a ! -e "$(readlink -f $l)" ]; then
|
||||
rm "$l"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue