Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Random Album Button (I know its there, but...)
#6
(12-10-2018, 09:05 PM)Tim Curtis Wrote: The old code did not check for an existing mount of the same name before trying to create a new one. This caused a lot of issues.

moOde 4 series added validation for certain fields entered into the NAS config screen and also some simple code to check if the mount already exists. That code is below. It grep's the output of the mount command for the value entire into the Name field.

Code:
function mountExists($mountname) {
    $result = sysCmd('mount | grep -ow ' . '"' . $mountname .'"');
    if (!empty($result)) {
        return true;
    }
    else {
        return false;
    }
}

But since mount points are in the form /mnt/NAS/<Name> the function would always return true if "NAS" were not excluded from <Name>

I'm sure it could be improved on...

@Tim Curtis

Am I missing something here? 

mount will output lines like

Code:
//<host>/<share> on /mnt/NAS/<mountname> type ...

Why couldn't this function grep on the string "/mnt/NAS/<mountname>"?

The syscmd line would then read


Code:
sysCmd('mount | grep -ow ' . '"' . '/mnt/NAS/' . $mountname .'"');

 
Just my 2-cents worth. I can barely read php  Tongue

Regards,
Kent
Reply


Messages In This Thread
RE: Random Album Button (I know its there, but...) - by TheOldPresbyope - 12-11-2018, 08:03 PM

Forum Jump: