General Enhancements, NixOS Support (#47)

* Begin adding Nix.

* Install LBRY from Nix since its Flatpak is no longer supported..

* Got the global install to work, now just figuring out why LBRY won't work.

* Add alias to blow away dev branch and start back up from remote or main.

* Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems.

* Start working on having a path for NixOS.

* Add NixOS.

* Skip the installer portion if using NixOS.

* Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix.

* This should have never been added. Was an accident if it snuck though.

* Test using env rather than hard-coded bash path.

* Use variables, start thinking about future.

* Add file to manage setting up NixOS for the first or any subsequent times.

* Use the new nixos.sh script.

* Ensure /usr/local/bin is in PATH.

* Do not use * inside of "" for ls.

* Add filename cleanup shortcut.

* Add a clean option as well as a few bugfixes and checking that convert is installed.

* Use underscores in filenames and remove plurality.

* Bring the file into better column compliance.

* Stop running the dconf psutil failures against NixOS for now.

* Ensure the old names of scripts are removed from bin.

* Clean filename fixes as well as a traversing version.

* Remove extra spacing.

* Begin adding swapfile creation.

* Add dangerous code reset command.

* Add some cleaning for NixOS package manager.

* The ~ was being taken literally and created as a new folder.

* More work on swap files, and a new ansible.nix file.

* Fix the swap confuration line.

* Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence.

* Reorder and enhance the update function for NixOS.

* Add comment.

* Start working on dconf for NixOS since don't have home-manager working yet in configration.nix.

* Add notes.

* If the file was created, make sure the user owns it and can edit by default.

* Favorites are working and only need maintained in one place! :)

* Add .zshrc for GNOME settings on NixOS.

* Add most other settings that are done manually post-install. Report any failures with their placement.

* FINALLY! Keyboard shortcuts and some final Gnome Tweak settings!

* Add night light settings.

* Move around some comments.

* Pull first then deal with any merge issues, rather than trying to push when there are things to pull.

* Test removing the dconf commands for non-NixOS.

* Alter output; remove extra newlines and add cache verbosity.

* dconf in rc files is working on Ubuntu!

* Add delete. Fix filename quotes. Other enhancements.

* Create new folder chain if clean changed directory names.

* Add TBD about changing the directory structure.

* Only say success if the file really exists. Skip if conversion fails.

* Only say success if the file really exists. Skip if conversion fails.

* Add quotes around dirname.

* Add quotes around the entire directory tree.

* Add quotes to comment in case it ever gets used.

* Add a bittorrent client.

* Disable Bluetooth on all devices, it's normally off anyways.

* Fix comments, this enables not disables.

* Create new services report.

* Add services report to main area and move all reports to NixOS area.

* Fix swap file variable name for non-NixOS distros.

* Add godot editor.

* Re-add extra programs Geary and OpenShot for variety.

* Shorten the output for 80 char terminals.

* Add Code-OSS for when Codium is having issues.

* Allow code-oss to be installed.

* Add the full desktop entry for Code-OSS.

* Ansible handles the newlines, prevent the -e from getting into the file.

* Enhance newlines in nmap report.

* Add NixOS.
This commit is contained in:
Hyperling 2023-10-17 04:30:36 -07:00 committed by GitHub
parent 295b309354
commit 392294fb45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 969 additions and 271 deletions

View File

@ -1,15 +1,20 @@
# ansible # ansible
Getting real with system management via ansible-pull. Getting real with system management via ansible-pull.
Per-system configuration is handled via local files to the provisioned machine, rather than using a hosts file. This keeps future hosts private and allows changing what's on the machine without code changes and releases. The files are accessed via the show-config and edit-config aliases. Per-system configuration is handled via local files to the provisioned machine,
rather than using a hosts file. This keeps future hosts private and allows
changing what's on the machine without code changes and releases. The files are
accessed via the show-config and edit-config aliases.
## Disclaimer ## Disclaimer
This setup is specific to the maintainer's devices and needs. You're welcome to use it as an example for your needs, but do not expect it to work as-is. This setup is specific to the maintainer's devices and needs. You're welcome to
use it as an example for your needs, but do not expect it to work as-is.
## Currently Supported Linux Systems ## Currently Supported Linux Systems
### Debian Family ### Debian Family
#### Debian #### Debian
100%, but only if using a recent enough version of Ansible. `pip` usually has a better version than `apt`. 100%, but only if using a recent enough version of Ansible. `pip` usually has a
better version than `apt`.
#### Ubuntu #### Ubuntu
100%, both server and desktop. 100%, both server and desktop.
#### Pop!_OS #### Pop!_OS
@ -17,7 +22,8 @@ This setup is specific to the maintainer's devices and needs. You're welcome to
#### Mint #### Mint
100%, but not really used, just tested once for fun. 100%, but not really used, just tested once for fun.
#### Parrot Security OS (MATE) #### Parrot Security OS (MATE)
100% for a while, but OS did not serve maintainer's needs and 404 errors were terrible while updating. Ubuntu Rolling Rhino filled the gap. 100% for a while, but OS did not serve maintainer's needs and 404 errors were
terrible while updating. Ubuntu Rolling Rhino filled the gap.
### Arch Family ### Arch Family
#### Manjaro #### Manjaro
@ -37,6 +43,10 @@ Workstation: 100%
Generic: 100% Generic: 100%
Workstation: Currently failing at `[Workstation | Linux | Flatpak Distro | Package Manager | Install From Repo]` with message `Problem: nothing provides libedataserver-1.2.so.24 needed by the to be installed evolution-data-server-32bit-3.34.4-3.3.1.x86_64`. Workstation: Currently failing at `[Workstation | Linux | Flatpak Distro | Package Manager | Install From Repo]` with message `Problem: nothing provides libedataserver-1.2.so.24 needed by the to be installed evolution-data-server-32bit-3.34.4-3.3.1.x86_64`.
### NixOS
99%, still need to get Telegraf going and refactor local.yml but everything else
is working well. It is automatically implementing github.com/Hyperling/NixOS.
## Currently Supported Unix Systems ## Currently Supported Unix Systems
### FreeBSD 12, 13 ### FreeBSD 12, 13
100%, although GUI is not working completely on 13 yet (dash-to-dock doesn't compile). 100%, although GUI is not working completely on 13 yet (dash-to-dock doesn't compile).
@ -44,18 +54,26 @@ Software choices are slightly more limited since not `flatpak`-enabled and not f
## Waiting To Be Tested ## Waiting To Be Tested
### Kali Linux ### Kali Linux
### Arch Linux ARM ### Arch Linux ARM
Specifically for the Pinephone. Specifically for the Pinephone.
### Arch Linux x86 ### Arch Linux x86
Would be great to have Arch get built up by this. Used for many years but left after update problems due to a long computer hiatus. Would be great to have Arch get built up by this. Used for many years but left
after update problems due to a long computer hiatus.
### Fedora Mobile ### Fedora Mobile
Specifically for the Pinephone. Specifically for the Pinephone.
## Future Goals ## Future Goals
Eventually some of the scripts and install files will be put into the files folder. This will allow initializing systems outside of the maintainer's home network. Eventually some of the scripts and install files will be put into the files
folder. This will allow initializing systems outside of the maintainer's home
network.
There may also be a refactor of task-specific facts to be in their task file so that some playbooks can be more self-sufficient and be provided to the community without hacking. The original goal was to never define facts in tasks, but the benefit has yet to be seen for some tasks. Shared facts will definitely continue to exist under the facts tree. There may also be a refactor of task-specific facts to be in their task file so
that some playbooks can be more self-sufficient and be provided to the community
without hacking. The original goal was to never define facts in tasks, but the
benefit has yet to be seen for some tasks. Shared facts will definitely continue
to exist under the facts tree.
## Other Notes ## Other Notes
### Get Setup Values ### Get Setup Values
Use this command to see the variables for a system: `ansible localhost -m setup --connection=local`. Use this command to see the variables for a system:
`ansible localhost -m setup --connection=local`.

View File

