Tried the following code in Vera Secure firmware v1.7.4002. The device was just recovered from a factory reset.
The device immediately froze and stopped responding to commands or ping. Restared it through the switch under the cover. But it never started again. Hardware reset did not work. The Powerled light is constantly lit and it does not take any IP from the router. Support said it was bricked, and no chance to recover it. They tried by remote control but did not succeed either.
No devices were paired yet and only basic configuration were made on it. Is there something in this code that really can make it completely stop responding to this way if the device is ok. ?
Do you have to install the cifs packages before running or trying the code? Unfortunately, I missed trying to manually mount the network device before this code was executed.
[quote=“samyoue, post:28, topic:185496”]Hi,
I’ve had to setup cifs on a few veras the last couple days and have come up with a way of doing it from within veras web ui (no ssh, no scp required and takes less than 3 mins)
First of all in the Startup Lua box, Enter the following (not forgetting to change the first 4 variables as appropriate): [code]–code to mount cifs share every restart, originally by akbooer and modified/updated by samyoue
–edit the following 4 variables to suit your credentials/directories
local device = “//192.168.0.1/volume”
local directory = “/nas”
local user = “admin”
local pass = “admin”
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 lfs = require “lfs”
lfs.mkdir (directory)
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,sec=ntlm %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
cifsmount {user=user, pass=pass, device=device, directory=directory}
local info=‘
’…df()…os.date(‘
Last update: %A, %c
’)
local wf = io.open(‘/www/df.html’,‘w’)
if wf then
wf:write (info)
wf:close ()
return true
end
–to test go to (veras ip address)/df.html (after restart)[/code] then in ‘Test Lua Code’, enter the following:[code]local function execute (command)
p = io.popen (command)
local out = p: read “*a”
p: close()
print (out)
print “-----------”
return out
end
execute “opkg update”
execute “opkg --force-depends install kmod-fs-cifs”
execute “opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc”
[/code]
Give it couple of minutes (don’t trigger any restarts if possible) then go to your veras IP address /df.html (eg. 192.168.0.55/df.html) and hopefully you should get something similar to:
[font=courier]
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 8832 6112 2720 69% /
/dev/root 10240 10240 0 100% /rom
tmpfs 127744 272 127472 0% /tmp
/dev/mtdblock7 8832 6112 2720 69% /overlay
overlayfs:/overlay 8832 6112 2720 69% /
tmpfs 512 0 512 0% /dev
/dev/mtdblock10 51200 11924 39276 23% /storage
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-firmware
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-backup
/dev/mtdblock9 10240 10240 0 100% /mios
[glow=red,2,300]//192.168.0.1/volume 530144 10200 519944 2% /nas[/glow]
Last update: Thursday, Thu Aug 23 10:34:54 2018[/font]
Note the last line of the df file (not the update timestamp) shows your cifs share should have been mounted.
Big thanks to all the contributors on this forum (this thread and this thread in particular)
Hope this helps someone,
Sam.
EDIT:- updated code with akbooers alterations (much smarter than me lol)[/quote]