Variable Names

This commit is contained in:
Michael Grote 2023-07-21 18:57:50 +02:00
parent 77c23ef27f
commit 7fd2a6727d

16
x
View file

@ -1,7 +1,7 @@
#!/bin/bash
# setze Variable
# Format <fqdn>,<path to ssh-private-key(passwordless)>
# Format <FQDN>,<SSH_KEY_PATH to ssh-private-key(passwordless)>
devices="rb5009.grote.lan,/home/mg/oxidized-selfmade/neu
hex.grote.lan,/ssh/keys/hex"
@ -33,17 +33,17 @@ OLD_IFS=$IFS
# Set the IFS to a comma to split the values
IFS=','
while read -r fqdn path; do
while read -r FQDN SSH_KEY_PATH; do
# bereinige FQDN
fqdn=$(echo $fqdn | tr -d "[:space:]")
FQDN=$(echo "$FQDN" | tr -d "[:space:]")
# prüfe ob Key existiert
if [ ! -e "$path" ]; then
echo "File file_path does not exist."
if [ ! -e "$SSH_KEY_PATH" ]; then
echo "File SSH_KEY_PATH does not exist."
exit 2
fi
ssh -n -i "$path" "$fqdn" "/export show-sensitive" > "config_${fqdn}.rsc"
git add "config_${fqdn}.rsc"
git commit -m "update config_${fqdn}"
ssh -n -i "$SSH_KEY_PATH" "$FQDN" "/export show-sensitive" > "config_${FQDN}.rsc"
git add "config_${FQDN}.rsc"
git commit -m "update config_${FQDN}"
done <<< "$devices"
git push