Compare commits
3 Commits
1.0.0
...
8b5a462fc4
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b5a462fc4 | |||
| ec594c0e4d | |||
| fdfbdf093f |
11
central_backend/Cargo.lock
generated
11
central_backend/Cargo.lock
generated
@@ -670,7 +670,6 @@ dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
"clap",
|
||||
"dotenvy",
|
||||
"env_logger",
|
||||
"foreign-types-shared",
|
||||
"fs4",
|
||||
@@ -998,12 +997,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "1.0.0"
|
||||
@@ -2305,9 +2298,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.129"
|
||||
version = "1.0.131"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2"
|
||||
checksum = "67d42a0bd4ac281beff598909bb56a86acaf979b84483e1c79c10dcaf98f8cf3"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
|
||||
@@ -7,7 +7,6 @@ edition = "2021"
|
||||
log = "0.4.22"
|
||||
env_logger = "0.11.5"
|
||||
lazy_static = "1.5.0"
|
||||
dotenvy = "0.15.7"
|
||||
clap = { version = "4.5.20", features = ["derive", "env"] }
|
||||
anyhow = "1.0.89"
|
||||
thiserror = "1.0.64"
|
||||
|
||||
@@ -45,4 +45,81 @@ The OTA update is then located in `build/main.bin`
|
||||
* DHCP configured on the network
|
||||
|
||||
## Configure server
|
||||
TODO
|
||||
|
||||
### Create a user dedicated to the central
|
||||
```bash
|
||||
sudo adduser --disabled-login central
|
||||
```
|
||||
|
||||
### Install binary
|
||||
You can use `scp` to copy the binary to the target server:
|
||||
|
||||
```bash
|
||||
scp central_backend/target/release/central_backend pierre@central:/home/pierre
|
||||
```
|
||||
|
||||
Then the executable must be installed system-wide:
|
||||
|
||||
```bash
|
||||
sudo mv central_backend /usr/local/bin/
|
||||
```
|
||||
|
||||
### Create configuration file
|
||||
Create a configuration file in `/home/central/config.yaml`:
|
||||
|
||||
```bash
|
||||
sudo touch /home/central/config.yaml
|
||||
sudo chown central:central /home/central/config.yaml
|
||||
sudo chmod 400 /home/central/config.yaml
|
||||
sudo nano /home/central/config.yaml
|
||||
```
|
||||
|
||||
Sample configuration:
|
||||
|
||||
```conf
|
||||
SECRET=RANDOM_VALUE
|
||||
COOKIE_SECURE=true
|
||||
LISTEN_ADDRESS=0.0.0.0:443
|
||||
ADMIN_USERNAME=admin
|
||||
ADMIN_PASSWORD=FIXME
|
||||
HOSTNAME=central.local
|
||||
STORAGE=/home/central/storage
|
||||
FRONIUS_ORIG=http://10.0.0.10
|
||||
```
|
||||
|
||||
### Test configuration
|
||||
Run the following command to check if the configuration is working:
|
||||
|
||||
```bash
|
||||
sudo -u central central_backend -c /home/central/config.yaml
|
||||
```
|
||||
|
||||
### Create systemd unit file
|
||||
Once you confirmed the configuration is working, you can configure a system service, in `/etc/systemd/system/central.service`:
|
||||
|
||||
```conf
|
||||
[Unit]
|
||||
Description=Central backend server
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
RestartSec=2s
|
||||
Type=simple
|
||||
User=central
|
||||
Group=central
|
||||
WorkingDirectory=/home/central
|
||||
ExecStart=/usr/local/bin/central_backend -c /home/central/config.yaml
|
||||
Restart=always
|
||||
Environment=USER=central
|
||||
HOME=/home/central
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Enable & start service:
|
||||
```bash
|
||||
sudo systemctl enable central
|
||||
sudo systemctl start central
|
||||
```
|
||||
Reference in New Issue
Block a user