2023-07-21 18:40:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# setze Variable
|
|
|
|
devices="rb5009.grote.lan,/home/mg/oxidized-selfmade/neu
|
|
|
|
hex.grote.lan,/ssh/keys/hex"
|
|
|
|
GIT_REPO_PATH=/home/mg/oxidized-selfmade
|
2023-07-21 18:46:16 +02:00
|
|
|
GIT_REPO_BRANCH=master
|
2023-07-21 18:42:14 +02:00
|
|
|
if [ -d "$GIT_REPO_PATH" ]; then
|
|
|
|
cd "$GIT_REPO_PATH"
|
|
|
|
if [ -d ".git" ]; then
|
2023-07-21 18:46:16 +02:00
|
|
|
git pull origin $GIT_REPO_BRANCH
|
2023-07-21 18:42:14 +02:00
|
|
|
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:43:31 +02:00
|
|
|
pwd
|
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=','
|
|
|
|
|
|
|
|
# Loop through the lines in the variable
|
|
|
|
while read -r fqdn path; do
|
|
|
|
# Print the variables (you can perform any actions you need here)
|
|
|
|
fqdn=$(echo $fqdn | tr -d "[:space:]")
|
|
|
|
|
|
|
|
ssh -n -i ${path} ${fqdn} "/export show-sensitive" > config_${fqdn}.rsc
|
2023-07-21 18:44:14 +02:00
|
|
|
echo add
|
2023-07-21 18:42:14 +02:00
|
|
|
git add config_${fqdn}.rsc
|
2023-07-21 18:44:14 +02:00
|
|
|
echo commit
|
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
|
|
|
|
|