37 lines
992 B
Rust
37 lines
992 B
Rust
|
|
pub mod config;
|
||
|
|
pub mod install;
|
||
|
|
pub mod wifi;
|
||
|
|
|
||
|
|
pub use config::TollGateConfig;
|
||
|
|
pub use install::install_tollgate;
|
||
|
|
pub use wifi::provision_ssid;
|
||
|
|
|
||
|
|
use anyhow::Result;
|
||
|
|
use tracing::info;
|
||
|
|
|
||
|
|
use crate::Router;
|
||
|
|
|
||
|
|
/// Full TollGate provisioning sequence:
|
||
|
|
/// 1. Install tollgate-module-basic-go via opkg
|
||
|
|
/// 2. Write TollGate UCI config (pricing, mint URL)
|
||
|
|
/// 3. Create the pay-as-you-go WiFi SSID
|
||
|
|
/// 4. Restart affected services
|
||
|
|
pub async fn provision(router: &Router, config: &TollGateConfig) -> Result<()> {
|
||
|
|
info!("[{}] Starting TollGate provisioning", router.host);
|
||
|
|
|
||
|
|
router.opkg_update()?;
|
||
|
|
install_tollgate(router)?;
|
||
|
|
config::apply(router, config)?;
|
||
|
|
wifi::provision_ssid(router, config)?;
|
||
|
|
restart_services(router)?;
|
||
|
|
|
||
|
|
info!("[{}] TollGate provisioning complete", router.host);
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
fn restart_services(router: &Router) -> Result<()> {
|
||
|
|
router.run_ok("/etc/init.d/tollgate restart || true")?;
|
||
|
|
router.run_ok("/etc/init.d/network restart")?;
|
||
|
|
Ok(())
|
||
|
|
}
|