2024-12-17 00:53:44 -05:00

39 lines
810 B
Bash
Executable File

#!/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