diff --git a/.gitignore b/.gitignore index 0836002..a57b65d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .crush CRUSH.md config.yml - +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..8fb4019 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,145 @@ +version: 2 + +project_name: scron + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - "386" + - amd64 + - arm + - arm64 + goarm: + - "6" + - "7" + main: ./ + binary: scron + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} + + +nfpms: + - id: scron + package_name: scron + vendor: SCRON Project + homepage: https://git.keks.cloud/kekskurse/scron + maintainer: SCRON Maintainers + description: |- + A lightweight, efficient cron-like scheduler written in Go. + SCRON executes shell commands at specified intervals with precise timing + and comprehensive logging support. + license: MIT + formats: + - deb + - rpm + - apk + bindir: /usr/bin + section: utils + priority: optional + file_name_template: "{{ .ConventionalFileName }}" + contents: + - src: config.yml + dst: /etc/scron/config.yml + type: config|noreplace + file_info: + mode: 0644 + - src: scripts/scron.service + dst: /etc/systemd/system/scron.service + file_info: + mode: 0644 + - dst: /etc/scron + type: dir + file_info: + mode: 0755 + scripts: + postinstall: scripts/postinstall.sh + preremove: scripts/preremove.sh + postremove: scripts/postremove.sh + dependencies: + - bash + - systemd + recommends: + - logrotate + +checksum: + name_template: 'checksums.txt' + + + +changelog: + sort: asc + use: github + filters: + exclude: + - "^docs:" + - "^test:" + - "^ci:" + - "^chore:" + - "^style:" + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: 'Bug fixes' + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: 'Performance improvements' + regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$' + order: 2 + - title: Others + order: 999 + +gitea_urls: + api: https://git.keks.cloud/api/v1/ + download: https://git.keks.cloud + skip_tls_verify: false + +release: + gitea: + owner: kekskurse + name: scron + draft: false + prerelease: auto + mode: replace + header: | + ## SCRON {{ .Tag }} + + A lightweight, efficient cron-like scheduler written in Go. + footer: | + ## Installation + + ### Binary Installation + Download the appropriate binary for your system from the assets above. + + ### Debian/Ubuntu (.deb package) + ```bash + wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.deb + sudo dpkg -i scron_{{ .Version }}_linux_amd64.deb + ``` + + ### RPM-based systems (.rpm package) + ```bash + wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.rpm + sudo rpm -i scron_{{ .Version }}_linux_amd64.rpm + ``` + + ### Alpine Linux (.apk package) + ```bash + wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.apk + sudo apk add --allow-untrusted scron_{{ .Version }}_linux_amd64.apk + ``` + + ## Quick Start + + 1. Edit configuration: `/etc/scron/config.yml` (for package installs) or `config.yml` (for binary) + 2. Start the service: `sudo systemctl start scron` (package) or `./scron` (binary) + 3. View logs: `sudo journalctl -u scron -f` (package) or check stdout (binary) + name_template: "{{.ProjectName}}-v{{.Version}}" diff --git a/.woodpecker.yml b/.woodpecker.yml index fcc1f55..a10fa24 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,10 +1,22 @@ when: - event: push - event: pull_request + - event: tag steps: test: image: golang:1.24-alpine commands: + - go mod download - go test ./... + when: + - event: [push, pull_request] + + release: + image: goreleaser/goreleaser:latest + commands: + - goreleaser release --clean + secrets: [gitea_token] + when: + - event: tag diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh new file mode 100755 index 0000000..f961e0a --- /dev/null +++ b/scripts/postinstall.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +# Reload systemd and enable service +systemctl daemon-reload +systemctl enable scron + +echo "SCRON installed successfully!" +echo "Configuration file: /etc/scron/config.yml" +echo "Start service: systemctl start scron" +echo "View logs: journalctl -u scron -f" + diff --git a/scripts/postremove.sh b/scripts/postremove.sh new file mode 100755 index 0000000..54458ab --- /dev/null +++ b/scripts/postremove.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +# Remove systemd service file +if systemctl is-enabled --quiet scron; then + systemctl disable scron +fi +rm -f /etc/systemd/system/scron.service +systemctl daemon-reload + +# Optionally remove user (commented out to preserve logs/data) +# userdel scron 2>/dev/null || true + diff --git a/scripts/preremove.sh b/scripts/preremove.sh new file mode 100755 index 0000000..7bc320d --- /dev/null +++ b/scripts/preremove.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +# Stop and disable service before removal +if systemctl is-active --quiet scron; then + systemctl stop scron +fi +if systemctl is-enabled --quiet scron; then + systemctl disable scron +fi \ No newline at end of file diff --git a/scripts/scron.service b/scripts/scron.service new file mode 100644 index 0000000..2d25b6b --- /dev/null +++ b/scripts/scron.service @@ -0,0 +1,18 @@ +[Unit] +Description=SCRON - Lightweight Cron Scheduler +After=network.target + +[Service] +Type=simple +User=root +Group=root +WorkingDirectory=/etc/scron +ExecStart=/usr/bin/scron +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal +SyslogIdentifier=scron + +[Install] +WantedBy=multi-user.target \ No newline at end of file