debamp/src/amp-proxmox-utils/usr/bin/lxc-debootstrap-image-create

30 lines
896 B
Plaintext
Executable File

set -e
SRC_DEBOOTSTRAP=/usr/share/debootstrap/scripts
IMAGE=$1
URL=$2
TARBALL=$1-$(date +%Y%m%d).tar.gz
if [ -f $SRC_DEBOOTSTRAP/$IMAGE ] ;
then
TARGET=$(mktemp)
rm $TARGET
mkdir $TARGET
echo create rootfs in temporary folder $TARGET
debootstrap $IMAGE $TARGET $URL > /dev/null
cat <<-EOF > $TARGET/etc/apt/apt.conf.d/99aptlight
APT::Install-Recommends "false";
APT::Install-Suggests "false";
EOF
chroot $TARGET /usr/bin/apt clean
echo create archive $TARBALL
tar -C $TARGET -zcvf $TARBALL . > /dev/null
echo Remove temporary folder
rm -fr $TARGET
chmod ugo+r $TARBALL
echo lxc image available in $TARBALL
else
echo $(basename $0) \<version\> [\<url\>]
echo $(basename $0) focal http://archive.ubuntu.com/ubuntu
ls $SRC_DEBOOTSTRAP
fi