Advertisement
csiknor

Fonz fun_plug bootstrap USB setup.sh

May 12th, 2013
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Script .bootstrap/setup.sh
  4. #
  5. # Called by fun_plug to prepare USB key execution environment
  6. # If everything is ok, fun_plug will run from the USB key
  7. #
  8. # 08/09/2012 - V1.0 by Nicolas Bernaerts
  9.  
  10. # Set default path
  11. PATH=/usr/sbin:/sbin:/usr/bin:/bin
  12. CONTINUE=1
  13.  
  14. # Environment variables. You may adjust them
  15. FFP_HD="/mnt/HD/HD_a2"
  16. FFP_USB="/mnt/USB/HD_c1"
  17. BCK_FLAG=${FFP_USB}/ffp/home/root/backup.do
  18.  
  19. # Check if a USB removable disk has been detected. If not, exit
  20. if [ "$CONTINUE" -eq 1 ]; then
  21.   # get the USB key partition
  22.   USB_PARTITION=`df | grep "${FFP_USB}" | sed 's/^\([a-z0-9\/]*\).*$/\1/g'`
  23.  
  24.   # if partition has been mounted, remount it with noatime, else exit
  25.   if [ -z "${USB_PARTITION}" ]; then
  26.     CONTINUE=0
  27.     echo "ERROR - USB device has not been detected as Mass Storage"
  28.   else
  29.     umount ${USB_PARTITION}
  30.     mount ${USB_PARTITION} -t ext2 ${FFP_USB} -o noatime 2>/dev/null
  31.     echo "USB - USB disk mounted under ${FFP_USB}"
  32.   fi
  33. fi
  34.  
  35. # Check presence of ffp directory at the USB key root. If not present, exit
  36. if [ "$CONTINUE" -eq 1 ]; then
  37.   if [ ! -d "${FFP_USB}/ffp" ] ; then
  38.     CONTINUE=0
  39.     echo "ERROR - Directory ${FFP_PATH} doesn't exist"
  40.   else
  41.     echo "USB - Directory ${FFP_PATH} present"
  42.   fi
  43. fi
  44.  
  45. # Check if a backup of USB key ffp directory is needed
  46. if [ "$CONTINUE" -eq 1 ]; then
  47.   if [ -f ${BCK_FLAG} ] ; then
  48.     echo "USB - Backup of ${FFP_USB}/ffp needed. Target is ${FFP_HD}/ffp"
  49.     rm -r ${FFP_HD}/ffp
  50.     cp -a ${FFP_USB}/ffp ${FFP_HD}/ffp
  51.     rm ${BCK_FLAG}
  52.     echo "USB - Backup of ${FFP_USB}/ffp done. Backup flag deleted"
  53.   fi
  54. fi
  55.  
  56. # Declare USB key ffp directory as ffp root
  57. if [ "$CONTINUE" -eq 1 ]; then
  58.   FFP_PATH=${FFP_USB}/ffp
  59.   echo "USB - Fun_Plug is running from USB key under ${FFP_PATH}, accessible thru /ffp"
  60. else
  61.   echo "ERROR - Fun_Plug root can't be moved to USB Key"
  62. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement