diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d314985 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Do not sync backup files. +*backup* diff --git a/facts/general/package.yml b/facts/general/package.yml index a85736c..2be5864 100644 --- a/facts/general/package.yml +++ b/facts/general/package.yml @@ -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 diff --git a/facts/general/service.yml b/facts/general/service.yml index aa340ea..91bbdfc 100644 --- a/facts/general/service.yml +++ b/facts/general/service.yml @@ -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: diff --git a/facts/workstation/package.yml b/facts/workstation/package.yml index 4b05217..ff60ab3 100644 --- a/facts/workstation/package.yml +++ b/facts/workstation/package.yml @@ -89,6 +89,7 @@ firefox_esr: firefox font_awesome: python3-XStatic-Font-Awesome nfs: nfs-utils + ffmpeg: ffmpeg-free when: ansible_distribution == "Fedora" diff --git a/files/scripts/compress_audio.sh b/files/scripts/compress_audio.sh new file mode 100755 index 0000000..4b30070 --- /dev/null +++ b/files/scripts/compress_audio.sh @@ -0,0 +1,216 @@ +#!/bin/bash +# 2023-12-04 Hyperling +# Lower resolution of audio and convert to mp3. Also +# Also see: compress-video.sh + +## Setup ## + +DIR="$(dirname -- "${BASH_SOURCE[0]}")" +PROG="$(basename -- "${BASH_SOURCE[0]}")" +echo "Running '$DIR/$PROG'." + +# Integers +typeset -i status + +# Strings +typeset -l quality +quality="256k" +mp3="mp3" +tag="shrunk" +date_YYYYMMDD="`date "+%Y%m%d"`" +location="." +search="ls" +large_extension="DoNotUse-LargerThanOriginal" +large_created=".$PROG.large_created.true" + +## Functions ## + +function usage() { + # Hit the user with knowledge on how to use this program. + # Parameters: + # 1) The exit status to use. + status=$1 + echo -n "Usage: $PROG [-q QUALITY] [-l LOCATION] " >&2 + echo "[-A | [-r] [-f] [-d] [-c] [-z]] [-h] [-x]" >&2 + cat <<- EOF + Compress audio to mp3. Can handle folders and work recursively. + + Parameters: + -q QUALITY : Integer for the maximum length of either media dimension. + -l LOCATION : The specific media or folder which needs compressed. + -r : Recursively shrink media based on the location passed. + -f : Force the media to be shrunk even if a file already exists for it. + -d : Delete the original media if the compressed media is smaller. + -c : Clean the filename of underscores, dashes, 'IMG', etc. + -z : Convert from 440 to 432 Hz + -A : Resursively Force, Delete, and Clean. + -h : Display this usage text. + -x : Enable BASH debugging. + EOF + exit $status +} + +## Parameters ## + +while getopts ":q:l:rfdczAhx" opt; do + case $opt in + q) quality="$OPTARG" ;; + l) location="$OPTARG" ;; + r) recurse="Y" && search="find" ;; + f) force="Y" ;; + d) delete="Y" ;; + c) clean="Y" ;; + z) frequency="Y" ;; + A) recurse="Y" && + search="find" && + force="Y" && + delete="Y" && + clean="Y" && + frequency="Y" ;; + h) usage 0 ;; + x) set -x ;; + *) echo "ERROR: Option $OPTARG not recognized." >&2 && usage 1 ;; + esac +done + +## Validations ## + +convert_exe="`which ffmpeg`" +if [[ "$convert_exe" == "" ]]; then + echo "ERROR: 'ffmpeg' command could not be found, " + echo "please install 'ffmpeg'." + usage 2 +fi + +## Main ## + +# If using ls, make sure full path is passed to the loop by adding '/*'. +if [[ -z "$recurse" && -d "$location" && "$location" != *'/*' ]]; then + if [[ "$location" != *'/' ]]; then + location="${location}/" + fi +fi + +settings="-ab $quality" +if [[ $frequency == "Y" ]]; then + settings="$settings -af asetrate=44100*432/440,aresample=44100,atempo=440/432" +fi + +$search "$location" | sort | while read media; do + # Avoid processing directories no matter the name. + [ -d "$media" ] && continue + + # Avoid processing files previously shrunk. + [[ "$media" == *"$tag"* ]] && continue + + echo -e "\n$media" + + # Only look through mp3, m4a, flac, wav for now. + typeset -l extension + extension="${media##*.}" + if [[ "$extension" != *"mp3" + && "$extension" != *"m4a" + && "$extension" != *"flac" + && "$extension" != *"wav" ]] + then + echo " SKIP: Sorry, currently only mp3, m4a, flac, and wav are supported." + continue + fi + + new_media="${media//.$extension/}.$tag-$date_YYYYMMDD.$mp3" + + # Clean the filename of extra junk so that they can be chronological order. + new_media_clean="$new_media" + new_media_clean="${new_media_clean//_/ }" + ###new_media_clean="${new_media_clean//-/}" + + # Delete the existing shrunk media if we are forcing a new compression. + if [[ -n "$force" && (-e "$new_media" || -e "$new_media_clean") ]]; then + echo -n " FORCE: " + rm -v "$new_media" "$new_media_clean" 2>/dev/null + fi + + # Skip if a compressed media was already created today. + if [[ -e "$new_media" || -e "$new_media_clean" ]]; then + echo " SKIP: Media has already been shrunk previously, moving on." + continue + fi + + # Whether or not to use the cleaned version or the normal version. + if [[ -n "$clean" ]]; then + new_media="$new_media_clean" + fi + + ### TBD Instead of this, only alter the file names, and set a dirname var? + # Create a new directory if the directory names were altered. + mkdir -pv "`dirname "$new_media"`" + + # This modifies the media to be $size at its longest end, not be a square. + $convert_exe -nostdin -hide_banner -loglevel quiet \ + -i "$media" $settings "$new_media" + + status="$?" + if [[ "$status" != 0 ]]; then + echo " SKIP: '$convert_exe' returned a status of '$status'." + continue + fi + + # Check file sizes and if the new one is larger then flag it as large. + echo " Checking file sizes:" + ls -sh "$media" "$new_media" | sort -hr | while read line; do + echo " $line" + done + smaller_file=` + ls -sh "$media" "$new_media" | sort -h | cut -f 2- -d ' ' | head -n 1 + ` + if [[ "$smaller_file" == "$media" ]]; then + echo -n " WARNING: Conversion caused growth, original was likely lesser " + echo "quality. Adding a suffix to the file to signify that it may be bad." + echo -n " " + mv -v "$new_media" "$new_media.$large_extension" + touch "$large_created" + continue + fi + + if [[ -e "$new_media" ]]; then + echo " SUCCESS: Conversion succeeded, file has been compressed." + else + echo " ERROR: New media '$new_media' could not be found. Aborting." + break; + fi + + if [[ -n "$delete" ]]; then + echo -n " DELETE: " + if [[ -d ~/TRASH ]]; then + mv -v "$media" ~/TRASH/ + else + rm -v "$media" + fi + fi +done + +# If large files do end up being created, allow the user to bulk delete them. +if [[ -e "$large_created" ]]; then + echo -e "\n*********************************************************" + echo -e "WARNING: The files below are larger than their originals!\n" + find "$location" -name "*"$large_extension + echo -e "*********************************************************" + + echo -en "\nWould you like to delete them? (Y/n): " + typeset -u confirm_delete + read confirm_delete + + if [[ -z "$confirm_delete" || "$confirm_delete" == "Y"* ]]; then + echo "" + find "$location" -name "*"$large_extension -exec rm -v {} \; + else + echo -e "\nKeeping files. Please use this if you change your mind:" + echo " find \"$location\" -name \"*\"$large_extension -exec rm -v {} \;" + fi + + rm "$large_created" +fi + +echo -e "\nDone!" + +exit 0 diff --git a/files/scripts/compress_image.sh b/files/scripts/compress_image.sh index cde7441..539ff11 100755 --- a/files/scripts/compress_image.sh +++ b/files/scripts/compress_image.sh @@ -28,7 +28,7 @@ function usage() { # Parameters: # 1) The exit status to use. status=$1 - echo "Usage: $PROG [-s SIZE] [-l LOCATION] [-r] [-f] [-d] [-c] [-h] [-x]" >&2 + echo "Usage: $PROG [-s SIZE] [-l LOCATION] [-A | [-r] [-f] [-d] [-c]] [-h] [-x]" >&2 cat <<- EOF Compress JPG or PNG image(s). Can handle folders and work recursively. @@ -39,6 +39,7 @@ function usage() { -f : Force the image to be shrunk even if a file already exists for it. -d : Delete the original image if the compressed image is smaller. -c : Clean the filename of underscores, dashes, 'IMG', etc. + -A : Resursively Force, Delete, and Clean. -h : Display this usage text. -x : Enable BASH debugging. EOF @@ -47,7 +48,7 @@ function usage() { ## Parameters ## -while getopts ":s:l:rfdchx" opt; do +while getopts ":s:l:rfdcAhx" opt; do case $opt in s) in_size="$OPTARG" && size="$in_size" ;; l) location="$OPTARG" ;; @@ -55,6 +56,7 @@ while getopts ":s:l:rfdchx" opt; do f) force="Y" ;; d) delete="Y" ;; c) clean="Y" ;; + A) recurse="Y" && search="find" && force="Y" && delete="Y" && clean="Y" ;; h) usage 0 ;; x) set -x ;; *) echo "ERROR: Option $OPTARG not recognized." >&2 && usage 1 ;; @@ -147,7 +149,7 @@ $search "$location" | sort | while read image; do echo " $line" done smaller_file=` - ls -sh "$image" "$new_image" | sort -h | awk '{print $2}' | head -n 1 + ls -sh "$image" "$new_image" | sort -h | cut -f 2- -d ' ' | head -n 1 ` if [[ "$smaller_file" == "$image" ]]; then echo -n " WARNING: Conversion caused growth, original was likely lesser " diff --git a/files/scripts/compress_video.sh b/files/scripts/compress_video.sh index 6430c95..ac173b0 100755 --- a/files/scripts/compress_video.sh +++ b/files/scripts/compress_video.sh @@ -175,7 +175,7 @@ $search_command "$input" | sort | while read file; do # Check the filesize compared to the original and note if it is larger. echo "Checking file sizes:" ls -sh "$file" "$newfile" | sort -hr - smaller_file=`ls -sh "$file" "$newfile" | sort -h | awk '{print $2}' | head -n 1` + smaller_file=`ls -sh "$file" "$newfile" | sort -h | cut -f 2- -d ' ' | head -n 1` if [[ "$smaller_file" == "$file" ]]; then echo -n "Conversion had the opposite effect, original was likely lesser " echo "quality. Adding a suffix to the file to signify that it grew." diff --git a/files/settings/firefox.client b/files/settings/firefox.client new file mode 100644 index 0000000..48c6625 --- /dev/null +++ b/files/settings/firefox.client @@ -0,0 +1,9 @@ +[Profile0] +Name=haxor +IsRelative=1 +Path=l33t.haxor +Default=1 + +[General] +StartWithLastProfile=1 +Version=2 diff --git a/files/settings/vscode.json b/files/settings/vscode.json new file mode 100644 index 0000000..0059b8a --- /dev/null +++ b/files/settings/vscode.json @@ -0,0 +1,14 @@ +// Needs saved as: +// ~/.var/app/com.visualstudio.code-oss/config/Code - OSS/{{ user_desc }}/settings.json +// ~/.var/app/com.vscodium.codium/config/VSCodium/{{ user_desc }}/settings.json +{ + "workbench.startupEditor": "none", + "editor.rulers": [ + 80, 120, 200 + ], + "files.trimTrailingWhitespace": true, + "editor.tabSize": 3, + "editor.insertSpaces": false, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true +} diff --git a/local.yml b/local.yml index 515bb90..68ccef0 100644 --- a/local.yml +++ b/local.yml @@ -121,15 +121,18 @@ - include_tasks: tasks/workstation/shared/software/dwm.yml # Software Tasks # - - include_tasks: tasks/workstation/linux/software/flatpaks.yml - when: ansible_system == "Linux" and flatpak_distro - - include_tasks: tasks/workstation/linux/software/packages.yml when: ansible_system == "Linux" + - include_tasks: tasks/workstation/linux/software/flatpaks.yml + when: ansible_system == "Linux" and flatpak_distro + - include_tasks: tasks/workstation/linux/software/brave.yml when: ansible_pkg_mgr in ("apt", "dnf", "zypper") and not mobile + - include_tasks: tasks/workstation/linux/software/vpn.yml + when: ansible_system == "Linux" + - include_tasks: tasks/workstation/freebsd/software/packages.yml when: ansible_system == "FreeBSD" diff --git a/tasks/general/acct_mgmt/groups.yml b/tasks/general/acct_mgmt/groups.yml index b22c1a4..fb55482 100644 --- a/tasks/general/acct_mgmt/groups.yml +++ b/tasks/general/acct_mgmt/groups.yml @@ -10,3 +10,4 @@ - sudo - video - render + - wheel diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 6697264..bdc0559 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -66,6 +66,7 @@ - sudo - video - render + - wheel append: yes shell: "{{ user_shell }}" create_home: yes @@ -170,10 +171,34 @@ {{ update_package_manager }} {{ update_flatpak }} + echo "*** Completed Successfully ***" return 0 + } + function_update_firmware: | + function update-firmware() { + PROG=$FUNCNAME + usage="Usage: $PROG [-y] + $PROG is used to run the firmware updater in one swoop. Flow stops if + any command returns a failure code. The hope is to run something as + easy as 'pacman -Syyu' but for non-Arch systems. + -y : Assume yes to any prompts." - echo "ERROR: $PROG experienced a problem and has aborted." >&2 - return 1 + unset OPTIND + unset accept + while getopts ":hy" opt; do + case $opt in + h) echo -e "$usage" + return 0 ;; + y) accept="-y" ;; + *) echo "ERROR: -$OPTARG is not a recognized option." >&2 + echo -e "$usage" + return 1 ;; + esac + done + + {{ update_firmware }} + echo "*** Completed Successfully ***" + return 0 } alias_sync: alias sync='date && echo "Syncing!" && sync && date' export_editor: export EDITOR='vi' @@ -388,6 +413,8 @@ --branch dev ~/Code/ansible-dev git clone git@github.com:Hyperling/Docker \ --branch dev ~/Code/docker-dev + git clone git@github.com:Hyperling/Website \ + --branch dev ~/Code/website-dev git clone git@github.com:Hyperling/NixOS \ --branch dev ~/Code/nixos-dev git clone git@github.com:Hyperling/BreakTheHabit \ @@ -422,6 +449,8 @@ done echo -e "\nDone!\n" } + alias_clone: | + alias clone="rsync -auPh --delete" - name: General | Account Management | Users | Files | Common Variable set_fact: @@ -436,6 +465,7 @@ {{ export_PS1 }} {{ alias_remount }} {{ function_update }} + {{ function_update_firmware }} {{ alias_sync }} {{ export_editor }} {{ init_aliases }} @@ -458,6 +488,7 @@ {{ alias_code_reseed }} {{ function_clean_filenames }} {{ function_clean_filenames_tree }} + {{ alias_clone }} - name: General | Account Management | Users | Files | .bashrc blockinfile: diff --git a/tasks/general/software/metasploit.yml b/tasks/general/software/metasploit.yml index 5a689b5..1ed589e 100644 --- a/tasks/general/software/metasploit.yml +++ b/tasks/general/software/metasploit.yml @@ -1,12 +1,17 @@ --- # Install Metasploit Framework +- name: General | Software | Metasploit | Facts + set_fact: + metasploit_installer: msfinstall + when: ansible_system in ("Linux", "Darwin") + - name: General | Software | Metasploit | Install shell: "{{ item }}" loop: - - curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall - - chmod 755 msfinstall - - mkdir -p /usr/local/bin/ - - mv ./msfinstall /usr/local/bin/msfinstall - - msfinstall + - "curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > {{ metasploit_installer }}" + - "chmod 755 {{ metasploit_installer }}" + - "mkdir -p {{ global_bin }}" + - "mv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}" + - "{{ global_bin }}/{{ metasploit_installer }}" when: ansible_system in ("Linux", "Darwin") diff --git a/tasks/general/tests/lynis.yml b/tasks/general/tests/lynis.yml index 9a83f39..87592cd 100644 --- a/tasks/general/tests/lynis.yml +++ b/tasks/general/tests/lynis.yml @@ -3,7 +3,7 @@ - name: General | Tests | Lynis | Set Facts set_fact: - lynis_file: "{{ user_user.home }}/Reports/{{ lynis_report }}" + lynis_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.{{ lynis_report }}" - name: General | Tests | Lynis | Set Facts 2 set_fact: diff --git a/tasks/general/tests/nmap.yml b/tasks/general/tests/nmap.yml index c66e34c..1b8d1c6 100644 --- a/tasks/general/tests/nmap.yml +++ b/tasks/general/tests/nmap.yml @@ -3,7 +3,7 @@ - name: General | Tests | nmap | Set Facts set_fact: - nmap_file: "{{ user_user.home }}/Reports/{{ nmap_report }}" + nmap_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.{{ nmap_report }}" nmap_separator: "\n*******************************\n" - name: General | Tests | nmap | Set Facts 2 diff --git a/tasks/general/tests/services.yml b/tasks/general/tests/services.yml index ab8cb74..7937615 100644 --- a/tasks/general/tests/services.yml +++ b/tasks/general/tests/services.yml @@ -3,8 +3,8 @@ - name: General | Tests | Services | Set Facts set_fact: - services_report_file: "{{ user_user.home }}/Reports/services.txt" - services_enabled_file: "{{ user_user.home }}/Reports/services-enabled.txt" + services_report_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.services.txt" + services_enabled_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.services-enabled.txt" services_command: "systemctl list-unit-files" - name: General | Tests | Services | Create Main Report diff --git a/tasks/workstation/linux/software/flatpaks.yml b/tasks/workstation/linux/software/flatpaks.yml index 5a890b9..43186a1 100644 --- a/tasks/workstation/linux/software/flatpaks.yml +++ b/tasks/workstation/linux/software/flatpaks.yml @@ -37,12 +37,11 @@ flatpaks_generic: - { app: "org.libreoffice.LibreOffice", name: "office", extra: "" } - { app: "io.gitlab.librewolf-community", name: "librewolf", extra: "" } - - { app: "chat.delta.desktop", name: "deltachat", extra: "" } - { app: "org.signal.Signal", name: "signal", extra: "" } - { app: "org.mozilla.firefox", name: "firefox-flatpak", extra: "" } - { app: "com.transmissionbt.Transmission", name: "transmission", extra: "" } - { app: "org.gnome.Geary", name: "geary", extra: "" } - flatpaks_coding: + flatpaks_coding: - { app: "com.vscodium.codium", name: "codium", extra: "" } - { app: "com.google.AndroidStudio", name: "android-studio", extra: "" } - { app: "io.dbeaver.DBeaverCommunity", name: "dbeaver", extra: "" } @@ -71,6 +70,7 @@ - { app: "com.jetbrains.PyCharm-Community", name: "pycharm", extra: "" } # End 2022-11-20 # - { app: "io.lbry.lbry-app", name: "lbry", extra: "dbus-launch" } # No longer supported, noticed 2023-09-01. + - { app: "chat.delta.desktop", name: "deltachat", extra: "" } # No longer used, removed 2023-12-18. # Generic # @@ -268,74 +268,3 @@ state: absent loop: "{{ flatpaks_remove }}" ignore_errors: yes - - -## Other Stuff ## - -# Software not yet available or working properly in Flatpak form. - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Install From Repo - package: - name: - - "{{ firefox_esr }}" - - vlc - - "{{ appimagelauncher }}" - - "{{ evolution }}" - - "{{ evolution }}*" - state: present - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Remove Firefox Normal - package: - name: - - "{{ firefox }}" - state: absent - when: firefox != firefox_esr - -# Lutris # - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Add Lutris PPA (Ubuntu) - apt_repository: - repo: ppa:lutris-team/lutris - update_cache: yes - state: present - when: ansible_distribution == "Ubuntu" and gaming == true - ignore_errors: yes - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Add Lutris (besides ARM) - package: - name: - - lutris - state: present - when: ansible_architecture != "aarch64" and gaming == true - ignore_errors: yes - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Remove Lutris (besides ARM) - package: - name: - - lutris - state: absent - when: ansible_architecture != "aarch64" and gaming is not defined - ignore_errors: yes - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Remove Lutris PPA (Ubuntu) - apt_repository: - repo: ppa:lutris-team/lutris - update_cache: yes - state: absent - when: ansible_distribution == "Ubuntu" and gaming is not defined - ignore_errors: yes - -# Remove Repo Software # - -- name: Workstation | Linux | Flatpak Distro | Package Manager | Remove Applications - package: - name: - - "{{ thunderbird }}" - - steam - - vscode - - code - - libreoffice - - "*libreoffice*" - - '*libreoffice*' - - gimp - state: absent diff --git a/tasks/workstation/linux/software/packages.yml b/tasks/workstation/linux/software/packages.yml index 727a917..78bccf4 100644 --- a/tasks/workstation/linux/software/packages.yml +++ b/tasks/workstation/linux/software/packages.yml @@ -1,9 +1,92 @@ --- # Packages specific to workstations. -- name: Workstation | Software | Packages | Install Software (Editing) - package: +## Repo Management ## + +# Needed for dnf packages such as vlc. +# https://docs.fedoraproject.org/en-US/quick-docs/rpmfusion-setup/ +- name: Workstation | Linux | Software | Packages | Fedora Fusion Repos + shell: "{{ item }}" + loop: + - "dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" + - "dnf config-manager --enable rpmfusion-free" + - "dnf config-manager --enable rpmfusion-free-updates" + - "dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" + - "dnf config-manager --enable rpmfusion-nonfree" + - "dnf config-manager --enable rpmfusion-nonfree-updates" + when: ansible_distribution == "Fedora" + + +## Packages ## + +- name: Workstation | Linux | Software | Packages | Install Software (Editing) + package: name: - "{{ ffmpeg }}" state: present when: editing == true + + +## Other Stuff + +# Software not yet available or working properly in Flatpak form. + +- name: Workstation | Linux | Software | Packages | Install From Repo + package: + name: + - vlc + - "{{ appimagelauncher }}" + - "{{ evolution }}" + - "{{ evolution }}*" + state: present + +# Lutris # + +- name: Workstation | Linux | Software | Packages | Add Lutris PPA (Ubuntu) + apt_repository: + repo: ppa:lutris-team/lutris + update_cache: yes + state: present + when: ansible_distribution == "Ubuntu" and gaming == true + ignore_errors: yes + +- name: Workstation | Linux | Software | Packages | Add Lutris (besides ARM) + package: + name: + - lutris + state: present + when: ansible_architecture != "aarch64" and gaming == true + ignore_errors: yes + +- name: Workstation | Linux | Software | Packages | Remove Lutris (besides ARM) + package: + name: + - lutris + state: absent + when: ansible_architecture != "aarch64" and gaming is not defined + ignore_errors: yes + +- name: Workstation | Linux | Software | Packages | Remove Lutris PPA (Ubuntu) + apt_repository: + repo: ppa:lutris-team/lutris + update_cache: yes + state: absent + when: ansible_distribution == "Ubuntu" and gaming is not defined + ignore_errors: yes + +# Remove Repo Software # + +- name: Workstation | Linux | Software | Packages | Remove Applications + package: + name: + - "{{ firefox }}" + - "{{ firefox_esr }}" + - "{{ thunderbird }}" + - steam + - vscode + - code + - libreoffice + - "*libreoffice*" + - '*libreoffice*' + - gimp + state: absent diff --git a/tasks/workstation/linux/software/vpn.yml b/tasks/workstation/linux/software/vpn.yml new file mode 100644 index 0000000..c8ddd00 --- /dev/null +++ b/tasks/workstation/linux/software/vpn.yml @@ -0,0 +1,23 @@ +--- +# Install VPN client(s). +# https://mullvad.net/en/help/install-mullvad-app-linux + +- name: Workstation | Software | VPN | Add Mullvad Repo [apt] + shell: "{{ item }}" + loop: + - sudo curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc https://repository.mullvad.net/deb/mullvad-keyring.asc + - echo "deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mullvad.list + - apt update + when: ansible_pkg_mgr == "apt" + +- name: Workstation | Software | VPN | Add Mullvad Repo [dnf] + shell: "{{ item }}" + loop: + - sudo dnf config-manager --add-repo https://repository.mullvad.net/rpm/stable/mullvad.repo + when: ansible_pkg_mgr == "dnf" + +- name: Workstation | Software | VPN | Install + package: + name: + - mullvad-vpn + state: present diff --git a/tasks/workstation/shared/settings/gnome.yml b/tasks/workstation/shared/settings/gnome.yml index 0064f30..d2b6dcf 100644 --- a/tasks/workstation/shared/settings/gnome.yml +++ b/tasks/workstation/shared/settings/gnome.yml @@ -1,6 +1,8 @@ --- # GNOME settings, extensions, and setup. +# Temporarily removed while it's broken: +# , 'com.vscodium.codium.desktop', 'codium.desktop' - name: Workstation | Account Management | GNOME | Facts set_fact: # Only do multiple entries per line if they are for the same exact program. @@ -14,7 +16,6 @@ , 'chat.delta.desktop.desktop', 'deltachat.desktop' , 'org.gnome.Geary.desktop' , 'org.mozilla.Thunderbird.desktop' - , 'com.vscodium.codium.desktop', 'codium.desktop' , 'com.visualstudio.code-oss.desktop', 'code-oss.desktop' , 'org.godotengine.Godot.desktop' , 'org.shotcut.Shotcut.desktop' @@ -152,145 +153,12 @@ become_user: "{{ user }}" when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed - # Settings # - - - name: Workstation | Account Management | GNOME | Dash To Dock | Dock Position - dconf: - key: /org/gnome/shell/extensions/dash-to-dock/dock-position - value: "'LEFT'" - state: present - become_user: "{{ user }}" - - - name: Workstation | Account Management | GNOME | Dash To Dock | Dock Fixed - dconf: - key: /org/gnome/shell/extensions/dash-to-dock/dock-fixed - value: "true" - state: present - become_user: "{{ user }}" - - - name: Workstation | Account Management | GNOME | Dash To Dock | Icon Size - dconf: - key: /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size - value: "28" - state: present - become_user: "{{ user }}" - when: ansible_distribution not in ("NixOS") ignore_errors: yes # End block for Dash To Dock. -## TBD Remove this after testing the RC version is successful on Ubuntu. -#- name: Workstation | Account Management | GNOME | More Settings -# block: -# -# - name: Workstation | Account Management | GNOME + Cinnamon | Favorites (Linux) -# dconf: -# key: "{{ item }}" -# value: "{{ gnome_favorites }}" -# state: present -# become_user: "{{ user }}" -# #when: ansible_system == "Linux" -# loop: -# - /org/gnome/shell/favorite-apps -# # - /org/cinnamon/favorite-apps -# # As of 2023-07-01 this only sets the Menu Favorites on Cinnamon, not the -# # Panel Pins. Cannot find any details online of where the pinned application -# # data lives. Cloned and searched the linuxmint/cinnamon project too and -# # couldn't find which function handles it. Leaving the loop for it but it's -# # not what was hoped for and is sort of a TBD/TODO. -# -# ## This is now handled by the task above, it's OK to have values not found. -# #- name: Workstation | Account Management | GNOME | Favorites (FreeBSD) -# # dconf: -# # key: /org/gnome/shell/favorite-apps -# # value: "['org.gnome.Terminal.desktop', 'org.gnome.Nautilus.desktop', -# # 'firefox.desktop', 'org.gnome.Evolution.desktop', 'org.mozilla.Thunderbird.desktop', -# # 'code-oss.desktop', 'org.telegram.desktop.desktop']" -# # state: present -# # become_user: "{{ user }}" -# # when: ansible_system == "FreeBSD" -# -# -# ## Top Bar Settings ## -# # (Battery Percentage, Clock Weekday+Seconds, Calendar Week Numbers) -# -# - name: Workstation | Account Management | GNOME | Interface - Show Date -# dconf: -# key: /org/gnome/desktop/interface/clock-show-date -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Interface - 24h Format -# dconf: -# key: /org/gnome/desktop/interface/clock-format -# value: "'24h'" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Interface - Show Seconds -# dconf: -# key: /org/gnome/desktop/interface/clock-show-seconds -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Interface - Show Weekday -# dconf: -# key: /org/gnome/desktop/interface/clock-show-weekday -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Interface - 24h Format -# dconf: -# key: /org/gnome/desktop/interface/show-battery-percentage -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Interface - Show Week Date -# dconf: -# key: /org/gnome/desktop/calendar/show-weekdate -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# ## TBD These are done for NixOS in the section below. ## -# # Never Prompt for Removal Media -# -# # Dark theme? -# #Pop-dark on Pop -# #Adwaita-dark on everything else -# -# # Window Titlebars (Titlebar Buttons Minimize) -# - name: Workstation | Account Management | GNOME | Window Buttons -# dconf: -# key: /org/gnome/desktop/wm/preferences/button-layout -# value: "'appmenu:minimize,close'" -# state: present -# become_user: "{{ user }}" -# -# -# # Security -# - name: Workstation | Account Management | GNOME | Privacy - Camera -# dconf: -# key: /org/gnome/desktop/privacy/disable-camera -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# - name: Workstation | Account Management | GNOME | Privacy - Microphone -# dconf: -# key: /org/gnome/desktop/privacy/disable-microphone -# value: "true" -# state: present -# become_user: "{{ user }}" -# -# when: ansible_distribution not in ("NixOS") - -## NixOS support, in an odd but working fashion for now. :) -- name: Workstation | Account Management | GNOME | Dash To Dock | NixOS +# Apply dconf settings through RC files due to distros without working psutil. +- name: Workstation | Account Management | GNOME | Settings blockinfile: path: "{{ user_user.home }}/{{ item }}" block: | @@ -383,6 +251,7 @@ dconf write /org/gnome/desktop/screensaver/lock-delay "uint32 0" && inc_dconf && dconf write /org/gnome/desktop/session/idle-delay "uint32 900" && inc_dconf && dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'" && inc_dconf && + dconf write /org/gnome/settings-daemon/plugins/power/power-button-action "'nothing'" && inc_dconf && dconf write /org/gnome/desktop/media-handling/autorun-never true && inc_dconf && @@ -406,4 +275,3 @@ loop: - .bashrc - .zshrc - #when: ansible_distribution in ("NixOS")