From 0848db107ca7d166265f31b4baaefe895d64100a Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:40:05 +0100 Subject: [PATCH 1/7] updated edi backup script --- scripts/backup_edi.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/backup_edi.sh b/scripts/backup_edi.sh index d1497f4..434ea39 100755 --- a/scripts/backup_edi.sh +++ b/scripts/backup_edi.sh @@ -11,25 +11,26 @@ shopt -s expand_aliases # make aliases work BACKUP_DIR=/sync/backup BACKUP_DIR_HOME=$BACKUP_DIR/home -if [[ !($HOME/.bash_aliases_local -ef $BACKUP_DIR_HOME/.bash_aliases_local) ]]; then - ln $HOME/.bash_aliases_local $BACKUP_DIR_HOME/.bash_aliases_local -fi -rsync_backup --link-dest="$HOME/.ssh/" $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/ +rsync_backup $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/ BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc -sd rsync_backup --link-dest="/etc/ddclient/" /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/ -sd rsync_backup --link-dest="/etc/letsencrypt/" /etc/letsencrypt/ $BACKUP_DIR_ROOT/letsencrypt/ -sd rsync_backup --link-dest="/etc/nginx/" /etc/nginx/ $BACKUP_DIR_ROOT/nginx/ -sd rsync_backup --link-dest="/etc/ssh/" /etc/ssh/ $BACKUP_DIR_ROOT/ssh/ -sd rsync_backup --link-dest="/etc/wireguard/" /etc/wireguard/ $BACKUP_DIR_ROOT/wireguard/ -if [[ !(/etc/ddclient.conf -ef $BACKUP_DIR_ROOT/ddclient.conf) ]]; then - ln /etc/ddclient.conf $BACKUP_DIR_ROOT/ddclient.conf -fi +sd rsync_backup /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/ +sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/ +sd rsync_backup /etc/letsencrypt/ $BACKUP_DIR_ROOT/letsencrypt/ +sd rsync_backup /etc/nginx/ $BACKUP_DIR_ROOT/nginx/ +sd rsync_backup /etc/ssh/ $BACKUP_DIR_ROOT/ssh/ +sd rsync_backup /etc/wireguard/ $BACKUP_DIR_ROOT/wireguard/ +sd rsync_backup /etc/hosts $BACKUP_DIR_ROOT/ +sd rsync_backup /etc/docker/daemon.json $BACKUP_DIR_ROOT/docker/ ##################### ### upload backup ### ##################### +if [[ "$1" == "--noupload" ]]; then + exit 0; +fi + sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" --filter="P /home/docker" /sync/backup/ fabian@garrus:/citadel/backup/edi/ sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" /home/edi/docker/ fabian@garrus:/citadel/backup/edi/home/docker/ From c926e32cda3235556f289d33ae93513842755469 Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:43:43 +0100 Subject: [PATCH 2/7] accomodate for filenames with e.g.spaces --- scripts/reencode_audio.sh | 2 +- scripts/reencode_m4a.sh | 2 +- scripts/transcode_opus.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/reencode_audio.sh b/scripts/reencode_audio.sh index 814eb43..511ea6d 100755 --- a/scripts/reencode_audio.sh +++ b/scripts/reencode_audio.sh @@ -5,7 +5,7 @@ set -euo pipefail dir="$(pwd)" dest=${dir%/*}/${dir##*/}_reencode if [[ !(-d $dest) ]]; then - mkdir $dest + mkdir "$dest" fi for file in ./*.$1; do diff --git a/scripts/reencode_m4a.sh b/scripts/reencode_m4a.sh index 38e1bcc..8ddc742 100755 --- a/scripts/reencode_m4a.sh +++ b/scripts/reencode_m4a.sh @@ -21,7 +21,7 @@ fi dir="$(pwd)" dest=${dir%/*}/${dir##*/}_reencode if [[ !(-d $dest) ]]; then - mkdir $dest + mkdir "$dest" fi for file in ./*.m4a; do diff --git a/scripts/transcode_opus.sh b/scripts/transcode_opus.sh index 8ca6e3a..f3da181 100755 --- a/scripts/transcode_opus.sh +++ b/scripts/transcode_opus.sh @@ -16,7 +16,7 @@ done dir="$(pwd)" dest=${dir%/*}/${dir##*/}_ogg if [[ !(-d $dest) ]]; then - mkdir $dest + mkdir "$dest" fi for file in ./*.$file_suffix; do From 43a70bb9ded053b130802946d3e7fc886abfeb13 Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:49:21 +0100 Subject: [PATCH 3/7] updated settings --- .../sublime-text-3/Packages/User/Preferences.sublime-settings | 1 + 1 file changed, 1 insertion(+) diff --git a/home_external/.config/sublime-text-3/Packages/User/Preferences.sublime-settings b/home_external/.config/sublime-text-3/Packages/User/Preferences.sublime-settings index 22fac81..ec5cd32 100644 --- a/home_external/.config/sublime-text-3/Packages/User/Preferences.sublime-settings +++ b/home_external/.config/sublime-text-3/Packages/User/Preferences.sublime-settings @@ -44,4 +44,5 @@ "use_tab_stops": false, "word_wrap": true, "wrap_width": 120, + "index_files": true, } From 3820ea02979155243c62af6113d99b5463f55013 Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:50:08 +0100 Subject: [PATCH 4/7] updated more or less common characters that could need escaping --- scripts/escapeFilenames.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/escapeFilenames.sh b/scripts/escapeFilenames.sh index d0c350f..e41eb3e 100755 --- a/scripts/escapeFilenames.sh +++ b/scripts/escapeFilenames.sh @@ -11,6 +11,8 @@ replacements[':']='_'; replacements["'"]='_'; replacements['(']='_'; replacements[')']='_'; +replacements['[']='_'; +replacements[']']='_'; while [[ $# > 0 ]]; do replacements["$1"]="$2"; shift 2; From 34baf7e029264c201df3ed5d9d57e1e9ad3a901d Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:50:34 +0100 Subject: [PATCH 5/7] simplified finding the home dir --- scripts/mount_general.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/mount_general.sh b/scripts/mount_general.sh index 8519483..1a16264 100644 --- a/scripts/mount_general.sh +++ b/scripts/mount_general.sh @@ -2,13 +2,12 @@ set -euo pipefail sshMount () { - clientUser=$(whoami); serverUser=$1; serverHost=$2; shift 2; args=($@) for ((i=0; i < ${#args[@]}; i=i + 2)); do - sshfs ${serverUser}@${serverHost}:/citadel/${args[$i]}/ /home/${clientUser}/${args[$i + 1]}/ -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=8 + sshfs ${serverUser}@${serverHost}:/citadel/${args[$i]}/ $HOME/${args[$i + 1]}/ -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=8 done } From d79688f50fca3711d181d2d671f4dc801e0922a2 Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:51:11 +0100 Subject: [PATCH 6/7] new script for easier transcoding --- scripts/transcode_flac.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/transcode_flac.sh diff --git a/scripts/transcode_flac.sh b/scripts/transcode_flac.sh new file mode 100755 index 0000000..161499c --- /dev/null +++ b/scripts/transcode_flac.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +# evaluate options through given arguments +file_suffix='wav' +map= +while [[ $# > 0 ]]; do + case $1 in + -t | --type) file_suffix=$2; shift 2;; + -map ) map='-map 0:0'; shift;; + * ) break ;; # Anything else stops command line processing. + esac +done + +# ensure existence of destination folder +dir="$(pwd)" +dest=${dir%/*}/${dir##*/}_flac +if [[ !(-d $dest) ]]; then + mkdir "$dest" +fi + +for file in ./*.$file_suffix; do + echo "ffmpeg -i '$file' -c:a flac $map '$dest/${file%$file_suffix}flac'"; + ffmpeg -i "$file" -c:a flac $map "$dest/${file%$file_suffix}flac"; +done From 91d3d1d98d95f971e5efde065e8a336e6d50c78a Mon Sep 17 00:00:00 2001 From: fabian Date: Thu, 18 Jan 2024 15:51:40 +0100 Subject: [PATCH 7/7] new script for easy archiving and compression and reversal of both --- scripts/archive_and_compress.sh | 3 +++ scripts/decompress_and_unarchive.sh | 4 ++++ 2 files changed, 7 insertions(+) create mode 100755 scripts/archive_and_compress.sh create mode 100755 scripts/decompress_and_unarchive.sh diff --git a/scripts/archive_and_compress.sh b/scripts/archive_and_compress.sh new file mode 100755 index 0000000..1386094 --- /dev/null +++ b/scripts/archive_and_compress.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +source=${1%/}; # cut off trailing "/" +tar cfv $source.tar $source && xz $source.tar; diff --git a/scripts/decompress_and_unarchive.sh b/scripts/decompress_and_unarchive.sh new file mode 100755 index 0000000..b0f34c2 --- /dev/null +++ b/scripts/decompress_and_unarchive.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +source=$1; +archive=${source%.xz}; # cut off trailing ".xz" +unxz $source && tar xfv $archive