feat: add systemd installation

This commit is contained in:
2025-05-06 13:40:55 +02:00
parent 3bbb689cac
commit c2b483d20d
6 changed files with 56 additions and 27 deletions

View File

@@ -10,8 +10,18 @@ build:
mkdir -p bin mkdir -p bin
env GOOS=linux GOARCH=${ARCH} go build -o bin/rcond-${ARCH} ./cmd/rcond/main.go env GOOS=linux GOARCH=${ARCH} go build -o bin/rcond-${ARCH} ./cmd/rcond/main.go
install:
sudo mkdir -p /etc/rcond
sudo mkdir -p /var/rcond
sudo cp config/rcond.yaml /etc/rcond/config.yaml
sudo cp bin/rcond-${ARCH} /usr/local/bin/rcond
sudo cp systemd/rcond.service /etc/systemd/system/rcond.service
sudo systemctl daemon-reload
sudo systemctl enable rcond
sudo systemctl start rcond
run: run:
bin/rcond-${ARCH} -config config.yaml bin/rcond-${ARCH} -config config/rcond.yaml
dev: dev:
RCOND_ADDR=127.0.0.1:8080 \ RCOND_ADDR=127.0.0.1:8080 \

View File

@@ -13,6 +13,16 @@ A simple daemon and REST API to manage:
- systemd - systemd
- Linux operating system - Linux operating system
## Installation
In order to install `rcond`as a systemd service, you need to specify the target architecture and then run the build and install make targets.
```sh
export ARCH=arm64
make build
make install
```
## Build and Run ## Build and Run
```bash ```bash
@@ -20,6 +30,34 @@ make build
make run make run
``` ```
## Develop
```sh
make dev
```
## Configuration
### File
The default config file location is `/etc/rcond/config.yaml`.
It can be overwritten by environment variables and flags.
An full example configuration with comments can be found in `config/rcond.yaml`
Example configuration:
```yaml
rcond:
addr: 0.0.0.0:8080
api_token: 1234567890
```
### Environment Variables
| Environment Variable | Description | Default |
|----------------------|-----------------------------------------|---------------|
| RCOND_ADDR | Address to bind the HTTP server to. | 0.0.0.0:8080 |
| RCOND_API_TOKEN | API token to use for authentication. | N/A |
## API ## API
The full API specification can be found in [api/rcond.yaml](api/rcond.yaml). The full API specification can be found in [api/rcond.yaml](api/rcond.yaml).
@@ -51,27 +89,6 @@ All endpoints except `/health` require authentication via an API token passed in
### Request/Response Format ### Request/Response Format
All endpoints use JSON for request and response payloads. All endpoints use JSON for request and response payloads.
## Configuration
### File
The default config file location is `/etc/rcond/config.yaml`.
It can be overwritten by environment variables and flags.
Example configuration:
```yaml
rcond:
addr: 0.0.0.0:8080
api_token: 1234567890
```
### Environment Variables
| Environment Variable | Description | Default |
|----------------------|-----------------------------------------|---------------|
| RCOND_ADDR | Address to bind the HTTP server to. | 0.0.0.0:8080 |
| RCOND_API_TOKEN | API token to use for authentication. | N/A |
## Examples ## Examples
### Setup an Access Point ### Setup an Access Point

View File

@@ -1,3 +0,0 @@
rcond:
addr: 0.0.0.0:8080
api_token: 1234567890

View File

5
config/rcond.yaml Normal file
View File

@@ -0,0 +1,5 @@
rcond:
# Address to bind the HTTP server to
addr: 0.0.0.0:8080
# API token to use for authentication
api_token: 1234567890

View File

@@ -5,8 +5,8 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
User=root User=root
WorkingDirectory=/path/to/your/rcond WorkingDirectory=/var/rcond
ExecStart=/path/to/your/rcond/bin/rcond-${ARCH} ${ADDR} ExecStart=/usr/local/bin/rcond
Restart=on-failure Restart=on-failure
[Install] [Install]