Enhance Functions + General Improvements (#52)

* Add an alternative to Audacity.

* Remove the Brave Browser since the repo has started failing and I only use Firefox browsers these days.

* Remove alias audacity for tenacity.

* Ignore if the repos are already removed.

* Stop installing Telegraf.

* Add the new dconf name for System Monitor.

* Remove the download if it already exists. Force the move.

* Fix overwrite prompt for Metasploit.

* Don't do flatpaks during a battery device's goodbye.

* Fix variable case, add quotes.

* Fix double quotes.

* Add full set of commands for compressing videos.

* Fix trash size checking to work for folders.

* Allow only updating system or Flatpak programs.

* Also check the DE trash folder.

* No longer have Flatpaks contingent on system updates.

* Improve variable names and flow.

* Fix maxdepth.

* Check network mounts for hidden trash folders.

* Add media. Only restrict maxdepth for Home directory.

* Properly check media.

* Ensure hidden files also get seen and removed.
This commit is contained in:
Hyperling 2024-09-23 11:51:17 -07:00 committed by GitHub
parent 742f225de1
commit e66dbed7a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 279 additions and 184 deletions

View File

@ -217,7 +217,7 @@
echo " distribution='${distribution}', pkg_mgr='${pkg_mgr}'" >&2 echo " distribution='${distribution}', pkg_mgr='${pkg_mgr}'" >&2
fi fi
;; ;;
esac && esac
# End of update_package_manager # End of update_package_manager
# Flatpaks # Flatpaks

View File

@ -98,7 +98,7 @@ fi
if [[ -z "$video_bitrate" ]]; then if [[ -z "$video_bitrate" ]]; then
video_bitrate="2000k" video_bitrate="2000k"
fi fi
video_bitrate="-maxrate $video_bitrate" video_bitrate="-b:v $video_bitrate -minrate 0 -maxrate $video_bitrate -bufsize $video_bitrate"
if [[ -z "$audio_bitrate" ]]; then if [[ -z "$audio_bitrate" ]]; then
audio_bitrate="192k" audio_bitrate="192k"

View File

@ -154,24 +154,47 @@
$PROG is used to run all the system's package manager commands $PROG is used to run all the system's package manager commands
in one swoop. Flow stops if any command returns a failure code. in one swoop. Flow stops if any command returns a failure code.
The hope is to run something as easy as 'pacman -Syyu'. The hope is to run something as easy as 'pacman -Syyu'.
-y : Assume yes to any prompts." -y : Assume yes to any prompts.
-g : Shutdown after updating.
-s : System updates only, no Flatpaks.
-f : Flatpaks only, no system updates."
unset OPTIND unset OPTIND
unset accept unset accept
while getopts ":hy" opt; do while getopts ":hygsf" opt; do
case $opt in case $opt in
h) echo -e "$usage" h) echo -e "$usage"
return 0 ;; return 0 ;;
y) accept="-y" ;; y) accept="-y" ;;
g) goodbye="Y" ;;
s) only_sys="Y" ;;
f) only_flat="Y" ;;
*) echo "ERROR: -$OPTARG is not a recognized option." >&2 *) echo "ERROR: -$OPTARG is not a recognized option." >&2
echo -e "$usage" echo -e "$usage"
return 1 ;; return 1 ;;
esac esac
done done
{{ update_package_manager }} if [[ "$only_flat" == "Y" ]]; then
{{ update_flatpak }} echo -e "\n*** Only Flatpaks - Skipping System Updates ***\n\n"
else
{{ update_package_manager }}
fi
if [[ "$goodbye" == "Y" && "{{ battery }}" == "True" ]]; then
echo -e "\n*** Only System Updates - Skipping Flatpak ***\n\n"
elif [[ "$only_sys" == "Y" ]]; then
echo -e "\n*** Manually Skipping Flatpak ***\n\n"
else
{{ update_flatpak }}
fi
echo "*** Completed Successfully ***" echo "*** Completed Successfully ***"
if [[ $goodbye == "Y" ]]; then
bye
fi
return 0 return 0
} }
function_update_firmware: | function_update_firmware: |
@ -218,7 +241,7 @@
alias init-prog=init-program alias init-prog=init-program
bye_aliases: | bye_aliases: |
alias bye="{{ shutdown_command }}" alias bye="{{ shutdown_command }}"
alias goodbye="update -y && bye" alias goodbye="update -yg"
metasploit_aliases: | metasploit_aliases: |
alias metasploit="msfconsole" alias metasploit="msfconsole"
alias hax="metasploit" alias hax="metasploit"
@ -256,7 +279,7 @@
* ) * )
echo " echo "
ERROR: Option '$1' with value '$2' not recognized. ERROR: Option '$1' with value '$2' not recognized.
$PROG [-c|-clean|--clean|-y] [-n|-net|--network] $PROG [-c|-y|--clean] [-n|-net|--network]
" >&2 " >&2
return 1 return 1
;; ;;
@ -268,18 +291,37 @@
echo "Grabbing sudo permissions..." echo "Grabbing sudo permissions..."
sudo echo "Success! Starting search..." sudo echo "Success! Starting search..."
function dirs_to_check { function dirs_to_check {
echo "/root" echo "/root 0"
echo "/home" echo "/home 4"
echo "/media 0"
} }
dirs_to_check | while read dir; do dirs_to_check | while read dir depth; do
if [[ "$depth" != 0 ]]; then
maxdepth="-maxdepth $depth"
fi
sudo="sudo"
if [[ "$dir" == "/media" ]]; then
sudo=""
dir="$dir/$LOGNAME"
fi
echo "Checking $dir..." echo "Checking $dir..."
sudo find $dir -name TRASH | while read trash; do $sudo find $dir -name TRASH | while read trash; do
if [[ "$trash" != "" && `sudo ls $trash` ]]; then if [[ "$trash" != "" && `$sudo ls -a $trash` ]]; then
echo "Found $trash with contents:" echo "Found $trash with contents:"
sudo ls -lh $trash $sudo du -ha $trash | sort -h
if [[ "$clean" == "Y" ]]; then if [[ "$clean" == "Y" ]]; then
echo "Cleaning trash..." echo "Cleaning trash..."
sudo sh -c "rm -rfv $trash/*" $sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *"
fi
fi
done
$sudo find $dir $maxdepth -name "*"Trash"*" | while read trash; do
if [[ "$trash" != "" && `$sudo ls -a $trash` ]]; then
echo "Found $trash with contents:"
$sudo du -ha $trash | sort -h
if [[ "$clean" == "Y" ]]; then
echo "Cleaning trash..."
$sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *"
fi fi
fi fi
done done
@ -291,12 +333,22 @@
network_to_check | while read dir; do network_to_check | while read dir; do
echo "Checking $dir..." echo "Checking $dir..."
sudo find $dir -name TRASH | while read trash; do sudo find $dir -name TRASH | while read trash; do
if [[ "$trash" != "" && `sudo ls $trash` ]]; then if [[ "$trash" != "" && `sudo ls -a $trash` ]]; then
echo "Found $trash with contents:" echo "Found $trash with contents:"
sudo ls -lh $trash sudo du -ha $trash | sort -h
if [[ "$clean" == "Y" ]]; then if [[ "$clean" == "Y" ]]; then
echo "Cleaning trash..." echo "Cleaning trash..."
sudo sh -c "rm -rfv $trash/*" sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *"
fi
fi
done
sudo find $dir -name .Trash"*" | while read trash; do
if [[ "$trash" != "" && `sudo ls -a $trash` ]]; then
echo "Found $trash with contents:"
sudo du -ha $trash | sort -h
if [[ "$clean" == "Y" ]]; then
echo "Cleaning trash..."
sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *"
fi fi
fi fi
done done

