From ca8cfe828f6b2adfcdb82c77099a75625a17f373 Mon Sep 17 00:00:00 2001 From: Ducky Date: Wed, 2 Mar 2022 00:35:53 +0000 Subject: [PATCH] various changes --- .gitignore | 17 +++++++++++++- etc/skel/.bashrc | 13 +++-------- .../sbin/zio-backup => opt/zio/bin/backup | 22 +++++++++---------- {usr/local/sbin => opt/zio/bin}/update-rootfs | 0 opt/zio/conf/backup/.gitkeep | 0 root/.bashrc | 1 - usr/local/bin/zio-backup | 2 ++ var/lib/zio-backup/de01.pre | 16 -------------- var/lib/zio-backup/de01.var | 4 ---- var/lib/zio-backup/passwd | 1 - 10 files changed, 32 insertions(+), 44 deletions(-) rename usr/local/sbin/zio-backup => opt/zio/bin/backup (85%) rename {usr/local/sbin => opt/zio/bin}/update-rootfs (100%) create mode 100644 opt/zio/conf/backup/.gitkeep delete mode 100644 root/.bashrc create mode 100755 usr/local/bin/zio-backup delete mode 100644 var/lib/zio-backup/de01.pre delete mode 100644 var/lib/zio-backup/de01.var delete mode 100644 var/lib/zio-backup/passwd diff --git a/.gitignore b/.gitignore index 0937247..176e893 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ /* +*~ !.gitignore -# /etc/ +!/opt/ +/opt/* +!/opt/zio/ + !/etc/ /etc/* @@ -10,6 +14,11 @@ /etc/skel/* !/etc/skel/.bashrc +# /etc/zio/backup/ +!/etc/zio/backup/ +/etc/zio/backup/* +!/etc/zio/backup/.gitkeep + # /root/ !/root/ /root/* @@ -23,6 +32,12 @@ !/usr/local/ /usr/local/* +# /usr/local/bin/ +!/usr/local/bin/ +/usr/local/bin/* +!/usr/local/bin/update-rootfs +!/usr/local/bin/zio-backup + # /usr/local/sbin/ !/usr/local/sbin/ /usr/local/sbin/* diff --git a/etc/skel/.bashrc b/etc/skel/.bashrc index a831e18..79843c2 100644 --- a/etc/skel/.bashrc +++ b/etc/skel/.bashrc @@ -2,8 +2,6 @@ # # Everytime this is sourced, a new version is pulled from /etc/skel/.bashrc, # rendering any changes you make here overwritten the next time you launch Bash. -# -# Put any extra aliases, functions, or other mess into ~/.bash_aliases. # If not running interactively, don't do anything case $- in @@ -93,11 +91,6 @@ else PS1="\h:\W > " fi -# Aliases -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - # Completions if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then @@ -113,6 +106,6 @@ if [[ -z $SUDO_USER ]]; then print_header fi -if [[ $UID != 0 ]]; then - update_bashrc -fi +# Update prompt +# TODO: Tell user if something has updated +update_bashrc diff --git a/usr/local/sbin/zio-backup b/opt/zio/bin/backup similarity index 85% rename from usr/local/sbin/zio-backup rename to opt/zio/bin/backup index 1e9ea81..22fdc69 100755 --- a/usr/local/sbin/zio-backup +++ b/opt/zio/bin/backup @@ -4,7 +4,7 @@ env_dir=$1 base_dir="$(dirname "$(realpath -s "$0")")" root_dir="$base_dir/../../.." -[[ -z $env_dir ]] && env_dir="/var/lib/zio-backup" +[[ -z $env_dir ]] && env_dir="/etc/zio/backup/" function restic_exec() { command="$1" @@ -98,7 +98,7 @@ function test_path() { fi } -host="de01" +host="$(hostname -s)" repo="b2:zio-euc-servers" excludes=() @@ -118,16 +118,16 @@ else chown root:root -R $env_dir chmod 660 -R $env_dir - [[ -f "$env_dir/$host.pre" ]] && pre_script="$env_dir/$host.pre" - [[ -f "$env_dir/$host.post" ]] && post_script="$env_dir/$host.post" + [[ -f "$env_dir/script-pre" ]] && pre_script="$env_dir/script-pre" + [[ -f "$env_dir/script-post" ]] && post_script="$env_dir/script-post" - if [[ -f "$env_dir/$host.var" ]]; then - [[ ! -z $(get_prop "$env_dir/$host.var" EXCLUDES) ]] && \ - IFS=';' read -ra excludes <<< "$(get_prop "$env_dir/$host.var" EXCLUDES)" - [[ ! -z $(get_prop "$env_dir/$host.var" PATHS) ]] && \ - IFS=';' read -ra paths <<< "$(get_prop "$env_dir/$host.var" PATHS)" - [[ ! -z $(get_prop "$env_dir/$host.var" SERVICES) ]] && \ - IFS=';' read -ra services <<< "$(get_prop "$env_dir/$host.var" SERVICES)" + if [[ -f "$env_dir/confi" ]]; then + [[ ! -z $(get_prop "$env_dir/config" EXCLUDES) ]] && \ + IFS=';' read -ra excludes <<< "$(get_prop "$env_dir/config" EXCLUDES)" + [[ ! -z $(get_prop "$env_dir/config" PATHS) ]] && \ + IFS=';' read -ra paths <<< "$(get_prop "$env_dir/config" PATHS)" + [[ ! -z $(get_prop "$env_dir/config" SERVICES) ]] && \ + IFS=';' read -ra services <<< "$(get_prop "$env_dir/config" SERVICES)" fi if [[ -f "$env_dir/passwd" ]]; then diff --git a/usr/local/sbin/update-rootfs b/opt/zio/bin/update-rootfs similarity index 100% rename from usr/local/sbin/update-rootfs rename to opt/zio/bin/update-rootfs diff --git a/opt/zio/conf/backup/.gitkeep b/opt/zio/conf/backup/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/root/.bashrc b/root/.bashrc deleted file mode 100644 index e12789d..0000000 --- a/root/.bashrc +++ /dev/null @@ -1 +0,0 @@ -. /etc/skel/.bashrc diff --git a/usr/local/bin/zio-backup b/usr/local/bin/zio-backup new file mode 100755 index 0000000..c1a9b56 --- /dev/null +++ b/usr/local/bin/zio-backup @@ -0,0 +1,2 @@ +#!/bin/bash +/opt/zio/bin/backup $@ diff --git a/var/lib/zio-backup/de01.pre b/var/lib/zio-backup/de01.pre deleted file mode 100644 index 9524516..0000000 --- a/var/lib/zio-backup/de01.pre +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -sql_dump_dir="/srv/store/common/sql" -postgres_dump_file="/srv/store/common/sql/postgres_$host.sql" -postgres_password="5H4bsfAVXGFQFYfpPzDtcYpUXB8vjQUT" - -mkdir -p $sql_dump_dir - -say "Photoprism: Importing media..." -podman exec -it photoprism photoprism import - -say "Postgres: Dumping database to '$postgres_dump_file'..." -podman exec -i -e PGPASSWORD=$postgres_password postgres /usr/local/bin/pg_dumpall -U postgres > $postgres_dump_file - -chmod -R 660 $sql_dump_dir -chown -R root:root $sql_dump_dir diff --git a/var/lib/zio-backup/de01.var b/var/lib/zio-backup/de01.var deleted file mode 100644 index 623918e..0000000 --- a/var/lib/zio-backup/de01.var +++ /dev/null @@ -1,4 +0,0 @@ -EXCLUDES="/var/lib/containers/storage/overlay;/var/lib/containers/storage/overlay-containers;/var/lib/containers/storage/overlay-images;/var/lib/containers/storage/overlay-layers" -PATHS="/etc" -#PATHS="/etc;/srv/store;/var" -SERVICES="container-photoprism" diff --git a/var/lib/zio-backup/passwd b/var/lib/zio-backup/passwd deleted file mode 100644 index b1381c0..0000000 --- a/var/lib/zio-backup/passwd +++ /dev/null @@ -1 +0,0 @@ -9%62hqWZwgLWEJ4@k7gG3*o4Zt#%dBiA