Mercurial Hosting > luan
comparison src/luan/host/main.luan @ 1394:8fe777ba5045
change postgres password
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Sep 2019 22:13:08 -0600 |
parents | 8d95711f6615 |
children | a5f61890ad84 |
comparison
equal
deleted
inserted
replaced
1393:cc0dbca576dc | 1394:8fe777ba5045 |
---|---|
15 local Logging = require "luan:logging/Logging.luan" | 15 local Logging = require "luan:logging/Logging.luan" |
16 local logger = Logging.logger "main" | 16 local logger = Logging.logger "main" |
17 local WebHandler = Hosting.WebHandler or error() | 17 local WebHandler = Hosting.WebHandler or error() |
18 local Util = require "classpath:luan/host/Util.luan" | 18 local Util = require "classpath:luan/host/Util.luan" |
19 local read_password = Util.read_password or error() | 19 local read_password = Util.read_password or error() |
20 local write_password = Util.write_password or error() | 20 local set_password = Util.set_password or error() |
21 | 21 |
22 | 22 |
23 local sites_dir = Io.schemes.file(Hosting.sites_dir) | 23 local sites_dir = Io.schemes.file(Hosting.sites_dir) |
24 | 24 |
25 sites_dir.mkdir() | 25 sites_dir.mkdir() |
102 type(password)=="string" or error() | 102 type(password)=="string" or error() |
103 domain = lower(domain) | 103 domain = lower(domain) |
104 local dir = sites_dir.child(domain) | 104 local dir = sites_dir.child(domain) |
105 dir.exists() and error "already exists" | 105 dir.exists() and error "already exists" |
106 dir.mkdir() | 106 dir.mkdir() |
107 write_password(domain,password) | 107 set_password(domain,password) |
108 dir = dir.child("site") | 108 dir = dir.child("site") |
109 dir.mkdir() | 109 dir.mkdir() |
110 return { name = dir.name(), path = dir.to_string(), children = {} } | 110 return { name = dir.name(), path = dir.to_string(), children = {} } |
111 end | 111 end |
112 | 112 |
177 end | 177 end |
178 | 178 |
179 function fns.change_password(domain,old_password,new_password) | 179 function fns.change_password(domain,old_password,new_password) |
180 local site_dir = get_dir(domain,old_password) | 180 local site_dir = get_dir(domain,old_password) |
181 site_dir or error "domain not found" | 181 site_dir or error "domain not found" |
182 write_password(domain,new_password) | 182 set_password(domain,new_password) |
183 WebHandler.removeHandler(domain) | 183 WebHandler.removeHandler(domain) |
184 WebHandler.loadHandler(domain) | 184 WebHandler.loadHandler(domain) |
185 end | 185 end |
186 | 186 |
187 fns.call = WebHandler.callSite | 187 fns.call = WebHandler.callSite |