View File

@ -9,9 +9,10 @@
- name: General | Software | Metasploit | Install - name: General | Software | Metasploit | Install
shell: "{{ item }}" shell: "{{ item }}"
loop: loop:
- "mv -fv /usr/share/keyrings/metasploit-framework.gpg /usr/share/keyrings/metasploit-framework.gpg.old"
- "curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > {{ metasploit_installer }}" - "curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > {{ metasploit_installer }}"
- "chmod 755 {{ metasploit_installer }}" - "chmod 755 {{ metasploit_installer }}"
- "mkdir -p {{ global_bin }}" - "mkdir -p {{ global_bin }}"
- "mv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}" - "mv -fv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}"
- "{{ global_bin }}/{{ metasploit_installer }}" - "{{ global_bin }}/{{ metasploit_installer }}"
when: ansible_system in ("Linux", "Darwin") when: ansible_system in ("Linux", "Darwin")

View File

@ -35,128 +35,130 @@
telegraf_input_temp: "" telegraf_input_temp: ""
when: ansible_system == "FreeBSD" when: ansible_system == "FreeBSD"
# Dependencies # # 2024-05-23 Server has not been running for a while, stop installing this.
- name: General | Telegraf | Pre-Reqs #### Dependencies #
package: ###
name: wget ###- name: General | Telegraf | Pre-Reqs
when: ansible_system == "Linux" ### package:
### name: wget
# Install # ### when: ansible_system == "Linux"
###
- name: General | Telegraf | Linux | Install #### Install #
shell: "{{ item }}" ###
args: ###- name: General | Telegraf | Linux | Install
chdir: "{{ ansible_env.HOME }}/Downloads/" ### shell: "{{ item }}"
loop: ### args:
- mkdir -p {{ telegraf_path }} ### chdir: "{{ ansible_env.HOME }}/Downloads/"
- mkdir -p {{ telegraf_config_path }} ### loop:
- wget --no-check-certificate "https://dl.influxdata.com/telegraf/releases/{{ telegraf_tar }}" ### - mkdir -p {{ telegraf_path }}
- tar xvf {{ telegraf_tar }} ### - mkdir -p {{ telegraf_config_path }}
- mv {{ telegraf_tar }} ~/TRASH/ ### - wget --no-check-certificate "https://dl.influxdata.com/telegraf/releases/{{ telegraf_tar }}"
- mv telegraf*/usr/bin/telegraf {{ telegraf_exec }} ### - tar xvf {{ telegraf_tar }}
- rm -r telegraf* ### - mv {{ telegraf_tar }} ~/TRASH/
when: ansible_system == "Linux" ### - mv telegraf*/usr/bin/telegraf {{ telegraf_exec }}
### - rm -r telegraf*
- name: General | Telegraf | FreeBSD | Install 1/2 ### when: ansible_system == "Linux"
shell: /usr/sbin/pwd_mkdb -p /etc/master.passwd ###
when: ansible_system == "FreeBSD" ###- name: General | Telegraf | FreeBSD | Install 1/2
### shell: /usr/sbin/pwd_mkdb -p /etc/master.passwd
- name: General | Telegraf | FreeBSD | Install 2/2 ### when: ansible_system == "FreeBSD"
package: ###
name: telegraf ###- name: General | Telegraf | FreeBSD | Install 2/2
when: ansible_system == "FreeBSD" ### package:
### name: telegraf
# Configuration # ### when: ansible_system == "FreeBSD"
###
- name: General | Telegraf | Config 1/2 #### Configuration #
shell: mv {{ telegraf_config }} ~/TRASH/ ###
ignore_errors: yes ###- name: General | Telegraf | Config 1/2
### shell: mv {{ telegraf_config }} ~/TRASH/
- name: General | Telegraf | Config 2/2 ### ignore_errors: yes
blockinfile: ###
path: "{{ telegraf_config }}" ###- name: General | Telegraf | Config 2/2
block: | ### blockinfile:
[global_tags] ### path: "{{ telegraf_config }}"
# dc = "us-east-1" # will tag all metrics with dc=us-east-1 ### block: |
# rack = "1a" ### [global_tags]
## Environment variables can be used as tags, and throughout the config file ### # dc = "us-east-1" # will tag all metrics with dc=us-east-1
# user = "$USER" ### # rack = "1a"
### ## Environment variables can be used as tags, and throughout the config file
[agent] ### # user = "$USER"
interval = "{{ '300s' if battery else '5s' }}" ###
metric_batch_size = 1000 ### [agent]
metric_buffer_limit = 10000 ### interval = "{{ '300s' if battery else '5s' }}"
collection_jitter = "0s" ### metric_batch_size = 1000
flush_interval = "30s" ### metric_buffer_limit = 10000
flush_jitter = "10s" ### collection_jitter = "0s"
precision = "" ### flush_interval = "30s"
# debug = false ### flush_jitter = "10s"
# quiet = false ### precision = ""
# logtarget = "file" ### # debug = false
# logfile = "" ### # quiet = false
# logfile_rotation_interval = "0d" ### # logtarget = "file"
# logfile_rotation_max_size = "0MB" ### # logfile = ""
# logfile_rotation_max_archives = 5 ### # logfile_rotation_interval = "0d"
hostname = "" ### # logfile_rotation_max_size = "0MB"
omit_hostname = false ### # logfile_rotation_max_archives = 5
### hostname = ""
[[outputs.influxdb]] ### omit_hostname = false
urls = ["http://192.168.1.82:8086"] ###
database = "main" ### [[outputs.influxdb]]
# database_tag = "" ### urls = ["http://192.168.1.82:8086"]
# exclude_database_tag = false ### database = "main"
# skip_database_creation = false ### # database_tag = ""
# retention_policy = "" ### # exclude_database_tag = false
# retention_policy_tag = "" ### # skip_database_creation = false
# exclude_retention_policy_tag = false ### # retention_policy = ""
# write_consistency = "any" ### # retention_policy_tag = ""
# timeout = "5s" ### # exclude_retention_policy_tag = false
# username = "telegraf" ### # write_consistency = "any"
# password = "metricsmetricsmetricsmetrics" ### # timeout = "5s"
# user_agent = "telegraf" ### # username = "telegraf"
# udp_payload = "512B" ### # password = "metricsmetricsmetricsmetrics"
# tls_ca = "/etc/telegraf/ca.pem" ### # user_agent = "telegraf"
# tls_cert = "/etc/telegraf/cert.pem" ### # udp_payload = "512B"
# tls_key = "/etc/telegraf/key.pem" ### # tls_ca = "/etc/telegraf/ca.pem"
# insecure_skip_verify = false ### # tls_cert = "/etc/telegraf/cert.pem"
# http_proxy = "http://corporate.proxy:3128" ### # tls_key = "/etc/telegraf/key.pem"
# http_headers = {"X-Special-Header" = "Special-Value"} ### # insecure_skip_verify = false
# content_encoding = "gzip" ### # http_proxy = "http://corporate.proxy:3128"
# influx_uint_support = false ### # http_headers = {"X-Special-Header" = "Special-Value"}
### # content_encoding = "gzip"
[[inputs.cpu]] ### # influx_uint_support = false
percpu = false ###
totalcpu = true ### [[inputs.cpu]]
collect_cpu_time = false ### percpu = false
report_active = false ### totalcpu = true
### collect_cpu_time = false
[[inputs.disk]] ### report_active = false
# mount_points = ["/"] ###
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "fdescfs", "procfs", "nullfs"] ### [[inputs.disk]]
### # mount_points = ["/"]
[[inputs.diskio]] ### ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "fdescfs", "procfs", "nullfs"]
# devices = ["sda", "sdb", "vd*"] ###
# skip_serial_number = false ### [[inputs.diskio]]
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"] ### # devices = ["sda", "sdb", "vd*"]
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"] ### # skip_serial_number = false
### # device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
[[inputs.kernel]] ### # name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
###
[[inputs.mem]] ### [[inputs.kernel]]
###
[[inputs.processes]] ### [[inputs.mem]]
###
[[inputs.swap]] ### [[inputs.processes]]
###
[[inputs.system]] ### [[inputs.swap]]
# fielddrop = ["uptime_format"] ###
### [[inputs.system]]
{{ telegraf_input_temp }} ### # fielddrop = ["uptime_format"]
###
marker: '# {mark} MANAGED BY ANSIBLE - telegraf.yml' ### {{ telegraf_input_temp }}
state: present ###
create: yes ### marker: '# {mark} MANAGED BY ANSIBLE - telegraf.yml'
### state: present
### create: yes
# Run # # Run #

