vbootstrap.sh.in 2.3 KB

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