mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
etc: rename activation script variables
This commit is contained in:
parent
63af129cb5
commit
c91c351943
1 changed files with 26 additions and 26 deletions
|
@ -52,40 +52,40 @@ in
|
|||
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
|
||||
|
||||
errorOccurred=false
|
||||
for f in $(find /etc/static/* -type l); do
|
||||
l=/etc/''${f#/etc/static/}
|
||||
d=''${l%/*}
|
||||
if [ ! -e "$d" ]; then
|
||||
mkdir -p "$d"
|
||||
for etcStaticFile in $(find /etc/static/* -type l); do
|
||||
etcFile=/etc/''${etcStaticFile#/etc/static/}
|
||||
etcDir=''${etcFile%/*}
|
||||
if [ ! -e "$etcDir" ]; then
|
||||
mkdir -p "$etcDir"
|
||||
fi
|
||||
if [ -e "$f".copy ]; then
|
||||
cp "$f" "$l"
|
||||
if [ -e "$etcStaticFile".copy ]; then
|
||||
cp "$etcStaticFile" "$etcFile"
|
||||
continue
|
||||
fi
|
||||
if [ -e "$l" ]; then
|
||||
if [ "$(readlink "$l")" != "$f" ]; then
|
||||
if ! grep -q /etc/static "$l"; then
|
||||
o=''$(shasum -a256 "$l")
|
||||
o=''${o%% *}
|
||||
for h in ''${etcSha256Hashes["$l"]}; do
|
||||
if [ "$o" = "$h" ]; then
|
||||
mv "$l" "$l.before-nix-darwin"
|
||||
ln -s "$f" "$l"
|
||||
if [ -e "$etcFile" ]; then
|
||||
if [ "$(readlink "$etcFile")" != "$etcStaticFile" ]; then
|
||||
if ! grep -q /etc/static "$etcFile"; then
|
||||
etcFileSha256=''$(shasum -a256 "$etcFile")
|
||||
etcFileSha256=''${etcFileSha256%% *}
|
||||
for knownSha256Hash in ''${etcSha256Hashes["$etcFile"]}; do
|
||||
if [ "$etcFileSha256" = "$knownSha256Hash" ]; then
|
||||
mv "$etcFile" "$etcFile.before-nix-darwin"
|
||||
ln -s "$etcStaticFile" "$etcFile"
|
||||
break
|
||||
else
|
||||
h=
|
||||
knownSha256Hash=
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$h" ]; then
|
||||
echo "[1;31merror: not linking environment.etc.\"''${l#/etc/}\" because $l already exists, skipping...[0m" >&2
|
||||
echo "[1;31mexisting file has unknown content $o, move and activate again to apply[0m" >&2
|
||||
if [ -z "$knownSha256Hash" ]; then
|
||||
echo "[1;31merror: not linking environment.etc.\"''${etcFile#/etc/}\" because $etcFile already exists, skipping...[0m" >&2
|
||||
echo "[1;31mexisting file has unknown content $etcFileSha256, move and activate again to apply[0m" >&2
|
||||
errorOccurred=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
ln -s "$f" "$l"
|
||||
ln -s "$etcStaticFile" "$etcFile"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -93,11 +93,11 @@ in
|
|||
exit 1
|
||||
fi
|
||||
|
||||
for l in $(find /etc/* -type l 2> /dev/null); do
|
||||
f="$(echo $l | sed 's,/etc/,/etc/static/,')"
|
||||
f=/etc/static/''${l#/etc/}
|
||||
if [ "$(readlink "$l")" = "$f" -a ! -e "$(readlink -f "$l")" ]; then
|
||||
rm "$l"
|
||||
for etcFile in $(find /etc/* -type l 2> /dev/null); do
|
||||
etcStaticFile="$(echo $etcFile | sed 's,/etc/,/etc/static/,')"
|
||||
etcStaticFile=/etc/static/''${etcFile#/etc/}
|
||||
if [ "$(readlink "$etcFile")" = "$etcStaticFile" -a ! -e "$(readlink -f "$etcFile")" ]; then
|
||||
rm "$etcFile"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
|
Loading…
Add table
Reference in a new issue