[Frubar Paste] Hosted by SkyLime - Chat with us at XChannel IRC

Posted by bert2002 on Sat 22nd Oct 21:19
download

  1. #!/bin/bash
  2. # script: mount playbook share
  3. # author: bert2002
  4.  
  5. MNT="/mnt/playbook"
  6.  
  7. PBUSER="playbook"
  8. PBPWD="test"
  9.  
  10. if [ `id -u` != "0" ]; then
  11.         echo "you are not root!"
  12.         exit 2
  13. fi
  14.  
  15. case $1 in
  16.  
  17.         mount)
  18.                 if [ ! -d "$MNT" ]; then
  19.                         mkdir -p $MNT
  20.                 fi
  21.  
  22.                 PBIP=`dhcpcd usb0 >/dev/null 2>&1`
  23.                 if [ $? == "0" ]; then
  24.                         NETWORK=`ifconfig usb0 | grep "inet" | grep -v "inet6" | awk '{print $2}'`
  25.                         LAST=$(echo "`echo $NETWORK | awk -F'.' '{print $4}'` - 1" | bc)
  26.                         NET=$(echo $NETWORK | awk -F'.' '{print $1"."$2"."$3"."}')
  27.                         PBIP="$NET$LAST"
  28.  
  29.                         mount -t cifs -o username=$PBUSER,password=$PBPWD,rw //$PBIP/media $MNT
  30.                         if [ $? == "0" ]; then
  31.                                 echo "mount was okay: $MNT"
  32.                         else
  33.                                 echo "mounting failed"
  34.                         fi
  35.  
  36.                 else
  37.                         echo "dhcpd didnt worked."
  38.                         exit 2
  39.                 fi
  40.  
  41.         ;;
  42.  
  43.         umount)
  44.  
  45.                 umount $MNT
  46.                 if [ $? == "0" ]; then
  47.                         echo "umoumnt was okay."
  48.                 else
  49.                         echo "umount failed"                   
  50.                 fi
  51.  
  52.         ;;
  53.  
  54.         *)
  55.                 echo "Usage: $0 <mount|umount>"
  56.         ;;
  57.  
  58. esac


Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

New posts are disabled. Archive only, sorry.