diff options
author | EuAndreh <eu@euandre.org> | 2019-05-31 21:04:04 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-05-31 21:04:04 -0300 |
commit | 0022d95be7c99aa711c16bbc53d358a1fd8c4e08 (patch) | |
tree | 4eb03d60c04033e6206197f140ec87f743b73dbb /public | |
parent | Add extra explanation on =fixme= derivation error (diff) | |
download | dotfiles-0022d95be7c99aa711c16bbc53d358a1fd8c4e08.tar.gz dotfiles-0022d95be7c99aa711c16bbc53d358a1fd8c4e08.tar.xz |
Add Bash confirmation before writing local-configuration.nix
Taken from:
https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
Diffstat (limited to 'public')
-rwxr-xr-x | public/install-nixos.sh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/public/install-nixos.sh b/public/install-nixos.sh index f5bf321..b1eb126 100755 --- a/public/install-nixos.sh +++ b/public/install-nixos.sh @@ -63,8 +63,22 @@ wget -O "${TMP_DIR}/hardware-configuration.nix" "${SERVER}/hardware-configuratio wget -O "${TMP_DIR}/template.nix" "${SERVER}/template.nix" green "Done." +yellow "Creating content of '/etc/nixos/local-configuration.nix'..." export HOST_NAME export DEVICE -envsubst < "${TMP_DIR}/template.nix" > /etc/nixos/local-configuration.nix +envsubst < "${TMP_DIR}/template.nix" > "${TMP_DIR}/local-configuration.nix" +blue "$(cat "${TMP_DIR}/local-configuration.nix")" +read -p "Confirm content of '/etc/nixos/local-configuration.nix'? (y/N) " -n 1 -r +echo # Move to a new line +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + red "Unconfirmed content of '/etc/nixos/local-configuration.nix'." + red "Exitting." + exit 1 +fi +green "Done." + +yellow "Moving presented content to '/etc/nixos/local-configuration.nix'..." +echo mv "${TMP_DIR}/local-configuration.nix" /etc/nixos/local-configuration.nix +green "Done." # fdisk |