changed functions definitions for more POSIX compatibility

This commit is contained in:
Djan 2024-08-23 10:52:06 +02:00
parent 189efbbd9f
commit 6bc10b823f

View File

@ -2,7 +2,7 @@
# help functions # help functions
############################################################################### ###############################################################################
function bobaman { bobaman() {
cat << EOF cat << EOF
BorgBackup alias and functions (by Djan GICQUEL) BorgBackup alias and functions (by Djan GICQUEL)
--- ---
@ -42,7 +42,7 @@ bobapassphrase Enter passphrase that will be used all env var by all borg
EOF EOF
} }
function bobaaide { bobaaide() {
cat << EOF cat << EOF
BorgBackup alias and functions (by Djan GICQUEL) BorgBackup alias and functions (by Djan GICQUEL)
--- ---
@ -87,7 +87,7 @@ alias bobahelp="bobaman"
# generals functions # generals functions
############################################################################### ###############################################################################
function TestBorgRepo { TestBorgRepo() {
if [ ! -f "config" ]; then if [ ! -f "config" ]; then
TestBorgErr=1 TestBorgErr=1
fi fi
@ -104,13 +104,13 @@ function TestBorgRepo {
fi fi
} }
function UnMount { UnMount() {
fusermount -u -z "$mountpoint" fusermount -u -z "$mountpoint"
sleep 5 sleep 5
rmdir "$mountpoint" rmdir "$mountpoint"
} }
function DirExists { DirExists() {
if [ ! -d "$1" ]; then if [ ! -d "$1" ]; then
echo "Error, directory $1 missing." echo "Error, directory $1 missing."
echo "Exiting.";sleep 10 echo "Exiting.";sleep 10
@ -118,7 +118,7 @@ function DirExists {
fi fi
} }
function bobapassphrase { bobapassphrase() {
stty -echo stty -echo
read -p "Enter borg passphrase : " BORG_PASSPHRASE read -p "Enter borg passphrase : " BORG_PASSPHRASE
stty echo stty echo
@ -126,7 +126,7 @@ function bobapassphrase {
export BORG_PASSPHRASE export BORG_PASSPHRASE
} }
function bobagencachedirfile { bobagencachedirfile() {
echo "Signature: 8a477f597d28d172789f06886806bc55" > CACHEDIR.TAG && echo "CACHEDIR.TAG created" echo "Signature: 8a477f597d28d172789f06886806bc55" > CACHEDIR.TAG && echo "CACHEDIR.TAG created"
} }
@ -134,44 +134,44 @@ function bobagencachedirfile {
# list and infos functions # list and infos functions
############################################################################### ###############################################################################
function bobals { bobals() {
TestBorgRepo TestBorgRepo
borg list --short ./ borg list --short ./
} }
function bobalstimes { bobalstimes() {
TestBorgRepo TestBorgRepo
borg list --format {barchive}{SPACE}{SPACE}{TAB}{start}{NL} ./ borg list --format {barchive}{SPACE}{SPACE}{TAB}{start}{NL} ./
} }
function bobagrepls { bobagrepls() {
TestBorgRepo TestBorgRepo
borg list --short --glob-archives "$1" ./ borg list --short --glob-archives "$1" ./
} }
function bobainfoa { bobainfoa() {
TestBorgRepo TestBorgRepo
borg info ./::$1 borg info ./::$1
} }
function bobainfor { bobainfor() {
TestBorgRepo TestBorgRepo
borg info ./ borg info ./
} }
function bobainfolast { bobainfolast() {
TestBorgRepo TestBorgRepo
archive=$(borg list --short ./ | tail -n 1) archive=$(borg list --short ./ | tail -n 1)
borg info .::"$archive" borg info .::"$archive"
} }
function bobainfotail { bobainfotail() {
TestBorgRepo TestBorgRepo
for archive in $(borg list --short ./ | tail -n 5);do for archive in $(borg list --short ./ | tail -n 5);do
@ -181,7 +181,7 @@ function bobainfotail {
done done
} }
function bobainfoall { bobainfoall() {
TestBorgRepo TestBorgRepo
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
@ -191,7 +191,7 @@ function bobainfoall {
done done
} }
function bobastats { bobastats() {
TestBorgRepo TestBorgRepo
if ! which jq ;then if ! which jq ;then
@ -205,7 +205,7 @@ function bobastats {
fi fi
} }
function bobadurationr { bobadurationr() {
TestBorgRepo TestBorgRepo
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
@ -215,7 +215,7 @@ function bobadurationr {
done done
} }
function bobadur { bobadur() {
TestBorgRepo TestBorgRepo
echo " Original size Compressed size Deduplicated size" echo " Original size Compressed size Deduplicated size"
@ -229,7 +229,7 @@ function bobadur {
# mount functions # mount functions
############################################################################### ###############################################################################
function bobamount { bobamount() {
TestBorgRepo TestBorgRepo
mountpoint="$HOME/borg_$1" mountpoint="$HOME/borg_$1"
@ -240,7 +240,7 @@ function bobamount {
UnMount UnMount
} }
function bobamountfirst { bobamountfirst() {
TestBorgRepo TestBorgRepo
archive=$(borg list ./ --short | head -n 1) archive=$(borg list ./ --short | head -n 1)
@ -252,7 +252,7 @@ function bobamountfirst {
UnMount UnMount
} }
function bobamountlast { bobamountlast() {
TestBorgRepo TestBorgRepo
archive="$(borg list ./ --short | tail -n 1)" archive="$(borg list ./ --short | tail -n 1)"
@ -269,7 +269,7 @@ function bobamountlast {
# search functions # search functions
############################################################################### ###############################################################################
function bobasearchinrepo { bobasearchinrepo() {
TestBorgRepo TestBorgRepo
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
@ -283,14 +283,14 @@ function bobasearchinrepo {
done done
} }
function bobasearchinarchive { bobasearchinarchive() {
TestBorgRepo TestBorgRepo
borg list --short .::"$1" | grep -i "$2" borg list --short .::"$1" | grep -i "$2"
} }
function bobacachedel { bobacachedel() {
TestBorgRepo TestBorgRepo
repoid=$(cat config | grep id | cut -f3 -d" ") repoid=$(cat config | grep id | cut -f3 -d" ")
@ -299,7 +299,7 @@ function bobacachedel {
rm -r $HOME/.cache/borg/$repoid rm -r $HOME/.cache/borg/$repoid
} }
function bobasecuritydel { bobasecuritydel() {
TestBorgRepo TestBorgRepo
repoid=$(cat config | grep id | cut -f3 -d" ") repoid=$(cat config | grep id | cut -f3 -d" ")
@ -312,20 +312,20 @@ function bobasecuritydel {
# modify repo # modify repo
############################################################################### ###############################################################################
function bobadel { bobadel() {
TestBorgRepo TestBorgRepo
borg delete ./::$1 borg delete ./::$1
} }
function bobadelast { bobadelast() {
TestBorgRepo TestBorgRepo
archive=$(borg list ./ --short | tail -n 1) archive=$(borg list ./ --short | tail -n 1)
borg delete .::$archive borg delete .::$archive
} }
function bobacheckrepo { bobacheckrepo() {
TestBorgRepo TestBorgRepo
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
@ -336,7 +336,7 @@ function bobacheckrepo {
# mass functions # mass functions
############################################################################### ###############################################################################
function bobadeleter { bobadeleter() {
TestBorgRepo TestBorgRepo
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
@ -371,7 +371,7 @@ function bobadeleter {
rm $file rm $file
} }
function bobagrepdeleter { bobagrepdeleter() {
TestBorgRepo TestBorgRepo
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
@ -397,7 +397,7 @@ function bobagrepdeleter {
# mass archive renaming # mass archive renaming
function bobarenamer { bobarenamer() {
TestBorgRepo TestBorgRepo
which paste || echo "Paste command not found." exit which paste || echo "Paste command not found." exit
@ -437,7 +437,7 @@ function bobarenamer {
rm $script rm $script
} }
function bobagreprenamer { bobagreprenamer() {
TestBorgRepo TestBorgRepo
which paste || echo "Paste command not found." exit which paste || echo "Paste command not found." exit
@ -477,7 +477,7 @@ function bobagreprenamer {
rm $script rm $script
} }
function bobaextractallfiles { bobaextractallfiles() {
TestBorgRepo TestBorgRepo
export BORG_REPO=$(echo $PWD) export BORG_REPO=$(echo $PWD)
export BorgName=$(echo ${PWD##*/}) export BorgName=$(echo ${PWD##*/})