wok view tazchroot/stuff/tazchroot.conf @ rev 8833

Fix: tazdev receipt
author Christophe Lincoln <pankso@slitaz.org>
date Thu Feb 24 16:18:46 2011 +0100 (2011-02-24)
parents
children
line source
1 # Tazchroot configuration file
2 # Allow you to build a chrooted cooking environnment using the last
3 # version available of packages.
5 # Use SliTaz version:
6 SLITAZ_VERSION=cooking
8 # Chroot path:
9 chroot_dir=/home/cooking
11 # SLITAZ_DIR (it's mounted on chroot)
12 SLITAZ_DIR=/home/slitaz
14 # Online repository path:
15 MIRROR=http://mirror.slitaz.org/packages/experimental/
17 # Default SliTaz paths.
18 LOCALSTATE=/var/lib/tazpkg
19 INSTALLED=$LOCALSTATE/installed
21 # Webserver path;
22 # Define where the chrooted webserver should be linker into
23 # the host system; In this case use the default path when
24 # setting up chrooted webserver.
25 # The host system needs php installed to make it works.
26 # Uncomment to following line to use this option.
27 #WEBSERVER="/var/www/vhosts/bb"
29 # Default scripts path (theses scripts are added in the
30 # $chroot_dir/usr/bin and can be called with tazchroot script)
31 script_dir="/usr/lib/slitaz/chroot-scripts/tazchroot"
33 # List of directories to mount.
34 # They are mounted to an equivalent location into chroot.
35 # (one per line)
36 list_dir="$SLITAZ_DIR"
38 create_chroot()
39 {
40 # Warning message.
41 echo -en "\\033[1;31mWarning:\\033[0m this script is going to use another packages repository than \
42 the one you generally use. Please don't install packages until chroot is created or it will \
43 screw you're main system.
44 Don't continue to run this script if you're installing something.
46 Continue to run (type 'yes' to continue) ? " | fold; read answer
47 [ "$answer" = yes ] || exit
49 if [ -f "$LOCALSTATE/priotity" ]; then
50 mv $LOCALSTATE/priotity $LOCALSTATE/priority.tmp-bak
51 fi
52 tazpkg add-undigest tmp.$SLITAZ_VERSION.mirror "$MIRROR"
53 echo "tmp.$SLITAZ_VERSION.mirror" > /var/lib/tazpkg/priority
54 tazpkg recharge
56 # Install needed packages.
57 tazpkg get-install busybox --root="$chroot_dir"
58 tazpkg get-install tazchroot --root="$chroot_dir"
59 tazpkg get-install tazpkg --root="$chroot_dir"
60 tazpkg get-install tazwok-experimental --root="$chroot_dir"
61 tazpkg get-install libtaz --root="$chroot_dir"
63 rm -r $LOCALSTATE/undigest/tmp.$SLITAZ_VERSION.mirror
64 if [ -f "$LOCALSTATE/priotity.tmp-bak" ]; then
65 mv -f $LOCALSTATE/priotity.tmp-bak $LOCALSTATE/priority
66 fi
67 tazpkg recharge
69 echo -e "\\033[1;31mWarning:\\033[0m You're SliTaz repository configuration is now \
70 back to normal state." | fold
71 }
73 mount_chroot()
74 {
75 # resolv.conf is needed to have network access into chroot.
76 cp -a /etc/resolv.conf "$chroot_dir/etc/resolv.conf"
78 # Setup mirror for chroot.
79 echo "$MIRROR" > "$chroot_dir/var/lib/tazpkg/mirror"
81 # Setup release.
82 echo "$SLITAZ_VERSION" > "$chroot_dir/etc/slitaz-release"
84 # Webserver setup.
85 if [ "$WEBSERVER" ]; then
86 if [ -e "$WEBSERVER" ]; then
87 if [ -L "$WEBSERVER" ]; then
88 [ "$(readlink $WEBSERVER)" = "$chroot_dir/var/www/vhosts/bb" ] || {
89 rm "$WEBSERVER"
90 ln -s "$chroot_dir/var/www/vhosts/bb" "$WEBSERVER"
91 }
92 else
93 echo "\\033[1;31mWarning:\\033[0m Something at $WEBSERVER prevent to setup the webserver link correctly."
94 fi
95 else
96 ln -s "$chroot_dir/var/www/vhosts/bb" "$WEBSERVER"
97 fi
98 fi
100 # Mount system directories
101 mount -t proc proc $chroot_dir/proc
102 mount -t sysfs sysfs $chroot_dir/sys
103 mount -t devpts devpts $chroot_dir/dev/pts
104 mount -t tmpfs shm $chroot_dir/dev/shm
106 # Mount directories of LIST_DIR.
107 # Create them if needed to avoid errors.
108 for dir in $list_dir; do
109 mkdir -p $dir
110 mkdir -p $chroot_dir$dir
111 mount $dir $chroot_dir$dir
112 done
113 }
115 umount_chroot()
116 {
117 # First umount directories of LIST_DIR.
118 for dir in $list_dir; do
119 umount $chroot_dir$dir
120 done
122 # Then umount system directories.
123 umount $chroot_dir/dev/shm
124 umount $chroot_dir/dev/pts
125 umount $chroot_dir/sys
126 umount $chroot_dir/proc
127 }