diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..98aabc3 --- /dev/null +++ b/build.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +OS=$1 +RELEASE=$2 +ARCH=$3 +TITLE=$4 +BASE=$5 +BASEPATH=$6 + +echo "architecture: \"$ARCH\" +creation_date: $(date +%s) # To get current date in Unix time, use \`date +%s\` command +properties: +architecture: \"$ARCH\" +description: \"$TITLE\" +os: \"$OS\" +release: \"$RELEASE\"" > images/$BASE/metadata.yaml + +tar -cvzf images/$BASE/metadata.tar.gz -C images/$BASE metadata.yaml +rm images/$BASE/metadata.yaml + +if [ ! -f images/$BASE/$BASE.tar.gz ]; then + + tar -cvzf images/$BASE/$BASE.tar.gz -C $BASEPATH . + # rm -rf $BASEPATH +else + + echo "$BASE.tar.gz already exists; not overwriting" +fi + +EXISTS=$(lxc image list | grep $BASE ) +if [ "$EXISTS" == "" ]; then + + lxc image import images/$BASE/metadata.tar.gz images/$BASE/$BASE.tar.gz --alias $BASE + +else + + echo "not importing image; already exists as $BASE" + +fi \ No newline at end of file diff --git a/provision.sh b/provision.sh new file mode 100755 index 0000000..96c154f --- /dev/null +++ b/provision.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# usage ./provision.sh + +if [ "$USER" != "root" ]; then + echo "must be run as root" + exit 2 +fi + +FLAVOR=$1 +BASEPATH=$2 + +if [ ! -d "$BASEPATH" ]; then + + debootstrap $FLAVOR "$BASEPATH" + +fi + +if [ ! -d "$BASEPATH" ]; then + echo "base path not found: $BASEPATH" + exit 2 +fi + +# update the sources.list - this is only for ubuntu!! +echo "deb http://archive.ubuntu.com/ubuntu $FLAVOR main universe +deb http://archive.ubuntu.com/ubuntu $FLAVOR-updates main universe +deb http://archive.ubuntu.com/ubuntu $FLAVOR-backports main universe +deb http://archive.ubuntu.com/ubuntu $FLAVOR-security main universe" > $BASEPATH/etc/apt/sources.list +