mirror of
https://gitlab.com/Zaney/zaneyos.git
synced 2024-11-22 14:43:08 +01:00
Updated the install script
This commit is contained in:
parent
85fcb2300e
commit
f6213d5513
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -n "$(cat /etc/os-release | grep -i nixos)" ]; then
|
||||
if [ -n "$(grep -i nixos < /etc/os-release)" ]; then
|
||||
echo "Verified this is NixOS."
|
||||
echo "-----"
|
||||
else
|
||||
@ -10,22 +10,27 @@ fi
|
||||
|
||||
if command -v git &> /dev/null; then
|
||||
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
|
||||
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/<yourhostname>"
|
||||
echo "To Install Run: sudo nixos-rebuild switch --flake .#<yourhostname>"
|
||||
echo "Please Edit Your Hosts Files"
|
||||
echo "Then Run: sudo nixos-rebuild switch --flake .#${hostName}"
|
||||
|
Loading…
Reference in New Issue
Block a user