setup.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. #
  3. # Based on multistrap/examples/chroot.sh
  4. set -e
  5. echo "Configuring rootfs..."
  6. HOSTNAME="devroot"
  7. # The script is called with the following arguments:
  8. # $1 = $DIR - the top directory of the bootstrapped system
  9. # $2 = $ARCH - the specified architecture, already checked with
  10. # dpkg-architecture.
  11. # setup.sh needs to be executable.
  12. TARGET=$1
  13. # upstart support
  14. if [ -x "$TARGET/sbin/initctl" ]; then
  15. echo "initctl: Trying to prevent daemons from starting in $TARGET"
  16. mv "$TARGET/sbin/start-stop-daemon" \
  17. "$TARGET/sbin/start-stop-daemon.REAL"
  18. echo \
  19. "#!/bin/sh
  20. echo
  21. echo \"Warning: Fake start-stop-daemon called, doing nothing\"" \
  22. >"$TARGET/sbin/start-stop-daemon"
  23. chmod 755 "$TARGET/sbin/start-stop-daemon"
  24. fi
  25. if [ -x "$TARGET/sbin/initctl" ]; then
  26. echo "initctl: Trying to prevent daemons from starting in $TARGET"
  27. mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
  28. echo \
  29. "#!/bin/sh
  30. echo
  31. echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
  32. chmod 755 "$TARGET/sbin/initctl"
  33. fi
  34. # sysvinit support - exit value of 101 is essential.
  35. if [ -x "$TARGET/sbin/init" -a ! -f "$TARGET/usr/sbin/policy-rc.d" ]; then
  36. echo "sysvinit: Using policy-rc.d to prevent daemons from starting" \
  37. "in $TARGET"
  38. mkdir -p $TARGET/usr/sbin/
  39. cat > $TARGET/usr/sbin/policy-rc.d << EOF
  40. #!/bin/sh
  41. echo "sysvinit: All runlevel operations denied by policy" >&2
  42. exit 101
  43. EOF
  44. chmod a+x $TARGET/usr/sbin/policy-rc.d
  45. fi
  46. sudo cp /usr/bin/qemu-arm-static ${TARGET}/usr/bin
  47. echo ${HOSTNAME} >${TARGET}/etc/hostname