From f609d41c51c47f913cd1c3a8a643093a6ae0b718 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 6 Dec 2024 18:04:58 -0500 Subject: [PATCH] service account needs exit --- scripts/1clickservice.groovy | 8 +++++++- scripts/serviceaccount.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/1clickservice.groovy b/scripts/1clickservice.groovy index 1947271..3a4a530 100644 --- a/scripts/1clickservice.groovy +++ b/scripts/1clickservice.groovy @@ -220,12 +220,18 @@ pipeline { ssh-keyscan -t ed25519 ${targetHost} >> ~/.ssh/known_hosts cat "${PK}" - curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/main/scripts/serviceaccount.sh --output serviceaccount.sh + curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/service/scripts/serviceaccount.sh --output serviceaccount.sh sed -i 's/USERNAMETOADD=/USERNAMETOADD="${servicename}"/' serviceaccount.sh sed -i 's/PASSWORDTOADD=/PASSWORDTOADD="${env.pw_linuxserviceaccount}"/' serviceaccount.sh sed -i 's/PUBKEYCONTENT=/PUBKEYCONTENT="${env.pubkeycontent}"/' serviceaccount.sh sed -i 's/SUDOER_PSW=/SUDOER_PSW="${SUDOER_PSW}"/' serviceaccount.sh + echo "serviceaccount :)" + + pwd + ls + cat serviceaccount.sh + ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost} authorized_keys + chmod 600 authorized_keys popd - chown -R "${USERNAMETOADD}:${USERNAMETOADD}' .ssh + chown -R '${USERNAMETOADD}:${USERNAMETOADD}' .ssh } -echo "${SUDOER_PSW}" | sudo -S restofscript \ No newline at end of file +echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript" +exit \ No newline at end of file