Mercurial Hosting > luan
view host/Config.luan @ 1640:570f3d483a31
host - move https.luan into src
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 21 Dec 2021 16:54:26 -0700 |
parents | 520707a70379 |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local ipairs = Luan.ipairs or error() local Io = require "luan:Io.luan" local uri = Io.uri or error() local Package = require "luan:Package.luan" local load = Package.load or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "Config" uri("file:local").mkdir() local password_file = uri("file:local/password.txt") local password = password_file.exists() and password_file.read_text() or "password" local site_config = nil local site_name for _, site_dir in ipairs( uri("file:sites").children() or {} ) do local name = site_dir.name() local config = load("file:sites/"..name.."/site/private/host/Config.luan") if config == false then continue end if config.password ~= password and config.old_password ~= password then logger.warn("wrong password for "..name) continue end if site_config == nil then site_config = config site_name = name else logger.error("conflicting Config in "..name.." and "..site_name) end end if site_config ~= nil then logger.info("using Config from "..site_name) local site_password = site_config.password or error() if site_password ~= password then password_file.write_text(password) end return site_config end if password ~= "password" then password_file.write_text("password") end local Config = {} Config.password = "password" --[[ an example Config.postgres = { class = "org.postgresql.Driver" url = "jdbc:postgresql://localhost:5432/postgres" user = "someone" password = "password" } ]] return Config