diff options
Diffstat (limited to 'recipes-core')
11 files changed, 233 insertions, 49 deletions
diff --git a/recipes-core/base-files/base-files_3.0.14.bbappend b/recipes-core/base-files/base-files_3.0.14.bbappend index c4b642d..335c8ee 100644 --- a/recipes-core/base-files/base-files_3.0.14.bbappend +++ b/recipes-core/base-files/base-files_3.0.14.bbappend @@ -1,5 +1,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" -PR = "m4" +PR = "m5" CONFFILES_${PN}_remove = "${sysconfdir}/fstab" FILES_${PN}_remove = "${sysconfdir}/fstab" @@ -7,6 +7,7 @@ FILES_${PN}_remove = "${sysconfdir}/fstab" # Create folders for generic mountpoints at build time dirs755_append = " /var/config \ /var/oem \ + /var/persistent \ " do_install_append() { diff --git a/recipes-core/multitech/config_2.4.bb b/recipes-core/multitech/config_2.4.bb index 6d6956b..e3d014f 100644 --- a/recipes-core/multitech/config_2.4.bb +++ b/recipes-core/multitech/config_2.4.bb @@ -3,7 +3,7 @@ SECTION = "base" LICENSE = "MIT" RDEPENDS_${PN} += "bash" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -PACKAGE_ARCH = "all" +PACKAGE_ARCH = "${MACHINE_ARCH}" PR = "r3" PACKAGES =+ "${PN}-mths" inherit update-rc.d @@ -79,7 +79,7 @@ pkg_postinst_${PN}-mths() { mkdir -p $X export X ( - + set -x if tar -tf $D${sysconfdir}/defaults.tar.gz | grep dnsmasq ; then : diff --git a/recipes-core/multitech/overlayfs-init-jffs2/overlayfs.init b/recipes-core/multitech/overlayfs-init-jffs2/overlayfs.init index 7a4d26d..5714fa3 100644 --- a/recipes-core/multitech/overlayfs-init-jffs2/overlayfs.init +++ b/recipes-core/multitech/overlayfs-init-jffs2/overlayfs.init @@ -12,9 +12,9 @@ TABLE=$'\n'"$(cat /proc/mtd)" # Erase the file system -DO_ERASE_PERSISTENT="/mnt/user/.persistent/mts_do_erase_persistent" +DO_ERASE_PERSISTENT=$(u-boot printenv erase_persistent_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true) # Remove files not hidden -DO_CLEAR_PERSISTENT="/mnt/user/.persistent/mts_do_clear_persistent" +DO_ERASE_ALL_EXCEPT_PERSISTENT=$(u-boot printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true) pid=$$ prefix="<3>overlayrootfs-generator[${pid}]: " @@ -37,7 +37,7 @@ else fi fs="/dev /proc /sys /run /var/volatile /dev/pts /sys/kernel/debug /sys/kernel/config" - + mnt_user() { mkdir -p $MNT_USER @@ -52,37 +52,27 @@ my_switch_root() { for f in $fs ; do if [[ -d $NEW_ROOT/$f ]] ; then loginfo "my_switch_root: mount -o noatime,move --bind $f $NEW_ROOT/$f" - mount -o noatime,move --bind $f $NEW_ROOT/$f + mount -o noatime,move --bind "$f" "$NEW_ROOT/$f" else # loginfo "my_switch_root: Skipping $NEW_ROOT/$f" : fi done - /sbin/pivot_root $NEW_ROOT $NEW_ROOT/orig -} - -do_remove_old() { - shopt -s dotglob - rm -rf $MNT_USER/*.old - shopt -u dotglob + /sbin/pivot_root "$NEW_ROOT" "$NEW_ROOT"/orig } -# select files for deletion -do_clear_old() { - # when "clear user data" is requested - mark all non-hidden files for deletion +do_erase_all_except_persistent() { + # Delete all files and folders except for the "${MNT_USER}/.persistent" directory. loginfo "Clearing user data. Persistent data will be left " - - for FILE_PATH in "$MNT_USER"/*; do - FILE_NAME=$(basename "$FILE_PATH") - # rename all files and folders that exist in /mnt/user - mv "$FILE_PATH" "$MNT_USER/$FILE_NAME.old" 2>&1 | logpipe - done - do_remove_old - rm -f $DO_CLEAR_PERSISTENT + #UPPERDIR has to be cleared except 'orig' folder + #erasing folders in ${UPPERDIR} + find ${UPPERDIR} -maxdepth 1 -type d | grep "${UPPERDIR}/" | grep -v orig | xargs rm -rf + #erasing rest (files, if they are there) in ${UPPERDIR} + rm ${UPPERDIR}/* >/dev/null 2>&1 } # Most efficient way to clear UBIFS file system -do_erase_old() { +do_erase_persistent() { loginfo "Erasing user data" # Sys must be mounted to use ubifs utilities mount -t sysfs sysfs /sys @@ -98,12 +88,13 @@ do_rw_mount() { mount -t tmpfs inittemp /mnt mnt_user # user_data is now accessible - do_remove_old - - if [[ -f $DO_ERASE_PERSISTENT ]] ; then - do_erase_old - elif [[ -f $DO_CLEAR_PERSISTENT ]] ; then - do_clear_old + if [[ "$DO_ERASE_PERSISTENT" -eq 1 ]] ; then + do_erase_persistent + u-boot setenv default_reset_f + u-boot setenv erase_persistent_f 0 + elif [[ "$DO_ERASE_ALL_EXCEPT_PERSISTENT" -eq 1 ]] ; then + do_erase_all_except_persistent + u-boot setenv default_reset_f fi mkdir -p $UPPERDIR $WORKDIR $OVERLAY $USER_ORIG ${MNT_USER}/.persistent @@ -112,11 +103,9 @@ do_rw_mount() { loginfo "/proc/mounts:" cat /proc/mounts | grep overlay | logpipe - mkdir -p ${OVERLAY}/var/persistent - - mount --bind ${MNT_USER}/.persistent ${OVERLAY}/var/persistent loginfo "Switch root to $OVERLAY" my_switch_root $OVERLAY + mount --bind /orig/mnt/user/.persistent/ /var/persistent cat /proc/mounts | grep overlay | logpipe mount -o remount,rw / cat /proc/mounts | grep overlay | logpipe @@ -126,7 +115,7 @@ do_rw_mount() { cgroupmnts=$(sed -r -e 's/[^[:space:]]*[[:space:]]//' -e 's/[[:space:]]+.*//g' /proc/mounts | grep '^/orig') for mp in ${cgroupmnts} ; do if [[ $mp != /orig ]] && [[ -d $mp ]] ; then - umount -l $mp >/dev/null 2>&1 + umount -l "$mp" >/dev/null 2>&1 fi done } diff --git a/recipes-core/multitech/overlayfs-init-jffs2_0.1.bb b/recipes-core/multitech/overlayfs-init-jffs2_0.1.bb index 0bc10df..2babc4a 100644 --- a/recipes-core/multitech/overlayfs-init-jffs2_0.1.bb +++ b/recipes-core/multitech/overlayfs-init-jffs2_0.1.bb @@ -2,8 +2,8 @@ DESCRIPTION = "OverlayFS init" HOMEPAGE = "http://www.multitech.com/" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" -PACKAGE_ARCH = "all" -PR = "r1" +PACKAGE_ARCH = "${MACHINE_ARCH}" +PR = "r2" RDEPENDS_${PN} += "bash" SRC_URI = " \ diff --git a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init index f19abef..445bcde 100644 --- a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init +++ b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init @@ -10,7 +10,7 @@ LOWERDIR="/" USER_ORIG="$UPPERDIR/orig" USER_PARTITION="ubi0:user-data" # Erase the file system -DO_ERASE_PERSISTENT="/mnt/user/.persistent/mts_do_erase_persistent" +DO_ERASE_PERSISTENT=$(fw_printenv erase_persistent_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true) # Remove files not hidden DO_CLEAR_PERSISTENT=$(fw_printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true) @@ -34,7 +34,7 @@ mnt_user() { fs="/run /dev /proc /sys /sys/kernel/security /dev/shm /dev/pts /sys/fs/cgroup /sys/fs/cgroup/unified /sys/fs/cgroup/systemd /sys/fs/cgroup/devices /sys/fs/cgroup/freezer /sys/fs/cgroup/pids /sys/fs/cgroup/memory /dev/mqueue /sys/kernel/debug /tmp /sys/fs/fuse/connections /sys/kernel/config /var/volatile" - + my_switch_root() { NEW_ROOT=$1 loginfo mountinfo @@ -88,6 +88,7 @@ do_erase_old() { ubiupdatevol ${DEV} -t 2>&1 | logpipe mnt_user + fw_setenv erase_persistent_f 0 } do_rw_mount() { @@ -97,8 +98,9 @@ do_rw_mount() { mnt_user # user_data is now accessible do_remove_old - if [[ -f $DO_ERASE_PERSISTENT ]] ; then + if [[ "$DO_ERASE_PERSISTENT" -eq 1 ]] ; then do_erase_old + fw_setenv default_reset_f 0 elif [[ "$DO_CLEAR_PERSISTENT" -eq 1 ]] ; then do_clear_old fi @@ -109,11 +111,9 @@ do_rw_mount() { loginfo "/proc/mounts:" cat /proc/mounts | grep overlay | logpipe - mkdir -p ${OVERLAY}/var/persistent - - mount --bind ${MNT_USER}/.persistent ${OVERLAY}/var/persistent loginfo "Switch root to $OVERLAY" my_switch_root $OVERLAY + mount --bind /orig/mnt/user/.persistent/ /var/persistent cat /proc/mounts | grep overlay | logpipe mount -o remount,rw / cat /proc/mounts | grep overlay | logpipe diff --git a/recipes-core/multitech/overlayfs-init-ubi_0.1.bb b/recipes-core/multitech/overlayfs-init-ubi_0.1.bb index b2d98af..b3b1882 100644 --- a/recipes-core/multitech/overlayfs-init-ubi_0.1.bb +++ b/recipes-core/multitech/overlayfs-init-ubi_0.1.bb @@ -3,7 +3,7 @@ HOMEPAGE = "http://www.multitech.com/" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" PACKAGE_ARCH = "all" -PR = "7" +PR = "8" RDEPENDS_${PN} += "bash" SRC_URI = " \ diff --git a/recipes-core/multitech/reset-handler-test/reset-handler.default b/recipes-core/multitech/reset-handler-test/reset-handler.default new file mode 100644 index 0000000..71b3e24 --- /dev/null +++ b/recipes-core/multitech/reset-handler-test/reset-handler.default @@ -0,0 +1,2 @@ +# set to "no" to disable reset-handler starting on boot +ENABLED="yes" diff --git a/recipes-core/multitech/reset-handler-test/reset-handler.init b/recipes-core/multitech/reset-handler-test/reset-handler.init new file mode 100644 index 0000000..b50e7b8 --- /dev/null +++ b/recipes-core/multitech/reset-handler-test/reset-handler.init @@ -0,0 +1,30 @@ +#!/bin/sh + +DAEMON=/usr/sbin/reset-handler +PIDFILE=/var/run/reset-handler.pid +ENABLED="yes" + +[ -r /etc/default/reset-handler ] && . /etc/default/reset-handler +[ -x $DAEMON ] || exit 0 +[ "$ENABLED" = "yes" ] || exit 0 + +case "$1" in + start) + if [ -f $PIDFILE ]; then + echo "reset-handler pid file exists, not starting" + exit 1 + else + echo "Starting reset-handler" + start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON + fi + ;; + stop) + echo "Stopping reset-handler" + start-stop-daemon --stop --oknodo --pidfile $PIDFILE + rm -f $PIDFILE + ;; + *) + echo "Usage: $0 {start|stop}" + exit 2 + ;; +esac diff --git a/recipes-core/multitech/reset-handler-test/reset-handler.sh b/recipes-core/multitech/reset-handler-test/reset-handler.sh new file mode 100755 index 0000000..08e4e51 --- /dev/null +++ b/recipes-core/multitech/reset-handler-test/reset-handler.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +# Copyright (C) 2014 Multi-Tech Systems + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +PERSISTENT_DIR="/var/persistent/" +ERASE_PERSISTENT="${PERSISTENT_DIR}/mts_do_erase_persistent" + +name="reset-handler" +log="logger -t $name -s" +pid="$$" + +off_leds_test() { + logger 'Turning LEDs to off' + leds=$(ls $led_dir/ | grep -v status) + nleds=$(echo "$leds" | wc -w) + # turn LEDs off + for led in $leds; do + echo none > $led_dir/$led/trigger + echo 0 > $led_dir/$led/brightness + done + logger 'Done LEDs off' +} +blink_leds_test() { + logger 'Turning LEDs to test' + led_dir=/sys/class/leds + # blink all programmable LEDs except status + # in reverse order + leds=$(ls $led_dir/ | grep -v status | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }') + nleds=$(echo "$leds" | wc -w) + + # turn LEDs off + for led in $leds; do + echo "timer" > $led_dir/$led/trigger + echo 0 > $led_dir/$led/delay_off + done + + + # make a pattern + int=1200 + total=$(( int * (nleds+1) )) + on=$(( total - int )) + off=$(( total - on )) + for led in $leds; do + echo "$on" > $led_dir/$led/delay_on + echo "$off" > $led_dir/$led/delay_off + on=$(( total - int )) + off=$(( total - on )) + done + sleep 4 + off_leds_test + logger 'Done Turning LEDs to test' +} + +short_signal=10 # SIGUSR1 +long_signal=12 # SIGUSR2 +extralong_signal=1 # SIGHUP + +do_reboot() { + $log "Rebooting on button press" + sleep 1 + reboot +} + +do_shutdown() { + $log "Shutting down" + shutdown -h now +} + +do_restore_defaults() { + $log "Removing /var/config contents" + rm -rf /var/config/* + $log "Setting restore defaults on reboot" + touch /var/config/force_defaults + if [[ -x /usr/bin/rmpasswd ]] + then + $log "Resetting passwords" + source rmpasswd + fi + if [[ -d ${PERSISTENT_DIR} ]] ; then + touch ${ERASE_PERSISTENT} + fi + $log "Blink LEDs" + sleep 1 + reboot +} + +log_exit() { + $log "Exiting on SIGTERM" + exit 0 +} + +idle_wait() { + pipe=/var/tmp/$name.fifo + rm -f $pipe + mkfifo -m 400 $pipe + + # sneaky way to do nothing forever + while true; do + read < $pipe + done +} + +trap blink_leds_test $short_signal +trap blink_leds_test $long_signal +trap blink_leds_test $extralong_signal +trap log_exit TERM + +$log "Enabling reset-monitor for pid $pid" +mts-io-sysfs store reset-monitor "$pid $short_signal $long_signal $extralong_signal" +# set long press to 5 seconds for reset to defaults +mts-io-sysfs store reset-monitor-intervals "5 30" +# set up SIGPWR shutdown + +# wait for signals +idle_wait + diff --git a/recipes-core/multitech/reset-handler-test_1.0.bb b/recipes-core/multitech/reset-handler-test_1.0.bb new file mode 100644 index 0000000..38cd0ae --- /dev/null +++ b/recipes-core/multitech/reset-handler-test_1.0.bb @@ -0,0 +1,31 @@ +DESCRIPTION = "Test reset button" +SECTION = "base" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +PR = "r3" +RDEPENDS_${PN} += "bash" + +inherit update-rc.d +inherit allarch + +INITSCRIPT_NAME = "reset-handler" +INITSCRIPT_PARAMS = "start 95 2 3 4 5 ." +CONFFILES_${PN} = "${sysconfdir}/default/reset-handler" + +SRC_URI = "\ + file://reset-handler.sh \ + file://reset-handler.init \ + file://reset-handler.default \ +" + +do_install () { + install -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/reset-handler.sh ${D}${sbindir}/reset-handler + + # init script + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/reset-handler.init ${D}${sysconfdir}/init.d/reset-handler + + install -d ${D}${sysconfdir}/default + install -m 0644 ${WORKDIR}/reset-handler.default ${D}${sysconfdir}/default/reset-handler +} diff --git a/recipes-core/multitech/reset-handler/reset-handler.sh b/recipes-core/multitech/reset-handler/reset-handler.sh index f36136e..fe6b903 100755 --- a/recipes-core/multitech/reset-handler/reset-handler.sh +++ b/recipes-core/multitech/reset-handler/reset-handler.sh @@ -21,7 +21,6 @@ # THE SOFTWARE. PERSISTENT_DIR="/var/persistent/" -ERASE_PERSISTENT="${PERSISTENT_DIR}/mts_do_erase_persistent" name="reset-handler" log="logger -t $name -s" @@ -53,9 +52,7 @@ do_restore_defaults() { $log "Resetting passwords" source rmpasswd fi - if [[ -d ${PERSISTENT_DIR} ]] ; then - touch ${ERASE_PERSISTENT} - fi + u-boot setenv erase_persistent_f 1 $log "Rebooting" sleep 1 reboot |