Mercurial > prosody-modules
comparison mod_captcha_registration/install.lua @ 1373:985bfc6e8cad
mod_captcha_registration: initial commit
author | mrDoctorWho <mrdoctorwho@gmail.com> |
---|---|
date | Sat, 29 Mar 2014 22:56:24 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1372:a573d64968e9 | 1373:985bfc6e8cad |
---|---|
1 -- simple installer for mod_register with dependicies | |
2 | |
3 files = {"util/dataforms.lua", "modules/mod_register.lua", "FiraSans-Regular.ttf"} | |
4 | |
5 default_path = "/usr/lib/prosody" | |
6 | |
7 | |
8 function exists(name) | |
9 if type(name) ~= "string" then return false end | |
10 return os.rename(name, name) and true or false | |
11 end | |
12 | |
13 function copy_file(name, target) | |
14 local file = io.open(name) | |
15 local data = file:read("*all") | |
16 file:close() | |
17 local file = io.open(target, "w") | |
18 file:write(data) | |
19 file:close() | |
20 end | |
21 | |
22 function copy_files(path) | |
23 for index = 1, #files do | |
24 local filename = files[index] | |
25 os.remove(default_path.."/"..filename) | |
26 copy_file(filename, default_path.."/"..filename) | |
27 print("copied: "..default_path.."/"..filename) | |
28 end | |
29 end | |
30 | |
31 if not exists(default_path) then | |
32 io.write("\nEnter prosody path [/usr/lib/prosody]: ") | |
33 path = io.read("*line") | |
34 end | |
35 | |
36 copy_files(path or default_path) |