I’m not sure that this is significantly different from the @parkerc version, and I haven’t been able to test the retry mode (since it always works first time!)
-- cifs mount for use during startup
-- @akbooer 2014-04-23
--
local function df ()
local info
local p = io.popen ("df",'r')
if p then info = p:read "*a"; p:close () end
return info
end
function cifsmount (x)
local function log (msg) luup.log (("cifsmount: '%s' %s"): format (x.device or '?', msg)) end
local df = df ()
if df: find (x.device, 1, true) then
log "already mounted"
else
local cmd = ("mount -t cifs -o user=%s,pass=%s,nounix,noserverino %s %s"): format (x.user, x.pass, x.device, x.directory)
local ok, term, status = os.execute (cmd)
log ("mounted status: "..tostring(status))
if ok
then log ("mounted OK: "..tostring(ok))
elseif x.retry then luup.call_delay ("cifsmount", 60 * x.retry)
else log "failed to mount"
end
end
end
local device = "//172.16.42.100/DATAMINE"
local directory = "/dataMine"
local user = "XXX"
local pass = "xxxxxxxxxxx"
-- optional retry gives interval in minutes to retry failed mount attempt
cifsmount {user=user, pass=pass, device=device, directory=directory, retry=30}