#!/bin/sh echo "`uptime | awk -F" " '{print $1}'`: entering $0 \"$1\"" >>/tmp/.startup_log ## dependencies: # cifsmount_1.5-2_mips.ipk: # /sbin/mount.cifs # kmod-fs-cifs_2.4.32-ar531x-1_mips.ipk: # /etc/modules.d/30-fs-cifs # /lib/modules/2.4.32/cifs.o # (postinst: insmod cifs) . /etc/functions.sh . /tmp/network-config equal() { case "$1" in "$2") return 0 ;; *) return 255 ;; esac } mount_share(){ double_bs="\\" # bs->backslash mount -t cifs //${1}${double_bs}${2} /mnt/${3} -o unc=\\\\${1}\\${2},ip=${1},user=${4},pass=${5} } config_load cifsmount config_get enable cifsmount enable config_get remote_host cifsmount remote_host config_get remote_share cifsmount remote_share config_get remote_user cifsmount remote_user config_get remote_pass cifsmount remote_pass config_get local_mountpoint cifsmount local_mountpoint enabled "$FORM_enable" && { echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled sleep 3 count=0; while ! ping -c 1 ${remote_host} >/dev/null 2>&1; do if [ $count -gt 15 ]; then break; fi sleep 3; count=$((count+1)) done if [ ! -d /mnt/${local_mountpoint} ]; then mkdir -p /mnt/${local_mountpoint} else umount /mnt/${local_mountpoint} >/dev/null 2>&1 fi if ! equal "`df -h | grep "/mnt/${local_mountpoint}" | awk '{print $6}'`" "/mnt/${local_mountpoint}"; then mount_share ${remote_host} ${remote_share} ${local_mountpoint} ${remote_user} ${remote_pass} >/tmp/cifsmount.log 2>&1 fi if [ -z "`cat /tmp/cifsmount.log 2>/dev/null`" ]; then echo "`uptime | awk -F" " '{print $1}'`: Network Share '\\\\${remote_host}\\${remote_share}' mounted successfully" >>/tmp/.startup_log else echo "`uptime | awk -F" " '{print $1}'`: `cat /tmp/cifsmount.log`" >>/tmp/.startup_log fi rm -f /tmp/cifsmount.log }