From 7f6506c2acc3f75357f6ebbbe381aa2d2c66e333 Mon Sep 17 00:00:00 2001 From: hschang Date: Tue, 7 Nov 2017 17:37:36 +0900 Subject: [PATCH] [udev] mount hdd storage to /media/hdd using udev. --- .../recipes-core/base-files/base-files/fstab | 1 - .../base-files/base-files_3.0.14.bbappend | 3 +- .../recipes-core/udev/udev-182/99_vuplus.rules | 4 +- .../recipes-core/udev/udev-182/automount.py | 69 ++++++++++++++++++++++ .../recipes-core/udev/udev-182/automount.sh | 17 ------ .../recipes-core/udev/udev-182/autoumount.py | 35 +++++++++++ .../recipes-core/udev/udev-182/autoumount.sh | 19 ------ .../recipes-core/udev/udev_182.bbappend | 10 ++-- meta-openvuplus/recipes-vuplus/enigma2/enigma2.bb | 2 +- .../enigma2/enigma2_vuplus_fix_standby_name.patch | 44 +++++++------- 10 files changed, 135 insertions(+), 69 deletions(-) create mode 100755 meta-openvuplus/recipes-core/udev/udev-182/automount.py delete mode 100644 meta-openvuplus/recipes-core/udev/udev-182/automount.sh create mode 100755 meta-openvuplus/recipes-core/udev/udev-182/autoumount.py delete mode 100644 meta-openvuplus/recipes-core/udev/udev-182/autoumount.sh diff --git a/meta-openvuplus/recipes-core/base-files/base-files/fstab b/meta-openvuplus/recipes-core/base-files/base-files/fstab index 2d1de8c..2117fd2 100644 --- a/meta-openvuplus/recipes-core/base-files/base-files/fstab +++ b/meta-openvuplus/recipes-core/base-files/base-files/fstab @@ -5,5 +5,4 @@ usbdevfs /proc/bus/usb usbdevfs noauto 0 0 tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0 tmpfs /var/volatile tmpfs defaults 0 0 tmpfs /dev/shm tmpfs mode=0777 0 0 -/dev/sda1 /media/hdd auto defaults 0 0 diff --git a/meta-openvuplus/recipes-core/base-files/base-files_3.0.14.bbappend b/meta-openvuplus/recipes-core/base-files/base-files_3.0.14.bbappend index 051c010..735b51a 100644 --- a/meta-openvuplus/recipes-core/base-files/base-files_3.0.14.bbappend +++ b/meta-openvuplus/recipes-core/base-files/base-files_3.0.14.bbappend @@ -1,4 +1,4 @@ -PR .= "-vuplus3" +PR .= "-vuplus4" do_install_append() { rm -rf ${D}/hdd @@ -9,6 +9,7 @@ do_install_append() { ln -sf var/run ${D}/run install -m 0755 -d ${D}/media/net + install -m 0755 -d ${D}/media/hdd } FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" diff --git a/meta-openvuplus/recipes-core/udev/udev-182/99_vuplus.rules b/meta-openvuplus/recipes-core/udev/udev-182/99_vuplus.rules index 9459ec7..b7e4a8a 100644 --- a/meta-openvuplus/recipes-core/udev/udev-182/99_vuplus.rules +++ b/meta-openvuplus/recipes-core/udev/udev-182/99_vuplus.rules @@ -13,5 +13,5 @@ KERNEL=="fb[0-9]*", SYMLINK+="fb/%n" KERNEL=="i2c-[0-9]*", SYMLINK+="i2c/%n" KERNEL=="mtdblock[0-9]*", SYMLINK+="mtdblock/%n" KERNEL=="tty[0-9]*", SYMLINK+="vc/%n" -ACTION=="add", KERNEL=="sda1", RUN+="/etc/udev/automount.sh sda1" -ACTION=="remove", KERNEL=="sda1", RUN+="/etc/udev/autoumount.sh sda1" +ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/etc/udev/automount.py %k" +ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/etc/udev/autoumount.py %k" diff --git a/meta-openvuplus/recipes-core/udev/udev-182/automount.py b/meta-openvuplus/recipes-core/udev/udev-182/automount.py new file mode 100755 index 0000000..01695b6 --- /dev/null +++ b/meta-openvuplus/recipes-core/udev/udev-182/automount.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +import os +import sys + +def readFile(fn): + return open(fn, "r").read() + +def isMountedByDevName(devName): + ismounted = False + mounts = file('/proc/mounts').read().split('\n') + for x in mounts: + if not x.startswith('/'): + continue + + devpath, mountpoint = x.split()[:2] + if devpath == devName: + ismounted = True + break + + return ismounted + +def automount(): + kernel = sys.argv[1] + dev_kernel = os.path.join("/dev/", kernel) + dev_index = os.path.basename(kernel)[-1] + dev_base = os.path.basename(kernel)[:-1] + removable=readFile("/sys/block/%s/removable" % dev_base).strip() == "1" + dev_real_path = os.path.realpath("/sys/block/%s/device" % dev_base) + external = False + if (dev_real_path.find("pci") != -1) or (dev_real_path.find("ahci") != -1) or (dev_real_path.find("sata") != -1): + external = True + + if isMountedByDevName(dev_kernel): + return + + deviceType = "hdd" +# if removable or external: + if removable: + deviceType = "usb" + + if dev_index == "1": + mountPoint = "/media/" + deviceType + + if os.path.ismount(mountPoint): + mountPoint = "/media/" + kernel + + elif not os.access(mountPoint, os.F_OK): + os.mkdir(mountPoint) + if not os.access(mountPoint, os.F_OK): + mountPoint = "/media/" + kernel + + else: + mountPoint = "/media/" + kernel + + if not os.access(mountPoint, os.F_OK): + os.mkdir(mountPoint) + if not os.access(mountPoint, os.F_OK): + return + + if os.system("mount -t auto -o noatime %s %s" % (dev_kernel, mountPoint)): + os.rmdir(mountPoint) + else: + if mountPoint == "/media/hdd": + defaultMoviePath = "/media/hdd/movie" + if not os.access(defaultMoviePath, os.F_OK): + os.mkdir(defaultMoviePath) + +if __name__=="__main__": + automount() diff --git a/meta-openvuplus/recipes-core/udev/udev-182/automount.sh b/meta-openvuplus/recipes-core/udev/udev-182/automount.sh deleted file mode 100644 index b81c135..0000000 --- a/meta-openvuplus/recipes-core/udev/udev-182/automount.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -get_mount_point() { - mount |grep /dev/$1 |cut -d ' ' -f3 -} - -DEVICE=$1 - -if test -z $DEVICE; then - exit 1 -fi - -if test -z "$(get_mount_point $DEVICE)"; then - echo "[udev] mount /dev/$DEVICE" - mount /dev/sda1 -fi - diff --git a/meta-openvuplus/recipes-core/udev/udev-182/autoumount.py b/meta-openvuplus/recipes-core/udev/udev-182/autoumount.py new file mode 100755 index 0000000..87e4e21 --- /dev/null +++ b/meta-openvuplus/recipes-core/udev/udev-182/autoumount.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +import os +import sys + +def getMountPoint(devName): + mounts = file('/proc/mounts').read().split('\n') + for x in mounts: + if not x.startswith('/'): + continue + + devpath, mountpoint = x.split()[:2] + if devpath == devName: + return mountpoint + + return None + +def autoumount(): + kernel = sys.argv[1] + dev_kernel = os.path.join("/dev/", kernel) + + mountPoint = getMountPoint(dev_kernel) + if mountPoint is None: + mountPoint = os.path.join("/media/", kernel) + + if os.system("umount %s" % mountPoint): + os.system("umount %s" % os.path.join("/dev/", kernel)) + + try: + os.rmdir(mountPoint) + except: + pass + +if __name__=="__main__": + autoumount() + diff --git a/meta-openvuplus/recipes-core/udev/udev-182/autoumount.sh b/meta-openvuplus/recipes-core/udev/udev-182/autoumount.sh deleted file mode 100644 index a8f26bf..0000000 --- a/meta-openvuplus/recipes-core/udev/udev-182/autoumount.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -get_mount_point() { - mount |grep /dev/$1 |cut -d ' ' -f3 -} - -DEVICE=$1 - -if test -z $DEVICE; then - exit 1 -fi - -MOUNTPOINT="$(get_mount_point $DEVICE)" - -if test -n "${MOUNTPOINT}"; then - echo "[udev] umount -l ${MOUNTPOINT}" - umount -l ${MOUNTPOINT} -fi - diff --git a/meta-openvuplus/recipes-core/udev/udev_182.bbappend b/meta-openvuplus/recipes-core/udev/udev_182.bbappend index 76b0feb..4e285d8 100644 --- a/meta-openvuplus/recipes-core/udev/udev_182.bbappend +++ b/meta-openvuplus/recipes-core/udev/udev_182.bbappend @@ -1,16 +1,16 @@ -PR .= "-vuplus2" +PR .= "-vuplus3" SRC_URI += " \ file://99_vuplus.rules \ - file://automount.sh \ - file://autoumount.sh \ + file://automount.py \ + file://autoumount.py \ " do_install_append () { rm ${D}${sysconfdir}/udev/rules.d/*.rules || /bin/true install -m 0755 ${WORKDIR}/99_vuplus.rules ${D}${sysconfdir}/udev/rules.d - install -m 0755 ${WORKDIR}/automount.sh ${D}${sysconfdir}/udev - install -m 0755 ${WORKDIR}/autoumount.sh ${D}${sysconfdir}/udev + install -m 0755 ${WORKDIR}/automount.py ${D}${sysconfdir}/udev + install -m 0755 ${WORKDIR}/autoumount.py ${D}${sysconfdir}/udev sed -i s@udev_run=\"\/var\/run\/udev\"@\#udev_run=\"\/var\/run\/udev\"@ -i ${D}${sysconfdir}/udev/udev.conf } diff --git a/meta-openvuplus/recipes-vuplus/enigma2/enigma2.bb b/meta-openvuplus/recipes-vuplus/enigma2/enigma2.bb index c660eb1..ee25774 100644 --- a/meta-openvuplus/recipes-vuplus/enigma2/enigma2.bb +++ b/meta-openvuplus/recipes-vuplus/enigma2/enigma2.bb @@ -231,7 +231,7 @@ DEPENDS += "${@base_contains("VUPLUS_FEATURES", "uianimation", "libgles libvugle RDEPENDS_${PN}_append_vuplus += "${@base_contains("VUPLUS_FEATURES", "uianimation", "libvugles2" , "", d)}" PN = "enigma2" -PR = "r165" +PR = "r166" inherit gitpkgv pythonnative diff --git a/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_fix_standby_name.patch b/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_fix_standby_name.patch index 05eb3ae..0f8abf0 100644 --- a/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_fix_standby_name.patch +++ b/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_fix_standby_name.patch @@ -1,8 +1,8 @@ diff --git a/RecordTimer.py b/RecordTimer.py -index d3ccd75..e1c9c58 100755 +index 32fb923..58ef5b3 100755 --- a/RecordTimer.py +++ b/RecordTimer.py -@@ -297,7 +297,7 @@ class RecordTimerEntry(timer.TimerEntry, object): +@@ -307,7 +307,7 @@ class RecordTimerEntry(timer.TimerEntry, object): self.record_service = None if self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby @@ -34,10 +34,10 @@ index a6f39ef..bb12b6d 100755 self.standby(True) diff --git a/data/menu.xml b/data/menu.xml -index 03e582c..ccdd6d3 100755 +index 5c8cbb2..a71c036 100755 --- a/data/menu.xml +++ b/data/menu.xml -@@ -96,10 +96,10 @@ self.session.openWithCallback(msgClosed, FactoryReset) +@@ -97,10 +97,10 @@ self.session.openWithCallback(msgClosed, FactoryReset) @@ -51,11 +51,11 @@ index 03e582c..ccdd6d3 100755 diff --git a/data/setup.xml b/data/setup.xml -index 442fe13..719e94a 100755 +index 9613440..8e42c57 100755 --- a/data/setup.xml +++ b/data/setup.xml -@@ -63,7 +63,7 @@ - config.recording.filename_composition +@@ -86,7 +86,7 @@ + config.subtitles.pango_autoturnon - config.usage.hdd_standby @@ -63,7 +63,7 @@ index 442fe13..719e94a 100755 config.network.dhcp -@@ -93,7 +93,7 @@ +@@ -116,7 +116,7 @@ config.lcd.bright config.lcd.contrast @@ -88,9 +88,7 @@ index 0ea65cd..2baadf9 100644 config.ParentalControl.setuppinactive = ConfigYesNo(default = False) config.ParentalControl.type = ConfigSelection(default = "blacklist", choices = [(LIST_WHITELIST, _("whitelist")), (LIST_BLACKLIST, _("blacklist"))]) diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py -old mode 100644 -new mode 100755 -index b98be60..a00132d +index d262448..26eac19 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -23,7 +23,7 @@ def InitUsageConfig(): @@ -118,18 +116,18 @@ index b98be60..a00132d config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [ diff --git a/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py b/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py -index 86aa991..e702068 100755 +index 5922fde..06dbd74 100755 --- a/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py -@@ -85,7 +85,7 @@ class DeviceManagerConfiguration(Screen, ConfigListScreen): +@@ -84,7 +84,7 @@ class DeviceManagerConfiguration(Screen, ConfigListScreen): def createConfigList(self): self.list = [] self.list.append(getConfigListEntry(_("Enable mount check for HDD : "), config.plugins.devicemanager.mountcheck_enable)) - self.list.append(getConfigListEntry(_("Harddisk standby after : "), config.usage.hdd_standby)) + self.list.append(getConfigListEntry(_("Harddisk idle mode after : "), config.usage.hdd_standby)) - self.list.append(getConfigListEntry(_("Mount known devices automatically : "), config.plugins.devicemanager.hotplug_enable)) - def keySave(self): + class DeviceManager(Screen): + skin = """ diff --git a/lib/python/Plugins/SystemPlugins/Fancontrol/meta/plugin_fancontrol.xml b/lib/python/Plugins/SystemPlugins/Fancontrol/meta/plugin_fancontrol.xml index b766e34..f208ec0 100644 --- a/lib/python/Plugins/SystemPlugins/Fancontrol/meta/plugin_fancontrol.xml @@ -159,7 +157,7 @@ index d28fe8e..c90b6cd 100644 diff --git a/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py b/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py -index e73d9a2..8deddf1 100755 +index bd93f4d..826c1b1 100755 --- a/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py +++ b/lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py @@ -46,8 +46,8 @@ class HdmiCec: @@ -269,10 +267,10 @@ index 48f871f..d2588ec 100644 ConfigListScreen.__init__(self, self.list, session = self.session) #self["config"].list = self.list diff --git a/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py b/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py -index bf29218..1acc43d 100644 +index 6d285fd..956b108 100644 --- a/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py -@@ -27,7 +27,7 @@ _ethDevice = "eth0" +@@ -31,7 +31,7 @@ if SystemInfo.get("WOWLSupport", False): config.plugins.wolconfig = ConfigSubsection() config.plugins.wolconfig.activate = ConfigYesNo(default = False) @@ -281,7 +279,7 @@ index bf29218..1acc43d 100644 import socket class NetTool: -@@ -189,7 +189,7 @@ def MenuSelected(selected, **kwargs): +@@ -199,7 +199,7 @@ def MenuSelected(selected, **kwargs): if selected == "system": return [(_("WakeOnLan Setup"), PluginMain, "wolconfig", 80)] if selected == "shutdown" and config.plugins.wolconfig.activate.value and config.plugins.wolconfig.location.value == "menu": @@ -291,7 +289,7 @@ index bf29218..1acc43d 100644 def Plugins(**kwargs): diff --git a/lib/python/Screens/SleepTimerEdit.py b/lib/python/Screens/SleepTimerEdit.py -index 1305b62..9f30c2d 100755 +index 4945df8..bbc8365 100755 --- a/lib/python/Screens/SleepTimerEdit.py +++ b/lib/python/Screens/SleepTimerEdit.py @@ -79,12 +79,12 @@ class SleepTimerEdit(Screen): @@ -353,7 +351,7 @@ index 9885e70..c3e71c7 100644 self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) diff --git a/po/en.po b/po/en.po -index 6937349..4ce5bad 100755 +index 5acb840..6aa7f7b 100644 --- a/po/en.po +++ b/po/en.po @@ -445,6 +445,14 @@ msgstr "" @@ -369,7 +367,7 @@ index 6937349..4ce5bad 100755 +# +msgid "" "A finished record timer wants to shut down\n" - "your Dreambox. Shutdown now?" + "your STB. Shutdown now?" msgstr "" @@ -549,6 +557,22 @@ msgstr "" @@ -392,7 +390,7 @@ index 6937349..4ce5bad 100755 +# +msgid "" "A sleep timer wants to shut down\n" - "your Dreambox. Shutdown now?" + "your STB. Shutdown now?" msgstr "" @@ -3392,6 +3416,21 @@ msgstr "ISO path" msgid "Icelandic" -- 2.7.4