Compare commits

...

25 Commits

Author SHA1 Message Date
d32b636a99 Add more output. 2025-10-23 20:02:52 -07:00
a7083733cc Add check on whether any zips were successful. 2025-10-23 19:59:56 -07:00
97ddcc4573 Properly handle removing the failed files. 2025-10-23 19:50:57 -07:00
dc2ae57bd6 Add command to pull production backups while making sure that failed downloads are easily identified. 2025-10-23 19:42:50 -07:00
82ab31b9ea Add Grayjay to GNOME favorites. 2025-10-20 19:33:09 -07:00
49ababedc5 Add the flatpak Grayjay. 2025-10-20 19:32:49 -07:00
0d3931d738 Fix cronjobs to use BASH for RANDOM variable. 2025-10-19 21:41:59 -07:00
7c93f25a5d Add output for why dev branch shows up twice during load-prod. 2025-10-15 06:45:49 -07:00
8445b64d6b Check if the dev branch exists before moving to it. 2025-10-15 06:42:16 -07:00
8dfb3fe2a6 Change rollback aliases to only go down 1 layer. Add reset aliases for going all the way back to main. 2025-10-15 06:38:50 -07:00
5b749d2100 Fix failed branch switch. Hardcode to dev! 2025-10-15 06:35:02 -07:00
57ca267aa5 Add back the display of the current local branch we're on. Add newlines for readability. 2025-10-15 06:32:28 -07:00
2ca308c287 Re-do changes lost between branch pointing. 2025-10-15 06:28:38 -07:00
40ee72b587 Only continue each commnd if they are successful. 2025-10-15 06:15:13 -07:00
13bc98d7ef Further enhancments to load-branch. Better output and branch choices. 2025-10-15 06:06:05 -07:00
d916637798 Complete the conditional branches. 2025-10-15 05:53:48 -07:00
71d236d0ba Add aliases to roll branches back to main, AKA the last official pull request. 2025-10-15 05:48:18 -07:00
d81c424878 Allow using load-prod and load-stage with any branch, and default to dev if nothing is provided. 2025-10-15 05:47:01 -07:00
73e527640f Add heads back onto the ls-remote command. 2025-10-15 05:41:12 -07:00
aa3075a9fc Do not do switch back to sender if did not switch to receiver. 2025-10-15 05:33:17 -07:00
89cdf8157f Add other missing then. 2025-10-15 05:19:57 -07:00
4e0ff86295 Add missing then. 2025-10-15 05:19:21 -07:00
305b8df6ff Ensure user is on dev branch if it exists. 2025-10-15 05:09:56 -07:00
6a78933875 Add helper for reorienting a git branch. 2025-10-15 04:52:15 -07:00
7095636915 Remove trailing s. 2025-10-14 15:03:43 -07:00
5 changed files with 126 additions and 5 deletions

View File

@@ -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

View File

@@ -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,61 @@
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 BACKUP="Backup"
export SYSTEM="System"
function pull_prod_backup {
if [[ -z "$1" || ("$1" != "$BACKUP" && "$1" != "$SYSTEM") ]]; then
echo "ERROR: Parameter 1 not correct, expecting '$BACKUP' or '$SYSTEM'."
return 1
fi
backup_type="$1"
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/*${backup_type}*.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 "$BACKUP"
pull_prod_backup "$SYSTEM"
du -h *.zip
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 +936,68 @@
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"
- name: General | Account Management | Users | Files | Common Variable
set_fact:
@@ -952,10 +1069,12 @@
{{ alias_ansible_facts }}
{{ function_now }}
{{ function_backup }}
{{ function_pull_prod_backups }}
{{ function_log }}
{{ function_debian_upgrade }}
{{ function_ebook_convert }}
{{ alias_sudo }}
{{ function_load_branch }}
- name: General | Account Management | Users | Files | .bashrc
blockinfile:

View File

@@ -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' }}"

View File

@@ -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: "" }

View File

@@ -19,6 +19,7 @@
, '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'