#!/bin/sh UCI_SPOOLDIR="/var/spool/uvol" _uvol_init_spooldir() { [ ! -d "$(dirname "$UCI_SPOOLDIR")" ] && mkdir -p "$(dirname "$UCI_SPOOLDIR")" mkdir -m 0700 -p "$UCI_SPOOLDIR" } uvol_uci_add() { local volname="$1" local devname="$2" local mode="$3" local autofs=0 local target="/var/run/uvol/$volname" local uuid uciname [ "$mode" = "ro" ] && autofs=1 uciname="${volname//[-.]/_}" uciname="${uciname//[!([:alnum:]_)]}" uuid="$(/sbin/block info | grep "^$2" | xargs -n 1 echo | grep "^UUID=.*")" [ "$uuid" ] || return 22 uuid="${uuid:5}" case "$uciname" in "_uxc") target="/var/run/uxc" ;; "_"*) return 1 ;; esac _uvol_init_spooldir if [ -e "${UCI_SPOOLDIR}/remove-$1" ]; then rm "${UCI_SPOOLDIR}/remove-$1" fi cat >"${UCI_SPOOLDIR}/add-$1" <"${UCI_SPOOLDIR}/remove-$1" <