Skip to content

Commit

Permalink
update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
hansode committed Mar 29, 2015
1 parent 69d1d3f commit d5cf7e7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,37 @@ Requirements

+ RHEL/CentOS/Scientific

xexecscript(*.sh)
-----------------

Run SCRIPT after distro installation finishes.
Script will be called with the guest's chroot as first argument, so you can use `chroot $1 <cmd>` to run code in the virtual machine.
Usage
-----

copy.txt/postcopy.txt
---------------------
```
$ add-book.sh <book-name>
```

Read `source dest` lines from FILE, copying source files from host to dest in the guest's file system.
```
$ run-book.sh <book-name> <book-name> <book-name> ...
$ CHROOT_DIR=/ run-book.sh <book-name>
$ CHROOT_DIR=/path/to/chroot run-book.sh <book-name>
```

Getting Started
---------------

Add a new book.
### 1: Add a book

```
$ ./add-book.sh untitled
generated => untitled
untitled
untitled/xexecscript.d
untitled/xexecscript.d/untitled.sh
untitled/copy.txt
untitled/guestroot
untitled/xexecscript.d
untitled/xexecscript.d/untitled.sh
```

`untitled/xexecscript.d/untitled.sh` is a sample execscript.
`untitled/xexecscript.d/untitled.sh`:

Script will be called with the guest's chroot as first argument, so you can use `chroot $1 <cmd>` to run code in the virtual machine.

```
#!/bin/bash
Expand All @@ -52,6 +56,28 @@ chroot $1 $SHELL -ex <<'EOS'
EOS
```

`untitled/copy.txt`:

Reading `source dest` lines from FILE, copying source files from host to dest in the guest's file system before running execscript.

```
guestroot/etc/hostname /etc/hostname
```

### 2: Run the book

Run the book in `CHROOT_DIR`(default is `/`).

```
$ sudo CHROOT_DIR=/path/to/chroot ./run-book.sh untitled
```

If you want to run the book on a host, you can set '/' to `CHROOT_DIR` like this.

```
$ sudo CHROOT_DIR= ./run-book.sh untitled
```

Contributing
------------

Expand Down
3 changes: 3 additions & 0 deletions add-book.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# requires:
# bash
#
# usage:
# # add-book.sh <book-name>
#
set -e
set -o pipefail

Expand Down
8 changes: 4 additions & 4 deletions run-book.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# bash
#
# usage:
# # run-book.sh <name>
# # run-book.sh <name> <name> <name> ...
# # run-book.sh <book-name>
# # run-book.sh <book-name> <book-name> <book-name> ...
#
# # CHROOT_DIR=/ run-book.sh <name>
# # CHROOT_DIR=/path/to/chroot run-book.sh <name>
# # CHROOT_DIR=/ run-book.sh <book-name>
# # CHROOT_DIR=/path/to/chroot run-book.sh <book-name>
#

### functions
Expand Down

0 comments on commit d5cf7e7

Please sign in to comment.