From 76ec891138d64081f132fc94ac43b63f1bc1caae Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 2 Jan 2025 13:37:22 -0700 Subject: [PATCH 01/17] Add summarize parameter to check-trash. --- tasks/general/acct_mgmt/users.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 24d186e..e711c12 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -287,10 +287,13 @@ clean="Y" ;; -n | -net | --network ) network="Y" ;; + -s | -sum | --summarize ) + summarize="-s" ;; * ) echo " ERROR: Option '$1' with value '$2' not recognized. - $PROG [-c|-y|--clean] [-n|-net|--network] + $PROG [-c | -y | --clean] [-n | -net | --network] \ + [-s | -sum | --summarize] " >&2 return 1 ;; @@ -318,8 +321,8 @@ echo "Checking $dir..." $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 + echo "Found $trash:" + $sudo du -ha $summarize $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." $sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -328,8 +331,8 @@ 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 + echo "Found $trash:" + $sudo du -ha $summarize $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." $sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -345,8 +348,8 @@ echo "Checking $dir..." 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 + echo "Found $trash:" + sudo du -ha $summarize $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -355,8 +358,8 @@ 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 + echo "Found $trash:" + sudo du -ha $summarize $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" -- 2.47.2 From db3e610c913cda1e9920f91732ffa8ce752b0d95 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 2 Jan 2025 15:51:41 -0700 Subject: [PATCH 02/17] Add a `prod` alias similar to how the `env-termux` project does it. --- tasks/general/acct_mgmt/provision_config.yml | 26 ++++++++++++++++++-- tasks/general/acct_mgmt/users.yml | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tasks/general/acct_mgmt/provision_config.yml b/tasks/general/acct_mgmt/provision_config.yml index 00c3822..c56d261 100644 --- a/tasks/general/acct_mgmt/provision_config.yml +++ b/tasks/general/acct_mgmt/provision_config.yml @@ -35,11 +35,11 @@ ; ; user : Provide the name of the user account. ; Example: tom, jerry, kim, sarah - ; Default: ling + ; Default: user ; ; user_desc : Provide the description of the user account. ; Example: Thomas, Jerry, Kimberly, Sarah - ; Default: Hyperling + ; Default: User ; ; sshd_port : Determine the port which SSHD should listen on. ; Example: 12345 @@ -101,6 +101,22 @@ ; Slows down the rate of services such as telegraf and cron. ; Default: false ; + ;;;;;;;;;;;;;;;;;;;; Server Shortcut ;;;;;;;;;;;;;;;;;;;; + ; + ; For typing `prod` and getting straight to a server, like in env-termux. + ; + ; prod_host : Branch to use on this machine. + ; Example: myserver.com, mywebhost.net + ; Default: hyperling.com + ; + ; prod_port : Provide the git host that the machine should poll. + ; Example: 22, 222, 2222 + ; Default: 22 + ; + ; prod_user : Port of the server host to use for SSH requests. + ; Example: jim, bob, jeff, anne + ; Default: user + ; [global] marker: '; {mark} MANAGED BY ANSIBLE | Generic Config' state: present @@ -124,6 +140,9 @@ git_user: "{{ lookup('ini', 'git_user file={{gen_file}} default=me') }}" git_project: "{{ lookup('ini', 'git_project file={{gen_file}} default=env-ansible') }}" git_ssh_port: "{{ lookup('ini', 'git_ssh_port file={{gen_file}} default=22') }}" + prod_host: "{{ lookup('ini', 'prod_host file={{gen_file}} default=hyperling.com') }}" + prod_port: "{{ lookup('ini', 'prod_port file={{gen_file}} default=22') }}" + prod_user: "{{ lookup('ini', 'prod_user file={{gen_file}} default=user') }}" - name: General | Account Management | Provisioning Configuration | General | List set_fact: @@ -144,6 +163,9 @@ - { 'git_user': "{{ git_user }}" } - { 'git_project': "{{ git_project }}" } - { 'git_ssh_port': "{{ git_ssh_port }}" } + - { 'prod_host': "{{ prod_host }}" } + - { 'prod_port': "{{ prod_port }}" } + - { 'prod_user': "{{ prod_user }}" } ## Workstation ## diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index e711c12..66e219b 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -558,6 +558,8 @@ fi alias_scan: | alias scan="nmap -A -p- --script=vuln" + alias_prod: | + alias prod="ssh -p {{ prod_port }} {{ prod_user }}@{{ prod_host }}" - name: General | Account Management | Users | Files | Common Variable set_fact: @@ -599,6 +601,7 @@ {{ export_hyperling }} {{ source_docker_env }} {{ alias_scan }} + {{ alias_prod }} - name: General | Account Management | Users | Files | .bashrc blockinfile: -- 2.47.2 From ae3112d969c0b4d9ff3b60a4f95e370dc22b72c7 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 2 Jan 2025 15:59:50 -0700 Subject: [PATCH 03/17] Fix the new summarize feature on check-trash. --- tasks/general/acct_mgmt/users.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 66e219b..3c5af85 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -281,6 +281,7 @@ unset OPTIND unset clean unset network + du_params="-ha" while (( $# > 0 )); do case $1 in -c | -y | --clean ) @@ -288,7 +289,7 @@ -n | -net | --network ) network="Y" ;; -s | -sum | --summarize ) - summarize="-s" ;; + du_params="-sh" ;; * ) echo " ERROR: Option '$1' with value '$2' not recognized. @@ -322,7 +323,7 @@ $sudo find $dir -name TRASH | while read trash; do if [[ "$trash" != "" && `$sudo ls -a $trash` ]]; then echo "Found $trash:" - $sudo du -ha $summarize $trash | sort -h + $sudo du $du_params $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." $sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -332,7 +333,7 @@ $sudo find $dir $maxdepth -name "*"Trash"*" | while read trash; do if [[ "$trash" != "" && `$sudo ls -a $trash` ]]; then echo "Found $trash:" - $sudo du -ha $summarize $trash | sort -h + $sudo du $du_params $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." $sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -349,7 +350,7 @@ sudo find $dir -name TRASH | while read trash; do if [[ "$trash" != "" && `sudo ls -a $trash` ]]; then echo "Found $trash:" - sudo du -ha $summarize $trash | sort -h + sudo du $du_params $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" @@ -359,7 +360,7 @@ sudo find $dir -name .Trash"*" | while read trash; do if [[ "$trash" != "" && `sudo ls -a $trash` ]]; then echo "Found $trash:" - sudo du -ha $summarize $trash | sort -h + sudo du $du_params $trash | sort -h if [[ "$clean" == "Y" ]]; then echo "Cleaning trash..." sudo sh -c "cd $trash; rm -rfv ..?* .[!.]* *" -- 2.47.2 From 391129e19b9a988f35910a438eb5748c7715723b Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 3 Jan 2025 12:31:51 -0700 Subject: [PATCH 04/17] Give the desktop update function nice output like just done in Termux. --- facts/general/package.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/facts/general/package.yml b/facts/general/package.yml index bd07628..bcfd018 100644 --- a/facts/general/package.yml +++ b/facts/general/package.yml @@ -95,30 +95,39 @@ case $pkg_mgr in apt) if [[ $distribution != "ParrotOS" ]]; then - echo "*** Apt ***" && + echo -e "******* Apt *******\n*** Update Cache ***" && sudo apt update && + echo -e "\n*** Auto Remove ***" && sudo apt autoremove {{ update_accept_var }} && + echo -e "\n*** Clean ***" && sudo apt clean {{ update_accept_var }} && + echo -e "Cleaned!\n\n*** Configure DPKG ***" && sudo dpkg --configure -a && + echo -e "\n*** Fix Broken/Missing ***" && sudo apt --fix-broken --fix-missing install && + echo -e "\n*** Upgrade ***" && sudo apt dist-upgrade --allow-downgrades --fix-broken \ --fix-missing {{ update_accept_var }} || return 1 else - echo "*** Parrot ***" + echo -e "******* Parrot *******\n*** Update Cache ***" && sudo apt update && + echo -e "\n*** Auto Remove ***" && sudo apt autoremove {{ update_accept_var }} && parrot_mirrors_suck=true && while [[ $parrot_mirrors_suck ]]; do unset parrot_mirrors_suck + echo -e "\n*** Upgrade ***" sudo parrot-upgrade if [[ $? != 0 ]]; then parrot_mirrors_suck=true + echo -e "*** Update Cache, Again ***" sudo apt update --fix-missing fi done || return 1 fi + echo -e "\n******* Mission Complete!! *******" ;; pacman) -- 2.47.2 From 3dffbc11db24307cde58e85057d8cf64a3a67452 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 5 Jan 2025 16:59:37 -0700 Subject: [PATCH 05/17] Fancify the `editing` setting to allow only audio or only video programs. Move GIMP to Generic so that it's always installed.. --- tasks/general/acct_mgmt/provision_config.yml | 4 + .../workstation/freebsd/software/packages.yml | 20 ++--- tasks/workstation/linux/software/flatpaks.yml | 75 +++++++++++++++---- tasks/workstation/linux/software/packages.yml | 2 +- tasks/workstation/mac-os/software/brew.yml | 14 +++- 5 files changed, 87 insertions(+), 28 deletions(-) diff --git a/tasks/general/acct_mgmt/provision_config.yml b/tasks/general/acct_mgmt/provision_config.yml index c56d261..b1de527 100644 --- a/tasks/general/acct_mgmt/provision_config.yml +++ b/tasks/general/acct_mgmt/provision_config.yml @@ -181,6 +181,10 @@ ; coding : Set to true for installation of code editors (VSCode, PyCharm, Android Studio) ; ; editing : Set to true for installation of Audio/Video editors (Shotcut, Audacity, OBS Stdio, GIMP) + ; Set to video for only the video related portions. + ; - Shotcut, OpenShot, OBS Studio, etc. + ; Set to audio for only the music related portions. + ; - Audacity (or similar), LMMS, VMPK, etc. ; ; gaming : Set to true for installation of gaming software (Steam, Lutris) ; diff --git a/tasks/workstation/freebsd/software/packages.yml b/tasks/workstation/freebsd/software/packages.yml index 3ea36ed..4562427 100644 --- a/tasks/workstation/freebsd/software/packages.yml +++ b/tasks/workstation/freebsd/software/packages.yml @@ -4,7 +4,7 @@ # General # - name: Workstation | FreeBSD | Software | Packages | General | Install - package: + package: name: - "{{ firefox_esr }}" - "{{ evolution }}" @@ -13,7 +13,7 @@ state: present - name: Workstation | FreeBSD | Software | Packages | General | Uninstall Bloat - package: + package: name: - "{{ firefox }}" - "{{ thunderbird }}" @@ -22,14 +22,14 @@ # Coding # - name: Workstation | FreeBSD | Software | Packages | Coding | Install - package: + package: name: - vscode state: present when: coding == true - name: Workstation | FreeBSD | Software | Packages | Coding | Install - package: + package: name: - vscode state: absent @@ -38,27 +38,27 @@ # Media Editors # - name: Workstation | FreeBSD | Software | Packages | Editing | Install - package: + package: name: - gimp - shotcut - obs-studio state: present - when: editing == true + when: editing in (true, "video") - name: Workstation | FreeBSD | Software | Packages | Editing | Install - package: + package: name: - gimp - shotcut - obs-studio state: absent - when: not editing == true + when: not editing in (true, "video") # Gaming # - name: Workstation | FreeBSD | Software | Packages | Gaming | Install - package: + package: name: - 0ad - supertuxkart @@ -66,7 +66,7 @@ when: gaming == true - name: Workstation | FreeBSD | Software | Packages | Gaming | Install - package: + package: name: - 0ad - supertuxkart diff --git a/tasks/workstation/linux/software/flatpaks.yml b/tasks/workstation/linux/software/flatpaks.yml index 52850ca..0041a47 100644 --- a/tasks/workstation/linux/software/flatpaks.yml +++ b/tasks/workstation/linux/software/flatpaks.yml @@ -40,17 +40,18 @@ - { app: "org.signal.Signal", name: "signal", extra: "" } - { app: "org.mozilla.firefox", name: "firefox-flatpak", extra: "" } - { app: "com.transmissionbt.Transmission", name: "transmission", extra: "" } + - { app: "org.gimp.GIMP", name: "gimp", extra: "" } flatpaks_coding: - { app: "com.vscodium.codium", name: "codium", extra: "" } - { app: "com.google.AndroidStudio", name: "android-studio", extra: "" } - { app: "io.dbeaver.DBeaverCommunity", name: "dbeaver", extra: "" } - { app: "org.godotengine.Godot", name: "godot", extra: "" } - { app: "com.visualstudio.code-oss", name: "code", extra: "" } - flatpaks_editing: + flatpaks_editing_video: - { app: "org.shotcut.Shotcut", name: "shotcut", extra: "" } - { app: "com.obsproject.Studio", name: "obs", extra: "" } - - { app: "org.gimp.GIMP", name: "gimp", extra: "" } - { app: "org.openshot.OpenShot", name: "openshot", extra: "" } + flatpaks_editing_audio: - { app: "org.tenacityaudio.Tenacity", name: "tenacity", extra: "" } - { app: "io.lmms.LMMS", name: "lmms", extra: "" } - { app: "net.sourceforge.VMPK", name: "vmpk", extra: "" } @@ -158,14 +159,62 @@ # Media Editors # -- name: Workstation | Linux | Flatpak Distro | Flatpak | Audio/Video Editors | Installs +- name: Workstation | Linux | Flatpak Distro | Flatpak | Video Editors | Installs flatpak: name: "{{ item.app }}" remote: flathub state: present - loop: "{{ flatpaks_editing }}" + loop: "{{ flatpaks_editing_video }}" ignore_errors: yes - when: editing == true + when: editing in (true, "video") + +- name: Workstation | Linux | Flatpak Distro | Flatpak | Video Editors | Executables + blockinfile: + path: "{{ flatpak_exec_dir }}/{{ item.name }}" + block: | + {{ item.extra }} {{ flatpak_exec }} {{ item.app }} + marker: '{mark}' + marker_begin: "#!{{ bash_exec.stdout }}" + marker_end: "exit 0" + state: present + create: yes + loop: "{{ flatpaks_editing_video }}" + become_user: "{{ user }}" + when: editing in (true, "video") + +- name: Workstation | Linux | Flatpak Distro | Flatpak | Video Editors | Executable Permissions + file: + path: "{{ flatpak_exec_dir }}/{{ item.name }}" + state: file + mode: '0755' + loop: "{{ flatpaks_editing_video }}" + when: editing in (true, "video") + +- name: Workstation | Linux | Flatpak Distro | Flatpak | Video Editor Uninstalls + flatpak: + name: "{{ item.app }}" + remote: flathub + state: absent + loop: "{{ flatpaks_editing_video }}" + ignore_errors: yes + when: not editing in (true, "video") + +- name: Workstation | Linux | Flatpak Distro | Flatpak | Video Editors | Remove Executables + file: + path: "{{ flatpak_exec_dir }}/{{ item.name }}" + state: absent + loop: "{{ flatpaks_editing_video }}" + ignore_errors: yes + when: not editing in (true, "video") + +- name: Workstation | Linux | Flatpak Distro | Flatpak | Audio Editors | Installs + flatpak: + name: "{{ item.app }}" + remote: flathub + state: present + loop: "{{ flatpaks_editing_audio }}" + ignore_errors: yes + when: editing in (true, "audio") - name: Workstation | Linux | Flatpak Distro | Flatpak | Audio/Video Editors | Executables blockinfile: @@ -177,34 +226,34 @@ marker_end: "exit 0" state: present create: yes - loop: "{{ flatpaks_editing }}" + loop: "{{ flatpaks_editing_audio }}" become_user: "{{ user }}" - when: editing == true + when: editing in (true, "audio") - name: Workstation | Linux | Flatpak Distro | Flatpak | Audio/Video Editors | Executable Permissions file: path: "{{ flatpak_exec_dir }}/{{ item.name }}" state: file mode: '0755' - loop: "{{ flatpaks_editing }}" - when: editing == true + loop: "{{ flatpaks_editing_audio }}" + when: editing in (true, "audio") - name: Workstation | Linux | Flatpak Distro | Flatpak | Audio/Video Editor Uninstalls flatpak: name: "{{ item.app }}" remote: flathub state: absent - loop: "{{ flatpaks_editing }}" + loop: "{{ flatpaks_editing_audio }}" ignore_errors: yes - when: not editing == true + when: not editing in (true, "audio") - name: Workstation | Linux | Flatpak Distro | Flatpak | Audio/Video Editors | Remove Executables file: path: "{{ flatpak_exec_dir }}/{{ item.name }}" state: absent - loop: "{{ flatpaks_editing }}" + loop: "{{ flatpaks_editing_audio }}" ignore_errors: yes - when: not editing == true + when: not editing in (true, "audio") # Gaming # diff --git a/tasks/workstation/linux/software/packages.yml b/tasks/workstation/linux/software/packages.yml index 78bccf4..8d72d8b 100644 --- a/tasks/workstation/linux/software/packages.yml +++ b/tasks/workstation/linux/software/packages.yml @@ -24,7 +24,7 @@ name: - "{{ ffmpeg }}" state: present - when: editing == true + when: editing in (true, "video", "audio") ## Other Stuff diff --git a/tasks/workstation/mac-os/software/brew.yml b/tasks/workstation/mac-os/software/brew.yml index 26c7c90..1dc9920 100644 --- a/tasks/workstation/mac-os/software/brew.yml +++ b/tasks/workstation/mac-os/software/brew.yml @@ -1,5 +1,5 @@ --- -# Download packages from Homebrew. +# Download packages from Homebrew. # Should this just be done in a Generic view? Is this really mac-specific, or just the facts? # FreeBSD has its own. May be good to keep it separate so it's more to-the-point. @@ -22,13 +22,19 @@ status: present when: coding == true -- name: Workstation | Mac OS | Software | Brew | Install Packages (Editing) +- name: Workstation | Mac OS | Software | Brew | Install Packages (Editing:Video) + package: + name: + - shotcut + status: present + when: editing in (true, "video") + +- name: Workstation | Mac OS | Software | Brew | Install Packages (Editing:Audio) package: name: - audacity - - shotcut status: present - when: editing == true + when: editing in (true, "audio") - name: Workstation | Mac OS | Software | Brew | Install Packages (Gaming) package: -- 2.47.2 From eba289c1d764d5ccaaf4704c16e752b196cc426f Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 9 Jan 2025 11:37:42 -0700 Subject: [PATCH 06/17] Automatically exclude unnecessary Android files when copying data. --- tasks/general/acct_mgmt/users.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 3c5af85..7320494 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -547,7 +547,7 @@ echo -e "\nDone!\n" } alias_clone: | - alias clone="rsync -auPhz --delete" + alias clone="rsync -auPhz --delete --exclude '.gradle' --exclude 'app/build'" export_hyperling: | export HYPERLING6="2a07:e03:3:80::1" export HYPERLING4="185.130.47.173" -- 2.47.2 From 658f13d74aed0d7e6b509eebea2accfe2b0a2171 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 9 Jan 2025 13:25:23 -0700 Subject: [PATCH 07/17] Add helper to clean up Code folder. --- tasks/general/acct_mgmt/users.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index 7320494..d8a3fd4 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -561,6 +561,17 @@ alias scan="nmap -A -p- --script=vuln" alias_prod: | alias prod="ssh -p {{ prod_port }} {{ prod_user }}@{{ prod_host }}" + function_clean_code: | + function clean-code { + echo -e "******* Android *******\n*** Build Caches ***" + find ~/Code/android-*/app -maxdepth 1 -type d -name "build" \ + -exec du -hs {} \; -exec rm -rf {} \; + echo -e "\n*** Gradle Caches ***" + find ~/Code/android-*/ -maxdepth 1 -type d -name ".gradle" \ + -exec du -hs {} \; -exec rm -rf {} \; + + echo -e "\n*** Done! ***" + } - name: General | Account Management | Users | Files | Common Variable set_fact: @@ -603,6 +614,7 @@ {{ source_docker_env }} {{ alias_scan }} {{ alias_prod }} + {{ function_clean_code }} - name: General | Account Management | Users | Files | .bashrc blockinfile: -- 2.47.2 From 7cd8fc4eac3fc26acf61ef91ccf8b823c77941d0 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 9 Jan 2025 16:26:40 -0700 Subject: [PATCH 08/17] Add alias for command so that it is consistent with `code-check`, `code-reseed`, etc. --- tasks/general/acct_mgmt/users.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/general/acct_mgmt/users.yml b/tasks/general/acct_mgmt/users.yml index d8a3fd4..b80f432 100644 --- a/tasks/general/acct_mgmt/users.yml +++ b/tasks/general/acct_mgmt/users.yml @@ -572,6 +572,7 @@ echo -e "\n*** Done! ***" } + alias code-clean="clean-code" - name: General | Account Management | Users | Files | Common Variable set_fact: -- 2.47.2 From aa97e9ba6ea5bf2a5b3ae0b310650333838c5950 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 9 Jan 2025 17:23:37 -0700 Subject: [PATCH 09/17] Add `adb` to the default workstation packages. --- tasks/workstation/linux/software/packages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/workstation/linux/software/packages.yml b/tasks/workstation/linux/software/packages.yml index 8d72d8b..c8b1db6 100644 --- a/tasks/workstation/linux/software/packages.yml +++ b/tasks/workstation/linux/software/packages.yml @@ -38,6 +38,7 @@ - "{{ appimagelauncher }}" - "{{ evolution }}" - "{{ evolution }}*" + - adb state: present # Lutris # -- 2.47.2 From 8fc05c43b574f91a102d30316edd965b356f86ec Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 9 Jan 2025 17:24:36 -0700 Subject: [PATCH 10/17] Add fastboot too! --- tasks/workstation/linux/software/packages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/workstation/linux/software/packages.yml b/tasks/workstation/linux/software/packages.yml index c8b1db6..c0b0fd9 100644 --- a/tasks/workstation/linux/software/packages.yml +++ b/tasks/workstation/linux/software/packages.yml @@ -39,6 +39,7 @@ - "{{ evolution }}" - "{{ evolution }}*" - adb + - fastboot state: present # Lutris # -- 2.47.2 From 4a3ac3622f83d7017af4fdee75d44980fcd69198 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 19 Jan 2025 12:41:16 -0700 Subject: [PATCH 11/17] Allow shrinking a shrunk image. Add size to tag. Add defaults to usage. Tested successfully! --- files/scripts/compress_image.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/files/scripts/compress_image.sh b/files/scripts/compress_image.sh index 9b647ac..0bc32cc 100755 --- a/files/scripts/compress_image.sh +++ b/files/scripts/compress_image.sh @@ -34,9 +34,12 @@ function usage() { Parameters: -s SIZE : Integer for the maximum length of either image dimension. + Default size is 2000. -l LOCATION : The specific image or folder which needs images shrunk. + Default location is the current directory. -r : Recursively shrink images based on the location passed. -f : Force the image to be shrunk even if a file already exists for it. + -F : FORCE the image to be shrunk even if the file is already shrunk. -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. @@ -48,12 +51,13 @@ function usage() { ## Parameters ## -while getopts ":s:l:rfdcAhx" opt; do +while getopts ":s:l:rfFdcAhx" opt; do case $opt in s) in_size="$OPTARG" && size="$in_size" ;; l) location="$OPTARG" ;; r) recurse="Y" && search="find" ;; f) force="Y" ;; + F) super_force="Y" ;; d) delete="Y" ;; c) clean="Y" ;; A) recurse="Y" && search="find" && force="Y" && delete="Y" && clean="Y" ;; @@ -90,8 +94,8 @@ $search "$location" | sort | while read image; do # Avoid processing directories no matter the name. [ -d "$image" ] && continue - # Avoid processing files previously shrunk. - [[ "$image" == *"$tag"* ]] && continue + # Avoid processing files previously shrunk, unless we are FORCEing. + [[ "$image" == *"$tag"* && -z "$super_force" ]] && continue echo -e "\n$image" @@ -107,7 +111,7 @@ $search "$location" | sort | while read image; do fi - new_image="${image//.$extension/}.$tag-$date_YYYYMMDD.$extension" + new_image="${image//.$extension/}.$tag-$date_YYYYMMDD-$size.$extension" ## Clean Filename ## # Prevent directory from having its name cleaned too. -- 2.47.2 From e69b5d2d338347d9dc72fac9471882b971378849 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 19 Jan 2025 16:37:02 -0700 Subject: [PATCH 12/17] Determine default video bitrates based on dimensions. Add file options to extension. Fix shrinking to certain sizes by using -2 as width. Tested successfully! --- files/scripts/compress_video.sh | 37 ++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/files/scripts/compress_video.sh b/files/scripts/compress_video.sh index 9939667..f172177 100755 --- a/files/scripts/compress_video.sh +++ b/files/scripts/compress_video.sh @@ -32,7 +32,14 @@ function usage { -i input : The input file or folder with which to search for video files. If nothing is provided, current directory (.) is assumed. -v bitrate : The video bitrate to convert to. - Defaults to '2000k'. + Defaults are based on the size passed. + >= 2160: '30M' + >= 1440: '12M' + >= 1080: '5M' + >= 720: '2000k' + >= 480: '750k' + >= 360: '250k' + < 360: '100k' -a bitrate : The audio bitrate to convert to. Defaults to '192k'. -c vcodec : The video codec you'd like to use, such as libopenh264. @@ -96,13 +103,30 @@ if [[ -z "$input" ]]; then fi if [[ -z "$video_bitrate" ]]; then - video_bitrate="2000k" + # Based roughly on the 2.5 step iteration used for 720 and 1080. + if (( $size >= 2160 )); then + video_bitrate="30M" + elif (( $size >= 1440 )); then + video_bitrate="12M" + elif (( $size >= 1080 )); then + video_bitrate="5M" + elif (( $size >= 720 )); then + video_bitrate="2000k" + elif (( $size >= 480 )); then + video_bitrate="750k" + elif (( $size >= 360 )); then + video_bitrate="250k" + else + video_bitrate="100k" + fi fi +compress_tags="$video_bitrate" video_bitrate="-b:v $video_bitrate -minrate 0 -maxrate $video_bitrate -bufsize $video_bitrate" if [[ -z "$audio_bitrate" ]]; then audio_bitrate="192k" fi +compress_tags="$compress_tags-$audio_bitrate" audio_bitrate="-b:a $audio_bitrate" if [[ -z "$codec" ]]; then @@ -124,7 +148,11 @@ fi if [[ -z $size ]]; then size="720" fi -size="-filter:v scale=-1:$size" +while (( ${#size} < 4 )); do + size="0$size" +done +compress_tags="$size-$compress_tags" +size="-filter:v scale=-2:$size" ## Main ## @@ -172,6 +200,9 @@ $search_command "$input" | sort | while read file; do # Build the new filename to signify it is different than the original. newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension_lower}" + # Add the size, video, and audio quality it was converted to. + newfile="${newfile//\.$extension_lower/_$compress_tags.$extension_lower}" + if [[ $newfile == $file ]]; then echo "ERROR: The new calculated filename matches the old, skipping." >&2 continue -- 2.47.2 From 95d1f714912d510e757323703692f69b07830489 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 20 Jan 2025 17:17:32 -0700 Subject: [PATCH 13/17] Add flutter and dependencies. --- local.yml | 4 +- tasks/workstation/linux/software/flutter.yml | 150 +++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 tasks/workstation/linux/software/flutter.yml diff --git a/local.yml b/local.yml index c582912..96db67f 100644 --- a/local.yml +++ b/local.yml @@ -75,7 +75,6 @@ - include_tasks: tasks/general/software/sendmail.yml when: ansible_system == "FreeBSD" - # Gather again in case missing programs have now been installed. - include_tasks: facts/general/gather.yml @@ -154,6 +153,9 @@ - include_tasks: tasks/workstation/shared/settings/services.yml # Final Tasks (SLOW) # + - include_tasks: tasks/workstation/linux/software/flutter.yml + when: ansible_system == "Linux" + - include_tasks: tasks/workstation/linux/software/flatpaks.yml when: ansible_system == "Linux" and flatpak_distro diff --git a/tasks/workstation/linux/software/flutter.yml b/tasks/workstation/linux/software/flutter.yml new file mode 100644 index 0000000..bb99d70 --- /dev/null +++ b/tasks/workstation/linux/software/flutter.yml @@ -0,0 +1,150 @@ +--- +# Packages specific to workstations developing Flutter apps. + +## Facts ## + +- name: Workstation | Linux | Software | Flutter | Facts [1/2] + set_fact: + flutter_url: "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.27.2-stable.tar.xz" + flutter_download_file: "{{ user_user.home }}/Downloads/flutter.tar.xz" + flutter_sdk_location: "{{ user_user.home }}/SDKs/Flutter" + flutter_report: "{{ user_user.home }}/Reports/flutter.txt" + +- name: Workstation | Linux | Software | Flutter | Facts [2/2] + set_fact: + flutter_bin_location: "{{ flutter_sdk_location }}/flutter/bin" + +## Checks ## + +- name: Workstation | Linux | Software | Flutter | Check SDK Exists + stat: + path: "{{ flutter_sdk_location }}" + register: flutter_sdk_stat + +- name: Workstation | Linux | Software | Flutter | Check Download Exists + stat: + path: "{{ flutter_download_file }}" + register: flutter_download_stat + +## Packages ## + +- name: Workstation | Linux | Software | Flutter | Necessities + package: + name: + - curl + - git + - unzip + - xz-utils + - zip + - libglu1-mesa + state: present + when: coding == true + +# https://docs.flutter.dev/get-started/install/linux/desktop +- name: Workstation | Linux | Software | Flutter | Linux App Dependencies + package: + name: + - clang + - cmake + - git + - ninja-build + - pkg-config + - libgtk-3-dev + - liblzma-dev + - libstdc++-12-dev + state: present + when: coding == true + +# https://docs.flutter.dev/get-started/install/linux/android +- name: Workstation | Linux | Software | Flutter | Android App Dependencies + package: + name: + - libc6:amd64 + - libstdc++6:amd64 + - lib32z1 + - libbz2-1.0:amd64 + state: present + when: coding == true + +## Install SDK ## + +- name: Workstation | Linux | Software | Flutter | SDK + block: + + - name: Workstation | Linux | Software | Flutter | Download SDK + get_url: + url: "{{ flutter_url }}" + dest: "{{ flutter_download_file }}" + owner: "{{ user }}" + mode: '0664' + when: not flutter_download_stat.stat.exists + + - name: Workstation | Linux | Software | Flutter | Create Folder + file: + path: "{{ flutter_sdk_location }}" + state: directory + owner: "{{ user }}" + mode: '0755' + + - name: Workstation | Linux | Software | Flutter | Extract SDK + unarchive: + src: "{{ flutter_download_file }}" + dest: "{{ flutter_sdk_location }}" + owner: "{{ user }}" + + when: coding == true and not flutter_sdk_stat.stat.exists + +- name: Workstation | Linux | Software | Flutter | Delete Archive + file: + path: "{{ flutter_download_file }}" + state: absent + +## Configure Environment ## + +- name: Workstation | Linux | Software | Flutter | Modify PATH (.bashrc) + blockinfile: + path: "{{ item }}/.bashrc" + block: | + export PATH="$PATH:{{ flutter_bin_location }}" + marker: '# {mark} MANAGED BY ANSIBLE | Flutter' + state: present + create: yes + backup: yes + loop: + - "{{ user_root.home }}" + - "{{ user_user.home }}" + ignore_errors: yes + when: coding == true and user_root.home != "" and user_user.home != "" + +- name: Workstation | Linux | Software | Flutter | Modify PATH (.zshrc) + blockinfile: + path: "{{ item }}/.zshrc" + block: | + export PATH="$PATH:{{ flutter_bin_location }}" + marker: '# {mark} MANAGED BY ANSIBLE | Flutter' + state: present + create: yes + backup: yes + loop: + - "{{ user_root.home }}" + - "{{ user_user.home }}" + ignore_errors: yes + when: coding == true and user_root.home != "" and user_user.home != "" + +## Test SDK ## + +- name: Workstation | Linux | Software | Flutter | Doctor Report + shell: "{{ item }}" + loop: + - "date > {{ flutter_report }}" + - "{{ flutter_bin_location }}/flutter doctor -v >> {{ flutter_report }}" + - "date >> {{ flutter_report }}" + when: coding == true + +## Uninstall SDK ## + +- name: Workstation | Linux | Software | Flutter | Remove SDK + file: + path: "{{ flutter_sdk_location }}" + state: absent + when: not coding == true -- 2.47.2 From 127820d97114e736cf3756f730c79c0c105e92ee Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 20 Jan 2025 17:20:20 -0700 Subject: [PATCH 14/17] Disable analytics as part of the report. --- tasks/workstation/linux/software/flutter.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasks/workstation/linux/software/flutter.yml b/tasks/workstation/linux/software/flutter.yml index bb99d70..8a76796 100644 --- a/tasks/workstation/linux/software/flutter.yml +++ b/tasks/workstation/linux/software/flutter.yml @@ -131,12 +131,18 @@ ignore_errors: yes when: coding == true and user_root.home != "" and user_user.home != "" +## Disable Analytics ## + +flutter --disable-analytics + ## Test SDK ## - name: Workstation | Linux | Software | Flutter | Doctor Report shell: "{{ item }}" loop: - "date > {{ flutter_report }}" + - "{{ flutter_bin_location }}/flutter --disable-analytics >> {{ flutter_report }}" + - "date >> {{ flutter_report }}" - "{{ flutter_bin_location }}/flutter doctor -v >> {{ flutter_report }}" - "date >> {{ flutter_report }}" when: coding == true -- 2.47.2 From 135ef241dabe5c30c6a54b319c505489f9543815 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 20 Jan 2025 17:26:35 -0700 Subject: [PATCH 15/17] Remove extra text. --- tasks/workstation/linux/software/flutter.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tasks/workstation/linux/software/flutter.yml b/tasks/workstation/linux/software/flutter.yml index 8a76796..50cd305 100644 --- a/tasks/workstation/linux/software/flutter.yml +++ b/tasks/workstation/linux/software/flutter.yml @@ -131,10 +131,6 @@ ignore_errors: yes when: coding == true and user_root.home != "" and user_user.home != "" -## Disable Analytics ## - -flutter --disable-analytics - ## Test SDK ## - name: Workstation | Linux | Software | Flutter | Doctor Report -- 2.47.2 From 33705520708f27749e55c9dc4236690c3588ec64 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 20 Jan 2025 17:40:04 -0700 Subject: [PATCH 16/17] Need to have Code OSS back since Flutter wipes the workspace setup. Either it or Codium should be dedicated to Flutter, and the other will be all the other projects. --- tasks/workstation/shared/settings/gnome.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/workstation/shared/settings/gnome.yml b/tasks/workstation/shared/settings/gnome.yml index f36be37..d81bfb8 100644 --- a/tasks/workstation/shared/settings/gnome.yml +++ b/tasks/workstation/shared/settings/gnome.yml @@ -17,6 +17,7 @@ , 'org.telegram.desktop.desktop' , 'com.discordapp.Discord.desktop' , 'com.vscodium.codium.desktop' + , 'com.visualstudio.code-oss.desktop', 'code-oss.desktop' , 'com.google.AndroidStudio.desktop' , 'org.shotcut.Shotcut.desktop' , 'io.lmms.LMMS.desktop' @@ -33,7 +34,6 @@ #, 'org.mozilla.Thunderbird.desktop' # 2025-01-01 # Reduce the amount of icons on the sidebar, things that may get added back. -#, 'com.visualstudio.code-oss.desktop', 'code-oss.desktop' #, 'org.godotengine.Godot.desktop' - name: Workstation | Account Management | GNOME | Facts (NixOS) -- 2.47.2 From b387fe2c2a32801ac8ccf2c10ddbd1ae1f86c313 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 29 Jan 2025 11:22:15 -0700 Subject: [PATCH 17/17] Pull from the git repo rather than creating a local directory. --- tasks/general/scripts/root.yml | 4 +--- tasks/general/scripts/user.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tasks/general/scripts/root.yml b/tasks/general/scripts/root.yml index 26b88c3..6c3f9f7 100644 --- a/tasks/general/scripts/root.yml +++ b/tasks/general/scripts/root.yml @@ -6,9 +6,7 @@ path: "{{ user_root.home }}/bin/scm.sh" block: | # 20210211 - Make life easier! - git clone {{ git_repo_http }} ansible-pull - ansible-pull/setup.sh - mv ansible-pull ~/TRASH/ + time {{ ansible_pull_exec.stdout }} -U {{ git_repo_http }} marker: '{mark}' marker_begin: "#!{{ bash_exec.stdout }}" marker_end: "exit 0" diff --git a/tasks/general/scripts/user.yml b/tasks/general/scripts/user.yml index 87a51e0..3e6804c 100644 --- a/tasks/general/scripts/user.yml +++ b/tasks/general/scripts/user.yml @@ -6,9 +6,7 @@ path: "{{ user_user.home }}/bin/scm.sh" block: | # 20210211 - Make life easier! - git clone {{ git_repo_http }} ansible-pull - ansible-pull/setup.sh - mv ansible-pull ~/TRASH/ + time {{ ansible_pull_exec.stdout }} -U {{ git_repo_http }} marker: '{mark}' marker_begin: "#!{{ bash_exec.stdout }}" marker_end: "exit 0" -- 2.47.2