From d205cffca1f53fe1828f793435da411b17e14adb Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Mon, 31 Mar 2025 13:57:13 +0100 Subject: [PATCH] Add open-rc config and woodpecker build --- .woodpecker/pipeline.yaml | 25 +++++++++++++++++++++++++ rc-service | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .woodpecker/pipeline.yaml create mode 100644 rc-service diff --git a/.woodpecker/pipeline.yaml b/.woodpecker/pipeline.yaml new file mode 100644 index 0000000..2617130 --- /dev/null +++ b/.woodpecker/pipeline.yaml @@ -0,0 +1,25 @@ +when: + - event: push + branch: main + +steps: + - name: build + image: golang:1.24-alpine3.20 + commands: + - go mod tidy + - go build . + - name: deploy + image: alpine:latest + commands: + - apk add --no-cache openssh-client + - mkdir -p ~/.ssh + - echo "$SSH_KEY" > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - ssh -o StrictHostKeyChecking=no uncertainty@192.168.0.44 "rm $COPY_TO || true" + - scp -o StrictHostKeyChecking=no $COPY_FROM uncertainty@192.168.0.44:$COPY_TO + - ssh -o StrictHostKeyChecking=no uncertainty@192.168.0.44 "doas service lynxie restart" + environment: + COPY_FROM: lynxie + COPY_TO: /home/uncertainty/lynxie + SSH_KEY: + from_secret: ssh_key diff --git a/rc-service b/rc-service new file mode 100644 index 0000000..3fa91c9 --- /dev/null +++ b/rc-service @@ -0,0 +1,38 @@ +#!/sbin/openrc-run + +LYNXIE_USER="uncertainty" +LYNXIE_CMD="/home/uncertainty/lynxie" +APP_NAME="lynxie" + +command="$LYNXIE_CMD" +command_args="" +command_user="$LYNXIE_USER" +pidfile="/var/run/${APP_NAME}.pid" +output_log="/var/log/${APP_NAME}.log" +error_log="/var/log/${APP_NAME}_error.log" + +depend() { + need net +} + +start() { + ebegin "Starting ${APP_NAME}" + + export E621_USERNAME="" + export E621_PASSWORD="" + export TOKEN="" + + start-stop-daemon --start --user "$LYNXIE_USER" \ + --make-pidfile --pidfile "$pidfile" \ + --exec "$command" -- $command_args >> "$output_log" 2>> "$error_log" & + + eend $? +} + +stop() { + ebegin "Stopping ${APP_NAME}" + + start-stop-daemon --stop --pidfile "$pidfile" + + eend $? +}