Yep spaces are a pain in the ass. Not sure why \040 is interpreted as white space in preg_split. I will put it on my list.
Will OMV5 support the remote-mount plugin?
-
- OMV 5.x
- Moan
-
-
1. I manually edited file /srv/salt/omv/deploy/fstab/90remotemount.sls (Upd: for NFS):
Code
Alles anzeigen{% set config = salt['omv_conf.get']('conf.service.remotemount') %} {% set cifsCreds = '/root/.cifscredentials-' %} {% for mnt in config.mount %} {% set remotemount = salt['omv_conf.get_by_filter']( 'conf.system.filesystem.mountpoint', {'operator':'stringEquals', 'arg0':'uuid', 'arg1':mnt.mntentref}) %} {% set mntDir = remotemount[0].dir %} {% set mount = True %} {% set options = [] %} {% set options = mnt.options.split(',') %} {%- if mnt.mounttype == 'cifs' %} {%- if mnt.username | length > 0 %} {% set _ = options.append('credentials=' + cifsCreds + mnt.mntentref) %} {%- else %} {% set _ = options.append('guest') %} {%- endif %} #{% set share = '//' + mnt.server + '/' + mnt.sharename | replace(' ', '\\\\040') | replace('\'', '') %} #{% set sharedir = '//' + mnt.server + '/' + mnt.sharename %} {% set share = '//' + mnt.server + '/' + mnt.sharename | replace(' ', '\\\\040') | replace('\'', '') %} {% set sharedir = '//' + mnt.server + '/' + mnt.sharename %} {% set fstype = mnt.mounttype %} {%- elif mnt.mounttype == 'nfs' %} #{% set share = mnt.server + ':' + mnt.sharename | replace('\'', '') %} #{% set sharedir = mnt.server + ':' + mnt.sharename %} {% set share = mnt.server + ':' + mnt.sharename | replace(' ', '\\\\040') | replace('\'', '') %} {% set sharedir = mnt.server + ':' + mnt.sharename %} {% set fstype = mnt.mounttype %} {%- elif mnt.mounttype == 'davfs' %} {%- if mnt.username | length <= 0 %} {% set _ = options.append('guest') %} {%- endif %} {% set share = mnt.server | replace(' ', '\\\\040') | replace('\'', '') %} {% set sharedir = mnt.server %} {% set fstype = mnt.mounttype %} {% set mount = False %} {%- endif %} create_remotemount_mountpoint_{{ mnt.uuid }}: file.accumulated: - filename: "/etc/fstab" - text: "{{ share }}\t\t{{ mntDir }}\t{{ fstype }}\t{{ options | join(',') }}\t0 0" - require_in: - file: append_fstab_entries mount_filesystem_mountpoint_{{ mnt.uuid }}: mount.mounted: - name: {{ mntDir }} - device: {{ sharedir }} - fstype: {{ fstype }} - opts: {{ options }} - mkmnt: True - persist: False - mount: {{ mount }} {% endfor %}
2. Manually edited part of code at file /usr/share/php/openmediavault/system/filesystem/backend/remoteabstract.inc
Code: original part of code
Alles anzeigen/** * Fetch the mount point from either '/etc/fstab' or /proc/mounts'. * * @param string $fsname * @param string $type * * @return string * * @throws Exception */ private static function fetchMountPointFromFstabByFsnameAndType($fsname, $type) { //$mountsFile = strpos($fsname, DIRECTORY_SEPARATOR) === 0 ? '/etc/fstab' : '/proc/mounts'; if ($type == 'nfs' || $type == 'nfs4') { $mountsFile = '/proc/mounts'; } else { $mountsFile = '/etc/fstab'; } foreach (new SplFileObject($mountsFile) as $content) { $splitContent = preg_split('/\s+/', $content); if ($splitContent[2] == 'nfs4') { $fs = 'nfs'; } if ($splitContent[2] == 'davfs' && $type == 'fuse') { $type = 'davfs'; } if ($type === $splitContent[2] || $type === $fs) { if ($fsname === $splitContent[0] || $fsname === $splitContent[1]) { return $splitContent[1]; } } } throw new Exception(sprintf( 'Could not fetch a matching mount point from the provided fsname: \'%s\'.', $fsname )); } }
Code: Mod code
Alles anzeigen/** * Fetch the mount point from either '/etc/fstab' or /proc/mounts'. * * @param string $fsname * @param string $type * * @return string * * @throws Exception */ private static function fetchMountPointFromFstabByFsnameAndType($fsname, $type) { //$mountsFile = strpos($fsname, DIRECTORY_SEPARATOR) === 0 ? '/etc/fstab' : '/proc/mounts'; //if ($type == 'nfs' || $type == 'nfs4') { // $mountsFile = '/proc/mounts'; //} else { // $mountsFile = '/etc/fstab'; //} $mountsFile = '/etc/fstab'; foreach (new SplFileObject($mountsFile) as $content) { $splitContent = preg_split('/\t+/', $content); foreach($splitContent as $key => $value){ $splitContent[$key]=str_replace("\\040"," ",$value); } if ($splitContent[2] == 'nfs4') { $fs = 'nfs'; } if ($splitContent[2] == 'davfs' && $type == 'fuse') { $type = 'davfs'; } if ($type === $splitContent[2] || $type === $fs) { if (strcasecmp($fsname, $splitContent[0]) == 0 || strcasecmp($fsname, $splitContent[1]) == 0) { return $splitContent[1]; } } } throw new Exception(sprintf( 'Could not fetch a matching mount point from the provided fsname: \'%s\'. Type: \'%s\'.', $fsname, $type )); } }
And Plugin work with OMV5!
Upd:
1. Mark code.2. If you use name with space of share dir, you need use ' in name. For example: 'My documents'.
3. Attached my file.
Please do not scold me for my bad English. I hope you got what I meant.
-
Can you please just post what you changed? git diff would be nice.
-
Updated my previous post
-
Updated my previous post
That isn't quite what I meant. I would like to see only the lines you changed instead of the whole file. A diff output or even a github pull request.
-
I'm create github pull request - https://github.com/OpenMediaVa…penmediavault-remotemount
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!