This commit is contained in:
Michael Grote 2023-07-21 19:04:24 +02:00
parent 8a5de81a8c
commit 72263bf475

20
x
View file

@ -13,27 +13,27 @@ GIT_USER_MAIL=michael.grote@posteo.de
GIT_REPO_REMOTE_NAME=origin GIT_REPO_REMOTE_NAME=origin
# Checks # Checks
if [ -z $GIT_REPO_PATH ]; then if [ -z $GIT_REPO_PATH ] ; then
echo "GIT_REPO_PATH is not set." echo "GIT_REPO_PATH is not set."
exit 3 exit 3
fi fi
if [ -z $GIT_REPO_BRANCH ]; then if [ -z $GIT_REPO_BRANCH ] ; then
echo "GIT_REPO_BRANCH is not set." echo "GIT_REPO_BRANCH is not set."
exit 3 exit 3
fi fi
if [ -z $GIT_USERNAME ]; then if [ -z $GIT_USERNAME ] ; then
echo "GIT_USERNAME is not set." echo "GIT_USERNAME is not set."
exit 3 exit 3
fi fi
if [ -z $GIT_USER_MAIL ]; then if [ -z $GIT_USER_MAIL ] ; then
echo "GIT_USER_MAIL is not set." echo "GIT_USER_MAIL is not set."
exit 3 exit 3
fi fi
if [ -z $GIT_REPO_REMOTE_NAME ]; then if [ -z $GIT_REPO_REMOTE_NAME ] ; then
echo "GIT_REPO_REMOTE_NAME is not set." echo "GIT_REPO_REMOTE_NAME is not set."
exit 3 exit 3
fi fi
if [ -z $DEVICES ]; then if [ -z $DEVICES ] ; then
echo "DEVICES is not set." echo "DEVICES is not set."
exit 3 exit 3
fi fi
@ -41,9 +41,9 @@ fi
git config --global user.email "$GIT_USER_MAIL" git config --global user.email "$GIT_USER_MAIL"
git config --global user.name "$GIT_USERNAME" git config --global user.name "$GIT_USERNAME"
if [ -d "$GIT_REPO_PATH" ]; then if [ -d "$GIT_REPO_PATH" ] ; then
cd "$GIT_REPO_PATH" cd "$GIT_REPO_PATH"
if [ -d ".git" ]; then if [ -d ".git" ] ; then
git pull "$GIT_REPO_REMOTE_NAME" "$GIT_REPO_BRANCH" git pull "$GIT_REPO_REMOTE_NAME" "$GIT_REPO_BRANCH"
else else
echo "Error: The directory exists but is not a Git repository." echo "Error: The directory exists but is not a Git repository."
@ -63,10 +63,12 @@ while read -r FQDN SSH_KEY_PATH; do
# bereinige FQDN # bereinige FQDN
FQDN=$(echo "$FQDN" | tr -d "[:space:]") FQDN=$(echo "$FQDN" | tr -d "[:space:]")
# prüfe ob Key existiert # prüfe ob Key existiert
if [ ! -e "$SSH_KEY_PATH" ]; then if [ ! -e "$SSH_KEY_PATH" ] ; then
echo "File $SSH_KEY_PATH does not exist." echo "File $SSH_KEY_PATH does not exist."
echo "cant not export $FQDN config."
exit 2 exit 2
fi fi
echo "export $FQDN config."
ssh -n -i "$SSH_KEY_PATH" "$FQDN" "/export show-sensitive" > "config_${FQDN}.rsc" ssh -n -i "$SSH_KEY_PATH" "$FQDN" "/export show-sensitive" > "config_${FQDN}.rsc"
git add "config_${FQDN}.rsc" git add "config_${FQDN}.rsc"
git commit -m "update config_${FQDN}" git commit -m "update config_${FQDN}"