Skip to content

Instantly share code, notes, and snippets.

@atkinchris
Last active October 26, 2022 14:09
Show Gist options
  • Select an option

  • Save atkinchris/2b38521a4e98e8122b0e6b78bb329b65 to your computer and use it in GitHub Desktop.

Select an option

Save atkinchris/2b38521a4e98e8122b0e6b78bb329b65 to your computer and use it in GitHub Desktop.
Scripts to create a custom Ubuntu ISO
#!/bin/bash
set -e
mkdir -p /tmp/custom/{_squash,_work,iso,newiso,newlive,project}
mount -o loop ./ubuntu-budgie-17.04-desktop-amd64.iso /tmp/custom/iso
mount -t squashfs /tmp/custom/iso/casper/filesystem.squashfs /tmp/custom/_squash
mount -t overlay overlay -onoatime,lowerdir=/tmp/custom/_squash,upperdir=/tmp/custom/project,workdir=/tmp/custom/_work /tmp/custom/newlive
cp ./setup.sh /tmp/custom/newlive/
systemd-nspawn --bind-ro=/etc/resolv.conf:/run/resolvconf/resolv.conf --setenv=RUNLEVEL=1 -D /tmp/custom/newlive sh /setup.sh
# rm /tmp/custom/newlive/var/lib/dbus/machine-id
rsync -av --exclude casper/filesystem.squashfs /tmp/custom/iso/ /tmp/custom/newiso/
mksquashfs /tmp/custom/newlive /tmp/custom/newiso/casper/filesystem.squashfs -noappend -b 1048576 -comp xz -Xdict-size 100%
printf $(du -s --block-size=1 /tmp/custom/newlive | cut -f1) | tee /tmp/custom/newiso/casper/filesystem.size
umount /tmp/custom/_squash /tmp/custom/newlive /tmp/custom/iso
set -e
# Install apps
apt-get update
# VS Code
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# Node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
# Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# Update and install packages
apt-get update
apt-get -y install build-essential zsh git-core code nodejs yarn
# Clean up
apt-get autoremove --purge
apt-get clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment