Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
improve dovecot and PHP mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
arnisoph committed Nov 8, 2014
1 parent 3c28a2c commit 3f7fbde
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -22,6 +22,7 @@ TODO

* basic mail alias management?
* fix autoresponder in ``dovecot.lua``
* fix TODOs in ``web.lua``

Additional resources
====================
Expand All @@ -31,3 +32,6 @@ The official code can be found at https://www.liveconfig.com/de/downloads.
Implemented features:

* dovecot NOUPDATE
* special dovecot user sieve settings
* dovecot mdbox format for mailboxes
* improve PHP version management
43 changes: 43 additions & 0 deletions custom.lua
@@ -0,0 +1,43 @@
-- Env vars
dovecot.NOUPDATE = true
postfix.NOUPDATE = true

php_versions = {
php53 = {
bin = "/usr/bin/php53/php-cgi",
alias = "5.3",
},
php54 = {
bin = "/usr/bin/php54/php-cgi",
alias = "5.4",
},
php55 = {
bin = "/usr/bin/php55/php-cgi",
alias = "5.5",
prio = 0,
},
php56 = {
bin = "/usr/bin/php56/php-cgi",
alias = "5.6",
},
}


-- Magic goes below

for k, v in pairs(php_versions) do
if v.bin ~= nil and LC.fs.is_file(v.bin) then
local alias = nil
local prio = nil

if v.alias ~= nil then
alias = v.alias
end

if v.prio ~= nil then
prio = v.prio
end

LC.web.addPHP(k, v.bin, alias, prio)
end
end
2 changes: 1 addition & 1 deletion src/lua/dovecot.lua
Expand Up @@ -777,7 +777,7 @@ function addMailbox(cfg, opts, data)
pwd = LC.crypt.cram_md5(data.password)
algo = "CRAM-MD5"
end
new_line = data.name .. "@" .. data.domain .. ":{" .. algo .. "}" .. pwd .. ":" .. uid .. ":" .. gid .. "::/var/mail::userdb_mail=maildir:/var/mail/" .. data.contract .. "/" .. data.id .. "/"
new_line = data.name .. "@" .. data.domain .. ":{" .. algo .. "}" .. pwd .. ":" .. uid .. ":" .. gid .. "::/var/mail::userdb_mail=mdbox:/var/mail/" .. data.contract .. "/" .. data.id .. "/"
if data.quota ~= nil and data.quota > 0 then
new_line = new_line .. " userdb_quota_rule=*:storage=" .. data.quota .. "MB"
end
Expand Down
19 changes: 12 additions & 7 deletions src/lua/web.lua
Expand Up @@ -142,9 +142,12 @@ function detect()
elseif LC.fs.is_file("/usr/bin/php") then
php = "/usr/bin/php"
end
if php ~= nil then
addPHP(nil, php)
end

--TODO: some users may want to use the default bin, provide variable like
-- web.use_default_php = False to optionally disable it
--if php ~= nil then
-- addPHP(nil, php)
--end

LCS.web.phpVersions = phplist

Expand Down Expand Up @@ -898,7 +901,7 @@ for i in ${CONFDIR}/*.conf; do
if [ "${LOGFILE}" != "${NLOGFILE}" -a -r "${NLOGFILE}" ]; then
${WEBALIZER} -c ${i} -Q ${NLOGFILE} || continue;
fi;
done;
# done.
Expand Down Expand Up @@ -1117,7 +1120,7 @@ end
-- ---------------------------------------------------------------------------
-- updatePasswd()
--
-- Create/update
-- Create/update
-- ---------------------------------------------------------------------------
function updatePasswd(opts)

Expand Down Expand Up @@ -1185,15 +1188,17 @@ end
--
-- Register PHP version
-- ---------------------------------------------------------------------------
function addPHP(code, bin, version)
function addPHP(code, bin, version, prio)

-- check that this binary exists:
if not LC.fs.is_file(bin) then
return false
end

-- priority: 0=default version, 1=additional version
local prio = 1
if prio == nil then
prio = 1
end

local handle = io.popen(bin .. " -v", "r")
if handle == nil then
Expand Down

0 comments on commit 3f7fbde

Please sign in to comment.