Add hash checks
This commit is contained in:
parent
5b1eb5782b
commit
70889fd9fc
|
@ -0,0 +1 @@
|
||||||
|
/temp/
|
|
@ -2,19 +2,44 @@
|
||||||
|
|
||||||
source scripts/shared.fish
|
source scripts/shared.fish
|
||||||
|
|
||||||
|
mkdir -p "temp"
|
||||||
|
|
||||||
|
set dircontent $(find "nixos" -type f | sort -z)
|
||||||
|
|
||||||
|
for i in $dircontent
|
||||||
|
if [ $i != "" ]
|
||||||
|
echo "[INFO] Hashing $i"
|
||||||
|
set ihash "$(sha1sum $i)"
|
||||||
|
echo "$ihash" >> "temp/directorylisthashed.txt"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if fish_is_root_user
|
if fish_is_root_user
|
||||||
echo "[ERROR] Running with root permissions is not supported"
|
echo "[ERROR] Running with root permissions is not supported"
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
read -sP "[INPUT] Root password: " rpass
|
set hash1 "$(cat temp/directorylisthashed.txt)"
|
||||||
echo "$rpass" | sudo -S echo "[INFO] Obtaining admin permissions"
|
set hash1 $(string split " " $hash1)
|
||||||
sudo cp -r "nixos/" "/etc/"
|
set hash1 $hash1[1]
|
||||||
read -P "[INPUT] Trigger rebuild Y/n: " rebuild
|
set hash2 "$(cat temp/directorylisthashedprevious.txt)"
|
||||||
if [ "$rebuild" = "" ]
|
set hash2 $(string split " " $hash2)
|
||||||
set rebuild "y"
|
set hash2 $hash2[1]
|
||||||
end
|
if [ "$hash1" != "$hash2" ]
|
||||||
set rebuild "$(string lower $rebuild)"
|
read -sP "[INPUT] Root password: " rpass
|
||||||
if [ "$rebuild" = "y" ]
|
if [ "$rpass" = "" ]
|
||||||
sudo nixos-rebuild switch &> /dev/null
|
echo "[ERROR] Failed to get root password"
|
||||||
|
exit 0
|
||||||
|
end
|
||||||
|
echo "$rpass" | sudo -S echo "[INFO] Obtaining admin permissions"
|
||||||
|
sudo cp -r "nixos/" "/etc/"
|
||||||
|
read -P "[INPUT] Trigger rebuild Y/n: " rebuild
|
||||||
|
if [ "$rebuild" = "" ]
|
||||||
|
set rebuild "y"
|
||||||
|
end
|
||||||
|
set rebuild "$(string lower $rebuild)"
|
||||||
|
if [ "$rebuild" = "y" ]
|
||||||
|
sudo nixos-rebuild switch &> /dev/null
|
||||||
|
end
|
||||||
end
|
end
|
||||||
read -P "[INPUT] Git update Y/n: " gitpush
|
read -P "[INPUT] Git update Y/n: " gitpush
|
||||||
if [ "$gitpush" = "" ]
|
if [ "$gitpush" = "" ]
|
||||||
|
@ -24,10 +49,12 @@ else
|
||||||
if [ "$gitpush" = "y" ]
|
if [ "$gitpush" = "y" ]
|
||||||
read -P "[INPUT] Commit message: " cmessage
|
read -P "[INPUT] Commit message: " cmessage
|
||||||
echo "[INFO] Adding to git"
|
echo "[INFO] Adding to git"
|
||||||
git add .
|
git add . --quiet
|
||||||
echo "[INFO] Creating commit with message $cmessage"
|
echo "[INFO] Creating commit with message $cmessage"
|
||||||
git commit -m "$cmessage"
|
git commit -m "$cmessage" --quiet
|
||||||
echo "[INFO] Pushing to external repository"
|
echo "[INFO] Pushing to external repository"
|
||||||
git push --quiet
|
git push --quiet
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cp "temp/directorylisthashed.txt" "temp/directorylisthashedprevious.txt"
|
Loading…
Reference in New Issue