Compare commits
32 Commits
1.0.0
...
c73b848455
Author | SHA1 | Date | |
---|---|---|---|
c73b848455 | |||
598286d1cb | |||
30f196aa7a | |||
08f1ec6d4d | |||
d31a568c00 | |||
1b25c07e50 | |||
96f1640378 | |||
ccb4ae22f8 | |||
d66e2b9bf7 | |||
0660066941 | |||
7476924e0e | |||
65c3c534f4 | |||
995e1fa07e | |||
1735077db3 | |||
31bb956a29 | |||
ff0e548422 | |||
837835da7e | |||
2d262bb4c9 | |||
f594ebfbaa | |||
57a9c03308 | |||
7b9db9c7c3 | |||
b7720df305 | |||
445c1b014e | |||
aa732af571 | |||
c365f959e7 | |||
9a4c6d2de2 | |||
3c20cca915 | |||
5aaad54de3 | |||
b3edfb05d9 | |||
45029f24cc | |||
ec594c0e4d | |||
fdfbdf093f |
69
central_backend/Cargo.lock
generated
69
central_backend/Cargo.lock
generated
@@ -492,9 +492,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.89"
|
||||
version = "1.0.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
|
||||
|
||||
[[package]]
|
||||
name = "asn1"
|
||||
@@ -645,9 +645,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.30"
|
||||
version = "1.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
|
||||
checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
@@ -656,7 +656,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "central_backend"
|
||||
version = "0.1.0"
|
||||
version = "1.0.2"
|
||||
dependencies = [
|
||||
"actix",
|
||||
"actix-cors",
|
||||
@@ -1387,9 +1387,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.4.1"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05"
|
||||
checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
@@ -1498,9 +1498,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "impl-more"
|
||||
version = "0.1.6"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d"
|
||||
checksum = "aae21c3177a27788957044151cc2800043d127acaa460a47ebb9b84dfa2c6aa0"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
@@ -1955,9 +1955,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.87"
|
||||
version = "1.0.88"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -2178,9 +2178,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.14"
|
||||
version = "0.23.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8"
|
||||
checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"rustls-pki-types",
|
||||
@@ -2200,9 +2200,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55"
|
||||
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
@@ -2285,18 +2285,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.210"
|
||||
version = "1.0.214"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.210"
|
||||
version = "1.0.214"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2305,9 +2305,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.129"
|
||||
version = "1.0.132"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2"
|
||||
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@@ -2445,9 +2445,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.79"
|
||||
version = "2.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2510,18 +2510,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.64"
|
||||
version = "1.0.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
||||
checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.64"
|
||||
version = "1.0.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
|
||||
checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2576,9 +2576,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.40.0"
|
||||
version = "1.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
|
||||
checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
@@ -2698,12 +2698,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
@@ -2773,9 +2770,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.10.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
|
||||
checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"serde",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "central_backend"
|
||||
version = "0.1.0"
|
||||
version = "1.0.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
@@ -20,7 +20,7 @@ actix-web = { version = "4", features = ["openssl"] }
|
||||
futures = "0.3.31"
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
reqwest = { version = "0.12.7", features = ["json"] }
|
||||
serde_json = "1.0.128"
|
||||
serde_json = "1.0.131"
|
||||
rand = "0.8.5"
|
||||
actix = "0.13.5"
|
||||
actix-identity = "0.8.0"
|
||||
@@ -29,7 +29,7 @@ actix-cors = "0.7.0"
|
||||
actix-multipart = { version ="0.7.2", features = ["derive"] }
|
||||
actix-remote-ip = "0.1.0"
|
||||
futures-util = "0.3.31"
|
||||
uuid = { version = "1.10.0", features = ["v4", "serde"] }
|
||||
uuid = { version = "1.11.0", features = ["v4", "serde"] }
|
||||
semver = { version = "1.0.23", features = ["serde"] }
|
||||
lazy-regex = "3.3.0"
|
||||
tokio = { version = "1.40.0", features = ["full"] }
|
||||
|
@@ -39,8 +39,12 @@ pub enum ConsumptionBackend {
|
||||
/// Fronius inverter consumption
|
||||
Fronius {
|
||||
/// The origin of the domain where the webserver of the Fronius Symo can be reached
|
||||
#[clap(short, long, env = "FRONIUS_ORIG")]
|
||||
origin: String,
|
||||
#[clap(short, long, env)]
|
||||
fronius_orig: String,
|
||||
|
||||
/// Use cURL instead of reqwest to perform request
|
||||
#[clap(short, long)]
|
||||
curl: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,8 @@ pub enum ConsumptionError {
|
||||
NonExistentFile,
|
||||
#[error("The file that should contain the consumption has an invalid content!")]
|
||||
FileInvalidContent(#[source] ParseIntError),
|
||||
#[error("Failed to execute cURL request!")]
|
||||
CurlReqFailed,
|
||||
}
|
||||
|
||||
pub type EnergyConsumption = i32;
|
||||
@@ -63,9 +65,25 @@ pub async fn get_curr_consumption() -> anyhow::Result<EnergyConsumption> {
|
||||
.map_err(ConsumptionError::FileInvalidContent)?)
|
||||
}
|
||||
|
||||
ConsumptionBackend::Fronius { origin } => {
|
||||
let url = format!("{origin}/solar_api/v1/GetPowerFlowRealtimeData.fcgi");
|
||||
let response = reqwest::get(url).await?.json::<FroniusResponse>().await?;
|
||||
ConsumptionBackend::Fronius { fronius_orig, curl } => {
|
||||
let url = format!("{fronius_orig}/solar_api/v1/GetPowerFlowRealtimeData.fcgi");
|
||||
|
||||
let response = match curl {
|
||||
false => reqwest::get(url).await?.json::<FroniusResponse>().await?,
|
||||
true => {
|
||||
let res = std::process::Command::new("curl")
|
||||
.arg("--connect-timeout")
|
||||
.arg("1.5")
|
||||
.arg(url)
|
||||
.output()?;
|
||||
|
||||
if !res.status.success() {
|
||||
return Err(ConsumptionError::CurlReqFailed.into());
|
||||
}
|
||||
|
||||
serde_json::from_slice::<FroniusResponse>(&res.stdout)?
|
||||
}
|
||||
};
|
||||
|
||||
Ok(response.body.data.site.grid_production as i32)
|
||||
}
|
||||
|
@@ -25,7 +25,14 @@ impl EnergyActor {
|
||||
pub async fn new() -> anyhow::Result<Self> {
|
||||
let consumption_cache_size =
|
||||
AppConfig::get().refresh_interval / AppConfig::get().energy_fetch_interval;
|
||||
let curr_consumption = consumption::get_curr_consumption().await?;
|
||||
let curr_consumption = match consumption::get_curr_consumption().await {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
log::warn!("Failed to fetch consumption, using default value! {e}");
|
||||
constants::FALLBACK_PRODUCTION_VALUE
|
||||
}
|
||||
};
|
||||
log::info!("Initial consumption value: {curr_consumption}");
|
||||
let mut consumption_cache = ConsumptionCache::new(consumption_cache_size as usize);
|
||||
consumption_cache.add_value(curr_consumption);
|
||||
|
||||
|
@@ -9,14 +9,20 @@ use actix_web::HttpResponse;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct Consumption {
|
||||
consumption: i32,
|
||||
consumption: Option<i32>,
|
||||
}
|
||||
|
||||
/// Get current energy consumption
|
||||
pub async fn curr_consumption() -> HttpResult {
|
||||
let consumption = consumption::get_curr_consumption().await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(Consumption { consumption }))
|
||||
Ok(match consumption::get_curr_consumption().await {
|
||||
Ok(v) => HttpResponse::Ok().json(Consumption {
|
||||
consumption: Some(v),
|
||||
}),
|
||||
Err(e) => {
|
||||
log::error!("Failed to fetch current consumption! {e}");
|
||||
HttpResponse::Ok().json(Consumption { consumption: None })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Get curr consumption history
|
||||
@@ -34,7 +40,9 @@ pub async fn curr_consumption_history() -> HttpResult {
|
||||
pub async fn cached_consumption(energy_actor: WebEnergyActor) -> HttpResult {
|
||||
let consumption = energy_actor.send(energy_actor::GetCurrConsumption).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(Consumption { consumption }))
|
||||
Ok(HttpResponse::Ok().json(Consumption {
|
||||
consumption: Some(consumption),
|
||||
}))
|
||||
}
|
||||
|
||||
/// Get current relays consumption
|
||||
@@ -42,7 +50,9 @@ pub async fn relays_consumption(energy_actor: WebEnergyActor) -> HttpResult {
|
||||
let consumption =
|
||||
energy_actor.send(energy_actor::RelaysConsumption).await? as EnergyConsumption;
|
||||
|
||||
Ok(HttpResponse::Ok().json(Consumption { consumption }))
|
||||
Ok(HttpResponse::Ok().json(Consumption {
|
||||
consumption: Some(consumption),
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn relays_consumption_history() -> HttpResult {
|
||||
|
@@ -13,6 +13,7 @@ struct ServerConfig {
|
||||
auth_disabled: bool,
|
||||
constraints: StaticConstraints,
|
||||
unsecure_origin: String,
|
||||
backend_version: &'static str,
|
||||
}
|
||||
|
||||
impl Default for ServerConfig {
|
||||
@@ -21,6 +22,7 @@ impl Default for ServerConfig {
|
||||
auth_disabled: AppConfig::get().unsecure_disable_login,
|
||||
constraints: Default::default(),
|
||||
unsecure_origin: AppConfig::get().unsecure_origin(),
|
||||
backend_version: env!("CARGO_PKG_VERSION"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
937
central_frontend/package-lock.json
generated
937
central_frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,10 +15,10 @@
|
||||
"@fontsource/roboto": "^5.1.0",
|
||||
"@mdi/js": "^7.4.47",
|
||||
"@mdi/react": "^1.6.1",
|
||||
"@mui/icons-material": "^6.1.3",
|
||||
"@mui/material": "^6.1.3",
|
||||
"@mui/x-charts": "^7.20.0",
|
||||
"@mui/x-date-pickers": "^7.20.0",
|
||||
"@mui/icons-material": "^6.1.4",
|
||||
"@mui/material": "^6.1.4",
|
||||
"@mui/x-charts": "^7.21.0",
|
||||
"@mui/x-date-pickers": "^7.21.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
"date-and-time": "^3.6.0",
|
||||
"dayjs": "^1.11.13",
|
||||
@@ -31,13 +31,13 @@
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.11",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.8.0",
|
||||
"@typescript-eslint/parser": "^8.8.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
||||
"@typescript-eslint/parser": "^8.10.0",
|
||||
"@vitejs/plugin-react": "^4.3.2",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.12",
|
||||
"typescript": "^5.6.3",
|
||||
"vite": "^5.4.8"
|
||||
"vite": "^5.4.9"
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ export interface ServerConfig {
|
||||
auth_disabled: boolean;
|
||||
constraints: ServerConstraint;
|
||||
unsecure_origin: string;
|
||||
backend_version: string;
|
||||
}
|
||||
|
||||
export interface ServerConstraint {
|
||||
|
@@ -12,9 +12,11 @@ import {
|
||||
ListItemButton,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { RouterLink } from "./RouterLink";
|
||||
import { ServerApi } from "../api/ServerApi";
|
||||
|
||||
export function SolarEnergyNavList(): React.ReactElement {
|
||||
return (
|
||||
@@ -52,6 +54,13 @@ export function SolarEnergyNavList(): React.ReactElement {
|
||||
uri="/logs"
|
||||
icon={<Icon path={mdiNotebookMultiple} size={1} />}
|
||||
/>
|
||||
<Typography
|
||||
variant="caption"
|
||||
component="div"
|
||||
style={{ textAlign: "center", width: "100%", marginTop: "30px" }}
|
||||
>
|
||||
Version {ServerApi.Config.backend_version}
|
||||
</Typography>
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
1709
custom_consumption/Cargo.lock
generated
1709
custom_consumption/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,6 @@ edition = "2021"
|
||||
env_logger = "0.11.5"
|
||||
log = "0.4.22"
|
||||
clap = { version = "4.5.18", features = ["derive", "env"] }
|
||||
egui = "0.28.1"
|
||||
eframe = "0.28.1"
|
||||
egui = "0.29.1"
|
||||
eframe = "0.29.1"
|
||||
lazy_static = "1.5.0"
|
||||
|
@@ -1,5 +1,7 @@
|
||||
# Configure project for production
|
||||
|
||||
Note: This guide assumes that you use the default hostname, `central.internal` as hostname for your central system.
|
||||
|
||||
## Create production build
|
||||
|
||||
### Central
|
||||
@@ -44,5 +46,146 @@ The OTA update is then located in `build/main.bin`
|
||||
* A server running a recent Linux (Debian / Ubuntu preferred) with `central` as hostname
|
||||
* DHCP configured on the network
|
||||
|
||||
## Configure DNS server
|
||||
|
||||
If you need to setup a DNS server / proxy to point `central.internal` to the central server IP, you can follow this guide.
|
||||
|
||||
### Retrieve DNS server binary
|
||||
Use [DNSProxy](https://gitlab.com/pierre42100/dnsproxy) as DNS server. Get and compile the sources:
|
||||
|
||||
```bash
|
||||
git clone https://gitlab.com/pierre42100/dnsproxy
|
||||
cd dnsproxy
|
||||
cargo build --release
|
||||
scp target/release/dns_proxy USER@CENTRAL_IP:/home/USER
|
||||
```
|
||||
|
||||
Then, on the target server, install the binary to its final destination:
|
||||
|
||||
```bash
|
||||
sudo mv dns_proxy /usr/local/bin/
|
||||
```
|
||||
|
||||
### Configure DNS server
|
||||
Configure the server as a service `/etc/systemd/system/dns.service`:
|
||||
|
||||
```conf
|
||||
[Unit]
|
||||
Description=DNS server
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
RestartSec=2s
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/tmp
|
||||
ExecStart=/usr/local/bin/dns_proxy -l "CENTRAL_IP:53" -c "central.internal. A CENTRAL_IP"
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Enable and start the new service:
|
||||
|
||||
```bash
|
||||
sudo systemctl enable dns
|
||||
sudo systemctl start dns
|
||||
```
|
||||
|
||||
Check that it works correctly:
|
||||
|
||||
```bash
|
||||
dig central.internal. @CENTRAL_IP
|
||||
```
|
||||
|
||||
You should get an entry like this if it works:
|
||||
|
||||
```
|
||||
;; ANSWER SECTION:
|
||||
central.internal. 0 IN A CENTRAL_IP
|
||||
```
|
||||
|
||||
Then, in your DHCP service, define the central as the DNS server.
|
||||
|
||||
## 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.internal
|
||||
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 fronius -c
|
||||
```
|
||||
|
||||
### 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 fronius -c
|
||||
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
|
||||
```
|
@@ -8,7 +8,7 @@
|
||||
/**
|
||||
* Backend unsecure API URL
|
||||
*/
|
||||
#define BACKEND_UNSECURE_URL "http://devweb.internal:8080"
|
||||
#define BACKEND_UNSECURE_URL "http://central.internal:8080"
|
||||
|
||||
/**
|
||||
* Device name len
|
||||
|
@@ -1 +1 @@
|
||||
1.0.0
|
||||
1.0.2-b1
|
Reference in New Issue
Block a user