Remove guestfish recipes.

These were out of date.  We will replace them with more up to date
information.
This commit is contained in:
Richard W.M. Jones
2011-05-18 15:27:20 +01:00
parent 9536892721
commit 00d34429e5
47 changed files with 1 additions and 497 deletions

1
.gitignore vendored
View File

@@ -120,7 +120,6 @@ html/guestfs-perl.3.html
html/guestfs-python.3.html
html/guestfs-ruby.3.html
html/guestmount.1.html
html/recipes.html
html/virt-cat.1.html
html/virt-copy-in.1.html
html/virt-copy-out.1.html

View File

@@ -119,27 +119,13 @@ EXTRA_DIST = \
debian/shlibs.local \
debian/watch \
html/pod.css \
html/recipes.css \
libguestfs.pc libguestfs.pc.in \
libtool-kill-dependency_libs.sh \
logo/fish.svg logo/fish.png \
make-recipes.sh \
m4/.gitignore \
recipes/LICENSE \
recipes/README \
recipes/*.html \
recipes/*.sh \
recipes/*.example \
run \
update-bugs.sh
# Recipes web page.
html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile make-recipes.sh
mkdir -p html
rm -f $@ $@-t
sh make-recipes.sh recipes/*.sh > $@-t
mv $@-t $@
HTMLFILES = \
html/guestfs.3.html \
html/guestfs-examples.3.html \
@@ -165,9 +151,7 @@ HTMLFILES = \
html/virt-tar.1.html \
html/virt-tar-in.1.html \
html/virt-tar-out.1.html \
html/virt-win-reg.1.html \
html/recipes.html \
html/pod.css html/recipes.css
html/virt-win-reg.1.html
TEXTFILES = BUGS README RELEASE-NOTES ROADMAP TODO

View File

@@ -1,8 +0,0 @@
/* CSS to make pod2html files look a little bit better. */
@import url("http://people.redhat.com/~rjones/css/standard.css");
div.example pre {
/*font-weight: bold;*/
width: 40em;
border: 1px solid #c00;
}

View File