@ -65,6 +65,7 @@
- name: General | Facts | Package | Update Commands | Helpers - name: General | Facts | Package | Update Commands | Helpers
set_fact: set_fact:
update_accept_var: '$accept' update_accept_var: '$accept'
nix_days: 14
- name: General | Facts | Package | Update Commands | Helpers | pacman - name: General | Facts | Package | Update Commands | Helpers | pacman
set_fact: set_fact:
@ -76,7 +77,7 @@
update_package_manager: | update_package_manager: |
echo "*** Apt ***" && echo "*** Apt ***" &&
sudo apt update && sudo apt update &&
sudo apt autoremove {{ update_accept_var }} && sudo apt autoremove {{ update_accept_var }} &&
sudo apt clean {{ update_accept_var }} && sudo apt clean {{ update_accept_var }} &&
sudo dpkg --configure -a && sudo dpkg --configure -a &&
sudo apt --fix-broken --fix-missing install && sudo apt --fix-broken --fix-missing install &&
@ -96,7 +97,7 @@
- name: General | Facts | Package | Update Commands | pkg - name: General | Facts | Package | Update Commands | pkg
set_fact: set_fact:
update_package_manager: | update_package_manager: |
echo "*** FreeBSD-Update ***" echo "*** FreeBSD-Update ***"
clean="" clean=""
[[ "{{ update_accept_var }}" == "-y" ]] || echo "Are you sure you'd like to clean /var/db/freebsd-update? [y/N] " [[ "{{ 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 [[ "{{ update_accept_var }}" == "-y" ]] || read -N 1 clean
@ -112,7 +113,7 @@
sudo pkg update && sudo pkg update &&
sudo pkg clean {{ update_accept_var }} && sudo pkg clean {{ update_accept_var }} &&
sudo pkg autoremove {{ update_accept_var }} && sudo pkg autoremove {{ update_accept_var }} &&
sudo pkg upgrade {{ update_accept_var }} && sudo pkg upgrade {{ update_accept_var }} &&
when: ansible_pkg_mgr in ("pkg", "pkgng") when: ansible_pkg_mgr in ("pkg", "pkgng")
- name: General | Facts | Package | Update Commands | parrot-upgrade - name: General | Facts | Package | Update Commands | parrot-upgrade
@ -152,11 +153,47 @@
sudo zypper patch {{ update_accept_var }} && sudo zypper patch {{ update_accept_var }} &&
sudo zypper update {{ update_accept_var }} && sudo zypper update {{ update_accept_var }} &&
sudo zypper dist-upgrade {{ update_accept_var }} && sudo zypper dist-upgrade {{ update_accept_var }} &&
# This is a neat feature, but is installing things like GIMP from the # This is a neat feature, but is installing things like GIMP from the
# repos when it is already installed through Flatpak, so not needed. # repos when it is already installed through Flatpak, so not needed.
#sudo zypper install-new-recommends && #sudo zypper install-new-recommends &&
when: ansible_pkg_mgr in ("zypper") when: ansible_pkg_mgr in ("zypper")
- 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
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'
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 * Update channels with the latest expressions.\n"
echo "User:"
nix-channel --update
echo "Root:"
sudo nix-channel --update
echo -e "\n * Rebuild using the existing *.nix files.\n"
sudo nixos-rebuild switch
echo -e "\n * Hard link duplicates, saves 25-35% of store size.\n"
sudo nix-store --optimize
when: ansible_distribution == "NixOS"
- name: General | Facts | Package | Update Commands | flatpak | check - name: General | Facts | Package | Update Commands | flatpak | check
shell: which flatpak shell: which flatpak
@ -166,14 +203,14 @@
- name: General | Facts | Package | Update Commands | flatpak | exists - name: General | Facts | Package | Update Commands | flatpak | exists
set_fact: set_fact:
update_flatpak: | update_flatpak: |
echo "*** Flatpak ***" echo "*** Flatpak ***"
[[ {{ battery }} != 'True' ]] && sudo flatpak repair [[ {{ battery }} != 'True' ]] && sudo flatpak repair
sudo flatpak uninstall --unused {{ update_accept_var }} && sudo flatpak uninstall --unused {{ update_accept_var }} &&
sudo flatpak update {{ 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 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 Commands | flatpak | not exists
set_fact: set_fact:
update_flatpak: | update_flatpak: |
echo "*** Flatpak Not Installed ***" && echo "*** Flatpak Not Installed ***" &&
when: update_flatpak is not defined when: update_flatpak is not defined

View File

@ -14,6 +14,8 @@
crond_pattern: cron crond_pattern: cron
acpi: acpid acpi: acpid
acpi_pattern: acpid acpi_pattern: acpid
bluetooth: bluetooth
bluetooth_pattern: bluetooth
- name: General | Facts | Service | Arch Linux - name: General | Facts | Service | Arch Linux
set_fact: set_fact:

View File

@ -99,3 +99,9 @@
font_awesome: fontawesome-fonts font_awesome: fontawesome-fonts
nfs: utils-libnfs nfs: utils-libnfs
when: ansible_os_family == "Suse" when: ansible_os_family == "Suse"
- name: Workstation | Facts | Package | NixOS
set_fact:
flatpak_distro: false
when: ansible_distribution == "NixOS"

View File

@ -7,7 +7,7 @@
DIR="$(dirname -- "${BASH_SOURCE[0]}")" DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "Running $DIR/$PROG" echo "Running '$DIR/$PROG'."
# Integers # Integers
typeset -i size status typeset -i size status
@ -28,7 +28,7 @@ function usage() {
# Parameters: # Parameters:
# 1) The exit status to use. # 1) The exit status to use.
status=$1 status=$1
echo "Usage: $PROG [-s SIZE] [-l LOCATION] [-r] [-f] [-d] [-h] [-x]" >&2 echo "Usage: $PROG [-s SIZE] [-l LOCATION] [-r] [-f] [-d] [-c] [-h] [-x]" >&2
cat <<- EOF cat <<- EOF
Compress JPG or PNG image(s). Can handle folders and work recursively. Compress JPG or PNG image(s). Can handle folders and work recursively.
@ -38,6 +38,7 @@ function usage() {
-r : Recursively shrink images based on the location passed. -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 a file already exists for it.
-d : Delete the original image if the compressed image is smaller. -d : Delete the original image if the compressed image is smaller.
-c : Clean the filename of underscores, dashes, 'IMG', etc.
-h : Display this usage text. -h : Display this usage text.
-x : Enable BASH debugging. -x : Enable BASH debugging.
EOF EOF
@ -46,13 +47,14 @@ function usage() {
## Parameters ## ## Parameters ##
while getopts ":s:l:rfdhx" opt; do while getopts ":s:l:rfdchx" opt; do
case $opt in case $opt in
s) in_size="$OPTARG" && size="$in_size" ;; s) in_size="$OPTARG" && size="$in_size" ;;
l) location="$OPTARG" ;; l) location="$OPTARG" ;;
r) recurse="Y" && search="find" ;; r) recurse="Y" && search="find" ;;
f) force="Y" ;; f) force="Y" ;;
d) delete="Y" ;; d) delete="Y" ;;
c) clean="Y" ;;
h) usage 0 ;; h) usage 0 ;;
x) set -x ;; x) set -x ;;
*) echo "ERROR: Option $OPTARG not recognized." >&2 && usage 1 ;; *) echo "ERROR: Option $OPTARG not recognized." >&2 && usage 1 ;;
@ -66,6 +68,13 @@ if [[ -n "$in_size" && "$size" != "$in_size" ]]; then
usage 1 usage 1
fi fi
convert_exe="`which convert`"
if [[ "$convert_exe" == "" ]]; then
echo "ERROR: 'convert' command could not be found, "
echo "please install 'imagemagick'."
usage 2
fi
## Main ## ## Main ##
# If using ls, make sure full path is passed to the loop by adding '/*'. # If using ls, make sure full path is passed to the loop by adding '/*'.
@ -73,7 +82,6 @@ if [[ -z "$recurse" && -d "$location" && "$location" != *'/*' ]]; then
if [[ "$location" != *'/' ]]; then if [[ "$location" != *'/' ]]; then
location="${location}/" location="${location}/"
fi fi
location="${location}*"
fi fi
$search "$location" | sort | while read image; do $search "$location" | sort | while read image; do
@ -98,20 +106,40 @@ $search "$location" | sort | while read image; do
new_image="${image//.$extension/}.$tag-$date_YYYYMMDD.$extension" new_image="${image//.$extension/}.$tag-$date_YYYYMMDD.$extension"
# Clean the filename of extra junk so that they can be chronological order.
new_image_clean="${new_image//IMG/}"
new_image_clean="${new_image_clean//_/}"
new_image_clean="${new_image_clean//-/}"
new_image_clean="${new_image_clean// /}"
# Delete the existing shrunk image if we are forcing a new compression. # Delete the existing shrunk image if we are forcing a new compression.
if [[ -n "$force" && -e "$new_image" ]]; then if [[ -n "$force" && (-e "$new_image" || -e $new_image_clean) ]]; then
echo -n " FORCE: " echo -n " FORCE: "
rm -v "$new_image" rm -v "$new_image" "$new_image_clean" 2>/dev/null
fi fi
# Skip if a compressed image was already created today. # Skip if a compressed image was already created today.
if [[ -e "$new_image" ]]; then if [[ -e "$new_image" || -e $new_image_clean ]]; then
echo " SKIP: Image has already been shrunk previously, moving on." echo " SKIP: Image has already been shrunk previously, moving on."
continue continue
fi fi
# Whether or not to use the cleaned version or the normal version.
if [[ -n $clean ]]; then
new_image="$new_image_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_image"`"
# This modifies the image to be $size at its longest end, not be a square. # This modifies the image to be $size at its longest end, not be a square.
convert "$image" -resize ${size}x${size} "$new_image" $convert_exe "$image" -resize ${size}x${size} "$new_image"
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. # Check file sizes and if the new one is larger then flag it as large.
echo " Checking file sizes:" echo " Checking file sizes:"
@ -130,7 +158,12 @@ $search "$location" | sort | while read image; do
continue continue
fi fi
echo " SUCCESS: Conversion succeeded, file has been compressed." if [[ -e "$new_image" ]]; then
echo " SUCCESS: Conversion succeeded, file has been compressed."
else
echo " ERROR: New image '$new_image' could not be found. Aborting."
break;
fi
if [[ -n "$delete" ]]; then if [[ -n "$delete" ]]; then
echo -n " DELETE: " echo -n " DELETE: "
@ -143,7 +176,6 @@ $search "$location" | sort | while read image; do
done done
# If large files do end up being created, allow the user to bulk delete them. # If large files do end up being created, allow the user to bulk delete them.
echo "FORTEST"
if [[ -e "$large_created" ]]; then if [[ -e "$large_created" ]]; then
echo -e "\n*********************************************************" echo -e "\n*********************************************************"
echo -e "WARNING: The files below are larger than their originals!\n" echo -e "WARNING: The files below are larger than their originals!\n"

View File

@ -4,20 +4,20 @@
## Setup ## ## Setup ##
DIR=`dirname $0` DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG=`basename $0` PROG="$(basename -- "${BASH_SOURCE[0]}")"
if [[ "$DIR" == '.' ]]; then echo "Running '$DIR/$PROG'."
DIR=`pwd`
fi
echo "Running $DIR/$PROG"
filename_flag='compressed' filename_flag='compressed'
date_YYYYMMDD="`date "+%Y%m%d"`" date_YYYYMMDD="`date "+%Y%m%d"`"
large_extension='DoNotUse-LargerThanOriginal'
large_created=".$PROG.large_created.true"
## Functions ## ## Functions ##
function usage { function usage {
echo "Usage: $PROG [-i file/folder] [-v bitrate] [-a bitrate] [-c vcodec] [-r] [-f] [-m] [-V] [-x] [-h]" echo -n "Usage: $PROG [-i file/folder] [-v bitrate] [-a bitrate] [-c vcodec]"
echo " [-r] [-f] [-d] [-m] [-V] [-x] [-h]"
cat <<- EOF cat <<- EOF
Reduce the filesize of a video file to make it stream well. It also Reduce the filesize of a video file to make it stream well. It also
helps with the file size for placing the file into a backup system. helps with the file size for placing the file into a backup system.
@ -31,6 +31,7 @@ function usage {
-c vcodec : The video codec you'd like to use, such as libopenh264. -c vcodec : The video codec you'd like to use, such as libopenh264.
-r : Recurse the entire directory structure, compressing all video files. -r : Recurse the entire directory structure, compressing all video files.
-f : Force recompressing any files by deleting it if it already exists. -f : Force recompressing any files by deleting it if it already exists.
-d : Delete the original video if the compressed version is smaller.
-m : Measure the time it takes to compress each video and do the loop. -m : Measure the time it takes to compress each video and do the loop.
-V : Add verbosity, such as printing all the variable values. -V : Add verbosity, such as printing all the variable values.
-x : Set the shell's x flag to display every action which is taken. -x : Set the shell's x flag to display every action which is taken.
@ -41,7 +42,7 @@ function usage {
## Parameters ## ## Parameters ##
while getopts ":i:v:a:c:rfmVxh" opt; do while getopts ":i:v:a:c:rfdmVxh" opt; do
case $opt in case $opt in
i) input="$OPTARG" i) input="$OPTARG"
;; ;;
@ -55,6 +56,8 @@ while getopts ":i:v:a:c:rfmVxh" opt; do
;; ;;
f) force="Y" f) force="Y"
;; ;;
d) delete="Y"
;;
m) time_command="time -p" m) time_command="time -p"
;; ;;
V) verbose="Y" V) verbose="Y"
@ -109,6 +112,7 @@ if [[ "$verbose" == "Y" ]]; then
codec='$codec' codec='$codec'
search_command='$search_command' search_command='$search_command'
force='$force' force='$force'
delete='$delete'
time_command='$time_command' time_command='$time_command'
verbose='$verbose' verbose='$verbose'
set_x='$set_x' set_x='$set_x'
@ -119,7 +123,7 @@ if [[ "$verbose" == "Y" ]]; then
fi fi
SECONDS=0 SECONDS=0
$search_command $input | sort | while read file; do $search_command "$input" | sort | while read file; do
echo -e "\n$file" echo -e "\n$file"
if [[ -n "$time_command" ]]; then if [[ -n "$time_command" ]]; then
@ -140,13 +144,16 @@ $search_command $input | sort | while read file; do
extension="${file##*.}" extension="${file##*.}"
newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension}" newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension}"
# Convert spaces to underscores. #### Convert spaces to underscores.
newfile="${newfile// /_}" ###newfile="${newfile// /_}"
###
#### Ensure any directories that had spaces get recreated without them.
###mkdir -pv "`dirname "$newfile"`"
# More exception checks based on the new file. # More exception checks based on the new file.
if [[ -e "$newfile" ]]; then if [[ -e "$newfile" ]]; then
if [[ "$force" == "Y" ]]; then if [[ "$force" == "Y" ]]; then
echo "FORCE: Removing $newfile." echo "FORCE: Removing '$newfile'."
rm -vf "$newfile" rm -vf "$newfile"
else else
echo "SKIP: Already has a compressed version ($newfile)." echo "SKIP: Already has a compressed version ($newfile)."
@ -155,24 +162,66 @@ $search_command $input | sort | while read file; do
fi fi
# Convert the file. # Convert the file.
echo "Converting to $newfile." echo "Converting to '$newfile'."
$time_command bash -c "ffmpeg -nostdin -hide_banner -loglevel quiet \ $time_command bash -c "ffmpeg -nostdin -hide_banner -loglevel quiet \
-i '$file' -b:v $video_bitrate -b:a $audio_bitrate \ -i '$file' -b:v $video_bitrate -b:a $audio_bitrate \
$vcodec -movflags +faststart $newfile" $vcodec -movflags +faststart '$newfile'"
status="$?"
if [[ "$status" != 0 ]]; then
echo "SKIP: ffmpeg returned a status of '$status'."
continue
fi
# Check the filesize compared to the original and note if it is larger. # Check the filesize compared to the original and note if it is larger.
echo "Checking file sizes:" echo "Checking file sizes:"
ls -sh $file $newfile | sort -hr 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 | awk '{print $2}' | head -n 1`
if [[ "$smaller_file" == "$file" ]]; then if [[ "$smaller_file" == "$file" ]]; then
echo -n "Conversion had the opposite effect, original was likely lesser " echo -n "Conversion had the opposite effect, original was likely lesser "
echo "quality. Adding a suffix to the file to signify that it grew." echo "quality. Adding a suffix to the file to signify that it grew."
mv -v $newfile $newfile.DoNotUse-LargerThanOriginal mv -v "$newfile" "$newfile.$large_extension"
else continue
fi
if [[ -e "$newfile" ]]; then
echo "Conversion succeeded, file has been compressed." echo "Conversion succeeded, file has been compressed."
else
echo "ERROR: Converted file '$newfile' could not be found. Aborting."
break
fi
if [[ -n "$delete" ]]; then
echo -n "Original has been deleted: "
if [[ -d ~/TRASH ]]; then
mv -v "$file" ~/TRASH/
else
rm -v "$file"
fi
fi fi
done 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 "$input" -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 "$input" -name "*"$large_extension -exec rm -v {} \;
else
echo -e "\nKeeping files. Please use this if you change your mind:"
echo " find \"$input\" -name \"*\"$large_extension -exec rm -v {} \;"
fi
rm "$large_created"
fi
echo -e "\nDone!" echo -e "\nDone!"
# Display elapsed time # Display elapsed time

57
files/scripts/nixos.sh Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
# Script to consistently install configuration.nix.
# To be called by Ansible via setup.sh and nixos.yml, as well as CLI by users.
## Variables ##
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
nixos_working_dir=~/nixos-config-deleteme
nixos_working_exe=activate.sh
## Functions ##
function usage {
echo -e "\nUsage: $PROG -b BRANCH" >&2
cat <<- EOF
Run a setup script for NixOS based on the https://github.com/Hyperling/NixOS project.
Parameters:
-b BRANCH: The branch which should be installed, likely 'main' or 'dev'.
EOF
echo ""
exit $1
}
function cleanup {
sh -c "rm -rfv $nixos_working_dir" >/dev/null
}
## Parameters ##
while getopts ":b:h" opt; do
case $opt in
b) branch="$OPTARG" ;;
h) usage 0 ;;
*) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
esac
done
if [[ -z $branch ]]; then
echo "ERROR: Branch is required. $branch" >&2
usage 2
fi
## Main ##
cleanup
# Install the Hyperling NixOS configurations.
git clone https://github.com/Hyperling/NixOS --branch $branch $nixos_working_dir
chmod 755 $nixos_working_dir/$nixos_working_exe
$nixos_working_dir/$nixos_working_exe
cleanup
exit 0

104
local.yml
View File

@ -5,9 +5,13 @@
- name: Main | Default Setup - name: Main | Default Setup
hosts: localhost hosts: localhost
connection: local connection: local
become: true become: true
tasks: tasks:
####### Gather #######
# Load facts for all systems.
- include_tasks: facts/general/gather.yml - include_tasks: facts/general/gather.yml
- include_tasks: tasks/general/acct_mgmt/provision_config.yml - include_tasks: tasks/general/acct_mgmt/provision_config.yml
@ -16,35 +20,89 @@
- include_tasks: facts/general/service.yml - include_tasks: facts/general/service.yml
- include_tasks: facts/general/user.yml - include_tasks: facts/general/user.yml
- include_tasks: tasks/general/software/packages.yml
- include_tasks: tasks/general/software/services.yml
- include_tasks: tasks/general/software/sendmail.yml
when: ansible_system == "FreeBSD"
- include_tasks: facts/general/gather.yml ####### NixOS #######
# Install the .nix files and do a little data setup.
- include_tasks: tasks/general/acct_mgmt/groups.yml - name: Main | NixOS Setup
- include_tasks: tasks/general/acct_mgmt/users.yml block:
- include_tasks: tasks/general/acct_mgmt/sudo.yml
- include_tasks: tasks/general/acct_mgmt/doas.yml
- include_tasks: tasks/general/scripts/root.yml - include_tasks: tasks/general/software/nixos.yml
- include_tasks: tasks/general/scripts/user.yml
- include_tasks: tasks/general/scripts/install.yml
- include_tasks: tasks/general/cron/ansible.yml
# TODO Need to refactor. Maybe tasks/general/cron/freebsd.yml
- include_tasks: tasks/workstation/freebsd/cron/ansible.yml
when: ansible_system == "FreeBSD"
- include_tasks: tasks/general/software/metasploit.yml # TBD if we are going to use this many, then just have IF statements
when: pentesting == true # and use blocks within the General area for NixOS vs not-NixOS.
- include_tasks: tasks/general/software/swap.yml
- include_tasks: tasks/general/acct_mgmt/groups.yml
- include_tasks: tasks/general/acct_mgmt/users.yml
- include_tasks: tasks/general/acct_mgmt/sudo.yml
- include_tasks: tasks/general/acct_mgmt/doas.yml
- include_tasks: tasks/general/scripts/root.yml
- include_tasks: tasks/general/scripts/user.yml
- include_tasks: tasks/general/scripts/install.yml
- include_tasks: tasks/general/cron/ansible.yml
# psutil does not work in NixOS. Cannot figure out how to fix it. Maybe
# time to start looking into home-manager but still not wanting to
# maintain two different GNOME setups. HMMMM!
- include_tasks: tasks/workstation/shared/settings/gnome.yml
when: workstation == true
# Try including these. Really need to get NixOS working with the rest!
#- include_tasks: tasks/general/software/telegraf.yml # "Could not find a module for unknown.""
- include_tasks: tasks/general/tests/services.yml
- include_tasks: tasks/general/tests/lynis.yml
- include_tasks: tasks/general/tests/nmap.yml
- name: NixOS | Complete
meta: end_play
when: ansible_distribution == "NixOS"
####### General #######
# Basic setup for all enabled systems.
- name: Main | General Setup
block:
- include_tasks: tasks/general/software/swap.yml
- include_tasks: tasks/general/software/packages.yml
- include_tasks: tasks/general/software/services.yml
- 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
- include_tasks: tasks/general/acct_mgmt/groups.yml
- include_tasks: tasks/general/acct_mgmt/users.yml
- include_tasks: tasks/general/acct_mgmt/sudo.yml
- include_tasks: tasks/general/acct_mgmt/doas.yml
- include_tasks: tasks/general/scripts/root.yml
- include_tasks: tasks/general/scripts/user.yml
- include_tasks: tasks/general/scripts/install.yml
- include_tasks: tasks/general/cron/ansible.yml
# TODO Need to refactor. Maybe tasks/general/cron/freebsd.yml
- include_tasks: tasks/workstation/freebsd/cron/ansible.yml
when: ansible_system == "FreeBSD"
- include_tasks: tasks/general/software/metasploit.yml
when: pentesting == true
when: provision == true
####### Workstations ####### ####### Workstations #######
# Additional setup for systems with GUI. # Additional setup for systems with GUI.
- name: Main | Workstation Setup - name: Main | Workstation Setup
block: block:
@ -97,7 +155,7 @@
when: workstation == true when: workstation == true
# No longer mining, this is now considered deprecated. # No longer mining, this is now considered deprecated.
# ####### Miners ####### # ####### Miners #######
# #
@ -141,6 +199,7 @@
####### Servers ####### ####### Servers #######
# Easy to deploy server configurations. # Easy to deploy server configurations.
- name: Main | Server Setup - name: Main | Server Setup
block: block:
@ -180,5 +239,6 @@
- include_tasks: tasks/general/software/telegraf.yml - include_tasks: tasks/general/software/telegraf.yml
- include_tasks: tasks/general/tests/services.yml
- include_tasks: tasks/general/tests/lynis.yml - include_tasks: tasks/general/tests/lynis.yml
- include_tasks: tasks/general/tests/nmap.yml - include_tasks: tasks/general/tests/nmap.yml

View File

@ -1,10 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
# Script to initialize a system into Ansible collection. # Script to initialize a system into Ansible collection.
## Global Variables ## ## Global Variables ##
PROG=`basename $0` DIR="$(dirname -- "${BASH_SOURCE[0]}")"
LOCAL=`dirname $0`/local.yml PROG="$(basename -- "${BASH_SOURCE[0]}")"
LOCAL=$DIR/local.yml
URL="https://github.com/Hyperling/ansible" URL="https://github.com/Hyperling/ansible"
BRANCH="main" BRANCH="main"
@ -19,12 +20,12 @@ function usage {
$URL $URL
Parameters: Parameters:
-l : Run the local playbook associated with this $PROG. -l : Run the local playbook associated with this $PROG.
This is helpful for development or just saving bandwidth. This is helpful for development or just saving bandwidth.
It also provides prettier colors than the plaintext from ansible-pull. ;) It also provides prettier colors than the plaintext from ansible-pull. ;)
-b branch_name: Download and run a specific branch. Default is $BRANCH. -b branch_name: Download and run a specific branch. Default is $BRANCH.
-h : Display this help text -h : Display this help text
EOF EOF
exit $1 exit $1
} }
@ -33,22 +34,10 @@ function usage {
while getopts ":lb:h" arg; do while getopts ":lb:h" arg; do
case $arg in case $arg in
l) l) local="Y" && echo "Running $LOCAL as the playbook." ;;
echo "Running $LOCAL as the playbook." b) branch="$OPTARG" && echo "Using branch $branch instead of $BRANCH." ;;
local="Y" h) usage ;;
;; *) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
b)
echo -n "Using branch "
branch="$OPTARG"
echo "$branch instead of $BRANCH."
;;
h)
usage
;;
*)
echo "ERROR: A parameter was not recognized. Please check your command and try again."
usage 1
;;
esac esac
done done
@ -96,6 +85,10 @@ if [[ `which ansible > /dev/null; echo $?` != 0 ]]; then
sudo zypper install -y ansible git sudo zypper install -y ansible git
sudo mkdir -p /etc/ansible sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts' sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
elif [[ $os == *NixOS* ]]; then
$DIR/files/scripts/nixos.sh -b $branch
sudo mkdir -p /etc/ansible
sudo sh -c 'echo "localhost ansible_connection=local" > /etc/ansible/hosts'
else else
echo -e "ERROR: OS not detected." echo -e "ERROR: OS not detected."
echo -e "$os" echo -e "$os"

View File

@ -14,7 +14,7 @@
srv_file: "{{ prov_dir }}/server.ini" srv_file: "{{ prov_dir }}/server.ini"
- name: General | Account Management | Provisioning Configuration | Create Directory - name: General | Account Management | Provisioning Configuration | Create Directory
file: file:
path: "{{ prov_dir }}" path: "{{ prov_dir }}"
state: directory state: directory
mode: '0755' mode: '0755'
@ -29,24 +29,46 @@
;;;;;;; Available options - all require lowercase values ;;;;;; ;;;;;;; Available options - all require lowercase values ;;;;;;
; ;
; enable : Provide true for the provision to occur. ; enable : Provide true for the provision to occur.
; Default: false
; ;
; user : Provide the name of the user account. ; user : Provide the name of the user account.
; Example: tom, jerry, kim, sarah ; Example: tom, jerry, kim, sarah
; Default: ling
; ;
; user_desc : Provide the description of the user account. ; user_desc : Provide the description of the user account.
; Example: Thomas, Jerry, Kimberly, Sarah ; Example: Thomas, Jerry, Kimberly, Sarah
; Default: Hyperling
; ;
; branch : Provide the Github branch that the machine should poll. ; branch : Provide the Github branch that the machine should poll.
; Example: main, dev ; Example: main, dev
; Default: main
; ;
; pentesting : Set to true to install tools such as metasploit (nmap is already provided for reporting) ; pentesting : Set to true to install tools such as metasploit.
; nmap is already provided for reporting
; Default: false
; ;
; no_telem : Set to true to avoid setting up telemetry services. ; no_telem : Set to true to avoid setting up telemetry services.
; Disables GitHub updates to this project. ; Disables GitHub updates to this project.
; Disables all telegraf pings. ; Disables all telegraf pings.
; Default: false
; ;
; battery : Set to true to attempt to save battery life. ; battery : Set to true to attempt to save battery life.
; Slows down the rate of services such as telegraf and cron. ; Slows down the rate of services such as telegraf and cron.
; Default: false
;
; swap_block : Set to the block size if dd should create a swapfile.
; Preferably keep this under 2G for integrity sakes, the
; value is multiplied by count if you need a larger file.
; Example: 500M, 512MB, 1G
; Default: false
;
; swap_count : Set to the number of blocks to multiply the file size by.
; Example: 8
; Default: 1
;
; swap_file : Set to the name and location of where the file should be.
; Example: /usr/local/swap
; Default: /swapfile
; ;
[global] [global]
marker: '; {mark} MANAGED BY ANSIBLE | Generic Config' marker: '; {mark} MANAGED BY ANSIBLE | Generic Config'
@ -63,9 +85,12 @@
pentesting: "{{ lookup('ini', 'pentesting file={{gen_file}} default=false') }}" pentesting: "{{ lookup('ini', 'pentesting file={{gen_file}} default=false') }}"
no_telem: "{{ lookup('ini', 'no_telem file={{gen_file}} default=false') }}" no_telem: "{{ lookup('ini', 'no_telem file={{gen_file}} default=false') }}"
battery: "{{ lookup('ini', 'battery file={{gen_file}} default=false') }}" battery: "{{ lookup('ini', 'battery file={{gen_file}} default=false') }}"
swap_block: "{{ lookup('ini', 'swap_block file={{gen_file}} default=false') }}"
swap_count: "{{ lookup('ini', 'swap_count file={{gen_file}} default=1') }}"
swap_file: "{{ lookup('ini', 'swap_file file={{gen_file}} default=/swapfile') }}"
- name: General | Account Management | Provisioning Configuration | General | List - name: General | Account Management | Provisioning Configuration | General | List
set_fact: set_fact:
provision_variables: "{{ provision_variables | combine(item) }}" provision_variables: "{{ provision_variables | combine(item) }}"
loop: loop:
- { 'provision': "{{ provision }}" } - { 'provision': "{{ provision }}" }
@ -75,6 +100,9 @@
- { 'pentesting': "{{ pentesting }}" } - { 'pentesting': "{{ pentesting }}" }
- { 'no_telem': "{{ no_telem }}" } - { 'no_telem': "{{ no_telem }}" }
- { 'battery': "{{ battery }}" } - { 'battery': "{{ battery }}" }
- { 'swap_block': "{{ swap_block }}" }
- { 'swap_count': "{{ swap_count }}" }
- { 'swap_file': "{{ swap_file }}" }
## Workstation ## ## Workstation ##
@ -123,7 +151,7 @@
mobile: "{{ lookup('ini', 'mobile file={{wrk_file}} default=false') }}" mobile: "{{ lookup('ini', 'mobile file={{wrk_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | Workstation | List - name: General | Account Management | Provisioning Configuration | Workstation | List
set_fact: set_fact:
provision_variables: "{{ provision_variables | combine(item) }}" provision_variables: "{{ provision_variables | combine(item) }}"
loop: loop:
- { 'workstation': "{{ workstation }}" } - { 'workstation': "{{ workstation }}" }
@ -150,7 +178,7 @@
# ; # ;
# ; nanominer : Set to true for installation of nanominer # ; nanominer : Set to true for installation of nanominer
# ; # ;
# ; nanominer_cpu : Set to coin code that you'd like the CPU to work on # ; nanominer_cpu : Set to coin code that you'd like the CPU to work on
# ; Valid values: xmr # ; Valid values: xmr
# ; # ;
# ; nanominer_cpu_pool : Set to pool organization to use for CPU mining # ; nanominer_cpu_pool : Set to pool organization to use for CPU mining
@ -199,7 +227,7 @@
# xmr_stak_cpu: "{{ lookup('ini', 'xmr_stak_cpu file={{mnr_file}} default=false') }}" # xmr_stak_cpu: "{{ lookup('ini', 'xmr_stak_cpu file={{mnr_file}} default=false') }}"
# #
#- name: General | Account Management | Provisioning Configuration | Miner | List #- name: General | Account Management | Provisioning Configuration | Miner | List
# set_fact: # set_fact:
# provision_variables: "{{ provision_variables | combine(item) }}" # provision_variables: "{{ provision_variables | combine(item) }}"
# loop: # loop:
# - { 'miner': "{{ miner }}" } # - { 'miner': "{{ miner }}" }
@ -253,7 +281,7 @@
; Regardless of whether you choose http or https, the Certbot config will be skipped since the maintainer uses a reverse proxy. ; Regardless of whether you choose http or https, the Certbot config will be skipped since the maintainer uses a reverse proxy.
; Example: https://gitlab ; Example: https://gitlab
; ;
; git : Set to true for this server to be configured as an HTTP git server. ; git : Set to true for this server to be configured as an HTTP git server.
; ;
; git_name : Name(s) of project(s) that the Git server should host. ; git_name : Name(s) of project(s) that the Git server should host.
; Example: ansible#ansible-dev ; Example: ansible#ansible-dev
@ -293,7 +321,7 @@
git_sep: "{{ lookup('ini', 'git_sep file={{srv_file}} default=false') }}" git_sep: "{{ lookup('ini', 'git_sep file={{srv_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | Server | List - name: General | Account Management | Provisioning Configuration | Server | List
set_fact: set_fact:
provision_variables: "{{ provision_variables | combine(item) }}" provision_variables: "{{ provision_variables | combine(item) }}"
loop: loop:
- { 'server': "{{ server }}" } - { 'server': "{{ server }}" }
@ -323,5 +351,5 @@
## Display values ## ## Display values ##
- name: General | Account Management | Provisioning Configuration | Print - name: General | Account Management | Provisioning Configuration | Print
debug: debug:
var: provision_variables var: provision_variables

View File

@ -1,5 +1,5 @@
--- ---
# Create users for all machines. # Create and configure default users for all machines.
## Variables ## ## Variables ##
@ -58,7 +58,7 @@
## Superuser ## ## Superuser ##
- name: General | Account Management | Users | Hyperling - name: General | Account Management | Users | User
user: user:
name: "{{ user }}" name: "{{ user }}"
comment: "{{ user_desc }}" comment: "{{ user_desc }}"
@ -72,7 +72,7 @@
generate_ssh_key: yes generate_ssh_key: yes
register: user_user register: user_user
- name: General | Account Management | Users | Hyperling | Test Logging In - name: General | Account Management | Users | User | Test Logging In
shell: "echo SUCCESS" shell: "echo SUCCESS"
args: args:
executable: "{{ user_shell }}" executable: "{{ user_shell }}"
@ -81,7 +81,7 @@
## Folders ## ## Folders ##
- name: General | Account Management | Users | Folders | Root | Create bin, Downloads, TRASH - name: General | Account Management | Users | Root | Create Folders
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
@ -92,7 +92,7 @@
- "{{ user_root.home }}/TRASH" - "{{ user_root.home }}/TRASH"
when: user_root.home != "" when: user_root.home != ""
- name: General | Account Management | Users | Folders | Hyperling | Create bin, LBRY, TRASH - name: General | Account Management | Users | User | Create Folders
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
@ -106,7 +106,7 @@
become_user: "{{ user }}" become_user: "{{ user }}"
when: user_user.home != "" when: user_user.home != ""
- name: General | Account Management | Users | Folders | Home Directories 700 - name: General | Account Management | Users | Home Permissions
shell: "chmod 700 {{ user_user.home }}/../*" shell: "chmod 700 {{ user_user.home }}/../*"
@ -119,7 +119,7 @@
alias_rm: alias rm='echo "Use mv ~/TRASH/ instead!"' alias_rm: alias rm='echo "Use mv ~/TRASH/ instead!"'
alias_clean_dir: alias clean-dir='mv * ~/TRASH/' alias_clean_dir: alias clean-dir='mv * ~/TRASH/'
alias_clean_trash: alias clean-trash='sh -c "rm -rfv ~/TRASH/*"' alias_clean_trash: alias clean-trash='sh -c "rm -rfv ~/TRASH/*"'
export_path_additions: export PATH="~/bin:$PATH" export_path_additions: export PATH="~/bin:"{{ global_bin }}":$PATH"
function_wttr: | function_wttr: |
function weather() { function weather() {
# 20210301 - Someone showed me an awesome weather API! Had to implement it! # 20210301 - Someone showed me an awesome weather API! Had to implement it!
@ -138,7 +138,14 @@
curl "https://wttr.in/${1//\ /+}" curl "https://wttr.in/${1//\ /+}"
} }
export_PS1: export PS1='[\u@\h \w]\$ ' export_PS1: export PS1='[\u@\h \w]\$ '
alias_remount: alias remount='sudo umount /mnt/*; sudo umount /mnt/*/*; sudo mount -a; echo -e "\nRemount completed!"; mount | grep /mnt' alias_remount: |
alias remount='
sudo umount /mnt/*
sudo umount /mnt/*/*
sudo mount -a
echo -e "\nRemount completed!"
mount | grep /mnt
'
function_update: | function_update: |
function update() { function update() {
PROG=$FUNCNAME PROG=$FUNCNAME
@ -171,9 +178,18 @@
alias_sync: alias sync='date && echo "Syncing!" && sync && date' alias_sync: alias sync='date && echo "Syncing!" && sync && date'
export_editor: export EDITOR='vi' export_editor: export EDITOR='vi'
init_aliases: | init_aliases: |
alias init-video='mkdir -v raw; mkdir -v exports; cp ~/Templates/*video* ./' alias init-video='
mkdir -v raw
mkdir -v exports
cp ~/Templates/*video* ./
'
alias init-vid=init-video alias init-vid=init-video
alias init-program='echo -e "#!/bin/bash\n# `date +%Y-%m-%d` by Hyperling\n# REASON\n\nexit 0\n"' alias init-program='
echo "#!/usr/bin/env bash"
echo "# `date +%Y-%m-%d` Hyperling"
echo ""
echo "exit 0"
'
alias init-prog=init-program alias init-prog=init-program
bye_aliases: | bye_aliases: |
alias bye="{{ shutdown_command }}" alias bye="{{ shutdown_command }}"
@ -186,7 +202,15 @@
alias show-config-wrk="cat {{ wrk_file }}" alias show-config-wrk="cat {{ wrk_file }}"
alias show-config-mnr="cat {{ mnr_file }}" alias show-config-mnr="cat {{ mnr_file }}"
alias show-config-srv="cat {{ srv_file }}" alias show-config-srv="cat {{ srv_file }}"
alias show-config-all="show-config-gen && echo '' && show-config-wrk && echo '' && show-config-mnr && echo '' && show-config-srv" alias show-config-all="
show-config-gen &&
echo '' &&
show-config-wrk &&
echo '' &&
show-config-mnr &&
echo '' &&
show-config-srv
"
alias show-config="show-config-all" alias show-config="show-config-all"
edit_config_aliases: | edit_config_aliases: |
alias edit-config-gen="sudo $EDITOR {{ gen_file }}" alias edit-config-gen="sudo $EDITOR {{ gen_file }}"
@ -278,14 +302,26 @@
function flatpak-purge() { function flatpak-purge() {
flatpak remove --all --delete-data && flatpak remove --all --delete-data &&
flatpak repair && flatpak repair &&
echo "Finished purging all Flatpak apps. Executable may still need uninstalled." && echo -n "Finished purging all Flatpak apps. " &&
echo "Executable may still need uninstalled." &&
return return
echo "ERROR: Something went wrong while removing Flatpak apps!" >&2 echo "ERROR: Something went wrong while removing Flatpak apps!" >&2
} }
alias_vim: alias vi=vim alias_vim: alias vi=vim
alias_here: alias here='ls -alh `pwd`/*' alias_here: alias here='ls -alh `pwd`/*'
alias_docker_reload: alias docker-reload='docker compose down && docker compose build && docker compose up -d' alias_docker_reload: |
alias_docker_update: alias docker-update='docker compose down && docker compose pull && docker compose build && docker compose up -d' alias docker-reload='
docker compose down &&
docker compose build &&
docker compose up -d
'
alias_docker_update: |
alias docker-update='
docker compose down &&
docker compose pull &&
docker compose build &&
docker compose up -d
'
function_docker_upgrade: | function_docker_upgrade: |
function docker-upgrade() { function docker-upgrade() {
# Wrapper for a full-scale upgrade and log view of a container. # Wrapper for a full-scale upgrade and log view of a container.
@ -320,8 +356,72 @@
echo "Press ^C to escape." && echo "Press ^C to escape." &&
docker logs -f $container docker logs -f $container
} }
alias_docker_restart: alias docker-restart='docker compose down && docker compose up -d' alias_docker_restart: |
alias_code_check: alias code-check='ls -d ~/Code/* | while read project; do echo "*** `basename $project` ***"; cd $project; git push; git pull; done' alias docker-restart='docker compose down && docker compose up -d'
alias_code_check: |
alias code-check='
ls -d ~/Code/* | while read project; do
echo "*** `basename $project` ***"
cd $project
git pull
git push
done
'
alias_code_reset: |
alias code-reset='
ls -d ~/Code/* | while read project
do echo "*** `basename $project` ***"
cd $project
git switch main
git pull
git branch -D dev
git checkout dev
done
'
alias_code_reseed: |
alias code-reseed='
unseed_dir="$HOME/TRASH/`date +%Y-%m-%d`_UnseededCodeProjects"
mkdir -pv "$unseed_dir"
mv -v ~/Code/*{ansible,docker,nix,break,habit}* \
"$unseed_dir"/ 2>/dev/null
git clone git@github.com:Hyperling/Ansible \
--branch dev ~/Code/ansible-dev
git clone git@github.com:Hyperling/Docker \
--branch dev ~/Code/docker-dev
git clone git@github.com:Hyperling/NixOS \
--branch dev ~/Code/nixos-dev
git clone git@github.com:Hyperling/BreakTheHabit \
--branch dev ~/Code/breakthehabit-dev
'
function_clean_filenames: |
function clean-filenames() {
# Must provide the directory you'd like to clean all the filenames in.
# Otherwise defaults to the current directory and all of its files.
dir="$1"
if [[ -z $dir ]]; then
echo -e "Using current directory."
dir="."
fi
ls "$dir" | while read file; do
clean="${file//IMG/}"
clean="${clean//_/}"
clean="${clean//-/}"
clean="${clean// /}"
if [[ "$file" != "$clean" && ! -d "$file" ]]; then
mv -v "$dir"/"$file" "$dir"/"$clean"
fi
done
}
function_clean_filenames_tree: |
function clean-filenames-tree() {
find ./ | while read folder; do
if [[ -d "$folder" ]]; then
echo -e "\n*** Checking '$folder' ***"
clean-filenames "$folder"
fi
done
echo -e "\nDone!\n"
}
- name: General | Account Management | Users | Files | Common Variable - name: General | Account Management | Users | Files | Common Variable
set_fact: set_fact:
@ -354,13 +454,18 @@
{{ function_docker_upgrade }} {{ function_docker_upgrade }}
{{ alias_docker_restart }} {{ alias_docker_restart }}
{{ alias_code_check }} {{ alias_code_check }}
{{ alias_code_reset }}
{{ alias_code_reseed }}
{{ function_clean_filenames }}
{{ function_clean_filenames_tree }}
- name: General | Account Management | Users | Files | .bashrc - name: General | Account Management | Users | Files | .bashrc
blockinfile: blockinfile:
path: "{{ item }}/.bashrc" path: "{{ item }}/.bashrc"
block: | block: |
{{ rc_common }} {{ rc_common }}
[[ $(whoami) != "root" ]] && echo "`date` - Ansible .bashrc preferences loaded successfully!" [[ $(whoami) != "root" ]] &&
echo "`date` - Ansible .bashrc loaded successfully!"
marker: '# {mark} MANAGED BY ANSIBLE | Aliases' marker: '# {mark} MANAGED BY ANSIBLE | Aliases'
state: present state: present
create: yes create: yes
@ -376,7 +481,8 @@
path: "{{ item }}/.zshrc" path: "{{ item }}/.zshrc"
block: | block: |
{{ rc_common }} {{ rc_common }}
[[ $(whoami) != "root" ]] && echo "`date` - Ansible .zshrc preferences loaded successfully!" [[ $(whoami) != "root" ]] &&
echo "`date` - Ansible .zshrc loaded successfully!"
marker: '# {mark} MANAGED BY ANSIBLE | Aliases' marker: '# {mark} MANAGED BY ANSIBLE | Aliases'
state: present state: present
create: yes create: yes
@ -411,3 +517,13 @@
- "{{ user_user.home }}" - "{{ user_user.home }}"
ignore_errors: yes ignore_errors: yes
when: user_root.home != "" and user_user.home != "" when: user_root.home != "" and user_user.home != ""
- name: General | Account Management | Users | Files | Ownership
file:
path: "{{ user_user.home }}/{{ item }}"
owner: "{{ user }}"
mode: '0755'
loop:
- .bashrc
- .zshrc
- .vimrc

View File

@ -14,3 +14,13 @@
owner: root owner: root
group: "{{ root_group }}" group: "{{ root_group }}"
mode: '0755' mode: '0755'
- name: General | Scripts | Install | Remove Old Scripts
shell: |
if [[ -e {{ global_bin }}/{{ item }} ]]; then
rm -v {{ global_bin }}/{{ item }}
fi
loop:
- compress-video.sh
- compress-images.sh
ignore_errors: true

View File

@ -16,7 +16,7 @@
create: yes create: yes
- name: General | Scripts | Root | scm.sh Permissions - name: General | Scripts | Root | scm.sh Permissions
file: file:
path: "{{ user_root.home }}/bin/scm.sh" path: "{{ user_root.home }}/bin/scm.sh"
mode: '0755' mode: '0755'
@ -26,7 +26,7 @@
path: "{{ user_root.home }}/bin/scm-dev.sh" path: "{{ user_root.home }}/bin/scm-dev.sh"
block: | block: |
# 20210713 - Make life easier for development! # 20210713 - Make life easier for development!
## Variables ## ## Variables ##
# Use a specific branch if it was asked for. # Use a specific branch if it was asked for.
@ -35,7 +35,6 @@
branch="$1" branch="$1"
fi fi
## Main ## ## Main ##
time {{ ansible_pull_exec.stdout }} -U {{ repo_github }} --checkout $branch time {{ ansible_pull_exec.stdout }} -U {{ repo_github }} --checkout $branch
@ -47,6 +46,6 @@
create: yes create: yes
- name: General | Scripts | Root | scm-dev.sh Permissions - name: General | Scripts | Root | scm-dev.sh Permissions
file: file:
path: "{{ user_root.home }}/bin/scm-dev.sh" path: "{{ user_root.home }}/bin/scm-dev.sh"
mode: '0755' mode: '0755'

View File

@ -16,7 +16,7 @@
create: yes create: yes
- name: General | Scripts | User | scm.sh Permissions - name: General | Scripts | User | scm.sh Permissions
file: file:
path: "{{ user_user.home }}/bin/scm.sh" path: "{{ user_user.home }}/bin/scm.sh"
mode: '0755' mode: '0755'
@ -26,7 +26,7 @@
path: "{{ user_user.home }}/bin/scm-dev.sh" path: "{{ user_user.home }}/bin/scm-dev.sh"
block: | block: |
# 20210713 - Make life easier for development! # 20210713 - Make life easier for development!
## Variables ## ## Variables ##
# Use a specific branch if it was asked for. # Use a specific branch if it was asked for.
@ -35,7 +35,6 @@
branch="$1" branch="$1"
fi fi
## Main ## ## Main ##
time sudo {{ ansible_pull_exec.stdout }} -U {{ repo_github }} --checkout $branch time sudo {{ ansible_pull_exec.stdout }} -U {{ repo_github }} --checkout $branch
@ -47,6 +46,6 @@
create: yes create: yes
- name: General | Scripts | User | scm-dev.sh Permissions - name: General | Scripts | User | scm-dev.sh Permissions
file: file:
path: "{{ user_user.home }}/bin/scm-dev.sh" path: "{{ user_user.home }}/bin/scm-dev.sh"
mode: '0755' mode: '0755'

View File

@ -0,0 +1,37 @@
---
# Install the Nix package manager
# https://nixos.org/download/
## TBD ##
# This may be able to replace Flatpak if it works well, is easy to use, takes up
# less space, is faster, etc etc. It also is supposed to have the benefit of
# working with FreeBSD and MacOS which is something that the current array of
# Ansible/package/Flatpak combo is lacking. Honestly might make FreeBSD as a
# desktop a possibility again since it was software availability that continues
# to be the reason to leave it. Could also get rid of all the distro-specific
# package names, and maybe packages.yml in general?? That stuff can be a mess.
###
- name: Nix Variables
set_fact:
nix_exe: ~/.deleteme.nix.sh
- name: Install Nix
shell: "{{ item }}"
loop:
- "curl -L https://nixos.org/nix/install > {{ nix_exe }}"
- "chmod 755 {{ nix_exe }}"
- "{{ nix_exe }} --daemon --yes"
- "rm -v {{ nix_exe }}"
become_user: "{{ user }}"
- name: Install Nix Software
shell: "{{ item }}"
loop:
- "nix-env -iA nixpkgs.lbry" # Installs, but doesnt launch?
#$ lbry
#Gtk-Message: 16:22:43.390: Failed to load module "canberra-gtk-module"
#Gtk-Message: 16:22:43.391: Failed to load module "canberra-gtk-module"
#[35:0100/000000.410595:ERROR:angle_platform_impl.cc(44)] Display.cpp:940 (initialize): ANGLE Display::initialize error 12289: glXQueryExtensionsString returned NULL
#[35:0100/000000.482531:ERROR:gl_surface_egl.cc(808)] EGL Driver message (Critical) eglInitialize: glXQueryExtensionsString returned NULL
#[35:0100/000000.482570:ERROR:gl_surface_egl.cc(1430)] eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type

View File

@ -0,0 +1,42 @@
---
# Update the Nix configuration at github.com/Hyperling/NixOS.
# This is also done in setup.sh if ansible is not found.
- name: General | Software | NixOS | Facts
set_fact:
nixos_working_dir: ~/nixos-config-deleteme
nixos_working_exe: activate.sh
- name: General | Software | NixOS | Facts [Swap]
set_fact:
nixos_swap: "swapDevices = [ { device = \"{{ swap_file }}\";} ];"
when: swap_block != false
- name: General | Software | NixOS | Update Config Project
shell: "files/scripts/nixos.sh -b {{ branch }}"
- name: General | Software | NixOS | Create Ansible Nix Config
blockinfile:
path: /etc/nixos/ansible.nix
block: |
# This file was created by https://github.com/Hyperling/Ansible
# Please do not alter it by hand. Use the proper ini files instead.
{ config, pkgs, nix, ... }:
{
# tasks/general/software/swap.yml
# Use general.ini to set up the swap commands for ths field to be used.
{{ nixos_swap }}
}
state: present
backup: yes
create: yes
# Maybe do home manager here? Or should it be under Workstation? Or maybe
# this is the spot where I start creating workstation.nix, server.nix, etc.
#- name: General | Software | NixOS | Home Manager? *.nix file management?
# shell:
# loop:
# - ???
# - ???

View File

@ -84,3 +84,15 @@
shell: journalctl --vacuum-size=100M shell: journalctl --vacuum-size=100M
when: ansible_system == "Linux" when: ansible_system == "Linux"
ignore_errors: yes ignore_errors: yes
## Bluetooth ##
# Do people seriously depend on Bluetooth? Plug your devices in, silly!
- name: General | Software | Services | Bluetooth | Disable
service:
name: "{{ bluetooth }}"
pattern: "{{ bluetooth_pattern }}"
state: stopped
enabled: no
ignore_errors: yes

View File

@ -0,0 +1,40 @@
---
# Setup swap file on systems without any swap available.
# Must have the swap amount preferred set up in general.ini.
# This does not handle if the user changes the file name or location later on.
- name: General | Software | Swap
block:
- name: General | Software | Swap | Check For Swapfile
stat:
path: "{{ swap_file }}"
register: swap_check
- name: General | Software | Swap | Install Block
block:
- name: General | Software | Swap | Create Swapfile
shell: "{{ item }}"
loop:
- dd if=/dev/zero of={{ swap_file }} bs={{ swap_block }}
count={{ swap_count }} status=progress
- chmod 600 {{ swap_file }}
- mkswap {{ swap_file }}
- swapon {{ swap_file }}
# Only do the swapfile generation if it does not already exist.
when: not swap_check.stat.exists
# NixOS's swap setup is handled in nixos.yml when ansible.nix is created.
- name: General | Software | Swap | Add to FSTAB
lineinfile:
path: /etc/fstab
regexp: '^[\#]?{{ swap_file }}'
line: '{{ swap_file }} none swap sw 0 0'
state: present
backup: yes
when: ansible_distribution != "NixOS"
# Only run through this file if the ini has been changed from false.
when: swap_block != false

View File

@ -4,7 +4,7 @@
- name: General | Tests | nmap | Set Facts - name: General | Tests | nmap | Set Facts
set_fact: set_fact:
nmap_file: "{{ user_user.home }}/Reports/{{ nmap_report }}" nmap_file: "{{ user_user.home }}/Reports/{{ nmap_report }}"
nmap_separator: "\n*******************************\n\n" nmap_separator: "\n*******************************\n"
- name: General | Tests | nmap | Set Facts 2 - name: General | Tests | nmap | Set Facts 2
set_fact: set_fact:
@ -12,15 +12,15 @@
- name: General | Tests | nmap | Create Report - name: General | Tests | nmap | Create Report
shell: "{{ item }}" shell: "{{ item }}"
loop: loop:
- "date > {{ nmap_temp_file }}" - "date > {{ nmap_temp_file }}"
- "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}" - "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}"
- "echo '-=Open Ports=-' >> {{ nmap_temp_file }}" - "echo '\n-=Open Ports=-\n' >> {{ nmap_temp_file }}"
- "printf 'Number of open ports: ' >> {{ nmap_temp_file }}" - "printf 'Number of open ports: ' >> {{ nmap_temp_file }}"
- "nmap --open localhost | grep -c open >> {{ nmap_temp_file }}; echo success" - "nmap --open localhost | grep -c open >> {{ nmap_temp_file }}; echo success"
- "nmap --open localhost | grep open >> {{ nmap_temp_file }}; echo success" - "nmap --open localhost | grep open >> {{ nmap_temp_file }}; echo success"
- "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}" - "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}"
- "echo '-=Aggressive Vulnerability Check=-' >> {{ nmap_temp_file }}" - "echo '\n-=Aggressive Vulnerability Check=-\n' >> {{ nmap_temp_file }}"
- "nmap -A localhost >> {{ nmap_temp_file }}; echo success" - "nmap -A localhost >> {{ nmap_temp_file }}; echo success"
- "mv {{ nmap_temp_file }} {{ nmap_file }}" - "mv {{ nmap_temp_file }} {{ nmap_file }}"

View File

@ -0,0 +1,27 @@
---
# List all the services under the Reports folder.
- 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_command: "systemctl list-unit-files"
- name: General | Tests | Services | Create Main Report
shell: "{{ item }}"
loop:
- "date > {{ services_report_file }}"
- "echo '\n-= {{ services_command }} =-\n' >> {{ services_report_file }}"
- "{{ services_command }} >> {{ services_report_file }}"
- name: General | Tests | Services | Create Enabled Report
shell: "{{ item }}"
loop:
- "date > {{ services_enabled_file }}"
- "echo '\n-= Enabled + Sorted =-\n' >> {{ services_enabled_file }}"
- "grep 'enabled' {{ services_report_file }} | sort >> {{ services_enabled_file }}"
- name: General | Tests | Services | Make Viewable
file:
path: "{{ services_report_file }}"
mode: '0644'

View File

@ -1,4 +0,0 @@
---
# Install LBRY desktop client.
# TODO: https://github.com/lbryio/lbry-desktop#install

View File

@ -36,26 +36,29 @@
set_fact: set_fact:
flatpaks_generic: flatpaks_generic:
- { app: "org.libreoffice.LibreOffice", name: "office", extra: "" } - { app: "org.libreoffice.LibreOffice", name: "office", extra: "" }
- { app: "io.lbry.lbry-app", name: "lbry", extra: "dbus-launch" }
- { app: "io.gitlab.librewolf-community", name: "librewolf", extra: "" } - { app: "io.gitlab.librewolf-community", name: "librewolf", extra: "" }
- { app: "chat.delta.desktop", name: "deltachat", extra: "" } - { app: "chat.delta.desktop", name: "deltachat", extra: "" }
- { app: "org.signal.Signal", name: "signal", extra: "" } - { app: "org.signal.Signal", name: "signal", extra: "" }
- { app: "org.mozilla.firefox", name: "firefox-flatpak", extra: "" } - { app: "org.mozilla.firefox", name: "firefox-flatpak", extra: "" }
flatpaks_coding: - { app: "com.transmissionbt.Transmission", name: "transmission", extra: "" }
- { app: "org.gnome.Geary", name: "geary", extra: "" }
flatpaks_coding:
- { app: "com.vscodium.codium", name: "codium", extra: "" } - { app: "com.vscodium.codium", name: "codium", extra: "" }
- { app: "com.google.AndroidStudio", name: "android-studio", extra: "" } - { app: "com.google.AndroidStudio", name: "android-studio", extra: "" }
- { app: "io.dbeaver.DBeaverCommunity", name: "dbeaver", 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:
- { app: "org.shotcut.Shotcut", name: "shotcut", extra: "" } - { app: "org.shotcut.Shotcut", name: "shotcut", extra: "" }
- { 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: "" }
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: "" }
- { app: "net.supertuxkart.SuperTuxKart", name: "tuxkart", extra: "" } - { app: "net.supertuxkart.SuperTuxKart", name: "tuxkart", extra: "" }
flatpaks_remove: flatpaks_remove:
- { app: "com.visualstudio.code", name: "vscode", extra: "" } # Why does this throw an error? It's the correct ID. - { app: "com.visualstudio.code", name: "vscode", extra: "" } # Why does this throw an error? It's the correct ID.
- { app: "com.visualstudio.code-oss", name: "code-oss", extra: "" }
- { app: "org.midori_browser.Midori", name: "midori", extra: "" } - { app: "org.midori_browser.Midori", name: "midori", extra: "" }
- { app: "com.github.Eloston.UngoogledChromium", name: "unchrome", extra: "" } - { app: "com.github.Eloston.UngoogledChromium", name: "unchrome", extra: "" }
- { app: "org.gnome.Evolution", name: "evolution", extra: "" } # Doesn't pick up GNOME theme since contained. - { app: "org.gnome.Evolution", name: "evolution", extra: "" } # Doesn't pick up GNOME theme since contained.
@ -67,6 +70,7 @@
- { app: "org.telegram.desktop", name: "telegram", extra: "" } - { app: "org.telegram.desktop", name: "telegram", extra: "" }
- { app: "com.jetbrains.PyCharm-Community", name: "pycharm", extra: "" } - { app: "com.jetbrains.PyCharm-Community", name: "pycharm", extra: "" }
# End 2022-11-20 # # End 2022-11-20 #
- { app: "io.lbry.lbry-app", name: "lbry", extra: "dbus-launch" } # No longer supported, noticed 2023-09-01.
# Generic # # Generic #

View File

@ -1,6 +1,45 @@
--- ---
# GNOME settings, extensions, and setup. # GNOME settings, extensions, and setup.
- name: Workstation | Account Management | GNOME | Facts
set_fact:
# Only do multiple entries per line if they are for the same exact program.
gnome_favorites: "[ 'org.gnome.Terminal.desktop'
, 'org.gnome.Console.desktop'
, 'gnome-system-monitor.desktop'
, 'org.gnome.Nautilus.desktop'
, 'io.gitlab.librewolf-community.desktop', 'librewolf.desktop'
, 'org.mozilla.firefox.desktop', 'firefox.desktop'
, 'org.gnome.Evolution.desktop'
, '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'
, 'io.lbry.lbry-app.desktop', 'lbry.desktop'
, 'org.signal.Signal.desktop', 'signal-desktop.desktop'
, 'im.riot.Riot.desktop'
, 'org.telegram.desktop.desktop'
, 'com.discordapp.Discord.desktop'
, 'com.valvesoftware.Steam.desktop'
]"
dconf_terminal: gnome-terminal
dconf_theme: Adwaita-dark
dconf_icons: Adwaita
- name: Workstation | Account Management | GNOME | Facts (NixOS)
set_fact:
dconf_terminal: kgx
when: ansible_distribution in ("NixOS")
- name: Workstation | Account Management | GNOME | Facts (Ubuntu)
set_fact:
dconf_theme: Yaru-purple-dark
dconf_icons: Yaru-purple-dark
when: ansible_distribution in ("Ubuntu")
# Make sure Gnome-Tweaks is installed # Make sure Gnome-Tweaks is installed
- name: Workstation | Account Management | GNOME | Install Dependencies - name: Workstation | Account Management | GNOME | Install Dependencies
package: package:
@ -9,7 +48,7 @@
- "{{ dconf_editor }}" - "{{ dconf_editor }}"
- "{{ psutil }}" - "{{ psutil }}"
state: present state: present
when: ansible_distribution not in ("NixOS")
## Dash to Dock Extension ## ## Dash to Dock Extension ##
# Note: Validate DtD by checking /org/gnome/shell/enabled-extensions for dash-to-dock@micxgx.gmail.com # Note: Validate DtD by checking /org/gnome/shell/enabled-extensions for dash-to-dock@micxgx.gmail.com
@ -136,140 +175,235 @@
state: present state: present
become_user: "{{ user }}" become_user: "{{ user }}"
when: ansible_distribution not in ("NixOS")
ignore_errors: yes ignore_errors: yes
# End block for Dash To Dock. # End block for Dash To Dock.
# The first Firefox is from Flatpak, and firefox_firefox.desktop is snap/apt. ## TBD Remove this after testing the RC version is successful on Ubuntu.
- name: Workstation | Account Management | GNOME + Cinnamon | Favorites (Linux) #- name: Workstation | Account Management | GNOME | More Settings
dconf: # block:
key: "{{ item }}" #
value: "[ 'org.gnome.Terminal.desktop', 'gnome-system-monitor.desktop' # - name: Workstation | Account Management | GNOME + Cinnamon | Favorites (Linux)
, 'org.gnome.Nautilus.desktop' # dconf:
, 'io.gitlab.librewolf-community.desktop' # key: "{{ item }}"
, 'org.mozilla.firefox.desktop' # value: "{{ gnome_favorites }}"
, 'org.gnome.Evolution.desktop', 'chat.delta.desktop.desktop' # state: present
, 'com.vscodium.codium.desktop', 'org.shotcut.Shotcut.desktop' # become_user: "{{ user }}"
, 'io.lbry.lbry-app.desktop' # #when: ansible_system == "Linux"
, 'org.signal.Signal.desktop', 'im.riot.Riot.desktop' # loop:
, 'org.telegram.desktop.desktop', 'com.discordapp.Discord.desktop' # - /org/gnome/shell/favorite-apps
, 'com.valvesoftware.Steam.desktop' # # - /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
blockinfile:
path: "{{ user_user.home }}/{{ item }}"
block: |
## Temporary Variables + Functions ##
dconf_count=1
function inc_dconf() {
dconf_count=$(( dconf_count + 1 ))
}
## Dash to Dock ##
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-position "'LEFT'" && inc_dconf &&
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-fixed true && inc_dconf &&
dconf write /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size 24 && inc_dconf &&
dconf write /org/gnome/shell/favorite-apps "{{ gnome_favorites }}" && inc_dconf &&
## Generic ##
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/gtk-theme "'{{ dconf_theme }}'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/icon-theme "'{{ dconf_icons }}'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-date true && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-format "'24h'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-seconds true && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-weekday true && inc_dconf &&
dconf write /org/gnome/desktop/calendar/show-weekdate true && inc_dconf &&
dconf write /org/gnome/desktop/interface/show-battery-percentage true && inc_dconf &&
dconf write /org/gnome/desktop/wm/preferences/button-layout "'appmenu:minimize,maximize,close'" && inc_dconf &&
dconf write /org/gnome/desktop/wm/preferences/num-workspaces 1 && inc_dconf &&
dconf write /org/gnome/mutter/dynamic-workspaces false && inc_dconf &&
dconf write /org/gnome/mutter/edge-tiling true && inc_dconf &&
dconf write /org/gnome/desktop/interface/enable-hot-corners false && inc_dconf &&
dconf write /org/gnome/mutter/center-new-windows true && inc_dconf &&
dconf write /org/gnome/desktop/notifications/show-banners false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable-sound-alerts false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution/enable-sound-alerts false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution/enable false && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/color/night-light-enabled true
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-automatic false
dconf write /org/gnome/settings-daemon/plugins/color/night-light-temperature "uint32 3170"
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-from 2.0
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-to 1.99
## Keyboard Shortcuts ##
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding \
"'<Control><Alt>t'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/command \
"'{{ dconf_terminal }}'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/name \
"'Open Terminal'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/binding \
"'<Super>t'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/command \
"'{{ dconf_terminal }}'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/name \
"'Open Terminal 2'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings "
[ '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/'
, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/'
]" && inc_dconf &&
## Privacy ##
dconf write /org/gnome/desktop/privacy/disable-camera true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/disable-microphone true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/recent-files-max-age 7 && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remember-recent-files false && inc_dconf &&
dconf write /org/gnome/desktop/privacy/old-files-age "uint32 14" && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remove-old-trash-files true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remove-old-temp-files true && inc_dconf &&
dconf write /org/gnome/desktop/notifications/show-in-lock-screen false && inc_dconf &&
dconf write /org/gnome/desktop/screensaver/lock-enabled true && inc_dconf &&
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/desktop/media-handling/autorun-never true && inc_dconf &&
## Success ##
sleep 0 ||
## Error Catch ##
echo "ERROR: DConf setting# $dconf_count failed!"
## Cleanup ##
unset -f inc_dconf
unset dconf_count
marker: '# {mark} MANAGED BY ANSIBLE | NixOS GNOME Settings'
state: present state: present
create: yes
backup: yes
become_user: "{{ user }}" become_user: "{{ user }}"
when: ansible_system == "Linux"
loop: loop:
- /org/gnome/shell/favorite-apps - .bashrc
- /org/cinnamon/favorite-apps - .zshrc
# As of 2023-07-01 this only sets the Menu Favorites on Cinnamon, not the #when: ansible_distribution in ("NixOS")
# 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.
- 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 }}"
# 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 }}"
# Schemas to try after looking at gsettings list-schemas | sort
# org.gnome.ControlCenter -- not very interesting
# org.gnome.desktop.default-applications -- nothing?? Where do we set Brave and Evolution?
# org.gnome.desktop.interface -- Good stuff in here.
# org.gnome.desktop.peripherals -- Nothing :(
# org.gnome.desktop.privacy -- Good stuff here too!! Cool!
# org.gnome.desktop.session
# org.gnome.desktop.wm.keybindings
# org.gnome.desktop.wm.preferences
# org.gnome.power-manager
# org.gnome.SessionManager
# org.gnome.shell
# org.gnome.shell.extensions.pop-shell
# org.gnome.shell.keybindings

View File

@ -3,7 +3,7 @@
## CUPS ## ## CUPS ##
- name: General | Software | Services | Disable CUPS Daemon - name: General | Software | Services | Enable CUPS Daemon
service: service:
name: "{{ cups }}" name: "{{ cups }}"
pattern: "{{ cups_pattern }}" pattern: "{{ cups_pattern }}"
@ -11,7 +11,7 @@
enabled: yes enabled: yes
ignore_errors: yes ignore_errors: yes
- name: General | Software | Services | Disable CUPS-Browse Daemon - name: General | Software | Services | Enable CUPS-Browse Daemon
service: service:
name: "{{ cups_browse }}" name: "{{ cups_browse }}"
pattern: "{{ cups_browse_pattern }}" pattern: "{{ cups_browse_pattern }}"