From f6213d5513f3bca327c98dadedb77c180dac2f27 Mon Sep 17 00:00:00 2001 From: Tyler Kelley Date: Sat, 18 May 2024 19:24:55 -0500 Subject: [PATCH] Updated the install script --- install-zaneyos.sh | 82 +++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 56 deletions(-) diff --git a/install-zaneyos.sh b/install-zaneyos.sh index b705dad..95578af 100755 --- a/install-zaneyos.sh +++ b/install-zaneyos.sh @@ -1,31 +1,36 @@ #!/usr/bin/env bash -if [ -n "$(cat /etc/os-release | grep -i nixos)" ]; then - echo "Verified this is NixOS." - echo "-----" +if [ -n "$(grep -i nixos < /etc/os-release)" ]; then + echo "Verified this is NixOS." + echo "-----" else - echo "This is not NixOS or the distribution information is not available." - exit + echo "This is not NixOS or the distribution information is not available." + exit fi if command -v git &> /dev/null; then - echo "Git is installed, continuing with installation." + echo "Git is installed, continuing with installation." + echo "-----" else - echo "Git is not installed. Please install Git and try again." - echo "Example: nix-shell -p git" - exit + echo "Git is not installed. Please install Git and try again." + echo "Example: nix-shell -p git" + exit fi +echo "Default options are in brackets []" +echo "Just press enter to select the default" +sleep 2 + echo "-----" echo "Ensure In Home Directory" -cd +cd || exit echo "-----" -read -p "Enter Your New Hostname: [ hyprnix ] " hostName +read -rp "Enter Your New Hostname: [ default ] " hostName if [ -z "$hostName" ]; then - hostName="hyprnix" + hostName="default" fi echo "-----" @@ -35,12 +40,12 @@ if [ -d "zaneyos" ]; then echo "ZaneyOS exists, backing up to .config/zaneyos-backups folder." if [ -d ".config/zaneyos-backups" ]; then echo "Moving current version of ZaneyOS to backups folder." - mv $HOME/zaneyos .config/zaneyos-backups/$backupname + mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" sleep 1 else echo "Creating the backups folder & moving ZaneyOS to it." mkdir -p .config/zaneyos-backups - mv $HOME/zaneyos .config/zaneyos-backups/$backupname + mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" sleep 1 fi else @@ -52,42 +57,16 @@ echo "-----" echo "Cloning & Entering ZaneyOS Repository" git clone https://gitlab.com/zaney/zaneyos.git -cd zaneyos -mkdir hosts/$hostName -cp hosts/default/*.nix hosts/$hostName +cd zaneyos || exit +mkdir hosts/"$hostName" +cp hosts/default/*.nix hosts/"$hostName" git add . -sed -i "/^\s*setHostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./hosts/$hostName/options.nix sed -i "/^\s*host[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./flake.nix echo "-----" -echo "Default options are in brackets []" -echo "Just press enter to select the default" -sleep 2 - -echo "-----" - -installusername=$(echo $USER) -read -p "Enter Your Username: [ $installusername ] " userName -if [ -z "$userName" ]; then - userName=$(echo $USER) -else - if [ $installusername != $userName ]; then - echo "This will create a hashedPassword for the new user in the options file." - while true; do - read -s -p "Enter New User Password: " newPass - read -s -p "Enter New User Password Again: " newPass2 - if [ $newPass == $newPass2 ]; then - echo "Passwords Match. Setting password." - userPassword=$(mkpasswd -m sha-512 $newPass) - escaped_userPassword=$(echo "$userPassword" | sed 's/\//\\\//g') - sed -i "/^\s*hashedPassword[[:space:]]*=[[:space:]]*\"/s#\"\(.*\)\"#\"$escaped_userPassword\"#" ./system.nix - break - fi - done - fi -fi -sed -i "/^\s*setUsername[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$userName\"/" ./hosts/$hostName/options.nix +installusername=$("$USER") +sed -i "/^\s*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$installusername\"/" ./flake.nix echo "-----" @@ -97,19 +76,10 @@ sudo nixos-generate-config --show-hardware-config > ./hosts/$hostName/hardware.n echo "-----" echo "Setting Required Nix Settings & Committing Changes" -git add . -git commit -am "Add new hosts folder and all the new settings" NIX_CONFIG="experimental-features = nix-command flakes" -if [ $userName != $installusername ]; then - cd - cp -r zaneyos /home/$userName/ - sudo chown -R $userName:users /home/$userName/zaneyos - echo "Ensuring ZaneyOS repository is in your users HOME directory." -fi - echo "-----" echo "ZaneyOS Has Been Setup" -echo "Make Sure To Change Your Options In hosts/" -echo "To Install Run: sudo nixos-rebuild switch --flake .#" \ No newline at end of file +echo "Please Edit Your Hosts Files" +echo "Then Run: sudo nixos-rebuild switch --flake .#${hostName}"