Commit bb22f4ca authored by Erwan BOUSSE's avatar Erwan BOUSSE
Browse files

Add proto customization mecanism

parent fc69d267
......@@ -5,15 +5,16 @@ set -e
OUTPUT_FOLDER=output
OUTPUT_IMG=$OUTPUT_FOLDER/mini-ubuntu.img
OUTPUT_VDI=$OUTPUT_FOLDER/mini-ubuntu.vdi
OUTPUT_OVA=$OUTPUT_FOLDER/mini-ubuntu.ova
OUTPUT_IMG=$OUTPUT_FOLDER/mini-ubuntu-customized.img
OUTPUT_VDI=$OUTPUT_FOLDER/mini-ubuntu-customized.vdi
OUTPUT_OVA=$OUTPUT_FOLDER/mini-ubuntu-customized.ova
VBoxManage unregistervm "mini-ubuntu" --delete || true
rm -rf vbox
mkdir -p vbox
mkdir -p $OUTPUT_FOLDER
rm $OUTPUT_VDI || true
rm $OUTPUT_OVA || true
VBoxManage convertfromraw --format vdi $OUTPUT_IMG $OUTPUT_VDI
VBoxManage createvm --name "mini-ubuntu" --ostype "Ubuntu_64" --register --basefolder $OUTPUT_FOLDER
......
......@@ -7,7 +7,7 @@ set -e
UBUNTU_VERSION=20.10
ISO_FOLDER=isos
OUTPUT_FOLDER=output
OUTPUT_IMG=$OUTPUT_FOLDER/mini-ubuntu.img
OUTPUT_IMG=$OUTPUT_FOLDER/mini-ubuntu-base.img
# Intermediate variables
ISO=$(curl -s http://releases.ubuntu.com/$UBUNTU_VERSION/ | grep "server install image</a>" | cut -d'"' -f 2)
......
#!/bin/bash
set -x
set -e
if [ $# -ne 1 ];
then
echo "Illegal number of parameters"
exit 2
fi
CUSTOMIZATION_FOLDER=$1
CUSTOMIZATION_FOLDER_BASE=$(basename $CUSTOMIZATION_FOLDER)
function cleanup() {
sudo rm /mnt/etc/resolv.conf || true
sudo umount -f -l /mnt || true
sudo vgchange -an ubuntu-vg || true
sudo kpartx -d "$LOOP" || true
sudo losetup -D
sudo dmsetup remove_all
}
cleanup
# Variables
#TODO
OUTPUT_FOLDER=output
BASE_IMG=$OUTPUT_FOLDER/mini-ubuntu-base.img
CUSTOMIZED_IMG=$OUTPUT_FOLDER/mini-ubuntu-customized.img
LOOP=$(sudo losetup -f)
# Copy base img if needed
touch $CUSTOMIZED_IMG
# if [ ! "$(md5sum $BASE_IMG)" = "$(md5sum $CUSTOMIZED_IMG)" ]
if ! cmp --silent $BASE_IMG $CUSTOMIZED_IMG
then
rm $CUSTOMIZED_IMG || true
cp $BASE_IMG $CUSTOMIZED_IMG
fi
# Mount img file
#TODO
sudo losetup "$LOOP" $CUSTOMIZED_IMG
sudo kpartx -a "$LOOP"
sudo vgscan
sudo vgchange -ay
sudo mount /dev/ubuntu-vg/ubuntu-lv /mnt
# Copy data in /root
#TODO
# Enable DNS in chroot
sudo cp /etc/resolv.conf /mnt/etc || true
# Copy script in /root
#TODO
# Copy data in /root
sudo cp -R $CUSTOMIZATION_FOLDER /mnt/root
# Chroot and run script
#TODO
\ No newline at end of file
sudo chroot /mnt /bin/bash /root/$CUSTOMIZATION_FOLDER_BASE/run.sh
# Cleanup and exit
cleanup
\ No newline at end of file
#!/bin/bash
set -x
set -e
mkdir -p /home/etudiant/Bureau
touch /home/etudiant/Bureau/Hello
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment