pastebin

Paste Search Dynamic
Recent pastes
l2chroot
  1. #!/bin/bash
  2. # Use this script to copy shared (libs) files to Apache/Lighttpd chrooted
  3. # jail server.
  4. # ----------------------------------------------------------------------------
  5. # Written by nixCraft <http://www.cyberciti.biz/tips/>
  6. # (c)  nixCraft under GNU GPL v2.0+
  7. # + Added ld-linux support
  8. # + Added error checking support
  9. # ------------------------------------------------------------------------------
  10. # See url for usage:
  11. # http://www.cyberciti.biz/tips/howto-setup-lighttpd-php-mysql-chrooted-jail.html
  12. # -------------------------------------------------------------------------------
  13. # Set CHROOT directory name
  14. BASE="/webroot"
  15.  
  16. if [ $# -eq 0 ]; then
  17.   echo "Syntax : $0 /path/to/executable"
  18.   echo "Example: $0 /usr/bin/php5-cgi"
  19.   exit 1
  20. fi
  21.  
  22. [ ! -d $BASE ] && mkdir -p $BASE || :
  23.  
  24. # iggy ld-linux* file as it is not shared one
  25. FILES="$(ldd $1 | awk '{ print $3 }' |egrep -v ^'(')"
  26.  
  27. echo "Copying shared files/libs to $BASE..."
  28. for i in $FILES
  29. do
  30.   d="$(dirname $i)"
  31.   [ ! -d $BASE$d ] && mkdir -p $BASE$d || :
  32.   /bin/cp $i $BASE$d
  33. done
  34.  
  35. # copy /lib/ld-linux* or /lib64/ld-linux* to $BASE/$sldlsubdir
  36. # get ld-linux full file location
  37. sldl="$(ldd $1 | grep 'ld-linux' | awk '{ print $1}')"
  38. # now get sub-dir
  39. sldlsubdir="$(dirname $sldl)"
  40.  
  41. if [ ! -f $BASE$sldl ];
  42. then
  43.   echo "Copying $sldl $BASE$sldlsubdir..."
  44.   /bin/cp $sldl $BASE$sldlsubdir
  45. else
  46.   :
  47. fi
Parsed in 0.023 seconds