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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#!/usr/bin/env bash
set -e
set -x
: "[1m Build a temporary directory; make sure ocid is running.[0m"
export PATH=`pwd`:$PATH
d=`mktemp -d`
trap 'cd /;rm -fr "$d"' EXIT
cd "$d"
systemctl restart ocid
read
: "[1m Check if we have some images to work with.[0m"
read
ocic image list
read
: "[1m Create a working container, and capture its name [0m"
read
echo '[container1=`buildah from ${1:-alpine}`]'
container1=`buildah from ${1:-alpine}`
read
: "[1m Mount that working container, and capture the mountpoint [0m"
read
echo '[mountpoint1=`buildah mount $container1`]'
mountpoint1=`buildah mount $container1`
read
: "[1m List random files in the container [0m"
read
echo '[find $mountpoint1 -name "random*"]'
find $mountpoint1 -name "random*"
read
: "[1m Ensure the default destination for copying files is / [0m"
read
echo '[buildah config $container1 --workingdir /]'
buildah config $container1 --workingdir /
read
: "[1m Add a file to the container [0m"
read
echo '[dd if=/dev/urandom of=random1 bs=512 count=1]'
echo '[buildah copy $container1 random1]'
dd if=/dev/urandom of=random1 bs=512 count=1
buildah copy $container1 random1
read
: "[1m Change the default destination for copying files [0m"
read
echo '[buildah config $container1 --workingdir /tmp]'
buildah config $container1 --workingdir /tmp
read
: "[1m Add another new file to the container [0m"
read
echo '[dd if=/dev/urandom of=random2 bs=512 count=1]'
echo '[buildah copy $container1 random2]'
dd if=/dev/urandom of=random2 bs=512 count=1
buildah copy $container1 random2
read
: "[1m Copy a subdirectory with some files in it [0m"
read
echo '[mkdir -p randomsubdir]'
echo '[dd if=/dev/urandom of=randomsubdir/random3 bs=512 count=1]'
echo '[dd if=/dev/urandom of=randomsubdir/random4 bs=512 count=1]'
echo '[buildah copy $container1 randomsubdir]'
mkdir -p randomsubdir
dd if=/dev/urandom of=randomsubdir/random3 bs=512 count=1
dd if=/dev/urandom of=randomsubdir/random4 bs=512 count=1
buildah copy $container1 randomsubdir
read
: "[1m List some of the container's contents [0m"
read
echo '[find $mountpoint1 -name "random*"]'
find $mountpoint1 -name "random*"
read
: "[1m Download a tarball [0m"
read
echo '[wget -c https://releases.pagure.org/tmpwatch/tmpwatch-2.9.17.tar.bz2]'
wget -c https://releases.pagure.org/tmpwatch/tmpwatch-2.9.17.tar.bz2
read
: "[1m Copy that tarball to the container [0m"
read
echo '[mkdir -p $mountpoint1/tmpwatch]'
echo '[buildah copy $container1 --dest /tmpwatch tmpwatch-2.9.17.tar.bz2]'
mkdir -p $mountpoint1/tmpwatch
buildah copy $container1 --dest /tmpwatch tmpwatch-2.9.17.tar.bz2
read
: "[1m Download another tarball to the container [0m"
read
echo '[buildah copy $container1 --dest /tmpwatch https://releases.pagure.org/newt/newt-0.52.19.tar.gz]'
buildah copy $container1 --dest /tmpwatch https://releases.pagure.org/newt/newt-0.52.19.tar.gz
read
: "[1m List the contents of the target directory [0m"
read
echo '[find $mountpoint1/tmpwatch]'
find $mountpoint1/tmpwatch
read
: "[1m Now 'add' the downloaded tarball to the container [0m"
read
echo '[buildah add $container1 --dest /tmpwatch tmpwatch-2.9.17.tar.bz2]'
buildah add $container1 --dest /tmpwatch tmpwatch-2.9.17.tar.bz2
read
: "[1m List the contents of the target directory again [0m"
read
echo '[find $mountpoint1/tmpwatch]'
find $mountpoint1/tmpwatch
read
: "[1m Clean up, because I ran this like fifty times while testing [0m"
read
echo '[buildah delete $container1]'
buildah rm $container1
|