From a672887719bf344634a5c5227d05dea69b7e3d04 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 6 Dec 2024 22:29:52 -0500 Subject: [PATCH] omg it works. --- scripts/1clickservice.groovy | 50 +++++++++++++----------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/scripts/1clickservice.groovy b/scripts/1clickservice.groovy index 03ed754..fa9c367 100644 --- a/scripts/1clickservice.groovy +++ b/scripts/1clickservice.groovy @@ -97,7 +97,7 @@ pipeline { sh """#!/bin/bash #mkdir -p ~/.ssh - #ssh-keyscan -t ed25519 gitea.arg.rip >> ~/.ssh/known_hosts + ssh-keyscan -t ed25519 gitea.arg.rip >> ~/.ssh/known_hosts #cat ~/.ssh/known_hosts #shit doesn't work. ssh in, git clone, get your shit set up for keys. git -c core.sshCommand="ssh -i '$PK'\" clone ssh://git@gitea.arg.rip:8022/greyn/${servicename}.git @@ -222,15 +222,11 @@ pipeline { sh """#!/bin/bash ssh-keyscan -t ed25519 ${targetHost} >> ~/.ssh/known_hosts - curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/service/scripts/serviceaccount.sh --output serviceaccount.sh + curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/main/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/SUDOER_PSW=/SUDOER_PSW="${SUDOER_PSW}"/' serviceaccount.sh - echo "serviceaccount :)" - - cat serviceaccount.sh - ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost} > ~/.ssh/known_hosts - ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost} servicename=${servicename} pw_productiondatabase=${env.pw_productiondatabase} pw_developmentdatabase=${env.pw_developmentdatabase} 'echo "$SUDOER_PSW" | sudo -Sv && bash -s' << 'ENDSSH' - sudo -u postgres psql && bash -s << 'ENDPSQL' - create database $servicename; - create user $servicename with encrypted password '$pw_productiondatabase'; - grant all privileges on database $servicename to $servicename; - ENDPSQL - - service_dev="${servicename}_dev" - sudo -u postgres psql && bash -s << 'ENDPSQL' - create database \$service_dev; - create user \$service_dev with encrypted password '\$pw_developmentdatabase'; - grant all privileges on database \$service_dev to \$service_dev; - ENDPSQL - - ENDSSH + curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/main/scripts/databases.sh --output databases.sh + + sed -i 's/SUDOER_PSW=/SUDOER_PSW="${SUDOER_PSW}"/' databases.sh + sed -i 's/pw_productiondatabase=/pw_productiondatabase="${env.pw_productiondatabase}/' databases.sh + sed -i 's/pw_developmentdatabase=/pw_developmentdatabase="${env.pw_developmentdatabase}/' databases.sh + sed -i 's/servicename=/servicename="${servicename}"/' databases.sh + + ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost}