vbootstrap.sh.in 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. TEXTDOMAIN=vbootstrap
  3. TEXTDOMAINDIR=/usr/share/locale
  4. VERSION=@@VBOOTSTRAP_VERSION@@
  5. ##
  6. VBOOTSTRAPDIR="/usr/share/vbootstrap"
  7. SUPPORTED_VERSION="$(ls $VBOOTSTRAPDIR/scripts/)"
  8. ##
  9. usage()
  10. {
  11. echo "Usage: vbootstrap <version>_<arch> <url> <targetdir>"
  12. echo " supported <version>_<arch>:"
  13. for ver in $SUPPORTED_VERSION
  14. do
  15. echo " $ver"
  16. done
  17. }
  18. ##
  19. if [ "$(id -u)" != "0" ]
  20. then
  21. usage
  22. echo "E: You should run vbooststrap as super user."
  23. exit 0
  24. fi
  25. if ! [ $# -eq 3 ]
  26. then
  27. usage
  28. echo "E: You must specify a vine version, location and target."
  29. exit 0
  30. fi
  31. INSTVER=$1
  32. shift
  33. if [ -f "$VBOOTSTRAPDIR/scripts/$INSTVER" ]
  34. then
  35. source $VBOOTSTRAPDIR/scripts/$INSTVER
  36. else
  37. usage
  38. echo "E: $INSTVER is not supported."
  39. exit 0
  40. fi
  41. FETCHURL=$1
  42. shift
  43. INSTDIR=$1
  44. shift
  45. if [ -d "$INSTDIR" ]
  46. then
  47. echo "E: Specified directory \"$INSTDIR\" is already exists."
  48. usage
  49. exit 0
  50. fi
  51. ##
  52. APT_OPTS="
  53. -o Dir::Etc::sourcelist=$INSTDIR/etc/vbootstrap/sources.list.d/$INSTVER
  54. -o RPM::RootDir=$INSTDIR
  55. -o Dir::Etc::sourceparts=$INSTDIR/etc/apt/sources.list.d
  56. -o Dir::State=$INSTDIR/var/lib/apt
  57. -o Dir::Cache=$INSTDIR/var/cache/apt "
  58. ##
  59. # generate source.list of $INSTVER
  60. mkdir -p $INSTDIR/etc/vbootstrap/sources.list.d
  61. sed -e "s,@@FETCHURL@@,${FETCHURL}," $VBOOTSTRAPDIR/sources.list.d/$INSTVER > $INSTDIR/etc/vbootstrap/sources.list.d/$INSTVER || exit 1
  62. # initialize rpm database
  63. echo $"Initializing RPM database in $INSTDIR."
  64. mkdir -p $INSTDIR/var/lib/rpm
  65. rpm --initdb --root $INSTDIR
  66. # update apt database
  67. echo $"update apt database."
  68. mkdir -p $INSTDIR/var/lib/apt/lists/partial
  69. mkdir -p $INSTDIR/var/cache/apt/archives/partial
  70. apt-get -qq $APT_OPTS update
  71. # misc setup files
  72. mkdir -p $INSTDIR/etc
  73. touch $INSTDIR/etc/mtab
  74. # create some device files
  75. mkdir $INSTDIR/dev
  76. mknod $INSTDIR/dev/null c 1 3
  77. mknod $INSTDIR/dev/console c 5 1
  78. # install base vine linux system.
  79. echo $"Installing basesystem."
  80. for i in $BASE_PKGS
  81. do
  82. apt-get -y -qq $APT_OPTS install $i
  83. done
  84. # run post install script
  85. vbootstrap_post
  86. echo $"vbootstrap done."