summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-01 15:53:01 +0100
committerRichard Jones <rjones@redhat.com>2009-04-01 15:53:01 +0100
commit2aecd64fe51659409760a2c1e15145325f09b7e6 (patch)
treeed649cea4b24bf787ab309a19cbc3eca0454eacc
parentd86b1dce34291e094a263ef1ec63486ba934fb24 (diff)
downloadfebootstrap-2aecd64fe51659409760a2c1e15145325f09b7e6.tar.gz
febootstrap-2aecd64fe51659409760a2c1e15145325f09b7e6.tar.xz
febootstrap-2aecd64fe51659409760a2c1e15145325f09b7e6.zip
Use febootstrap-run properly.
Better documentation for febootstrap-run.
-rwxr-xr-xexamples/guestfs-test.sh10
-rwxr-xr-xexamples/minimal-filesystem.sh10
-rw-r--r--febootstrap-run.pod29
3 files changed, 43 insertions, 6 deletions
diff --git a/examples/guestfs-test.sh b/examples/guestfs-test.sh
index f487f50..8092ff2 100755
--- a/examples/guestfs-test.sh
+++ b/examples/guestfs-test.sh
@@ -41,7 +41,9 @@ echo -n "After minimization: "; du -sh guestfs
# Create the /init which will scan for and enable all LVM volume groups.
-( cd guestfs && cat > init <<'__EOF__'
+create_init ()
+{
+ cat > /init <<'__EOF__'
#!/bin/sh
PATH=/sbin:/usr/sbin:$PATH
MAKEDEV mem null port zero core full ram tty console fd \
@@ -54,8 +56,10 @@ lvm vgscan --ignorelockingfailure
lvm vgchange -ay --ignorelockingfailure
/bin/bash -i
__EOF__
-chmod +x init
-)
+ chmod +x init
+}
+export -f create_init
+../febootstrap-run ./guestfs -- bash -c create_init
# Convert the filesystem to an initrd image.
diff --git a/examples/minimal-filesystem.sh b/examples/minimal-filesystem.sh
index 678d612..497d209 100755
--- a/examples/minimal-filesystem.sh
+++ b/examples/minimal-filesystem.sh
@@ -35,15 +35,19 @@ echo -n "After minimization: "; du -sh minimal
# Create the /init which is just a simple script to give users an
# interactive shell.
-( cd minimal && cat > init <<'__EOF__'
+create_init ()
+{
+ cat > /init <<'__EOF__'
#!/bin/sh
echo; echo; echo
echo "Welcome to the minimal filesystem example"
echo; echo; echo
/bin/bash -i
__EOF__
-chmod +x init
-)
+ chmod +x /init
+}
+export -f create_init
+../febootstrap-run ./minimal -- bash -c create_init
# Convert the filesystem to an initrd image.
diff --git a/febootstrap-run.pod b/febootstrap-run.pod
index c5e713c..9072f5a 100644
--- a/febootstrap-run.pod
+++ b/febootstrap-run.pod
@@ -37,6 +37,35 @@ contents still happen).
=back
+=head1 EXAMPLES
+
+One way to create a new file with specific ownership and permissions
+from a script is to create new content for a file as C<root/file.new>:
+
+ #!/bin/bash
+
+ echo blah > root/file.new
+
+then "install" it with the correct ownership and permissions.
+
+ febootstrap-run root -- install -m 0644 -o root -g root /file.new /file
+ rm root/file.new
+
+(This requires that the C</usr/bin/install> command from coreutils
+exists inside the root.)
+
+Another way to do complex operations from a script is to export a
+function:
+
+ #!/bin/bash
+
+ do_stuff ()
+ {
+ # complex operations inside the root
+ }
+ export -f do_stuff
+ febootstrap-run root -- bash -c do_stuff
+
=head1 ENVIRONMENT VARIABLES
Some L<fakechroot(1)> environment variables are applicable. In