shellchecking

This commit is contained in:
Jonas Forsberg 2020-10-13 09:13:20 +02:00
parent a4bbc226f2
commit 8faaf0922a
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9
4 changed files with 25 additions and 12 deletions

View File

@ -2,13 +2,13 @@
[[ ! -f "$HOME/.borgbackup.env" ]] && printf "\$HOME/.borgbackup.env doesn't exist!\n" && exit 1
if [[ "$(stat -c %A $HOME/.borgbackup.env)" != "-rw-------" ]]; then
if [[ "$(stat -c "$HOME/.borgbackup.env")" != "-rw-------" ]]; then
printf "WARNING!!!! \$HOME/.borgbackup.env has the wrong permissions!\n"
printf "\nrun : chmod 0600 \$HOME/.borgbackup.env\n"
exit 1
fi
source "$HOME/.borgbackup.env"
source "${HOME}/.borgbackup.env"
# some helpers and error handling:
@ -78,3 +78,16 @@ borg prune \
--keep-monthly 6 \
prune_exit=$?
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
else
info "Backup and/or Prune finished with errors"
fi
exit ${global_exit}

View File

@ -4,15 +4,15 @@ keepassdb="$HOME/Nextcloud/passwords/Passwords.kdbx"
type qrencode >/dev/null 2>&1 || { printf "qrencode is not installed\n" >&2; exit 1; }
type keepassxc-cli >/dev/null 2>&1 || { printf "KeepassXC is not installed\n" >&2; exit 1; }
printf "Enter password for $keepassdb: "
read -s password
printf "Enter password for %s: " "$keepassdb"
read -r -s password
printf "\n"
printf "Enter device name you want to generate the code for: "
read device
read -r device
printf "Enter the tunnel name: "
read tunnel
read -r tunnel
echo "$password" | keepassxc-cli show -q --attributes Notes "$keepassdb" /Wireguard/"$device"/"$tunnel" | qrencode -t ansiutf8

View File

@ -134,7 +134,7 @@ function firefox_config(){
set +e
pkill -f firefox
set -e
$HOME/bin/install_firefox_addon
"$HOME"/bin/install_firefox_addon
}
function chrome_config(){
@ -231,7 +231,7 @@ while :; do
break
;;
-?*)
printf "'$1' is not a valid option\n" >&2
printf "'%s' is not a valid option\n" "$1" >&2
exit 1
;;
*) #Break out of case, no more options

View File

@ -5,14 +5,14 @@ type wg >/dev/null 2>&1 || { printf "wireguard is not installed\n" >&2; exit 1;
type keepassxc-cli >/dev/null 2>&1 || { printf "KeepassXC is not installed\n" >&2; exit 1; }
printf "Enter password for $keepassdb: "
read -s password
printf "Enter password for %s: " "$keepassdb":
read -s -r password
printf "\n"
networks=$(echo "$password" | keepassxc-cli ls "$keepassdb" /Wireguard/$HOSTNAME)
networks=$(echo "$password" | keepassxc-cli ls "$keepassdb" /Wireguard/"$HOSTNAME")
umask 077
for network in $networks;do
echo "configuring /etc/wireguard/${network}.conf"
echo "$password" | keepassxc-cli show -q --attributes Notes "$keepassdb" /Wireguard/$HOSTNAME/$network | sudo tee /etc/wireguard/${network}.conf > /dev/null
echo "$password" | keepassxc-cli show -q --attributes Notes "$keepassdb" /Wireguard/"$HOSTNAME"/"$network" | sudo tee /etc/wireguard/"${network}".conf > /dev/null
done
unset password