env-ansible/setup.sh

123 lines
3.5 KiB
Bash
Raw Normal View History

General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
#!/usr/bin/env bash
# Script to initialize a system into Ansible collection.
## Global Variables ##
General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
LOCAL=$DIR/local.yml
URL="https://git.hyperling.com/me/env-ansible"
BRANCH="main"
## Functions ##
# Accepts 1 parameter, it is used as the exit status.
function usage {
cat <<- EOF
$PROG [-l] [-b branch_name] [-h]
Program to initialize synchronization with Hyperling's Ansible configuration.
$URL
Parameters:
General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
-l : Run the local playbook associated with this $PROG.
This is helpful for development or just saving bandwidth.
It also provides prettier colors than the plaintext from ansible-pull. ;)
-b branch_name: Download and run a specific branch. Default is $BRANCH.
-h : Display this help text
General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
EOF
exit $1
}
## Parameter Parsing ##
while getopts ":lb:h" arg; do
case $arg in
General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
l) local="Y" && echo "Running $LOCAL as the playbook." ;;
b) branch="$OPTARG" && echo "Using branch $branch instead of $BRANCH." ;;
h) usage ;;
*) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
esac
done
# Alert on historic usage of `setup.sh BRANCH`.
if [[ ! -z $1 && $1 != "-"* ]]; then
echo "ERROR: '$1' is not a valid option, please check your parameters and try again."
usage 1
fi
if [[ $branch == "" ]]; then
echo "Using default branch $BRANCH."
branch="$BRANCH"
fi
## Main ##
os="$(cat /etc/os-release)"
os="$os $(uname -a)"
echo "Making sure all necessary packages are installed..."
if [[ `which ansible > /dev/null; echo $?` != 0 ]]; then
if [[ $os == *Debian* || $os == *Ubuntu* || $os == *"Pop!_OS"* || $os == *Mint* || $os == *Parrot* ]]; then
sudo apt update
sudo apt install -y ansible git <<< N
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
elif [[ $os == *FreeBSD* ]]; then
sudo pkg install -y py38-ansible git
sudo mkdir -p /usr/local/etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /usr/local/etc/ansible/hosts'
elif [[ $os == *Arch* || $os == *Manjaro* || $os == *Artix* ]]; then
sudo pacman -Sy --noconfirm ansible git
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
elif [[ $os == *Darwin* ]]; then
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "TESTING - EXIT!"
exit 0
brew install ansible git
elif [[ $os == *Fedora* ]]; then
sudo dnf install -y ansible git python3-libselinux
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
elif [[ $os == *openSUSE* ]]; then
sudo zypper install -y ansible git
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
General Enhancements, NixOS Support (#47) * Begin adding Nix. * Install LBRY from Nix since its Flatpak is no longer supported.. * Got the global install to work, now just figuring out why LBRY won't work. * Add alias to blow away dev branch and start back up from remote or main. * Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems. * Start working on having a path for NixOS. * Add NixOS. * Skip the installer portion if using NixOS. * Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix. * This should have never been added. Was an accident if it snuck though. * Test using env rather than hard-coded bash path. * Use variables, start thinking about future. * Add file to manage setting up NixOS for the first or any subsequent times. * Use the new nixos.sh script. * Ensure /usr/local/bin is in PATH. * Do not use * inside of "" for ls. * Add filename cleanup shortcut. * Add a clean option as well as a few bugfixes and checking that convert is installed. * Use underscores in filenames and remove plurality. * Bring the file into better column compliance. * Stop running the dconf psutil failures against NixOS for now. * Ensure the old names of scripts are removed from bin. * Clean filename fixes as well as a traversing version. * Remove extra spacing. * Begin adding swapfile creation. * Add dangerous code reset command. * Add some cleaning for NixOS package manager. * The ~ was being taken literally and created as a new folder. * More work on swap files, and a new ansible.nix file. * Fix the swap confuration line. * Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence. * Reorder and enhance the update function for NixOS. * Add comment. * Start working on dconf for NixOS since don't have home-manager working yet in configration.nix. * Add notes. * If the file was created, make sure the user owns it and can edit by default. * Favorites are working and only need maintained in one place! :) * Add .zshrc for GNOME settings on NixOS. * Add most other settings that are done manually post-install. Report any failures with their placement. * FINALLY! Keyboard shortcuts and some final Gnome Tweak settings! * Add night light settings. * Move around some comments. * Pull first then deal with any merge issues, rather than trying to push when there are things to pull. * Test removing the dconf commands for non-NixOS. * Alter output; remove extra newlines and add cache verbosity. * dconf in rc files is working on Ubuntu! * Add delete. Fix filename quotes. Other enhancements. * Create new folder chain if clean changed directory names. * Add TBD about changing the directory structure. * Only say success if the file really exists. Skip if conversion fails. * Only say success if the file really exists. Skip if conversion fails. * Add quotes around dirname. * Add quotes around the entire directory tree. * Add quotes to comment in case it ever gets used. * Add a bittorrent client. * Disable Bluetooth on all devices, it's normally off anyways. * Fix comments, this enables not disables. * Create new services report. * Add services report to main area and move all reports to NixOS area. * Fix swap file variable name for non-NixOS distros. * Add godot editor. * Re-add extra programs Geary and OpenShot for variety. * Shorten the output for 80 char terminals. * Add Code-OSS for when Codium is having issues. * Allow code-oss to be installed. * Add the full desktop entry for Code-OSS. * Ansible handles the newlines, prevent the -e from getting into the file. * Enhance newlines in nmap report. * Add NixOS.
2023-10-17 04:30:36 -07:00
elif [[ $os == *NixOS* ]]; then
$DIR/files/scripts/nixos.sh -b $branch
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
else
echo -e "ERROR: OS not detected."
echo -e "$os"
exit 1
fi
fi
echo "Installed!"
#echo "Adding Ansible Collections..."
#ansible-galaxy collection install community.general
#echo "Added!"
echo "Provisioning Ansible..."
if [[ $local == "Y" ]]; then
sudo ansible-playbook $LOCAL
else
sudo ansible-pull -U $URL.git --checkout $branch
fi
echo "Provisioned!"
echo "Mounting all drives..."
mount -a
echo "Mounted!"
echo "Don't forget to set any new users' passwords!"
## Finish ##
echo "We're done!"
exit 0