View File

@ -1,48 +1,87 @@
--- ---
# Everything needed to install Brave # Everything needed to install Brave
- name: Workstation | Software | Brave | Pre-Reqs [apt] # 2024-05-23, No longer incude this software, has not been used since switching
package: # to Firefox months/years back for avoiding DRM and other junk Google stuff.
name: ###
- apt-transport-https ###- name: Workstation | Software | Brave | Pre-Reqs [apt]
state: present ### package:
when: ansible_pkg_mgr == "apt" ### name:
### - apt-transport-https
### state: present
### when: ansible_pkg_mgr == "apt"
###
###- name: Workstation | Software | Brave | Pre-Reqs [dnf]
### package:
### name:
### - dnf-plugins-core
### state: present
### when: ansible_pkg_mgr == "dnf"
###
#### https://brave.com/linux/#debian-ubuntu-mint
###- name: Workstation | Software | Brave | Add Repo [apt]
### shell: "{{ item }}"
### loop:
### - curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
### - echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | tee /etc/apt/sources.list.d/brave-browser-release.list
### - apt update
### when: ansible_pkg_mgr == "apt"
###
#### https://brave.com/linux/#fedora-centos-streamrhel
###- name: Workstation | Software | Brave | Add Repo [dnf]
### shell: "{{ item }}"
### loop:
### - dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/
### - rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
### when: ansible_pkg_mgr == "dnf"
###
#### https://brave.com/linux/#opensuse
###- name: Workstation | Software | Brave | Add Repo [zypper]
### shell: "{{ item }}"
### loop:
### - rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
### - zypper addrepo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
### when: ansible_pkg_mgr == "zypper"
### ignore_errors: yes
###
###- name: Workstation | Software | Brave | Install
### package:
### name:
### - brave-browser
### state: present
###
- name: Workstation | Software | Brave | Pre-Reqs [dnf] # Remove Brave Browser and Repos
package: # https://support.brave.com/hc/en-us/articles/4404876135565-How-do-I-uninstall-Brave
name:
- dnf-plugins-core
state: present
when: ansible_pkg_mgr == "dnf"
# https://brave.com/linux/#debian-ubuntu-mint - name: Workstation | Software | Brave | Remove
- name: Workstation | Software | Brave | Add Repo [apt]
shell: "{{ item }}"
loop:
- curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
- echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | tee /etc/apt/sources.list.d/brave-browser-release.list
- apt update
when: ansible_pkg_mgr == "apt"
# https://brave.com/linux/#fedora-centos-streamrhel
- name: Workstation | Software | Brave | Add Repo [dnf]
shell: "{{ item }}"
loop:
- dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/
- rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
when: ansible_pkg_mgr == "dnf"
# https://brave.com/linux/#opensuse
- name: Workstation | Software | Brave | Add Repo [zypper]
shell: "{{ item }}"
loop:
- rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
- zypper addrepo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
when: ansible_pkg_mgr == "zypper"
ignore_errors: yes
- name: Workstation | Software | Brave | Install
package: package:
name: name:
- brave-browser - brave-browser
state: present - brave-keyring
state: absent
ignore_errors: yes
- name: Workstation | Software | Brave | Remove Repo [apt]
shell: "{{ item }}"
loop:
- rm /etc/apt/sources.list.d/brave-browser-*.list
- apt update
when: ansible_pkg_mgr == "apt"
ignore_errors: yes
- name: Workstation | Software | Brave | Remove Repo [dnf]
shell: "{{ item }}"
loop:
- rm /etc/yum.repos.d/brave-browser-*.repo
- rpm -e gpg-pubkey-c2d4e821-5e7252b8
when: ansible_pkg_mgr == "dnf"
ignore_errors: yes
- name: Workstation | Software | Brave | Remove Repo [zypper]
shell: "{{ item }}"
loop:
- zypper removerepo brave-browser
- rpm -e gpg-pubkey-c2d4e821-5e7252b8
when: ansible_pkg_mgr == "zypper"
ignore_errors: yes

