fix: Fixes updater failing in certain cases.
This commit is contained in:
parent
254658dfca
commit
bae947de74
1 changed files with 26 additions and 3 deletions
|
@ -1,15 +1,38 @@
|
||||||
#!/usr/bin/env bash
|
nix_bld_unset_err() {
|
||||||
if [[ "$NIX_BUILD_ID" == "" ]]; then
|
|
||||||
echo "ERROR: You have held a (potentially) broken install!"
|
echo "ERROR: You have held a (potentially) broken install!"
|
||||||
echo "NIX_BUILD_ID is not set (should be set by default!)"
|
echo "NIX_BUILD_ID is not set (should be set by default!)"
|
||||||
echo "Please set NIX_BUILD_ID manually. i.e:"
|
echo "Please set NIX_BUILD_ID manually. i.e:"
|
||||||
echo "NIX_BUILD_ID=kitteh-node-1/agent updater"
|
echo "NIX_BUILD_ID=kitteh-node-1/agent updater"
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$NIX_BUILD_ID" == "" ]]; then
|
||||||
|
if [[ ! -f "/tmp/nixbuildid" ]]; then
|
||||||
|
nix_bld_unset_err
|
||||||
|
fi
|
||||||
|
|
||||||
|
source /tmp/nixbuildid
|
||||||
|
|
||||||
|
if [[ "$NIX_BUILD_ID" == "" ]]; then
|
||||||
|
nix_bld_unset_err
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$UID" != "0" ]]; then
|
if [[ "$UID" != "0" ]]; then
|
||||||
|
# Hacky workaround for failing to read NIX_BUILD_ID when called like:
|
||||||
|
# ./update
|
||||||
|
# but this works:
|
||||||
|
# sudo ./update
|
||||||
|
|
||||||
|
echo "NIX_BUILD_ID=$NIX_BUILD_ID" > /tmp/nixbuildid
|
||||||
|
chmod +x /tmp/nixbuildid
|
||||||
|
|
||||||
sudo $0 $@
|
sudo $0 $@
|
||||||
exit $?
|
STATUS_CODE=$?
|
||||||
|
|
||||||
|
rm -rf /tmp/nixbuildid
|
||||||
|
|
||||||
|
exit $STATUS_CODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd /etc/nixos 2> /dev/null > /dev/null
|
pushd /etc/nixos 2> /dev/null > /dev/null
|
||||||
|
|
Reference in a new issue