def ebsmount_add(devname, mountdir): """ebs device attached""" matching_devices = [] for device in udevdb.query(): if device.name.startswith(basename(devname)): matching_devices.append(device) for device in matching_devices: devpath = join('/dev', device.name) mountpath = join(mountdir, device.env.get('ID_FS_UUID', devpath[-1])[:6]) mountoptions = ",".join(config.mountoptions.split()) filesystem = device.env.get('ID_FS_TYPE', None) if not filesystem: log(devname, "could not identify filesystem: %s" % devpath) continue if not filesystem in config.filesystems.split(): log(devname, "filesystem (%s) not supported: %s" % (filesystem,devpath)) continue if is_mounted(devpath): log(devname, "already mounted: %s" % devpath) continue mount(devpath, mountpath, mountoptions) if exists(config.postmountscript): log(devname, "Executing: %s -m %s -d %s" % (config.postmountscript, mountpath, devname)) res = system("exec '%s' -m %s -d %s" % (config.postmountscript, mountpath, devname)) else: log(devname, "Script does not exist at %s" % config.postmountscript)
def ebsmount_add(devname, mountdir): """ebs device attached""" matching_devices = [] for device in udevdb.query(): if device.name.startswith(basename(devname)): matching_devices.append(device) for device in matching_devices: devpath = join('/dev', device.name) mountpath = join(mountdir, device.env.get('ID_FS_UUID', devpath[-1])[:4]) mountoptions = ",".join(config.mountoptions.split()) scriptpath = join(mountpath, ".ebsmount") filesystem = device.env.get('ID_FS_TYPE', None) if not filesystem: log(devname, "could not identify filesystem: %s" % devpath) continue if not filesystem in config.filesystems.split(): log(devname, "filesystem (%s) not supported: %s" % (filesystem,devpath)) continue if is_mounted(devpath): log(devname, "already mounted: %s" % devpath) continue mount(devpath, mountpath, mountoptions) log(devname, "mounted %s %s (%s)" % (devpath, mountpath, mountoptions)) if exists(scriptpath): cmd = "run-parts --verbose --exit-on-error %s" % scriptpath cmd += " 2>&1 | tee -a %s" % config.logfile system(cmd)
def ebsmount_add(devname, mountdir): """ebs device attached""" matching_devices = [] for device in udevdb.query(): if device.name.startswith(basename(devname)): matching_devices.append(device) for device in matching_devices: devpath = join("/dev", device.name) mountpath = join(mountdir, device.env.get("ID_FS_UUID", devpath[-1])[:6]) mountoptions = ",".join(config.mountoptions.split()) hookspath = join(mountpath, ".ebsmount") filesystem = device.env.get("ID_FS_TYPE", None) if not filesystem: log(devname, "could not identify filesystem: %s" % devpath) continue if not filesystem in config.filesystems.split(): log(devname, "filesystem (%s) not supported: %s" % (filesystem, devpath)) continue if is_mounted(devpath): log(devname, "already mounted: %s" % devpath) continue mount(devpath, mountpath, mountoptions) log(devname, "mounted %s %s (%s)" % (devpath, mountpath, mountoptions)) if exists(hookspath): hooks = os.listdir(hookspath) hooks.sort() if hooks and not config.runhooks.lower() == "true": log(devname, "skipping hooks: RUNHOOKS not set to True") continue for file in hooks: fpath = join(hookspath, file) if not os.access(fpath, os.X_OK): log(devname, "skipping hook: '%s', not executable" % file) continue if not os.stat(fpath).st_uid == 0 or not os.stat(fpath).st_gid == 0: log(devname, "skipping hook: '%s', not owned root:root" % file) continue log(devname, "executing hook: %s" % file) os.environ["HOME"] = pwd.getpwuid(os.getuid()).pw_dir os.environ["MOUNTPOINT"] = mountpath system("/bin/bash --login -c '%s' 2>&1 | tee -a %s" % (fpath, config.logfile))
def ebsmount_add(devname, mountdir): """ebs device attached""" matching_devices = [] for device in udevdb.query(): if device.name.startswith(basename(devname)): matching_devices.append(device) for device in matching_devices: devpath = join('/dev', device.name) mountpath = join(mountdir, device.env.get('ID_FS_UUID', devpath[-1])[:6]) mountoptions = ",".join(config.mountoptions.split()) hookspath = join(mountpath, ".ebsmount") filesystem = device.env.get('ID_FS_TYPE', None) if not filesystem: log(devname, "could not identify filesystem: %s" % devpath) continue if not filesystem in config.filesystems.split(): log(devname, "filesystem (%s) not supported: %s" % (filesystem,devpath)) continue if is_mounted(devpath): log(devname, "already mounted: %s" % devpath) continue mount(devpath, mountpath, mountoptions) log(devname, "mounted %s %s (%s)" % (devpath, mountpath, mountoptions)) if exists(hookspath): hooks = os.listdir(hookspath) hooks.sort() if hooks and not config.runhooks.lower() == "true": log(devname, "skipping hooks: RUNHOOKS not set to True") continue for file in hooks: fpath = join(hookspath, file) if not os.access(fpath, os.X_OK): log(devname, "skipping hook: '%s', not executable" % file) continue if not os.stat(fpath).st_uid == 0 or not os.stat(fpath).st_gid == 0: log(devname, "skipping hook: '%s', not owned root:root" % file) continue log(devname, "executing hook: %s" % file) os.environ['HOME'] = pwd.getpwuid(os.getuid()).pw_dir os.environ['MOUNTPOINT'] = mountpath system("/bin/bash --login -c '%s' 2>&1 | tee -a %s" % (fpath, config.logfile))