fix: installation script for deb
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
kekskurse 2025-07-31 03:50:27 +02:00
parent ababaa3ff9
commit 660fc317ab
3 changed files with 10 additions and 123 deletions

129
README.md
View file

@ -12,19 +12,19 @@ A lightweight, efficient cron-like scheduler written in Go that executes shell c
## Installation ## Installation
### Prerequisites ### Recommended: Debian Package (.deb)
- Go 1.24.1 or later
### Build from Source Download the latest `.deb` package from the [releases page](https://git.keks.cloud/kekskurse/scron/releases) and install:
```bash
git clone <repository-url> # Install package
cd scron sudo dpkg -i scron_X.X.X_linux_amd64.deb
go build -o scron ./
```
Configuration file at `/etc/scron/config.yml`
## Configuration ## Configuration
Create a `config.yml` file in the same directory as the binary: Create a `config.yml` file in the same directory as the binary (or /etc/scron if install via .deb):
```yaml ```yaml
jobs: jobs:
@ -60,76 +60,6 @@ jobs:
- `n,m,o` - Multiple specific values - `n,m,o` - Multiple specific values
- `n-m` - Range of values - `n-m` - Range of values
## Usage
### Basic Usage
```bash
./scron
```
### With Debug Logging
```bash
ZEROLOG_LEVEL=debug ./scron
```
### Running as a Service
```bash
# systemd service example
sudo cp scron /usr/local/bin/
sudo cp config.yml /etc/scron/
# Create systemd service file...
```
## Development
### Testing
```bash
# Run all tests
go test ./...
# Run specific test
go test -run ^TestConfigParsing$ ./
# Run tests with coverage
go test -cover ./...
```
### Code Quality
```bash
# Format and vet code
go fmt ./... && go vet ./...
# Run linter (if golangci-lint is installed)
golangci-lint run
```
### Project Structure
```
scron/
├── main.go # Main application entry point
├── config.go # Configuration parsing and validation
├── config_test.go # Configuration tests
├── time.go # Time matching and cron logic
├── timer_test.go # Timer and scheduling tests
├── error.go # Custom error types
├── config.yml # Example configuration
└── README.md # This file
```
## Logging
SCRON uses structured logging with different levels:
- **Debug**: Detailed execution information, config parsing
- **Info**: Job execution start/completion
- **Warn**: Non-critical issues (empty config, etc.)
- **Error**: Execution failures, config errors
- **Fatal**: Critical errors that stop the application
Set log level via environment variable:
```bash
export ZEROLOG_LEVEL=debug # debug, info, warn, error, fatal
```
## Examples ## Examples
@ -170,44 +100,3 @@ jobs:
command: "cleanup.sh" command: "cleanup.sh"
``` ```
## Troubleshooting
### Common Issues
**Jobs not executing:**
- Check config.yml syntax with `go test ./...`
- Verify file permissions on commands
- Check logs for parsing errors
**High CPU usage:**
- Normal behavior - SCRON checks time every second for precision
- Consider reducing job frequency if not needed
**Commands failing:**
- Commands run via `bash -c`, ensure bash compatibility
- Check command paths and permissions
- Review captured output in logs
### Debug Mode
Enable debug logging to see detailed execution information:
```bash
ZEROLOG_LEVEL=debug ./scron
```
## Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes following the existing code style
4. Add tests for new functionality
5. Run tests and linting (`go test ./... && go fmt ./... && go vet ./...`)
6. Commit your changes (`git commit -am 'Add amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request
## License
This project is open source. Please check the repository for license details.
---
*Generated with Crush*

View file

@ -4,6 +4,7 @@ set -e
# Reload systemd and enable service # Reload systemd and enable service
systemctl daemon-reload systemctl daemon-reload
systemctl enable scron systemctl enable scron
systemctl start scron
echo "SCRON installed successfully!" echo "SCRON installed successfully!"
echo "Configuration file: /etc/scron/config.yml" echo "Configuration file: /etc/scron/config.yml"

View file

@ -2,9 +2,6 @@
set -e set -e
# Remove systemd service file # Remove systemd service file
if systemctl is-enabled --quiet scron; then
systemctl disable scron
fi
rm -f /etc/systemd/system/scron.service rm -f /etc/systemd/system/scron.service
systemctl daemon-reload systemctl daemon-reload