Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #DEBUG=; set -x # comment/uncomment to disable/enable debug mode
- # name: ddwrt-mount-usb-drives.sh
- # version: 1.2.3, 29-jun-2019, by eibgrad
- # purpose: mount usb drive(s)/partition(s)
- # script type: startup (autostart)
- # compatibility: ext2, ext3, ext4, fat, fat32
- # installation:
- # 1. enable jffs2 (administration->jffs2)
- # 2. enable syslogd (services->services->system log)
- # 3. set services->usb->usb support options as follows:
- # core usb support = enable
- # usb storage support = enable
- # automatic drive mount = disable
- # 4. install usb drive(s) and reboot
- # 5. use shell (telnet/ssh) and blkid utility to determine uuid(s)
- # 6. use shell (telnet/ssh) to execute one of the following commands:
- # curl -kLs bit.ly/ddwrt-installer|tr -d '\r'|sh -s VDZ32r2D startup
- # or
- # wget -qO - bit.ly/ddwrt-installer|tr -d '\r'|sh -s VDZ32r2D startup
- # 7. use vi editor to modify script w/ your preferred options and
- # mounting points:
- # vi /jffs/etc/config/ddwrt-mount-usb-drives.startup
- # 8. reboot
- # limitations:
- # - ntfs is NOT supported at this time
- {
- # ------------------------------ BEGIN OPTIONS ------------------------------- #
- # read/write access, no special devices, don't update access time
- OPT="-o rw,nodev,noatime" # uncomment/comment to enable/disable
- # check (and repair as necessary) all usb partitions
- CLEAN_PARTITIONS= # uncomment/comment to enable/disable
- # allow other startup scripts (if any) to run concurrently
- #DAEMONIZE= # uncomment/comment to enable/disable
- # ------------------------------- END OPTIONS -------------------------------- #
- add_mounts() {
- # ------------------------------- BEGIN MOUNTS ------------------------------- #
- # create mounting point(s) (/opt is pre-defined by the system)
- mkdir -p /mnt/dropbox
- # mount each partition to its preferred mounting point based on UUID
- mount $(findfs UUID=576f3b60-5cb7-4f5d-9800-c309778c2af8) $OPT /opt
- mount $(findfs UUID=427cb076-6681-4a15-9e27-4b90aaf8de3e) $OPT /mnt/dropbox
- # alternate method:
- # mount each partition to its preferred mounting point based on its LABEL;
- # this requires partitions to be uniquely labeled across all devices
- #
- # for linux filesystems only (ext*): if available in your build, use the
- # e2label utility to relabel partitions as necessary (beware, this will
- # likely change its UUID too), otherwise use the gparted utility found on
- # most linux distros
- #mount $(findfs LABEL=optware) $OPT /opt
- #mount $(findfs LABEL=dropbox) $OPT /mnt/dropbox
- # -------------------------------- END MOUNTS -------------------------------- #
- :;}
- # ---------------------- DO NOT CHANGE BELOW THIS LINE ----------------------- #
- # function is_mounted( partition )
- is_mounted() { df | grep -Eq "^$1[[:space:]]+"; }
- # function findfs( LABEL=<label>|UUID=<uuid> )
- findfs() { blkid | sed 's/"//g' | grep -wm1 "$1" | cut -d ':' -f 1; }
- if [ "$(which modprobe)" ]; then
- modprobe ext4
- modprobe msdos
- else
- insmod crc16 && insmod mbcache && insmod jbd2 && insmod ext4
- insmod fat && insmod vfat
- fi
- # check (and repair as necessary) usb partitions (ext* only)
- if [ ${CLEAN_PARTITIONS+x} ]; then
- for part in /dev/sd*; do
- if $(echo $part | grep -Eq '[0-9]+$'); then
- is_mounted $part || e2fsck -p $part 2>/dev/null
- fi
- done
- fi
- # add mounts
- add_mounts
- exit 0
- } 2>&1 | logger $([ ${DEBUG+x} ] && echo "-p user.debug") \
- -t $(echo $(basename $0) | grep -Eo '^.{0,23}')[$$] \
- $([ ${DAEMONIZE+x} ] && echo &)
Add Comment
Please, Sign In to add comment