View File

@ -52,6 +52,7 @@
- { app: "com.obsproject.Studio", name: "obs", extra: "" } - { app: "com.obsproject.Studio", name: "obs", extra: "" }
- { app: "org.gimp.GIMP", name: "gimp", extra: "" } - { app: "org.gimp.GIMP", name: "gimp", extra: "" }
- { app: "org.openshot.OpenShot", name: "openshot", extra: "" } - { app: "org.openshot.OpenShot", name: "openshot", extra: "" }
- { app: "org.tenacityaudio.Tenacity", name: "tenacity", extra: "" }
flatpaks_gaming: flatpaks_gaming:
- { app: "com.valvesoftware.Steam", name: "steam", extra: "" } - { app: "com.valvesoftware.Steam", name: "steam", extra: "" }
- { app: "com.play0ad.zeroad", name: "zeroad", extra: "" } - { app: "com.play0ad.zeroad", name: "zeroad", extra: "" }

View File

@ -8,7 +8,7 @@
# Only do multiple entries per line if they are for the same exact program. # Only do multiple entries per line if they are for the same exact program.
gnome_favorites: "[ 'org.gnome.Terminal.desktop' gnome_favorites: "[ 'org.gnome.Terminal.desktop'
, 'org.gnome.Console.desktop' , 'org.gnome.Console.desktop'
, 'gnome-system-monitor.desktop' , 'gnome-system-monitor.desktop', 'org.gnome.SystemMonitor.desktop'
, 'org.gnome.Nautilus.desktop' , 'org.gnome.Nautilus.desktop'
, 'io.gitlab.librewolf-community.desktop', 'librewolf.desktop' , 'io.gitlab.librewolf-community.desktop', 'librewolf.desktop'
, 'org.mozilla.firefox.desktop', 'firefox.desktop' , 'org.mozilla.firefox.desktop', 'firefox.desktop'