2023-07-21 18:40:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# setze Variable
|
2023-07-21 18:56:29 +02:00
|
|
|
# Format <fqdn>,<path to ssh-private-key(passwordless)>
|
2023-07-21 18:40:45 +02:00
|
|
|
devices="rb5009.grote.lan,/home/mg/oxidized-selfmade/neu
|
|
|
|
hex.grote.lan,/ssh/keys/hex"
|
2023-07-21 18:48:12 +02:00
|
|
|
|
2023-07-21 18:56:29 +02:00
|
|
|
|
|
|
|
GIT_REPO_PATH=/home/mg/oxidized-selfmade # wo soll das Repo angelegt werden
|
2023-07-21 18:46:16 +02:00
|
|
|
GIT_REPO_BRANCH=master
|
2023-07-21 18:56:29 +02:00
|
|
|
GIT_USERNAME=oxidized-selfmade
|
2023-07-21 18:48:12 +02:00
|
|
|
GIT_USER_MAIL=michael.grote@posteo.de
|
2023-07-21 18:56:29 +02:00
|
|
|
GIT_REPO_REMOTE_NAME=origin
|
|
|
|
|
|
|
|
git config --global user.email "$GIT_USER_MAIL"
|
|
|
|
git config --global user.name "$GIT_USERNAME"
|
|
|
|
|
|
|
|
if [ -d "$GIT_REPO_PATH" ]; then
|
|
|
|
cd "$GIT_REPO_PATH"
|
|
|
|
if [ -d ".git" ]; then
|
|
|
|
git pull "$GIT_REPO_REMOTE_NAME" "$GIT_REPO_BRANCH"
|
|
|
|
else
|
|
|
|
echo "Error: The directory exists but is not a Git repository."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git clone "$GIT_REPO_URL" "$GIT_REPO_PATH"
|
|
|
|
fi
|
2023-07-21 18:40:45 +02:00
|
|
|
|
|
|
|
# Save the current value of IFS to restore later
|
|
|
|
OLD_IFS=$IFS
|
|
|
|
|
|
|
|
# Set the IFS to a comma to split the values
|
|
|
|
IFS=','
|
|
|
|
|
|
|
|
while read -r fqdn path; do
|
2023-07-21 18:56:29 +02:00
|
|
|
# bereinige FQDN
|
2023-07-21 18:40:45 +02:00
|
|
|
fqdn=$(echo $fqdn | tr -d "[:space:]")
|
2023-07-21 18:56:29 +02:00
|
|
|
# prüfe ob Key existiert
|
|
|
|
if [ ! -e "$path" ]; then
|
2023-07-21 18:51:05 +02:00
|
|
|
echo "File file_path does not exist."
|
2023-07-21 18:56:29 +02:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
ssh -n -i "$path" "$fqdn" "/export show-sensitive" > "config_${fqdn}.rsc"
|
|
|
|
git add "config_${fqdn}.rsc"
|
2023-07-21 18:44:44 +02:00
|
|
|
git commit -m "update config_${fqdn}"
|
2023-07-21 18:40:45 +02:00
|
|
|
done <<< "$devices"
|
|
|
|
|
2023-07-21 18:46:16 +02:00
|
|
|
git push
|
|
|
|
|
2023-07-21 18:40:45 +02:00
|
|
|
# Restore the original IFS value
|
|
|
|
IFS=$OLD_IFS
|
|
|
|
|
2023-07-21 18:56:29 +02:00
|
|
|
|
|
|
|
# test mitvolume
|
|
|
|
# ohne volume wg git clone
|