This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Arch compatible script for managing samba shares

By: zefficace on Nov 15th, 2011  |  syntax: Bash  |  size: 1.68 KB  |  views: 61  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. You should set your share in fstab, similar to:
  2.  
  3. //192.168.0.100/share /home/some_user/mnt users,noatime,credentials=/root/.smbcredentials,workgroup=WORKGROUP 0 0
  4.  
  5. FOR NETWORKMANAGER
  6.  
  7. gedit /etc/NetworkManager/dispatcher.d/20_netfs  then paste...
  8.  
  9. #!/bin/sh
  10.  
  11. IF=$1 # The interface which is brought up or down
  12. STATUS=$2 # The new state of the interface
  13.  
  14. case "$STATUS" in
  15.     'up') # $IF is up
  16.         exec /etc/rc.d/netfs start
  17.         ;;
  18.     'down') # $IF is down
  19.         exec /etc/rc.d/netfs stop
  20.         ;;
  21. esac
  22.  
  23. FOR WICD
  24.  1- in /etc/wicd/scripts/postconnect (naming it mounting.sh for example)
  25.  
  26. #!/bin/bash
  27.  
  28. script="$(basename "$0")"
  29. script_name="${script/.sh/}"
  30.  
  31. echo "Running ${script}" >"/var/log/wicd/${script_name}.log"
  32. exec 2>>"/var/log/wicd/${script_name}.log"
  33. exec 1>&2
  34.  
  35. connection_type="$1"
  36. echo "Connection type: ${connection_type}"
  37.  
  38. if [ "${connection_type}" == "wired" ]; then
  39.         exec /etc/rc.d/netfs start
  40. elif [ "${connection_type}" == "wireless" ]; then
  41.         exec /etc/rc.d/netfs start
  42. else
  43.         echo "Unknown connection type: ${connection_type}" >&2
  44.         exit
  45. fi
  46.  
  47. 2- in /etc/wicd/scripts/predisconnect (unmounting.sh)
  48. #!/bin/bash
  49.  
  50. script="$(basename "$0")"
  51. script_name="${script/.sh/}"
  52.  
  53. echo "Running ${script}" >"/var/log/wicd/${script_name}.log"
  54. exec 2>>"/var/log/wicd/${script_name}.log"
  55. exec 1>&2
  56.  
  57. connection_type="$1"
  58. echo "Connection type: ${connection_type}"
  59.  
  60. if [ "${connection_type}" == "wired" ]; then
  61.         exec /etc/rc.d/netfs stop
  62. elif [ "${connection_type}" == "wireless" ]; then
  63.         exec /etc/rc.d/netfs stop
  64. else
  65.         echo "Unknown connection type: ${connection_type}" >&2
  66.         exit
  67. fi
clone this paste RAW Paste Data