Compare commits

..

48 Commits
1 ... main

Author SHA1 Message Date
76e0ddfdbc i assume this will work, we'll try it for the platform-as-place
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2025-04-26 14:20:24 -04:00
a8585ea76d keyscan earlier - scp was giving me host key verification failed
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2025-03-24 23:02:23 -04:00
6e55bc1ed2 almost entirely works
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
webhook linking doesn't. don't know why. Oh well.
2025-01-11 11:46:08 -05:00
622e269bd3 gitea link to video
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2025-01-10 09:45:43 -05:00
abbff95371 progress but still doesn't link webhook
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2025-01-09 17:28:34 -05:00
f109faa5db not sure what's wrong with auth token to link webhook, but everything else works
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2025-01-02 17:11:10 -05:00
159a0027ff theoretically works, BUT:
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
how do I add a room *to a space*? how do I give control of a room to someone else?
2024-12-27 20:04:25 -05:00
ca3d31de38 we use matrix comms until further notice anyway 2024-12-27 19:56:37 -05:00
bd45a49691 syntax fixed i think 2024-12-27 17:37:30 -05:00
9009120546 tripping on line 78, not sure why
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-27 17:15:11 -05:00
51b87b720b uhhh pretty sure it works
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-18 19:47:33 -05:00
41045a0973 connection string, ssh key 2024-12-13 22:49:00 -05:00
c3eda11c05 try and write in database string 2024-12-13 21:06:44 -05:00
88419c8985 cert id
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-13 17:01:31 -05:00
f085dc4aa4 change name so i can probably not accidentally pick it up out of nuget.org
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-09 14:56:03 -05:00
519990ba19 properly replace creds ids
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-07 00:25:43 -05:00
da1b6aaed8 fail-early guards 2024-12-06 23:46:36 -05:00
a672887719 omg it works.
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 22:29:52 -05:00
a47de1098c databases script update
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 21:50:54 -05:00
9b70bd9480 databases initializer script
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
I think I figured it out. your -s << 'ENDMARKER' is looking for a line that starts with ENDMARKER - no spaces. so you can't indent it nicely.
2024-12-06 21:23:57 -05:00
84c023783f it was the newline 2024-12-06 20:58:44 -05:00
d7ad1aff9d please don't be the newline
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 20:56:32 -05:00
440638a162 more debugging junk
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 20:53:57 -05:00
69a74f1855 don't command from within the new user's directory
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 20:39:16 -05:00
616f560e7b send the .pub separately
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 20:19:28 -05:00
76bb0ad258 no tilde!
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 18:23:59 -05:00
a98147901c ok maybe tho
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 18:20:35 -05:00
d24a36d7aa honestly, I think this works
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 18:14:24 -05:00
f609d41c51 service account needs exit
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 18:04:58 -05:00
4a4fb4158f new plan. forget end-document, doesn't cooperate.
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-06 17:06:04 -05:00
348817a74d reincarnate moloryb
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
"jenkins@moloryb.lan: Permission denied (publickey,password)."
2024-12-03 01:47:52 -05:00
ac0675df94 CREDS GO IN
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-03 00:21:42 -05:00
8c34cc29de its having trouble curling, because its having trouble keeping track of the command... because the password has a backslash. :lolsob:
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-02 22:13:47 -05:00
dd924662fb latest error:
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
116: notice that -s won't happen until line 123
/var/lib/jenkins/workspace/meta/greyn dotnet service@tmp/durable-01f2ce1d/script.sh.copy: line 19: -s: command not found
2024-12-02 22:00:17 -05:00
aa42c24735 sh work
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
god FUCKING dammit i need to get better at pushing! what am I, keeno? :Kappa:
2024-12-01 19:02:17 -05:00
056cb4f2a3 jq: parsed
after banging my head against it for long enough, the jq parse that i'm 100% convinced worked in test doesn't work, so I was able to work against that.
2024-11-27 15:39:21 -05:00
816bcff09d generates gitea project from template :)
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
jq is suffering shell-quoting issues.
2024-11-21 13:02:37 -05:00
7130f70aaf moloryb
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
i know I went to HS with a girl called "mallory". you can tell i'm L O S T because I'm like "what's she up to these days?" but can't remember anything other than she exists and has that name. Pretty sure black hair? lmao
2024-11-21 00:13:06 -05:00
3ab5269f40 default to .lan
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-20 01:06:49 -05:00
22b5691d99 passed linting
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-19 11:49:50 -05:00
351b806c33 hopefully it's ok that jenkins will be jenkinsing jenkins. down to 1 TODO!
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-19 02:07:51 -05:00
c2575e696a see this is the bad thing - i get distracted mid Thing so i have no idea what this is. but it's pending.
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-17 23:25:14 -05:00
6984d855b5 after much work, i have... added todos. there are now 10. 2024-11-17 16:02:56 -05:00
25a2dc093e future scripts
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-17 15:02:19 -05:00
b297a2345a i think I have it mostly figured out, still TODOs 2024-11-17 15:01:57 -05:00
c8b9a5cf0f more elaboration, still full of TODO's
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-11-17 13:24:01 -05:00
563fae4908 Merge branch 'release' 2024-11-16 23:12:08 -05:00
3b618d07d5 project 1click service is approaching 2024-11-16 22:50:41 -05:00
8 changed files with 525 additions and 1 deletions

2
Jenkinsfile vendored
View File

@ -4,7 +4,7 @@ pipeline {
stages {
stage('nuget pack'){
steps{
dotnetPack(outputDirectory: "./", project: "Deployment/Deployment.csproj")
dotnetPack(outputDirectory: "./", project: "Deployment/greyn.Deployment.csproj")
}
}
stage('build numberify'){

View File

@ -0,0 +1,299 @@
pipeline {
agent any
parameters {
string(name: 'servicename', description: "service name")
string(name: 'svcdesc', description: "service description")
string(name: 'targetHost', description: "system to live on", defaultValue: "moloryb.lan")
}
environment {
SUDOER_ALLOCES = credentials('a674f816-2b35-4d60-ba60-7b66e86f3c5c')
SUDOER_MOLORYB = credentials('1f3b965e-bcc0-4074-99f2-b64dddbf7de7')
SUDOERSSHID = '2c48e1a9-22b2-455c-9959-6b29e86d3fb5'
SUDOERSSH = credentials('2c48e1a9-22b2-455c-9959-6b29e86d3fb5')
JENKINS = credentials('68391381-e095-4b47-b956-d23055b0808e')
GITEATOKEN = credentials('d0e86441-2157-405f-8539-a9a9010c6ecf')
GITEA_USR='jenkins'
}
stages {
stage("environment setup") { //my environment, here.
steps {
script {
if (servicename.isEmpty()) {
error("servicename mandatory")
}
if (servicename.contains(' ')) {
error("servicename cannot have spaces. try dashes.")
}
sh """#!/bin/bash
function testcmd(){
if ! command -v \$1 2>&1 >/dev/null
then
echo "this agent doesn't have \$1"
exit 1
fi
}
testcmd mktemp
testcmd curl
testcmd git
testcmd sed
testcmd ssh
testcmd ssh-keyscan
testcmd ssh-keygen
testcmd scp
testcmd jq
"""
switch (targetHost) {
case "alloces.lan":
SUDOER_USR = SUDOER_ALLOCES_USR
SUDOER_PSW = SUDOER_ALLOCES_PSW
case "moloryb.lan":
SUDOER_USR=SUDOER_MOLORYB_USR
SUDOER_PSW=SUDOER_MOLORYB_PSW
break
default:
error("target host not recognized. btw: yes .lan, all lowercase.")
}
env.pw_linuxserviceaccount=sh(returnStdout: true, script: "mktemp -u XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").trim()
echo env.pw_linuxserviceaccount
env.pw_productiondatabase=sh(returnStdout: true, script: "mktemp -u XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").trim()
echo env.pw_productiondatabase
env.pw_developmentdatabase=sh(returnStdout: true, script: "mktemp -u XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").trim()
echo env.pw_developmentdatabase
}
}
}
stage("gitea project"){
steps{
sh """
curl -X 'POST' \
'https://gitea.arg.rip/api/v1/repos/greyn/_template-service/generate' \
-H 'accept: application/json' \
-H 'Authorization: token ${env.GITEATOKEN}' \
-H 'Content-Type: application/json' \
-d '{
"description": "${svcdesc}",
"git_content": true,
"git_hooks": true,
"labels": true,
"name": "${servicename}",
"owner": "greyn",
"private": false,
"protected_branch": true,
"topics": true,
"webhooks": true
}'
"""
}
}
stage("jenkins pipeline"){
steps{
//the bad news is that it looks like it's not allowed to trigger just any old job remotely
//the good news is that this seems to pick it up pretty reliably
//sh """
// curl -X POST -L --user ${env.JENKINS_USR}:${env.JENKINS_PSW} \
// alloces.lan:8080/job/gitea.arg.rip/build
// """
timeout(time: 5, unit: 'MINUTES') {
sh """
strRes=""
while [ -z "\$strRes" ];
do
sleep 5;
#curl -X GET ${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/api/json
curl -X GET -s ${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/api/json > f.json
strRes=\$(jq '.jobs' f.json | jq '.[] | select(.name==\"${env.servicename}\")')
rm f.json
done
"""
}
withCredentials([sshUserPrivateKey(credentialsId: 'f42347e9-e3b5-44af-a1af-c5e7b9775fee', keyFileVariable: 'PK')]) {
sh """#!/bin/bash
#mkdir -p ~/.ssh
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
#fyi, future me: pushd is useless here, it pops out. Like it's loading a script and exiting.
"""
script {
sh """#!/bin/bash
pushd ${servicename}
databaseString="Host=${targetHost};Database=${servicename};Username=${servicename};Password=${env.pw_productiondatabase};IncludeErrorDetail=true;"
databasecredsid=\$(uuidgen)
httpBasicAuth=\"http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/\"
urlGetData=\"crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\\":\\",//crumb)\"
CRUMB=\$(curl -s -c cookies.txt \"\${httpBasicAuth}\${urlGetData}\")
curl -H \$CRUMB -X POST \"http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/job/${servicename}/credentials/store/folder/domain/_/createCredentials\" \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "'"\$databasecredsid"'",
"secret": "\$databaseString",
"description": "database connection string",
"\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'
credsStr="productiondatabase_connectionString=credentials(\\"\$databasecredsid\\")"
sed -i "s/productiondatabase_connectionString=creds/\$credsStr/" Jenkinsfile
rm cookies.txt
git add .
git commit -m \"set up for database\"
cp appsettings.sample.json appsettings.json
sed -i "s/\\"DBConnectionString\\" *: *\\"[^\\"]*\\"/\\"DBConnectionString\\":\\"\${databaseString}\\"/" appsettings.json
"""
sh """#!/bin/bash
usernameCredsId=\$(uuidgen)
CRUMB=\$(curl -c cookies.txt 'http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
echo \$CRUMB
curl -X POST 'http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/job/${servicename}/credentials/store/folder/domain/_/createCredentials' \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "'"\$usernameCredsId"'",
"username": "${servicename}",
"password": "${env.pw_linuxserviceaccount}",
"description": "service account login",
"\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'
certCredsId=\$(uuidgen)
ssh-keygen -t ed25519 -f "${servicename}-ssh" -N ""
privatekeycontent=\$(cat ${servicename}-ssh)\$'\\n'
privatekeycontent="\$privatekeycontent
"
echo "private key content: \$privatekeycontent hopefully newline isn't the issue."
pubkeycontent=\$(cat ${servicename}-ssh.pub)
CRUMB=\$(curl -s 'http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
echo \$CRUMB
curl -X POST 'http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/job/${servicename}/credentials/store/folder/domain/_/createCredentials' \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "'"\$certCredsId"'",
"username": "${servicename}",
"password": "",
"privateKeySource": {
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey\$DirectEntryPrivateKeySource",
"privateKey": "\$privatekeycontent",
},
"description": "${servicename}",
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
},
"description": "service account ssh",
"\$class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
}
}'
rm cookies.txt
pushd ${servicename}
linuxServiceAccountStr="linuxServiceAccount=credentials(\\"\$usernameCredsId\\")"
linuxServiceAccountIDStr="linuxServiceAccountID=\\"\$certCredsId\\""
sed -i "s/linuxServiceAccount=creds/\$linuxServiceAccountStr/" Jenkinsfile
sed -i "s/linuxServiceAccountID=string/\$linuxServiceAccountIDStr/" Jenkinsfile
sed -i 's/targetHost=string/targetHost="${targetHost}"/' Jenkinsfile
git add .
git commit -m "linux account, service host"
git -c core.sshCommand="ssh -i '${PK}'\" push
"""
}
}
}
}
stage("service account"){
steps{
script {
withCredentials([sshUserPrivateKey(credentialsId: env.SUDOERSSHID, keyFileVariable: 'PK')])
{
sh """#!/bin/bash
ssh-keyscan -t ed25519 ${targetHost} >> ~/.ssh/known_hosts
"""
sh """#!/bin/bash
scp -i \"${PK}\" ${servicename}-ssh.pub ${SUDOER_USR}@${targetHost}:~/ssh.pub
"""
sh """#!/bin/bash
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
ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost} <serviceaccount.sh
rm serviceaccount.sh
"""
}
}
}
}
stage("db init"){
steps {
//i'm pretty sure "update" with nothing will init?
//meaning we don't have to init, first update will init
script {
withCredentials([sshUserPrivateKey(credentialsId: env.SUDOERSSHID, keyFileVariable: 'PK')])
{
sh """#!/bin/bash
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} <databases.sh
rm databases.sh
"""
}
}
}
}
stage("initial service setup"){
steps{
sh """#!/bin/bash
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} "mkdir -p ~/dist"
scp -i "${servicename}-ssh" ${servicename}/appsettings.json ${servicename}@${targetHost}:~/dist/appsettings.json
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} "mkdir -p ~/.config/systemd/user/"
scp -i "${servicename}-ssh" ${servicename}/${servicename}.service ${servicename}@${targetHost}:~/.config/systemd/user/${servicename}.service
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} 'systemctl --user daemon-reload'
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} 'systemctl --user enable ${servicename}.service'
"""
}
}
}
post {
failure {
matrixSendMessage https:true, hostname: 'greyn.club', port:8448, accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: '1-click service failed :(', formattedBody: "1-click service <b>failed</b> :("
}
success {
matrixSendMessage https:true, hostname: 'greyn.club', port:8448, accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: "${servicename} ready to go on ${targetHost}. username: ${servicename}, password: ${env.pw_linuxserviceaccount}. if db, prod db pw: ${env.pw_productiondatabase} and dev pw: ${env.pw_developmentdatabase}"
//TODO: archiveArtifacts the password data, then store them somewhere
}
}
}

View File

@ -0,0 +1,189 @@
pipeline {
agent any
parameters {
string(name: 'videoname', description: "video name")
string(name: 'videodesc', description: "video description")
}
environment {
JENKINSONGITEA=credentials('d0e86441-2157-405f-8539-a9a9010c6ecf')
JENKINSONMATRIXTOKEN=credentials('17d18fd7-29eb-4957-9532-ce42aaa9b4ec')
GITEAONMATRIXTOKEN=credentials('10bc888a-cb19-456e-b793-f85ee465d58e')
}
stages {
stage("environment setup") {
steps{
script{
if (videoname.isEmpty()) {
error("videoname mandatory")
}
if (videoname.contains(' ')) {
error("videoname cannot have spaces. try dashes.")
}
}
}
}
stage("create gitea project"){
steps{
script{
env.giteaCreateEvent=sh(returnStdout: true, script: """
curl -X 'POST' \
'https://gitea.arg.rip/api/v1/repos/beefhavers/_videotemplate/generate' \
-H 'accept: application/json' \
-H 'Authorization: token ${env.JENKINSONGITEA}' \
-H 'Content-Type: application/json' \
-d '{
"description": "${videodesc}",
"git_content": true,
"git_hooks": true,
"labels": true,
"name": "${videoname}",
"owner": "beefhavers",
"private": false,
"protected_branch": true,
"topics": true,
"webhooks": true
}'
""").trim()
if (!env.giteaCreateEvent?.trim()) {
error "couldn't make gitea repo, apparently"
}
}
}
}
stage("create matrix room"){
steps{
script{
env.roomcreationevent=sh(returnStdout: true, script: """
curl -X 'POST' \
'https://greyn.club:8448/_matrix/client/v3/createRoom' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ${JENKINSONMATRIXTOKEN}' \
-H 'Content-Type: application/json' \
-d '{
"creation_content": {
"m.federate": false
},
"name": "${videoname}",
"preset": "public_chat",
"invite": ["@adam:greyn.club", "@gitea:greyn.club"],
"topic": "https://gitea.arg.rip/beefhavers/${videoname}"
}'
"""
).trim()
if (!env.roomcreationevent?.trim()) {
error "couldn't make matrix room, apparently"
}
echo "roomcreationevent:"
echo env.roomcreationevent
def jsonObj = readJSON text: env.roomcreationevent
env.room_id =jsonObj.room_id
if(!env.room_id?.trim()){
error "couldn't make matrix room, apparently"
}
env.spaceaddevent=sh(returnStdout: true, script: """
curl -X 'PUT' 'https://greyn.club:8448/_matrix/client/r0/rooms/!xLgVvcqtVzquTkCQGx:greyn.club/state/m.space.child/${env.room_id}' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ${JENKINSONMATRIXTOKEN}' \
-H 'Content-Type: application/json' \
-d '{
"via": ["greyn.club"]
}'
""").trim()
echo "spaceaddevent:"
echo env.spaceaddevent
env.elevatePrivsEvent=sh(returnStdout: true, script: """
curl -X 'PUT' 'https://greyn.club:8448/_matrix/client/v3/rooms/${env.room_id}/state/m.room.power_levels' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ${JENKINSONMATRIXTOKEN}' \
-H 'Content-Type: application/json' \
-d '{
"users": {
"@adam:greyn.club": 100,
"@jenkins:greyn.club": 50
}
}'
""").trim()
echo "elevatePrivsEvent:"
echo env.elevatePrivsEvent
}
}
}
stage("tweak Jenkinsfile"){
steps{
withCredentials([sshUserPrivateKey(credentialsId: 'f42347e9-e3b5-44af-a1af-c5e7b9775fee', keyFileVariable: 'PK')]) {
sh """#!/bin/bash
#mkdir -p ~/.ssh
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/beefhavers/${videoname}.git
"""
script {
sh """#!/bin/bash
pushd ${videoname}
sed -i 's/MATRIX_ROOMID="todo"/MATRIX_ROOMID="${env.room_id}"/' Jenkinsfile
git add .
git commit -m "matrix room configured in jenkinsfile"
git -c core.sshCommand="ssh -i '${PK}'\" push
"""
}
}
}
}
stage("link gitea webhook"){
steps{
sh """
curl -X 'GET' 'https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks' \
-H 'accept: application/json' \
-H 'authorization: token ${env.JENKINSONGITEA}' \
>reporesponse.json
cat reporesponse.json
cat reporesponse.json | jq '.[] | select(.type=="matrix")' >matrixhook.json
cat matrixhook.json
"""
sh """
echo '{
"active": true,
"authorization_header": "Bearer ${env.GITEAONMATRIXTOKEN}",
"branch_filter": "*",
"config": {
"content_type": "json",' >request.json
echo "\\"url\\": \\"https://greyn.club:8448/_matrix/client/r0/rooms/\$(echo ${env.room_id} | sed 's/!/%21/')/send/m.room.message\\"" >>request.json
echo "}," >>request.json
echo "\\"events\\": \$(cat matrixhook.json | jq .[0].events)" >>request.json
echo '}' >>request.json
cat request.json
"""
//delete old
sh """
curl -X 'DELETE' "https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks/\$(cat matrixhook.json | jq .[0].id)" \
-H 'accept: application/json' \
-H 'authorization: token ${env.JENKINSONGITEA}' \
"""
//make a new one
sh """
curl -X 'POST' "https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks" \
-H 'accept: application/json' \
-H 'authorization: token ${env.JENKINSONGITEA}' \
-H 'Content-Type: application/json' \
-d @request.json
rm request.json
rm reporesponse.json
rm matrixhook.json
"""
}
}
}
}

15
scripts/databases.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
SUDOER_PSW=
function restofscript(){
pw_productiondatabase=
pw_developmentdatabase=
servicename=
service_dev="${servicename}_dev"
sudo -u postgres psql -c "create database $servicename;"
sudo -u postgres psql -c "create user $servicename with encrypted password '$pw_productiondatabase';"
sudo -u postgres psql -c "grant all privileges on database $servicename to $servicename;"
}
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
exit

View File

@ -0,0 +1 @@
//TODO

1
scripts/nupkg.groovy Normal file
View File

@ -0,0 +1 @@
//TODO

19
scripts/serviceaccount.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
SUDOER_PSW=
function restofscript(){
USERNAMETOADD=
PASSWORDTOADD=
useradd -m -s /bin/bash ${USERNAMETOADD}
echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd
loginctl enable-linger ${USERNAMETOADD}
mkdir /home/${USERNAMETOADD}/.ssh
touch /home/${USERNAMETOADD}/.ssh/authorized_keys
cat ssh.pub >> /home/${USERNAMETOADD}/.ssh/authorized_keys
chmod 600 /home/${USERNAMETOADD}/authorized_keys
chown -R "${USERNAMETOADD}:${USERNAMETOADD}" /home/${USERNAMETOADD}/.ssh
}
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
exit