Initial commit

This commit is contained in:
Michael Becker 2024-12-17 00:53:44 -05:00
parent 7e2a8511b1
commit 14d5df15fc
2 changed files with 68 additions and 0 deletions

39
build.sh Executable file
View File

@ -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

29
provision.sh Executable file
View File

@ -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