diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-16 19:26:25 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-16 19:26:25 +0200 |
commit | 4dc1eee385f1b5115976db8d6b60ca0a08ed05ce (patch) | |
tree | 8c2562a28e69949dee07563a8bedc6029d7acc9a /package/system/fstools/files | |
parent | be049529e6a883601fd47303a05165a6a0b9a4a5 (diff) | |
download | mtk-20170518-4dc1eee385f1b5115976db8d6b60ca0a08ed05ce.zip mtk-20170518-4dc1eee385f1b5115976db8d6b60ca0a08ed05ce.tar.gz mtk-20170518-4dc1eee385f1b5115976db8d6b60ca0a08ed05ce.tar.bz2 |
package/system: probably from OpenWRT
Diffstat (limited to 'package/system/fstools/files')
-rw-r--r-- | package/system/fstools/files/fstab.default | 2 | ||||
-rw-r--r-- | package/system/fstools/files/samba.hotplug | 47 |
2 files changed, 49 insertions, 0 deletions
diff --git a/package/system/fstools/files/fstab.default b/package/system/fstools/files/fstab.default index dd4ba1c..f794bb9 100644 --- a/package/system/fstools/files/fstab.default +++ b/package/system/fstools/files/fstab.default @@ -1 +1,3 @@ +touch /tmp/fstab [ ! -f /etc/config/fstab ] && ( block detect > /etc/config/fstab ) +exit 0 diff --git a/package/system/fstools/files/samba.hotplug b/package/system/fstools/files/samba.hotplug new file mode 100644 index 0000000..270e32c --- /dev/null +++ b/package/system/fstools/files/samba.hotplug @@ -0,0 +1,47 @@ +logger $ACTION $DEVNAME $DEVTYPE + +[ "$ACTION" = "add" ] && { + [ "$DEVTYPE" = "partition" -o "$DEVTYPE" = "disk" ] && { + [ "${DEVNAME:0:2}" = "sd" ] && { + [ "$(mount | grep $DEVNAME | cut -d ' ' -f1 | tr -d '\n')" = "/dev/$DEVNAME" ] && { + section=`/sbin/uci add samba sambashare` + /sbin/uci rename samba.$section=usb$DEVNAME + /sbin/uci set samba.usb$DEVNAME.name=usb$DEVNAME + /sbin/uci set samba.usb$DEVNAME.path=/mnt/$DEVNAME + /sbin/uci set samba.usb$DEVNAME.read_only=no + /sbin/uci set samba.usb$DEVNAME.guest_ok=yes + /sbin/uci set samba.usb$DEVNAME.create_mask=777 + /sbin/uci set samba.usb$DEVNAME.dir_mask=777 + /sbin/uci commit + chmod 777 /mnt/$DEVNAME + + touch /tmp/smb.flag + smp.sh storage + + /etc/init.d/samba restart + } + } + } +} + +[ "$ACTION" = "remove" ] && { + [ "$DEVTYPE" = "partition" -o "$DEVTYPE" = "disk" ] && { + [ "${DEVNAME:0:2}" = "sd" ] && { + [ `/sbin/uci get samba.usb$DEVNAME.name` = "" ] && break + [ `/sbin/uci get samba.usb$DEVNAME.name` = "usb$DEVNAME" ] && { + /sbin/uci delete samba.usb$DEVNAME + /sbin/uci commit + } + ret=$(/sbin/uci get samba.@sambashare[0] 2>&1 | awk '{print $3}' | tr -d '\n') + [ $ret = "not" ] && { + /etc/init.d/samba stop + rm -f /tmp/smb.flag + } + [ $ret = "not" ] || { + /etc/init.d/samba restart + } + } + } +} + + |