@@ -1,80 +0,0 @@
#!/bin/sh -
# libguestfs
# Copyright (C) 2009 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
cat <<EOF
<html>
<head>
<title>guestfish recipes</title>
<link rel="stylesheet" href="recipes.css" type="text/css" title="Standard"/>
</head>
<body>
<h1>guestfish recipes</h1>
<p>You can also find these in the
<a href="http://git.annexia.org/?p=libguestfs.git;a=tree;f=recipes;hb=HEAD"><code>recipes/</code>
subdirectory</a> of the source.</p>
<p>
<a href="http://libguestfs.org/download/">Download
libguestfs and guestfish here</a> or
<a href="http://libguestfs.org/">go to the
libguestfs home page</a>.
</p>
<h2>Table of recipes</h2>
<ul>
EOF
for f in recipes/*.sh; do
b=`basename $f .sh`
echo -n ' <li> <a href="#'$b'">'$b.sh
if [ -r recipes/$b.title ]; then
echo -n ': '
cat recipes/$b.title
fi
echo '</a> </li>'
done
echo ' </ul>'
echo
echo
for f in recipes/*.sh; do
b=`basename $f .sh`
echo -n '<a name="'$b'"></a>'
echo -n '<h2>'$b'.sh'
if [ -r recipes/$b.title ]; then
echo -n ': '
cat recipes/$b.title
fi
echo -n '<small style="font-size: 8pt; margin-left: 2em;"><a href="#'$b'">permalink</a></small>'
echo '</h2>'
if [ -r recipes/$b.html ]; then
cat recipes/$b.html
fi
echo '<h3>'$b'.sh</h3>'
echo '<div class="example">'
source-highlight --output=STDOUT --src-lang=sh --input=$f
echo '</div>'
if [ -r recipes/$b.example ]; then
echo '<h3>Example output</h3>'
echo '<pre>'
sed -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g' < recipes/$b.example
echo '</pre>'
fi
done
echo '</body></html>'

View File

@@ -1,2 +0,0 @@
All the scripts in the recipes/ subdirectory may be freely
copied without any restrictions.

View File

@@ -1,26 +0,0 @@
This directory contains guestfish-based shell which give some useful
recipes to follow.
These also get copied to the website here:
http://libguestfs.org/recipes.html
The format for each recipe is:
foo.sh Shell script, using guestfish.
foo.title The title of the recipe.
foo.html HTML snippet describing the recipe.
foo.example Plain text snippet showing example output.
Everything in the recipes/ directory may be used and distributed
without restrictions.
To run a script before libguestfs has been installed, you can do
something like this:
LIBGUESTFS_PATH=../appliance PATH=../fish:$PATH ./show-devices.sh disk.img
You can apply these recipes in your own programs by translating the
guestfish commands into API calls in the language of your choice. The
translation is a simple 1-1 mapping.
Got a useful tip or recipe? Please contribute ...

View File

@@ -1,18 +0,0 @@
$ clone.sh /tmp/test.img /tmp/new.img /dev/sda1 192.168.1.1 newmachine
204800+0 records in
204800+0 records out
104857600 bytes (105 MB) copied, 2.02821 s, 51.7 MB/s
$ guestfish -a /tmp/new.img -m /dev/sda1
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for a list of commands
'man' to read the manual
'quit' to quit the shell
><fs> cat /etc/resolv.conf
nameserver 192.168.1.1
><fs> cat /etc/HOSTNAME
newmachine

View File

@@ -1,22 +0,0 @@
<p>
This script shows how you might have a library of premade
virtual machines ready for cloning, but as a final step you
use libguestfs or guestfish to customize some configuration
files inside the VM before it's ready to go.
</p>
<p>
In this simple recipe, we overwrite the <code>/etc/resolv.conf</code> file
with a new nameserver entry, and change <code>/etc/HOSTNAME</code>.
</p>
<p>
There are lots of possible improvements to this script, such as
using qcow2 snapshots so that cloned VMs share storage with their
"parent" preimages.
</p>
<p>
For more information about cloning images using libvirt and libguestfs
see <a href="https://rwmj.wordpress.com/2010/09/24/tip-my-procedure-for-cloning-a-fedora-vm/#content">Richard Jones's procedure for cloning a Fedora VM</a>.
</p>

View File

@@ -1,14 +0,0 @@
#!/bin/sh -
preimage="$1" ;# original guest
newimage="$2" ;# new guest
root="$3" ;# root filesystem
nameserver="$4" ;# new nameserver
hostname="$5" ;# new hostname
dd if="$preimage" of="$newimage" bs=1M
guestfish -a "$newimage" -m "$root" <<EOF
write /etc/resolv.conf "nameserver $nameserver"
write /etc/HOSTNAME "$hostname"
EOF

View File

@@ -1 +0,0 @@
Clone and edit a virtual machine

View File

@@ -1,13 +0,0 @@
<p>
If you messed up your VM and made it unbootable, it's
often useful to be able to go in and edit <code>/boot/grub/grub.conf</code>.
This guestfish script shows how to do that.
</p>
<pre>
editgrub.sh broken-guest.img
</pre>
<p>
See also <a href="http://libguestfs.org/virt-edit.1.html">virt-edit</a>.
</p>

View File

@@ -1,3 +0,0 @@
#!/bin/sh -
guestfish -a "$1" -i edit /boot/grub/grub.conf

View File

@@ -1 +0,0 @@
Fix an unbootable VM by editing /boot/grub/grub.conf

View File

@@ -1,14 +0,0 @@
$ ./export2tar.sh /dev/mapper/Guests-RHEL53PV32 /dev/VolGroup00/LogVol00 \
/home /tmp/home.tar.gz
$ ll /tmp/home.tar.gz
-rw-rw-r--. 1 rjones rjones 824 2009-04-25 12:33 /tmp/home.tar.gz
$ tar ztf /tmp/home.tar.gz
./
./rjones/
./rjones/.bash_profile
./rjones/.mozilla/
./rjones/.mozilla/extensions/
./rjones/.mozilla/plugins/
./rjones/.bash_logout
./rjones/.bashrc
./rjones/.emacs

View File

@@ -1,20 +0,0 @@
<p>
This script lets you export any directory you like from a virtual
machine as a tarball. For example, to export <code>/home</code>
from a standard Fedora or RHEL virtual machine you would do:
</p>
<pre>
export2tar.sh guest.img /dev/VolGroup00/LogVol00 /home home.tar.gz
</pre>
<p>
<code>/dev/VolGroup00/LogVol00</code> is the partition or LV <i>inside</i>
the VM which contains the directory you want.
</p>
<p>
See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
Jones's complete list of ways to upload and download files</a>.
</p>

View File

@@ -1,3 +0,0 @@
#!/bin/sh -
guestfish --ro -a "$1" -m "$2" tgz-out "$3" "$4"

View File

@@ -1 +0,0 @@
Export the /home directory from a virtual machine into a tarball

View File

@@ -1,16 +0,0 @@
$ ll -h /tmp/Fedora-11-Beta-i386-netinst.iso
-r--r--r--. 1 rjones rjones 168M 2009-04-25 22:38 /tmp/Fedora-11-Beta-i386-netinst.iso
$ ./iso2tar.sh /tmp/Fedora-11-Beta-i386-netinst.iso /tmp/cd.tar.gz
$ ls -lh /tmp/cd.tar.gz
-rw-rw-r--. 1 rjones rjones 177M 2009-04-25 22:50 /tmp/cd.tar.gz
$ tar ztf /tmp/cd.tar.gz
./
./EFI/
./EFI/BOOT/
./EFI/BOOT/BOOT.conf
./EFI/BOOT/BOOTIA32.conf
./EFI/BOOT/splash.xpm.gz
./EFI/BOOT/TRANS.TBL
./images/
./images/efiboot.img
[etc]

View File

@@ -1,17 +0,0 @@
<p>
Convert a CD-ROM or DVD ISO to a tarball.
</p>
<p>
Usage is very simple:
</p>
<pre>
iso2tar.sh cd.iso output.tar.gz
</pre>
<p>
See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
Jones's complete list of ways to upload and download files</a>.
</p>

View File

@@ -1,3 +0,0 @@
#!/bin/sh -
guestfish -a "$1" --ro -m /dev/sda tgz-out / "$2"

View File

@@ -1 +0,0 @@
Convert a CD-ROM or DVD ISO to a tarball

View File

@@ -1,29 +0,0 @@
$ list-apps.sh win7.img
[0] = {
app_name: Mozilla Firefox (3.6.12)
app_display_name: Mozilla Firefox (3.6.12)
app_epoch: 0
app_version: 3.6.12 (en-GB)
app_release:
app_install_path: C:\Program Files\Mozilla Firefox
app_trans_path:
app_publisher: Mozilla
app_url: http://www.mozilla.com/en-GB/
app_source_package:
app_summary:
app_description: Mozilla Firefox
}
[1] = {
app_name: VLC media player
app_display_name: VLC media player 1.1.5
app_epoch: 0
app_version: 1.1.5
app_release:
app_install_path: C:\Program Files\VideoLAN\VLC
app_trans_path:
app_publisher: VideoLAN
app_url: http://www.videolan.org/
app_source_package:
app_summary:
app_description:
}

View File

@@ -1,9 +0,0 @@
<p>
The command lists the applications (eg. RPMs, debs, Windows programs)
installed inside a virtual machine. It does this using the
<a href="http://libguestfs.org/guestfs.3.html#inspection">inspection API</a>.
</p>
<p>
See also <a href="http://libguestfs.org/virt-inspector.1.html">virt-inspector</a>.
</p>

View File

@@ -1,6 +0,0 @@
#!/bin/sh -
eval "$(guestfish --ro -a "$1" --i --listen)"
root="$(guestfish --remote inspect-get-roots)"
guestfish --remote inspect-list-applications "$root"
guestfish --remote exit

View File

@@ -1 +0,0 @@
List the apps (eg. RPMs) installed inside a virtual machine

View File

@@ -1,3 +0,0 @@
<p>
List the files in a virtual machine.
</p>

View File

@@ -1,5 +0,0 @@
#!/bin/sh -
guestfish --ro -a "$1" -i find0 / - |
tr '\000' '\n' |
sort

View File

@@ -1 +0,0 @@
List the files and directories in a virtual machine

View File

@@ -1,2 +0,0 @@
$ product-name.sh win.img
Windows 7 Enterprise

View File

@@ -1,9 +0,0 @@
<p>
Get the string which describes the operating system installed in a
virtual machine. This uses the
<a href="http://libguestfs.org/guestfs.3.html#inspection">inspection API</a>.
</p>
<p>
See also <a href="http://libguestfs.org/virt-inspector.1.html">virt-inspector</a>.
</p>

View File

@@ -1,6 +0,0 @@
#!/bin/sh -
eval "$(guestfish --ro -a "$1" --i --listen)"
root="$(guestfish --remote inspect-get-roots)"
guestfish --remote inspect-get-product-name "$root"
guestfish --remote exit

View File

@@ -1 +0,0 @@
Get the operating system "Product Name" string

View File

@@ -1,8 +0,0 @@
$ show-devices.sh /dev/mapper/Guests-RHEL53PV32
/dev/sda
/dev/sda1
/dev/sda2
/dev/sda2
VolGroup00
/dev/VolGroup00/LogVol00
/dev/VolGroup00/LogVol01

View File

@@ -1,10 +0,0 @@
<p>
This very simple script shows how you can display an overview
of what devices, partitions and LVM data are found in a
guest image.
</p>
<p>
See
also <a href="http://libguestfs.org/virt-filesystems.1.html">virt-filesystems</a>.
</p>

View File

@@ -1,10 +0,0 @@
#!/bin/sh -
guestfish -a "$1" <<EOF
run
list-devices
list-partitions
pvs
vgs
lvs
EOF

View File

@@ -1 +0,0 @@
Display the devices, partitions, LVs, VGs and PVs in a guest image

View File

@@ -1,16 +0,0 @@
$ squashfs.sh
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on test.sqsh, block size 131072.
[===============================================================|] 752/752 100%
[...]
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 97M 3.5M 89M 4% /sysroot/output
$ guestfish -a test1.img -m /dev/sda1 ll /
total 38
drwxr-xr-x 4 root root 1024 Dec 21 16:52 .
drwxr-xr-x 23 500 500 4096 Dec 21 16:52 ..
drwx------ 2 root root 12288 Dec 21 16:52 lost+found
drwxr-xr-x. 2 root root 19456 Dec 18 07:20 man8

View File

@@ -1,22 +0,0 @@
<p>
You can use squashfs to import large amounts of data
into a guest. First you prepare the squashfs image:
</p>
<pre>
/sbin/mksquashfs data <i>[...]</i> data.sqsh
</pre>
<p>
and then you can add it to the guest as an extra data
drive. In the example below, we show how to make a
squashfs from the contents of some local directory
(<code>/usr/share/man/man8</code> in this example)
and then make that appear in the guest.
</p>
<p>
See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
Jones's complete list of ways to upload and download files</a>.
</p>

View File

@@ -1,18 +0,0 @@
#!/bin/sh -
datadir=/usr/share/man/man8
rm -f test.sqsh
/sbin/mksquashfs $datadir test.sqsh
guestfish -N fs -a test.sqsh <<'EOF'
mkmountpoint /output
mkmountpoint /squash
mount-options "" /dev/sda1 /output
mount-options "" /dev/sdb /squash
cp-a /squash /output/man8
umount /squash
df-h
umount /output
EOF
rm test.sqsh

View File

@@ -1 +0,0 @@
Mount data in a guest using squashfs

View File

@@ -1 +0,0 @@
$ ./tar2vm.sh ../libguestfs-1.0.10.tar.gz /tmp/test.img 10M

View File

@@ -1,25 +0,0 @@
<p>
This script shows how you might generate a whole virtual
machine, or a disk image for a virtual machine, starting
with a tarball that contains the content for the machine.
</p>
<p>
The usage is:
</p>
<pre>
tar2vm.sh input.tar.gz output.img 100M
</pre>
<p>
where (for example) <code>100M</code> is the size of the output
disk image. You have to specify a size that is large enough to contain all
the contents of the tarball, but not too large that there is too much
wasted space (unless you want to give the VM extra working space of
course).
</p>
<p>
See also <a href="http://libguestfs.org/virt-make-fs.1.html">virt-make-fs</a>.
</p>

View File

@@ -1,11 +0,0 @@
#!/bin/sh -
guestfish <<EOF
alloc $2 $3
run
part-disk /dev/sda mbr
mkfs ext3 /dev/sda1
mount /dev/sda1 /
tgz-in $1 /
umount-all
EOF

View File

@@ -1 +0,0 @@
Make a virtual machine out of a tarball

View File

@@ -1,6 +0,0 @@
<p>
A simple way to see which home directory is using most
space. Note this just counts the contents of directories
in /home and doesn't include other files that a user may
have.
</p>

View File

@@ -1,13 +0,0 @@
#!/bin/sh -
vmfile="$1"
dir=/home
eval $(guestfish --ro -a "$vmfile" -i --listen)
for d in $(guestfish --remote ls "$dir"); do
echo -n "$dir/$d"
echo -ne '\t'
guestfish --remote du "$dir/$d";
done | sort -nr -k 2
guestfish --remote exit

View File

@@ -1 +0,0 @@
See which user is using most space