Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Place this file on /etc/hotplug.d/iface. Example entry (on /etc/config/fstab):
  4. #------------------------------------------------------------
  5. #config netmount
  6. # option target '/mnt'
  7. # option src '//ADDRESS/RESOURCE'
  8. # option fstype 'cifs' #or nfs
  9. ## don't use qoutes inside the string, else the qoutes, they will not be removed
  10. # option options 'user=USER,password=PASSWORD'
  11. # option enabled '1'
  12. # option network 'br-lan'
  13. #------------------------------------------------------------
  14. # Delete these comments if you want to preserve space on /overlay
  15.  
  16. . /lib/functions.sh
  17.  
  18. network_mount() {
  19. local config="$1"
  20. local enabled
  21. local target
  22. local src
  23. local options
  24. local network
  25. local fstype
  26.  
  27. config_get_bool enabled "$config" enabled 0
  28.  
  29. for opt in target src options network fstype
  30. do
  31. config_get "$opt" "$config" "$opt"
  32. done
  33.  
  34. if [ "$enabled" = 1 -a "$INTERFACE" = "$network" ]
  35. then
  36. if [ "$ACTION" = "ifup" ]
  37. then
  38. logger "NetMount: $ACTION: Mounting $src in $target"
  39. mount -t $fstype $src $target -o "$options"
  40. elif [ "$ACTION" = "ifdown" ]
  41. then
  42. logger "NetMount: $ACTION: Umounting $src from $target"
  43. umount $target
  44. elif [ "$ACTION" = "ifupdate" ]
  45. then
  46. logger "NetMount: $ACTION: DHCP renew. Leaving $src mounted in $target"
  47. else
  48. logger "NetMount: Unknown action $ACTION: Leaving $src mounted in $target"
  49. fi
  50. fi
  51. }
  52.  
  53. config_load fstab
  54. config_foreach network_mount netmount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement