Fixes and Enhancements (#48)

* Fix metasplot install if /usr/local/bin is not active in path yet. Also use variables.

* Use plocate on openSUSE. Supposed to be faster. Cannot have both m and p installed at the same time and p comes with the base system.

* Include wheel group for user as well.

* Finalize GNOME settings, go with RC commands instead of dconf module.

* Add hostname to report files.

* Add TBD for shared home situation.

* Fix cron service for Fedora.

* Disable the power button.

* Fix Fedora ffmpeg issues. Move package modules from flatpak playbook. Uninstall firefox from package manager.

* Enhance update function to handle shared home between multiple distributions.

* Allow keeping local backups of files.

* Replace flatpak repair check with accept flag instead of battery so that any automated update runs do the cleanup.

* Begin hoarding settings files.

* Start building out a FireFox profile.

* Fix extra comment command in comment.

* Add an All option to completely compress the entire directory.

* Codium is still broken on all tested systems, hide from Favorites.

* Add scipt to handle audio files. Also can convert to 432Hz.

* Use cut instead of awk to get rid of first parameter. Fixes bugs when spaces are allowed in the filenames.

* Enhancements and bugfix for "$freq".

* Add playbook for desktop VPN clients. Start with Mullvad.

* Add website to the seeded projects.

* Add firmware updates to the update function.

* Allow `fwupdmgr` to fail and have `update` still continue.

* Shorten lines.

* Uninstall DeltaChat.

* Separate the firmware update into its own function.

* Add alias for cloning one folder to another without using rm/cp.

* Fix typo in rsync.

* Go ahead and add extra options.

* Make the files human readable size descriptions.

* Remove unnecessary v, P does good enough.
This commit is contained in:
2024-01-23 09:43:42 -07:00
committed by GitHub
parent 392294fb45
commit 7519f23a81
20 changed files with 588 additions and 347 deletions

View File

@ -54,7 +54,7 @@
- name: General | Facts | Package | zypper
set_fact:
locate: mlocate
locate: plocate
opensshd: openssh
microcode_amd: ucode-amd
microcode_intel: ucode-intel
@ -62,155 +62,203 @@
when: ansible_pkg_mgr == "zypper"
- name: General | Facts | Package | Update Commands | Helpers
- name: General | Facts | Package | Update Command | Helpers
set_fact:
update_accept_var: '$accept'
nix_days: 14
ansible_distribution_file: "{{ prov_dir }}/ansible_distribution.txt"
ansible_pkg_mgr_file: "{{ prov_dir }}/ansible_pkg_mgr.txt"
- name: General | Facts | Package | Update Commands | Helpers | pacman
- name: General | Facts | Package | Update Command | Helpers | pacman
set_fact:
update_accept_var: '--noconfirm'
when: ansible_pkg_mgr == "pacman"
- name: General | Facts | Package | Update Commands | apt
- name: General | Facts | Package | Update Command | Store Variables
shell: "{{ item }}"
loop:
- "echo '{{ ansible_distribution }}' > {{ ansible_distribution_file }}"
- "echo '{{ ansible_pkg_mgr }}' > {{ ansible_pkg_mgr_file }}"
- name: General | Facts | Package | Update Command
set_fact:
update_package_manager: |
echo "*** Apt ***" &&
sudo apt update &&
sudo apt autoremove {{ update_accept_var }} &&
sudo apt clean {{ update_accept_var }} &&
sudo dpkg --configure -a &&
sudo apt --fix-broken --fix-missing install &&
sudo apt dist-upgrade --allow-downgrades --fix-broken --fix-missing {{ update_accept_var }} &&
when: ansible_pkg_mgr == "apt"
- name: General | Facts | Package | Update Commands | pacman
set_fact:
update_package_manager: |
echo "*** Pacman ***"
if [[ "$accept" == "Y" ]]; then
auto_accept="{{ update_accept_var }}"
fi
sudo pacman -Syyu $auto_accept &&
when: ansible_pkg_mgr == "pacman"
distribution="`cat {{ ansible_distribution_file }}`"
pkg_mgr="`cat {{ ansible_pkg_mgr_file }}`"
- name: General | Facts | Package | Update Commands | pkg
set_fact:
update_package_manager: |
echo "*** FreeBSD-Update ***"
clean=""
[[ "{{ update_accept_var }}" == "-y" ]] || echo "Are you sure you'd like to clean /var/db/freebsd-update? [y/N] "
[[ "{{ update_accept_var }}" == "-y" ]] || read -N 1 clean
echo -e "\n"
typeset -l clean
if [[ "{{ update_accept_var }}" == "-y" || "$clean" == "y" ]]; then
echo "Cleaning directory..."
sudo sh -c "rm -rfv /var/db/freebsd-update; mkdir -v /var/db/freebsd-update"
fi
sudo freebsd-update fetch install
case $pkg_mgr in
apt)
if [[ $distribution != "ParrotOS" ]]; then
echo "*** Apt ***" &&
sudo apt update &&
sudo apt autoremove {{ update_accept_var }} &&
sudo apt clean {{ update_accept_var }} &&
sudo dpkg --configure -a &&
sudo apt --fix-broken --fix-missing install &&
sudo apt dist-upgrade --allow-downgrades --fix-broken \
--fix-missing {{ update_accept_var }} ||
return 1
else
echo "*** Parrot ***"
sudo apt update &&
sudo apt autoremove {{ update_accept_var }} &&
parrot_mirrors_suck=true &&
while [[ $parrot_mirrors_suck ]]; do
unset parrot_mirrors_suck
sudo parrot-upgrade
if [[ $? != 0 ]]; then
parrot_mirrors_suck=true
sudo apt update --fix-missing
fi
done ||
return 1
fi
;;
echo "*** Pkg ***" &&
sudo pkg update &&
sudo pkg clean {{ update_accept_var }} &&
sudo pkg autoremove {{ update_accept_var }} &&
sudo pkg upgrade {{ update_accept_var }} &&
when: ansible_pkg_mgr in ("pkg", "pkgng")
pacman)
echo "*** Pacman ***"
if [[ "$accept" == "Y" ]]; then
auto_accept="{{ update_accept_var }}"
fi
sudo pacman -Syyu $auto_accept ||
return 1
;;
- name: General | Facts | Package | Update Commands | parrot-upgrade
set_fact:
update_package_manager: |
echo "*** Parrot ***"
sudo apt update &&
sudo apt autoremove {{ update_accept_var }} &&
parrot_mirrors_suck=true &&
while [[ $parrot_mirrors_suck ]]; do
unset parrot_mirrors_suck
sudo parrot-upgrade
if [[ $? != 0 ]]; then
parrot_mirrors_suck=true
sudo apt update --fix-missing
fi
done &&
when: ansible_distribution == "Parrot OS"
pkg | pkgng)
echo "*** FreeBSD-Update ***"
clean=""
[[ "{{ update_accept_var }}" == "-y" ]] ||
echo "Are you sure you'd like to clean /var/db/freebsd-update? [y/N] "
[[ "{{ update_accept_var }}" == "-y" ]] ||
read -N 1 clean
echo -e "\n"
typeset -l clean
if [[ "{{ update_accept_var }}" == "-y" || "$clean" == "y" ]]; then
echo "Cleaning directory..."
sudo sh -c "rm -rfv /var/db/freebsd-update
mkdir -v /var/db/freebsd-update"
fi
sudo freebsd-update fetch install
- name: General | Facts | Package | Update Commands | dnf
set_fact:
update_package_manager: |
echo "*** DNF ***" &&
sudo dnf clean all {{ update_accept_var }} &&
sudo dnf autoremove {{ update_accept_var }} &&
sudo dnf upgrade {{ update_accept_var }} &&
when: ansible_pkg_mgr in ("dnf")
echo "*** Pkg ***" &&
sudo pkg update &&
sudo pkg clean {{ update_accept_var }} &&
sudo pkg autoremove {{ update_accept_var }} &&
sudo pkg upgrade {{ update_accept_var }} ||
return 1
;;
- name: General | Facts | Package | Update Commands | zypper
set_fact:
update_package_manager: |
echo "*** Zypper ***" &&
sudo zypper refresh &&
sudo zypper cleanlocks &&
sudo zypper purge-kernels &&
sudo zypper clean -a &&
sudo zypper patch {{ update_accept_var }} &&
sudo zypper update {{ update_accept_var }} &&
sudo zypper dist-upgrade {{ update_accept_var }} &&
# This is a neat feature, but is installing things like GIMP from the
# repos when it is already installed through Flatpak, so not needed.
#sudo zypper install-new-recommends &&
when: ansible_pkg_mgr in ("zypper")
dnf)
echo "*** DNF ***" &&
sudo dnf clean all {{ update_accept_var }} &&
sudo dnf autoremove {{ update_accept_var }} &&
sudo dnf upgrade {{ update_accept_var }} ||
return 1
;;
- name: General | Facts | Package | Update Commands | NixOS
set_fact:
update_package_manager: |
sudo echo "*** NixOS ***"
# Clean up!
# https://specific.solutions.limited/blog/recovering-diskspace-in-nixos
zypper)
echo "*** Zypper ***" &&
sudo zypper refresh &&
sudo zypper cleanlocks &&
sudo zypper purge-kernels &&
sudo zypper clean -a &&
sudo zypper patch {{ update_accept_var }} &&
sudo zypper update {{ update_accept_var }} &&
sudo zypper dist-upgrade {{ update_accept_var }} &&
# This is a neat feature, but is installing things like GIMP from the
# repos when it is already installed through Flatpak, so not needed.
#sudo zypper install-new-recommends ||
sleep 0 ||
return 1
;;
echo -en "\n * Delete any existing garbage and snapshots older than "
echo -e "{{ nix_days }} days.\n"
echo "User:"
nix-collect-garbage --delete-older-than '{{ nix_days }}d'
echo "Root:"
sudo nix-collect-garbage --delete-older-than '{{ nix_days }}d'
*)
if [[ $distribution == "NixOS" ]]; then
sudo echo "*** NixOS ***" &&
# Clean up!
# https://specific.solutions.limited/blog/recovering-diskspace-in-nixos
ls ~/.cache/*nix* /root/.cache/*nix* 2>/dev/null 1>&2 &&
echo -e "\n * Delete any cache.\n"
du -hs ~/.cache/*nix* 2>/dev/null &&
echo "User:" &&
rm -rfv ~/.cache/*nix*
sudo du -hs /root/.cache/*nix* 2>/dev/null &&
echo "Root:" &&
sudo rm -rfv /root/.cache/*nix*
echo -en "\n * Delete any existing garbage and snapshots older than " &&
echo -e "{{ nix_days }} days.\n" &&
echo "User:" &&
nix-collect-garbage --delete-older-than '{{ nix_days }}d' &&
echo "Root:" &&
sudo nix-collect-garbage --delete-older-than '{{ nix_days }}d'
echo -e "\n * Update channels with the latest expressions.\n"
echo "User:"
nix-channel --update
echo "Root:"
sudo nix-channel --update
ls ~/.cache/*nix* /root/.cache/*nix* 2>/dev/null 1>&2 &&
echo -e "\n * Delete any cache.\n"
du -hs ~/.cache/*nix* 2>/dev/null &&
echo "User:" &&
rm -rfv ~/.cache/*nix*
sudo du -hs /root/.cache/*nix* 2>/dev/null &&
echo "Root:" &&
sudo rm -rfv /root/.cache/*nix*
echo -e "\n * Rebuild using the existing *.nix files.\n"
sudo nixos-rebuild switch
echo -e "\n * Update channels with the latest expressions.\n" &&
echo "User:" &&
nix-channel --update &&
echo "Root:" &&
sudo nix-channel --update
echo -e "\n * Hard link duplicates, saves 25-35% of store size.\n"
sudo nix-store --optimize
when: ansible_distribution == "NixOS"
echo -e "\n * Rebuild using the existing *.nix files.\n" &&
sudo nixos-rebuild switch ||
return 1
echo -e "\n * Hard link duplicates, saves 25-35% of store size.\n" &&
sudo nix-store --optimize
else
echo "WARNING: This package manager is not supported yet." >&2
echo " distribution='${distribution}', pkg_mgr='${pkg_mgr}'" >&2
fi
;;
esac &&
# End of update_package_manager
- name: General | Facts | Package | Update Commands | flatpak | check
# Flatpaks
- name: General | Facts | Package | Update Command | Flatpak | Check
shell: which flatpak
register: flatpak_exec
ignore_errors: yes
- name: General | Facts | Package | Update Commands | flatpak | exists
- name: General | Facts | Package | Update Command | Flatpak | Exists
set_fact:
update_flatpak: |
echo "*** Flatpak ***"
[[ {{ battery }} != 'True' ]] && sudo flatpak repair
[[ -n {{ update_accept_var }} ]] && sudo flatpak repair
sudo flatpak uninstall --unused {{ update_accept_var }} &&
sudo flatpak update {{ update_accept_var }} &&
when: flatpak_exec is defined and flatpak_exec.failed is defined and not flatpak_exec.failed
sudo flatpak update {{ update_accept_var }} ||
return 1
when: flatpak_exec is defined
and flatpak_exec.failed is defined
and not flatpak_exec.failed
- name: General | Facts | Package | Update Commands | flatpak | not exists
- name: General | Facts | Package | Update Command | Flatpak | Missing
set_fact:
update_flatpak: |
echo "*** Flatpak Not Installed ***" &&
when: update_flatpak is not defined
# Firmware
- name: General | Facts | Package | Update Command | Firmware | Check
shell: which fwupdmgr
register: fwupdmgr_exec
ignore_errors: yes
- name: General | Facts | Package | Update Command | Firmware | Exists
set_fact:
update_firmware: |
echo "*** Firmware ***"
sudo fwupdmgr refresh --force &&
sudo fwupdmgr get-updates {{ update_accept_var }} &&
sudo fwupdmgr update --no-reboot-check {{ update_accept_var }} ||
return 1
when: fwupdmgr_exec is defined
and fwupdmgr_exec.failed is defined
and not fwupdmgr_exec.failed
- name: General | Facts | Package | Update Command | Firmware | Missing
set_fact:
update_firmware: |
echo "*** Firmware Updater (fwupdmgr) Not Installed ***" &&
when: update_firmware is not defined

View File

@ -21,7 +21,13 @@
set_fact:
crond: cronie
crond_pattern: cronie
when: ansible_distribution == "Archlinux"
when: ansible_distribution in ("Archlinux")
- name: General | Facts | Service | Fedora
set_fact:
crond: crond
crond_pattern: crond
when: ansible_distribution in ("Fedora")
- name: General | Facts | Service | Ubuntu Linux
set_fact:

View File

@ -89,6 +89,7 @@
firefox_esr: firefox
font_awesome: python3-XStatic-Font-Awesome
nfs: nfs-utils
ffmpeg: ffmpeg-free
when: ansible_distribution == "Fedora"