#!/bin/bash # setze Variable devices="rb5009.grote.lan,/home/mg/oxidized-selfmade/neu hex.grote.lan,/ssh/keys/hex" # teste auf dependencies GIT_REPO_PATH=/home/mg/oxidized-selfmade GIT_REPO_BRANCH=master GIT_USERNAME=oxidized GIT_USER_MAIL=michael.grote@posteo.de if [ -d "$GIT_REPO_PATH" ]; then git config --global user.email "$GIT_USER_MAIL" git config --global user.name "$GIT_USERNAME" cd "$GIT_REPO_PATH" if [ -d ".git" ]; then git pull origin $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 pwd # 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:]") #!/bin/bash if [ ! -e "$path" ]; then echo "File file_path does not exist." exit 1 fi ssh -n -i ${path} ${fqdn} "/export show-sensitive" > config_${fqdn}.rsc echo add git add config_${fqdn}.rsc echo commit git commit -m "update config_${fqdn}" done <<< "$devices" git push # Restore the original IFS value IFS=$OLD_IFS