File: build-basic-vm.sh

package info (click to toggle)
supermin 5.2.2-7.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,324 kB
  • sloc: ansic: 15,089; sh: 4,913; ml: 2,599; makefile: 251; perl: 26
file content (84 lines) | stat: -rwxr-xr-x 2,217 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash -

set -e

# This script builds a simple VM that just contains bash (plus any
# dependencies) and an init script that runs bash to give the user a
# shell.  Also included is coreutils so that commands such as 'ls'
# will work.

if [ "$(id -u)" -eq "0" ]; then
    echo "Do not run this script as root!"
    exit 1
fi

#----------------------------------------------------------------------

# Prepare mode:

pkgs="bash coreutils"

echo "Building a supermin appliance containing $pkgs ..."
echo

# Create a supermin appliance in basic-supermin.d/ subdirectory.
rm -rf basic-supermin.d
mkdir basic-supermin.d
../src/supermin --prepare $pkgs -o basic-supermin.d

# Create an init script.
rm -f init
cat > init <<EOF
#!/bin/bash
exec bash
EOF
chmod 0755 init

# Create a tar file containing the init script as "/init".
tar zcf basic-supermin.d/init.tar.gz init

echo "Built the supermin appliance:"
ls -lh basic-supermin.d/
echo

# Clean up temporary files.
rm init

#----------------------------------------------------------------------

# Build mode:

# Normally the contents of basic-supermin.d are what you would
# distribute to users.  However for this example, I'm now going to run
# supermin --build to build the final appliance.

echo "If you see 'Permission denied' errors here, it could be because your"
echo "distro has decided to engage in security-by-obscurity by making"
echo "some host binaries unreadable by ordinary users.  Normally you can"
echo "ignore these errors."
echo

# Build the full appliance.
rm -rf basic-full-appliance
mkdir basic-full-appliance
../src/supermin --build -f ext2 \
    --copy-kernel --host-cpu "$(uname -m)" \
    -o basic-full-appliance \
    basic-supermin.d

echo
echo "Built the full appliance:"
ls -lsh basic-full-appliance
echo

#----------------------------------------------------------------------

echo "To run the full appliance, use a command such as:"
echo "  qemu-kvm -m 512 -kernel kernel -initrd initrd \\"
echo "      -append 'vga=773 selinux=0' \\"
echo "      -drive file=root,format=raw,if=virtio"
echo

echo "You can examine the supermin appliance in basic-supermin.d/"
echo "You can examine the full appliance in basic-full-appliance/"
echo