Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 407bdb2ddf | |||
| d1cd9dddf1 | |||
| 68eb84af52 | |||
| 46d1bfb70e | |||
| 8970bb3a1b | |||
| eae66f9967 | |||
| 2770bbac5f | |||
| a0f7773998 | |||
| 6ccdb395cd | |||
| b48dbbeee1 | |||
| 07cc51a5cc | |||
| 428684b9b3 | |||
| e42e3b4fcd | |||
| 856290c33f | |||
| e7ae358fa9 | |||
| 16dfeca689 | |||
| 0e1cb8bacb | |||
| 8898959a95 | |||
| 4c467fff6d | |||
| c927a5bd2d | |||
| 32dfd0af25 | |||
| 8636a0e112 | |||
| 4864ee3869 | |||
| 0d8d872bfc | |||
| b562308cf1 | |||
| c2790e2de4 | |||
| 2be7e028b6 | |||
| 0920493634 | |||
| 03b8169401 | |||
| cfc2694737 | |||
| fca20b31bd | |||
| 1f4abd2d6c | |||
| a42d1d05df | |||
| 07d1adc926 | |||
| 71ca410123 | |||
| c46c78519b | |||
| 816a0d4f69 | |||
| f8a60b4287 | |||
| a7f395a62a | |||
| f02aec2cdb | |||
| a94959bcf9 | |||
| 5004250f85 | |||
| 4c4d4bbef7 | |||
| d32b636a99 | |||
| a7083733cc | |||
| 97ddcc4573 | |||
| dc2ae57bd6 | |||
| 82ab31b9ea | |||
| 49ababedc5 | |||
| 0d3931d738 | |||
| 7c93f25a5d | |||
| 8445b64d6b | |||
| 8dfb3fe2a6 | |||
| 5b749d2100 | |||
| 57ca267aa5 | |||
| 2ca308c287 | |||
| 40ee72b587 | |||
| 13bc98d7ef | |||
| d916637798 | |||
| 71d236d0ba | |||
| d81c424878 | |||
| 73e527640f | |||
| aa3075a9fc | |||
| 89cdf8157f | |||
| 4e0ff86295 | |||
| 305b8df6ff | |||
| 6a78933875 | |||
| 7095636915 |
@@ -2,7 +2,7 @@
|
||||
# Define program names for package builtin.
|
||||
# This file is for ALL systems and should not include UI components.
|
||||
|
||||
- name: General | Facts | Packages | Shared Defaults
|
||||
- name: General | Facts | Package | Shared Defaults
|
||||
set_fact:
|
||||
sshfs: sshfs
|
||||
tar: tar
|
||||
@@ -12,7 +12,7 @@
|
||||
dig: dig
|
||||
neofetch: neofetch
|
||||
|
||||
- name: General | Facts | Packages | Parrot OS Fixes
|
||||
- name: General | Facts | Package | Parrot OS Fixes
|
||||
set_fact:
|
||||
ansible_pkg_mgr: "apt"
|
||||
ansible_python_interpreter: "/usr/bin/python3"
|
||||
@@ -56,10 +56,15 @@
|
||||
encfs: fusefs-encfs
|
||||
when: ansible_system == "FreeBSD"
|
||||
|
||||
- name: General | Facts | Package | dnf (Fixes) # TBD: Fix + test package names: mlocate, dig, neofetch
|
||||
set_fact:
|
||||
ansible_pkg_mgr: dnf
|
||||
when: ansible_pkg_mgr in ("dnf5")
|
||||
|
||||
- name: General | Facts | Package | dnf
|
||||
set_fact:
|
||||
sshfs: fuse-sshfs
|
||||
locate: mlocate
|
||||
locate: plocate
|
||||
opensshd: openssh
|
||||
microcode_amd: microcode_ctl
|
||||
microcode_intel: microcode_ctl
|
||||
|
||||
8
files/dwm/battery.function
Executable file
8
files/dwm/battery.function
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# 2025-11-10 Hyperling
|
||||
|
||||
function battery {
|
||||
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9.%]*"
|
||||
}
|
||||
alias show-battery="battery"
|
||||
alias battery-display="battery"
|
||||
@@ -104,7 +104,11 @@ static Key keys[] = {
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
// Mine
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
// Volume (https://varunbpatil.github.io/2013/09/28/dwm.html)
|
||||
// extra search shortcut
|
||||
{ MODKEY, XK_s, spawn, {.v = dmenucmd } },
|
||||
// fullscreen shortcut for m onocle
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[2]} },
|
||||
// Volume (https://varunbpatil.github.io/2013/09/28/dwm.html)
|
||||
{ 0, 0x1008ff12,spawn, {.v = mutecmd } },
|
||||
{ 0, 0x1008ff11,spawn, {.v = lowervolcmd } },
|
||||
{ 0, 0x1008ff13,spawn, {.v = raisevolcmd } },
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
## Load System Libs ##
|
||||
|
||||
if [ -d /etc/X11/xinit/xinitrc.d ]; then
|
||||
for f in /etc/X11/xinit/xinitrc.d/*; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
for f in /etc/X11/xinit/xinitrc.d/*; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
fi
|
||||
|
||||
if [ -d /usr/local/etc/X11/xinit/xinitrc.d ]; then
|
||||
for f in /usr/local/etc/X11/xinit/xinitrc.d/*; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
for f in /usr/local/etc/X11/xinit/xinitrc.d/*; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
fi
|
||||
|
||||
|
||||
@@ -35,8 +35,23 @@ xsetroot -solid "$purple"
|
||||
#exec slstatus &
|
||||
|
||||
# Custom #
|
||||
source "`which volume.function`"
|
||||
source "`which battery.function`"
|
||||
source "`which storage.function`"
|
||||
if [[ "`storage-root`" == "`storage-home`" ]]; then
|
||||
storage_cmd=echo 'Storage: `storage-root-dwm`)"'
|
||||
else
|
||||
storage_cmd=echo '"Storage(Root:`storage-root-dwm` Home:`storage-home-dwm`)'
|
||||
fi
|
||||
while true; do
|
||||
xsetroot -name "`whoami`@`hostname` `date +"%Y-%m-%d %H:%M:%S"`"
|
||||
readout="$readout Battery: `battery-display`"
|
||||
readout="$readout | `storage_cmd`"
|
||||
readout="$readout | `volume-display`"
|
||||
readout="$readout | `whoami`@`hostname`"
|
||||
readout="$readout `date +"%Y-%m-%d %H:%M:%S"`"
|
||||
xsetroot -name "$readout"
|
||||
readout=""
|
||||
sleep 0.75
|
||||
done &
|
||||
|
||||
|
||||
|
||||
35
files/dwm/storage.function
Executable file
35
files/dwm/storage.function
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# 2025-11-10 Hyperling
|
||||
|
||||
function storage {
|
||||
location="$1"
|
||||
style="$2"
|
||||
|
||||
if [[ -z "$location" ]]; then
|
||||
echo "ERROR: Location must be passed. $location"
|
||||
fi
|
||||
|
||||
if [[ "$style" == "%" || "$style" == "pct" || "$style" == "percent" ]]; then
|
||||
df -h "$location" | tail -n 1 | awk '{print $5}'
|
||||
elif [[ "$style" == "/" || "$style" == "use" || "$style" == "usage" ]]; then
|
||||
df -h "$location" | tail -n 1 | awk '{print $3"/"$2}'
|
||||
else
|
||||
df -h "$location" | tail -n 1 | awk '{print $5" Free, "$3"/"$2" Used"}'
|
||||
fi
|
||||
}
|
||||
|
||||
export dwm_storage_style="usage"
|
||||
|
||||
function storage-root {
|
||||
storage / "$1"
|
||||
}
|
||||
function storage-root-dwm {
|
||||
storage-root "$dwm_storage_style"
|
||||
}
|
||||
|
||||
function storage-home {
|
||||
storage /home "$1"
|
||||
}
|
||||
function storage-home-dwm {
|
||||
storage-root "$dwm_storage_style"
|
||||
}
|
||||
153
files/dwm/volume.function
Executable file
153
files/dwm/volume.function
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env bash
|
||||
# 2025-11-10 Hyperling
|
||||
# Volume management for systems without working volume buttons.
|
||||
# Written for ease of use in terminal and simple window management systems.
|
||||
|
||||
function volume-usage {
|
||||
cat <<- EOF
|
||||
Usage: volume [%int] [(+/-)%int] [-d] [-r] [-t] [-h]
|
||||
|
||||
Set to a static value:
|
||||
volume 100, volume 65
|
||||
|
||||
Increment or decrement. Passing only + or - and no number defaults to 5.
|
||||
volume -5, volume 5-, volume - 5, volume 5 -
|
||||
volume +20, volume 20+, volume + 20, volume 20 +
|
||||
|
||||
Display the current volume:
|
||||
volume,
|
||||
volume-display, volume display, volume --display, volume -d,
|
||||
volume +d
|
||||
|
||||
Set volume to a random number between 0 and 100.
|
||||
volume-random, volume random, volume --random, volume -r
|
||||
|
||||
Be silly and oscillate volume in a loop:
|
||||
volume-trip, volume trip, volume --trip, volume -t
|
||||
|
||||
Display this help text:
|
||||
volume-usage,
|
||||
volume-help volume help, volume --help, volume -h
|
||||
EOF
|
||||
return "$1"
|
||||
}
|
||||
alias volume-help="volume-usage"
|
||||
alias vol-h="volume-help"
|
||||
|
||||
function volume {
|
||||
if [[ "$1" == "--help" || "$1" == "help" || "$1" == "-h" ]]; then
|
||||
volume-usage
|
||||
fi
|
||||
if [[ (-z "$1" && -z "$2")
|
||||
|| "$1" == "--display" || "$1" == "display" || "$1" == "-d" || "$1" == "+d"
|
||||
]]; then
|
||||
volume-display
|
||||
fi
|
||||
|
||||
if [[ "$1" == *"%"* || "$2" == *"%"* ]]; then
|
||||
set -- "${1//%/}" "${2//%/}"
|
||||
fi
|
||||
|
||||
dir=""
|
||||
amt=""
|
||||
|
||||
# Check if format is written text.
|
||||
if [[ "$1" == "full" || "$1" == "max" ]]; then
|
||||
amt=100
|
||||
fi
|
||||
if [[ "$1" == "mute" || "$1" == "none" ]]; then
|
||||
amt=0
|
||||
fi
|
||||
|
||||
# Check if the format is "volume +/- %int"
|
||||
if [[ -z "$amt" && -z "$dir" ]]; then
|
||||
if [[ "$1" == "+" || "$1" == "-" ]]; then
|
||||
dir="$1"
|
||||
amt="$2"
|
||||
if [[ -z "$2" ]]; then
|
||||
amt="5"
|
||||
else
|
||||
amt="$2"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if the format is "volume +/- %int".
|
||||
if [[ -z "$amt" && -z "$dir" ]]; then
|
||||
if [[ "$2" == "+" || "$2" == "-" ]]; then
|
||||
amt="$1"
|
||||
dir="$2"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if amount and direction are adjacent, and if so, pull the values.
|
||||
if [[ -z "$amt" && -z "$dir" ]]; then
|
||||
if [[ "$1" == *"+"* ]]; then
|
||||
dir="+"
|
||||
elif [[ "$1" == *"-"* ]]; then
|
||||
dir="-"
|
||||
fi
|
||||
if [[ -n "$dir" && -z "$amt" ]]; then
|
||||
amt="$1"
|
||||
amt=${amt//-/}
|
||||
amt=${amt//+/}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if format is direct volume.
|
||||
if [[ -z "$dir" && -z "$amt" && -n "$1" && -z "$2" ]]; then
|
||||
amt="$1"
|
||||
fi
|
||||
|
||||
if [[ -n "$dir" && -n "$amt" ]]; then
|
||||
echo "> Changing volume by '$dir$amt%'."
|
||||
amixer -q sset Master ${amt}%${dir}
|
||||
echo "> Volume is now '`volume-display`'."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -z "$dir" && -n "$1" ]]; then
|
||||
echo "> Setting volume to '$amt'."
|
||||
amixer -q sset Master ${amt}%
|
||||
echo "> Volume has been set to '`volume-display`'."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Error: Should not have made it here. Please report this to the developer."
|
||||
echo "$0 $1 $2"
|
||||
return 7
|
||||
}
|
||||
alias vol="volume "
|
||||
alias vol-="volume - "
|
||||
alias vol+="volume + "
|
||||
|
||||
function volume-display {
|
||||
if [[ "$1" == "-v" || "$1" == "--verbose" || "$1" == "verbose" ]]; then
|
||||
amixer sget Master
|
||||
else
|
||||
amixer sget Master | egrep -o '[0-9]{1,3}%' | head -n 1
|
||||
fi
|
||||
}
|
||||
alias "vol-d"="volume-display"
|
||||
|
||||
# Go up and down until cancelled.
|
||||
#function volume-trip {
|
||||
# curr eq amixer current readout
|
||||
# if curr lt 50 then dir eq + else dir eq -
|
||||
# while true; do
|
||||
# if vol is 0 then dir eq +
|
||||
# if vol is 100 then dir eq -
|
||||
# curr eq \$curr $dir 1
|
||||
# amixer set volume to curr
|
||||
# sleep 0.1
|
||||
# done
|
||||
#}
|
||||
#alias vol-t="volume-trip"
|
||||
#alias volume-wub="volume-trip"
|
||||
#alias vol-w="volume-wub"
|
||||
|
||||
#function volume-random {
|
||||
# v eq $RANDOM % 101
|
||||
# amixer set volume eq v
|
||||
#}
|
||||
#alias vol-r="volume-random"
|
||||
@@ -48,7 +48,7 @@ fi
|
||||
|
||||
if [[ -e "$BACKUP" ]]; then
|
||||
ls -alh "$BACKUP"
|
||||
echo "*** '$BACKUP' created successfully! ***"s
|
||||
echo "*** '$BACKUP' created successfully! ***"
|
||||
else
|
||||
echo "*** '$BACKUP' not found! ***"
|
||||
exit 1
|
||||
|
||||
103
setup.sh
103
setup.sh
@@ -9,13 +9,18 @@ LOCAL=$DIR/local.yml
|
||||
URL="https://git.hyperling.com/me/env-ansible"
|
||||
BRANCH="main"
|
||||
|
||||
config_dir="/usr/local/etc/hyperling-scm"
|
||||
general_config="$config_dir/general.ini"
|
||||
workstation_config="$config_dir/workstation.ini"
|
||||
server_config="$config_dir/server.ini"
|
||||
|
||||
## Functions ##
|
||||
|
||||
# Accepts 1 parameter, it is used as the exit status.
|
||||
function usage {
|
||||
cat <<- EOF
|
||||
|
||||
$PROG [-l] [-b branch_name] [-h]
|
||||
$PROG [-l] [-b branch_name] [-g] [-w] [-s] [-f] [-h]
|
||||
Program to initialize synchronization with Hyperling's Ansible configuration.
|
||||
$URL
|
||||
|
||||
@@ -23,8 +28,12 @@ function usage {
|
||||
-l : Run the local playbook associated with this $PROG.
|
||||
This is helpful for development or just saving bandwidth.
|
||||
It also provides prettier colors than the plaintext from ansible-pull. ;)
|
||||
-b branch_name: Download and run a specific branch. Default is $BRANCH.
|
||||
-h : Display this help text
|
||||
-b branch_name : Download and run a specific branch. Default is $BRANCH.
|
||||
-g : Enable the General config with test contents.
|
||||
-w : Enable the Workstation config with test contents.
|
||||
-s : Enable the Server config with test contents.
|
||||
-f : Display this system's facts.
|
||||
-h : Display this help text.
|
||||
|
||||
EOF
|
||||
exit $1
|
||||
@@ -32,10 +41,14 @@ function usage {
|
||||
|
||||
## Parameter Parsing ##
|
||||
|
||||
while getopts ":lb:h" arg; do
|
||||
while getopts ":lb:gwsfh" arg; do
|
||||
case $arg in
|
||||
l) local="Y" && echo "Running $LOCAL as the playbook." ;;
|
||||
b) branch="$OPTARG" && echo "Using branch $branch instead of $BRANCH." ;;
|
||||
g) create_general="Y" && echo "Requested '$general_config'." ;;
|
||||
w) create_workstation="Y" && echo "Requested '$workstation_config'." ;;
|
||||
s) create_server="Y" && echo "Requested '$server_config'." ;;
|
||||
f) show_facts="Y" ;;
|
||||
h) usage ;;
|
||||
*) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
|
||||
esac
|
||||
@@ -47,15 +60,32 @@ if [[ ! -z $1 && $1 != "-"* ]]; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
if [[ $branch == "" ]]; then
|
||||
if [[ -z "$local" && "$branch" == "" ]]; then
|
||||
echo "Using default branch $BRANCH."
|
||||
branch="$BRANCH"
|
||||
fi
|
||||
|
||||
if [[ -n "$create_general" && -f "$general_config" ]]; then
|
||||
echo "WARNING: General configuration already exists, will not overwrite."
|
||||
ls -lh "$general"
|
||||
fi
|
||||
if [[ -n "$create_workstation" && -f "$workstation_config" ]]; then
|
||||
echo "WARNING: Workstation configuration already exists, will not overwrite."
|
||||
ls -lh "$workstation_config"
|
||||
fi
|
||||
if [[ -n "$create_server" && -f "$server_config" ]]; then
|
||||
echo "WARNING: Server configuration already exists, will not overwrite."
|
||||
ls -lh "$server_config"
|
||||
fi
|
||||
|
||||
## Main ##
|
||||
|
||||
os="$(cat /etc/os-release)"
|
||||
os="$os $(uname -a)"
|
||||
if [[ ! -f /.dockerenv ]]; then
|
||||
# If we are not in a Docker container, also check what the kernel says.
|
||||
os="$os $(uname -a)"
|
||||
# Docker containers use the host kernel which gives an incorrect reading.
|
||||
fi
|
||||
|
||||
echo "Making sure all necessary packages are installed..."
|
||||
if [[ `which ansible > /dev/null; echo $?` != 0 ]]; then
|
||||
@@ -97,10 +127,71 @@ if [[ `which ansible > /dev/null; echo $?` != 0 ]]; then
|
||||
fi
|
||||
echo "Installed!"
|
||||
|
||||
if [[ "$show_facts" == "Y" ]]; then
|
||||
echo "Showing Ansible Facts"
|
||||
ansible localhost -m setup --connection=local
|
||||
fi
|
||||
|
||||
#echo "Adding Ansible Collections..."
|
||||
#ansible-galaxy collection install community.general
|
||||
#echo "Added!"
|
||||
|
||||
# Create basic layouts if configs do not exist and are requested.
|
||||
|
||||
if [[ -n "$create_general"
|
||||
|| -n "$create_workstation"
|
||||
|| -n "$create_server" ]]
|
||||
then
|
||||
sudo mkdir -pv "$config_dir"
|
||||
MARK1="BEGIN"
|
||||
MARK2="END"
|
||||
fi
|
||||
if [[ -n "$create_general" && ! -f "$general_config" ]]; then
|
||||
function print_general_contents {
|
||||
cat <<- EOF
|
||||
; $MARK1 MANAGED BY ANSIBLE | Generic Config
|
||||
; $MARK2 MANAGED BY ANSIBLE | Generic Config
|
||||
; TEST DATA
|
||||
enable=true
|
||||
user=test
|
||||
user_desc=Test
|
||||
branch=$branch
|
||||
; TEST DATA
|
||||
EOF
|
||||
}
|
||||
print_general_contents | sudo tee "$general_config"
|
||||
ls -lh "$general_config"
|
||||
fi
|
||||
if [[ -n "$create_workstation" && ! -f "$workstation_config" ]]; then
|
||||
function print_workstation_contents {
|
||||
cat <<- EOF
|
||||
; $MARK1 MANAGED BY ANSIBLE | Workstation Config
|
||||
; $MARK2 MANAGED BY ANSIBLE | Workstation Config
|
||||
; TEST DATA
|
||||
enable=true
|
||||
coding=true
|
||||
editing=false
|
||||
gaming=false
|
||||
; TEST DATA
|
||||
EOF
|
||||
}
|
||||
print_workstation_contents | sudo tee "$workstation_config"
|
||||
ls -lh "$workstation_config"
|
||||
fi
|
||||
if [[ -n "$create_server" && ! -f "$server_config" ]]; then
|
||||
function print_server_contents {
|
||||
cat <<- EOF
|
||||
; $MARK1 MANAGED BY ANSIBLE | Server Config
|
||||
; $MARK2 MANAGED BY ANSIBLE | Server Config
|
||||
; TEST DATA
|
||||
enable=true
|
||||
; TEST DATA
|
||||
EOF
|
||||
}
|
||||
print_server_contents | sudo tee "$server_config"
|
||||
ls -lh "$server_config"
|
||||
fi
|
||||
|
||||
echo "Provisioning Ansible..."
|
||||
if [[ $local == "Y" ]]; then
|
||||
sudo ansible-playbook $LOCAL
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
blockinfile:
|
||||
path: "{{ gen_file }}"
|
||||
block: |
|
||||
; Please note that all potions require lowercase keys and values.
|
||||
; Please note that all portions require lowercase keys and values.
|
||||
;
|
||||
;;;;;;;;;;;;;;;;;;;; Basic Options ;;;;;;;;;;;;;;;;;;;;
|
||||
;
|
||||
|
||||
@@ -564,6 +564,16 @@
|
||||
echo -e "\n*** `basename $project` ***"
|
||||
cd $project
|
||||
if [[ -d .git ]]; then
|
||||
git ls-remote --exit-code --heads origin dev
|
||||
dev_exists="$?"
|
||||
if [[ "$dev_exists" == 0 ]]; then
|
||||
git switch dev
|
||||
elif [[ "$dev_exists" == 2 ]]; then
|
||||
git switch main
|
||||
else
|
||||
echo "ERROR: Unknown status for dev_exists, '$dev_exists'."
|
||||
continue
|
||||
fi
|
||||
git pull
|
||||
git push
|
||||
else
|
||||
@@ -783,16 +793,70 @@
|
||||
date "+%Y%m%d"
|
||||
}
|
||||
function_backup: |
|
||||
export BACKUP_DIR="/srv/backup"
|
||||
function backup {
|
||||
/usr/local/bin/backup_system.sh
|
||||
}
|
||||
alias backup-system="backup"
|
||||
alias system-backup="backup"
|
||||
alias check-backups="ll /srv/backup"
|
||||
alias check-backups="ll $BACKUP_DIR"
|
||||
function clean-backup {
|
||||
sh -c "rm -rfv /srv/backup/*"
|
||||
sh -c "rm -rfv $BACKUP_DIR/*"
|
||||
}
|
||||
alias clean-backups="clean-backup"
|
||||
function_pull_prod_backups: |
|
||||
export DOCKER="Docker"
|
||||
export SYSTEM="System"
|
||||
function pull_prod_backup {
|
||||
if [[ -z "$1" || ("$1" != "$DOCKER" && "$1" != "$SYSTEM") ]]; then
|
||||
echo "ERROR: Parameter 1 not correct, expecting '$DOCKER' or '$SYSTEM'."
|
||||
return 1
|
||||
fi
|
||||
backup_type="$1"
|
||||
echo "Looking for '*${backup_type}*.zip'"
|
||||
ls -lh *${backup_type}*.zip 2>/dev/null
|
||||
status="$?"
|
||||
if [[ "$status" == "0" ]]; then
|
||||
echo "File already downloaded, skipping."
|
||||
return 0
|
||||
else
|
||||
echo "File still needed, downloading to local tmp/."
|
||||
fi
|
||||
mkdir -pv tmp
|
||||
scp -P {{ prod_port }} \
|
||||
{{ prod_user }}@{{ prod_host }}:"$BACKUP_DIR/*${backup_type}*.zip" \
|
||||
tmp/
|
||||
if [[ "$?" == "0" ]]; then
|
||||
echo "Succeeded!"
|
||||
mv -v tmp/*.zip ./
|
||||
rmdir -v tmp
|
||||
else
|
||||
echo "Failed!"
|
||||
mv tmp ~/TRASH/"tmp_`now`"
|
||||
fi
|
||||
}
|
||||
function pull_prod_backups {
|
||||
dir="ProductionBackups-Pulled`today`"
|
||||
mkdir -pv "$dir"
|
||||
cd "$dir"
|
||||
pull_prod_backup "$DOCKER"
|
||||
pull_prod_backup "$SYSTEM"
|
||||
du -h *.zip | sort -h
|
||||
status="$?"
|
||||
cd ..
|
||||
if [[ "$status" != 0 ]]; then
|
||||
echo "Failed to find zip files, removing folder."
|
||||
rmdir -v "$dir"
|
||||
return 1
|
||||
fi
|
||||
echo "Done!"
|
||||
}
|
||||
alias pull-prod-backups="pull_prod_backups"
|
||||
alias pull-backups="pull_prod_backups"
|
||||
alias prod-backups="pull_prod_backups"
|
||||
alias prod-backup="pull_prod_backups"
|
||||
alias pull-prod="pull_prod_backups"
|
||||
alias prod-pull="pull_prod_backups"
|
||||
function_log: |
|
||||
function log {
|
||||
echo -e "$1"
|
||||
@@ -881,6 +945,89 @@
|
||||
alias_sudo: |
|
||||
# Allows for alias expansions when using sudo, such as doing "sudo ll".
|
||||
alias sudo="sudo "
|
||||
function_load_branch: |
|
||||
# Change a branch to point at another.
|
||||
function load-branch {
|
||||
rcvr="$1" # branch which we want to modify
|
||||
base="$2" # branch with the changes we want
|
||||
|
||||
if [[ "$rcvr" == "main" ]]; then
|
||||
echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$base" ]]; then
|
||||
if [[ "$rcvr" == "prod" ]]; then
|
||||
base="stage"
|
||||
elif [[ "$rcvr" == "stage" ]]; then
|
||||
base="dev"
|
||||
else
|
||||
echo "* Unsure which branch to use for '$rcvr'. Please specify."
|
||||
exit 1
|
||||
fi
|
||||
echo "* Base was not specified, using '$base' for '$rcvr'."
|
||||
else
|
||||
echo "* Requested pointing '$rcvr' branch to '$base'."
|
||||
fi
|
||||
|
||||
echo -e "\n* Ensuring we are on base branch '$base'." &&
|
||||
git switch "$base" &&
|
||||
echo -e "\n* Changing pointer for '$rcvr' to '$base'." &&
|
||||
git branch -f "$rcvr" "$base" &&
|
||||
#echo -e "\n* Switching to branch '$rcvr'." &&
|
||||
#git switch "$rcvr" &&
|
||||
echo -e "\n* Forcing push on branch '$rcvr'." &&
|
||||
git push --force --set-upstream origin "$rcvr" &&
|
||||
echo -e "\n* Done! Displaying list of remote branches." &&
|
||||
git ls-remote --heads | sort
|
||||
|
||||
if [[ "$base" != "dev" ]]; then
|
||||
echo -e "\n* Checking if a dev branch exists."
|
||||
git ls-remote --exit-code --heads origin dev
|
||||
dev_exists="$?"
|
||||
if [[ "$dev_exists" == 0 ]]; then
|
||||
echo -e "\n* Switching back to dev."
|
||||
git switch dev
|
||||
elif [[ "$dev_exists" == 2 ]]; then
|
||||
echo -e "\n* Switching back to main."
|
||||
git switch main
|
||||
else
|
||||
echo "*** ERROR: Unknown status for dev_exists, '$dev_exists'. ***"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "\n* Verifying which branch we're on."
|
||||
git branch
|
||||
}
|
||||
alias load-prod="load-branch prod"
|
||||
alias load-stage="load-branch stage"
|
||||
alias rollback-prod="load-branch prod main"
|
||||
alias rollback-stage="load-branch stage prod"
|
||||
alias rollback-dev="load-branch dev stage"
|
||||
alias reset-prod="load-branch prod main"
|
||||
alias reset-stage="load-branch stage main"
|
||||
alias reset-dev="load-branch dev main"
|
||||
alias_reload_bash: |
|
||||
alias reload-bash="source ~/.bashrc"
|
||||
alias bash-reload="reload-bash"
|
||||
alias shell-reload="reload-bash"
|
||||
alias reload-shell="reload-bash"
|
||||
alias reload="reload-bash"
|
||||
alias_hugo_server: |
|
||||
alias hugo-server-dev="hugo server -D --gc --ignoreCache --noHTTPCache --disableFastRender"
|
||||
alias hugo-server-stage="hugo server --gc --noHTTPCache --disableFastRender"
|
||||
alias hugo-server-prod="hugo server --gc --minify"
|
||||
alias hugo-server="hugo-server-dev"
|
||||
dwm_functions: |
|
||||
if [[ -f "{{ global_bin }}/volume.function" ]]; then
|
||||
source "{{ global_bin }}/volume.function"
|
||||
fi
|
||||
if [[ -f "{{ global_bin }}/battery.function" ]]; then
|
||||
source "{{ global_bin }}/battery.function"
|
||||
fi
|
||||
if [[ -f "{{ global_bin }}/storage.function" ]]; then
|
||||
source "{{ global_bin }}/storage.function"
|
||||
fi
|
||||
|
||||
- name: General | Account Management | Users | Files | Common Variable
|
||||
set_fact:
|
||||
@@ -952,10 +1099,15 @@
|
||||
{{ alias_ansible_facts }}
|
||||
{{ function_now }}
|
||||
{{ function_backup }}
|
||||
{{ function_pull_prod_backups }}
|
||||
{{ function_log }}
|
||||
{{ function_debian_upgrade }}
|
||||
{{ function_ebook_convert }}
|
||||
{{ alias_sudo }}
|
||||
{{ function_load_branch }}
|
||||
{{ alias_reload_bash }}
|
||||
{{ alias_hugo_server }}
|
||||
{{ dwm_functions }}
|
||||
|
||||
- name: General | Account Management | Users | Files | .bashrc
|
||||
blockinfile:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
user: ansible
|
||||
name: "Ansible Sync"
|
||||
minute: "*/30"
|
||||
job: "sleep $(( $RANDOM / 20 )); sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}"
|
||||
job: "bash -c 'sleep $(( $RANDOM / 20 )); sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}'"
|
||||
state: present
|
||||
disabled: "{{ 'yes' if no_telem else 'no' }}"
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
user: ansible
|
||||
name: "Ansible Weekly Forced Sync"
|
||||
special_time: daily
|
||||
job: "sleep $(( $RANDOM / 1 )); sudo {{ ansible_pull_exec.stdout }} -v -U {{ git_repo_http }} --checkout {{ branch }}"
|
||||
job: "bash -c 'sleep $(( $RANDOM / 1 )); sudo {{ ansible_pull_exec.stdout }} -v -U {{ git_repo_http }} --checkout {{ branch }}'"
|
||||
state: present
|
||||
disabled: "{{ 'yes' if no_telem else 'no' }}"
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
- { app: "org.gimp.GIMP", name: "gimp", extra: "" }
|
||||
- { app: "org.libreoffice.LibreOffice", name: "office", extra: "" }
|
||||
- { app: "com.transmissionbt.Transmission", name: "transmission", extra: "" }
|
||||
- { app: "app.grayjay.Grayjay", name: "grayjay", extra: "" }
|
||||
flatpaks_coding:
|
||||
- { app: "com.vscodium.codium", name: "codium-flatpak", extra: "" }
|
||||
- { app: "com.google.AndroidStudio", name: "android-studio", extra: "" }
|
||||
|
||||
@@ -19,9 +19,11 @@
|
||||
, 'codium.desktop'
|
||||
, 'org.shotcut.Shotcut.desktop'
|
||||
, 'io.lmms.LMMS.desktop'
|
||||
, 'app.grayjay.Grayjay.desktop'
|
||||
, 'io.lbry.lbry-app.desktop', 'lbry.desktop'
|
||||
, 'com.valvesoftware.Steam.desktop'
|
||||
, 'net.lutris.Lutris.desktop'
|
||||
, 'mullvad-vpn.desktop'
|
||||
]"
|
||||
dconf_terminal: gnome-terminal
|
||||
dconf_theme: Adwaita-dark
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# https://dwm.suckless.org/
|
||||
# https://sites.google.com/site/lazyboxx/-articles/dwm-a-newbie-s-guide#TOC-Status-Bar
|
||||
|
||||
#TODO: Move this to tasks/shared/ pasth rather than tasks/linux/.
|
||||
#TODO: Move this to tasks/shared/ path rather than tasks/linux/.
|
||||
#TODO: Generate files based on blockinfile.
|
||||
#TODO: Fix config.mk for FreeBSD automatically (use /usr/local/ for libs not /usr/X11RC/)
|
||||
#TODO: scm.sh to use bash variable so that FreeBSD correctly hits /usr/local/bin/bash.
|
||||
@@ -23,14 +23,14 @@
|
||||
## Download ##
|
||||
|
||||
- name: Workstation | Linux | Software | DWM | Git Clone
|
||||
git:
|
||||
git:
|
||||
repo: https://git.suckless.org/dwm
|
||||
dest: "{{ dwm_install_dir }}"
|
||||
clone: yes
|
||||
force: yes
|
||||
|
||||
- name: Workstation | Linux | Software | DWM | Git Clone (st)
|
||||
git:
|
||||
git:
|
||||
repo: https://git.suckless.org/st
|
||||
dest: "{{ st_install_dir }}"
|
||||
clone: yes
|
||||
@@ -78,3 +78,16 @@
|
||||
owner: root
|
||||
group: "{{ root_group }}"
|
||||
mode: 0644
|
||||
|
||||
|
||||
## Helper Functions for Status Bar ##
|
||||
|
||||
- name: Workstation | Linux | Software | DWM | Status Bar Functions
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ global_bin }}"
|
||||
owner: root
|
||||
group: "{{ root_group }}"
|
||||
mode: 0644
|
||||
with_fileglob:
|
||||
- "dwm/*.function"
|
||||
|
||||
Reference in New Issue
Block a user