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