Last active
January 7, 2017 17:12
-
-
Save DJviolin/e2242d852a64a82246db8e1f1ba305f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
if [ "$EUID" -ne 0 ]; then | |
echo "This script uses functionality which requires root privileges" | |
exit 1 | |
fi | |
acbuildend () { | |
export EXIT=$?; | |
acbuild --debug end && exit $EXIT; | |
} | |
export MY_CHROOT=/var/lib/container/rkt/debian | |
mkdir -p $MY_CHROOT | |
cd $MY_CHROOT | |
acbuild --debug begin | |
trap acbuildend EXIT | |
# User entered acbuild commands go here | |
# Bootstrapping OS | |
export ROOTFS_DIR=rootfs | |
if test "$(ls -A "$ROOTFS_DIR")"; then | |
echo -e "$ROOTFS_DIR directory is not empty!\nYou have to remove everything from here to continue!\nRemove \"$ROOTFS_DIR\" directory (y/n)?" | |
read answer | |
if echo "$answer" | grep -iq "^y" ;then | |
rm -rf $ROOTFS_DIR | |
echo -e "\"$ROOTFS_DIR\" is removed, continue installation..."; | |
mkdir $ROOTFS_DIR | |
debootstrap --arch=amd64 --include=iputils-ping,iproute --components=main --variant=minbase stable $ROOTFS_DIR http://httpredir.debian.org/debian | |
echo -e "\nShowing working directory..." | |
ls -al $ROOTFS_DIR | |
else | |
echo -e "\nScript aborted to run\nExiting..."; exit 1; | |
fi | |
else | |
mkdir $ROOTFS_DIR | |
debootstrap --arch=amd64 --include=iputils-ping,iproute --components=main --variant=minbase stable $ROOTFS_DIR http://httpredir.debian.org/debian | |
echo -e "\nShowing working directory..." | |
ls -al $ROOTFS_DIR | |
fi | |
# Copy the OS to the ACI | |
acbuild --debug copy-to-dir ./rootfs/* / | |
# Name the ACI | |
acbuild --debug set-name lantosistvan.com/debian | |
acbuild --debug set-user 0 | |
acbuild --debug set-group 0 | |
# Set labels | |
acbuild --debug label add arch "amd64" | |
acbuild --debug label add os "linux" | |
acbuild --debug label add version "stable" | |
acbuild --debug label add author "Istvan Lantos <[email protected]>" | |
# Have the app listen on port 80 | |
#acbuild --debug environment add PORT 80 | |
# Add a port for http traffic on port 80 | |
#acbuild --debug port add http tcp 80 | |
# Add a mount point for files to serve | |
#acbuild --debug mount add $(pwd) /mnt | |
# Set default executible | |
#acbuild --debug set-exec -- /bin/sh -c echo "Hello, World from ACI!" | |
acbuild --debug set-exec -- /bin/sh | |
acbuild --debug set-working-directory /mnt | |
# Write the result | |
acbuild --debug write --overwrite debian.aci | |
acbuild --debug cat-manifest | |
acbuild --debug end | |
# https://wiki.debian.org/DontBreakDebian | |
# https://wiki.debian.org/CheckInstall | |
# https://github.com/docker/docker/blob/master/contrib/mkimage.sh | |
# https://github.com/docker/docker/blob/master/contrib/mkimage/debootstrap | |
# https://github.com/docker/docker/blob/master/contrib/mkimage-debootstrap.sh | |
# https://docs.docker.com/engine/userguide/eng-image/baseimages/ | |
# $ su - root | |
# $ su - | |
# $ cp /media/sf_SHARED/build-base.sh /home/user/build-base.sh | |
# $ wget --no-check-certificate --content-disposition https://gist.githubusercontent.com/DJviolin/e2242d852a64a82246db8e1f1ba305f4/raw/162cce6a7e7ca1489f9ca34551873301312d593a/build-base.sh | |
# $ chmod +x build-base.sh | |
# $ cd /var/lib/container/aci | |
# $ zcat debian.aci | tree | head | |
# $ ls -al --block-size=KB | |
# $ rkt run debian.aci | |
# $ rkt run debian.aci --insecure-options=image | |
# $ rkt run debian.aci --insecure-options=image --interactive --exec=/bin/bash | |
# $ ps auxf | |
# Remove exited containers | |
# $ rkt rm $(rkt list --no-legend | grep 'exited' | cut -f 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment