slitaz-dev-tools view oldstuff/tazchroot/tazchroot @ rev 285

mouve tazchroot to oldstuff
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 16 18:37:13 2017 +0100 (2017-03-16)
parents tazchroot/tazchroot@869d3bc4d3a6
children
line source
1 #!/bin/sh
2 # Tazchroot - SliTaz chroot manager tool.
3 #
4 # System wide config file for tazhack : /etc/slitaz/tazchroot.conf
5 # Expected system wide config (for SliTaz) : /etc/slitaz/slitaz.conf
6 #
7 # (ยข) Since end of time Anonymous - GNU gpl v3
8 # Version : Alpha
9 # Authors : Anonymous
10 #
12 # Get main SliTaz configuration file.
13 . /lib/libtaz.sh
14 source_lib commons
16 # Create chroot if needed
17 check_chroot()
18 {
19 if [ ! -d $chroot_dir ]; then
20 check_root
21 echo -n "Creating chroot in $chroot_dir..."
22 create_chroot
23 status
24 fi
25 if [ -d "$chroot_dir/proc/1" ]; then
26 echo "The chroot $chroot_dir is already mounted." >&2
27 exit 1
28 fi
29 }
31 update_scripts()
32 {
33 echo -n "Updating scripts"
34 for script in $(cd "$script_dir" && echo *); do
35 if [ ! -f "$chroot_dir/usr/bin/$script" ] || \
36 [ "$script_dir/$script" -nt "$chroot_dir/usr/bin/$script" ]; then
37 cp -a "$script_dir/$script" "$chroot_dir/usr/bin/$script"
38 chmod +x "$chroot_dir/usr/bin/$script"
39 fi
40 done
41 status
42 }
44 # Run the script.
45 check_root
46 get_config
47 command="$@"
48 [ -z "$command" ] && command='/bin/sh --login'
49 check_chroot
50 echo -n "Updating scripts..."
51 update_scripts
52 status
53 echo -n "Mounting chroot directories..."
54 mount_chroot
55 status
56 echo "Command : $command"
57 echo "Entering chroot..."
58 chroot $chroot_dir $command
59 echo -n "Leaving chroot..."
60 umount_chroot
61 status