Last active
March 12, 2016 11:46
-
-
Save jeremyvisser/17977f9e63bfe590fe4a to your computer and use it in GitHub Desktop.
SCLUG Installfest 2015
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
#!/bin/bash | |
set -e -x | |
# required for dpkg to work | |
export PATH=/usr/bin:/usr/sbin:/bin:/sbin | |
cat >/etc/apt/sources.list <<EOF | |
deb http://ap-southeast-2.archive.ubuntu.com/ubuntu/ trusty main restricted multiverse universe | |
deb http://ap-southeast-2.archive.ubuntu.com/ubuntu/ trusty-updates main restricted multiverse universe | |
deb http://ap-southeast-2.archive.ubuntu.com/ubuntu/ trusty-security main restricted multiverse universe | |
EOF | |
apt-get update | |
apt-get -y install software-properties-common | |
add-apt-repository -y ppa:webupd8team/java | |
apt-get update | |
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections | |
apt-get -y install oracle-java8-installer | |
apt-get -y install wget unzip | |
wget http://download.netbeans.org/netbeans/8.0.2/final/zip/netbeans-8.0.2-201411181905.zip | |
mkdir -p /opt | |
unzip netbeans-8.0.2-201411181905.zip -d /opt | |
rm netbeans-8.0.2-201411181905.zip | |
mkdir -p /usr/local/share/applications | |
cat >/usr/local/share/applications/netbeans.desktop <<EOF | |
[Desktop Entry] | |
Name=NetBeans | |
Exec=/opt/netbeans/bin/netbeans | |
Terminal=false | |
Type=Application | |
EOF | |
apt-get -y install \ | |
vim-gtk \ | |
gnuplot \ | |
nedit \ | |
kile \ | |
build-essential \ | |
ddd \ | |
wmaker \ | |
wmaker-data \ | |
menu \ | |
asclock \ | |
eclipse \ | |
anjuta \ | |
audacity \ | |
blender \ | |
bluefish \ | |
dia-gnome \ | |
eric \ | |
glade-gnome \ | |
inkscape \ | |
maxima \ | |
maxima-doc \ | |
mplayer \ | |
mplayer-doc \ | |
scilab \ | |
scilab-doc \ | |
scribus \ | |
scribus-doc \ | |
subversion \ | |
subversion-tools \ | |
umbrello \ | |
wxmaxima \ | |
openssh-server \ | |
git \ | |
valgrind \ | |
gfortran \ | |
cweb-latex \ | |
clisp | |
apt-get clean | |
cat >/etc/apt/sources.list <<EOF | |
deb http://au.archive.ubuntu.com/ubuntu/ trusty main restricted multiverse universe | |
deb http://au.archive.ubuntu.com/ubuntu/ trusty-updates main restricted multiverse universe | |
deb http://security.ubuntu.com/ubuntu/ trusty-security main restricted multiverse universe | |
EOF |
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
#!/bin/bash | |
ISO=ubuntu-14.04.2-desktop-amd64.iso | |
ISOURL=http://mirror.aarnet.edu.au/pub/ubuntu/releases/14.04.2/ubuntu-14.04.2-desktop-amd64.iso | |
LABEL='Installfest 2015' | |
DESTISO=sclug-installfest-2015.iso | |
# firstly, create your ./custom.sh | |
# then, run ./run.sh | |
# mounts $ISO, mounts filesystem.squashfs, runs ./custom.sh in it | |
# rebuilds squashfs into a new iso called $DESTISO | |
checks() { | |
if [ "$UID" -ne "0" ] | |
then | |
echo " *** ERROR: Please run this as root" | |
exit 1 | |
fi | |
if [ ! -e "$ISO" ] | |
then | |
wget $ISOURL | |
fi | |
if [ ! -e "/sbin/mount.aufs" ] | |
then | |
echo " *** mount.aufs not found. installing aufs-tools..." | |
apt-get -y install aufs-tools | |
fi | |
if [ ! -e "/lib/modules/`uname -r`/kernel/ubuntu/aufs/aufs.ko" ] | |
then | |
echo " *** aufs.ko not found. installing linux-image-extra-`uname -r`..." | |
apt-get -y install linux-image-extra-`uname -r` | |
fi | |
if [ ! -e "/usr/bin/mksquashfs" ] | |
then | |
echo " *** mksquashfs not found. installing squashfs-tools..." | |
apt-get -y install squashfs-tools | |
fi | |
if [ ! -e "/usr/bin/mkisofs" ] | |
then | |
echo " *** mkisofs not found. installing genisoimage..." | |
apt-get -y install genisoimage | |
fi | |
if [ ! -e "/usr/bin/lxc-start" ] | |
then | |
echo " *** lxc-start not found. installing LXC..." | |
apt-get -y install lxc | |
fi | |
if [ -e "tmp" -o -e "work" -o -e "iso" ] | |
then | |
echo " *** ERROR: The directory 'tmp', 'work', or 'iso' exists. Please clean it." | |
exit 1 | |
fi | |
} | |
mounts() { | |
mkdir \ | |
squashfs-rw squashfs-tmp squashfs-ro \ | |
iso-rw iso-tmp iso-ro | |
mount -t iso9660 -o loop,ro $ISO iso-ro | |
mount -t tmpfs none iso-tmp | |
mount -t aufs -o br=iso-tmp:iso-ro none iso-rw | |
echo " *** ISO $ISO mounted. Now mounting squashfs..." | |
mount -t squashfs -o ro iso-ro/casper/filesystem.squashfs squashfs-ro | |
mount -t tmpfs none squashfs-tmp | |
mount -t aufs -o br=squashfs-tmp:squashfs-ro none squashfs-rw | |
echo " *** Squashfs mounted." | |
} | |
cleanup() { | |
RET=$1 | |
umount \ | |
squashfs-rw squashfs-tmp squashfs-ro \ | |
iso-rw iso-tmp iso-ro | |
echo " *** tmp directories unmounted" | |
rmdir \ | |
squashfs-rw squashfs-tmp squashfs-ro \ | |
iso-rw iso-tmp iso-ro | |
echo " *** tmp directories removed" | |
exit $RET | |
} | |
enter() { | |
cp custom.sh squashfs-rw/custom.sh | |
cp /etc/resolv.conf squashfs-rw/etc/resolv.conf | |
echo " *** Running custom.sh inside LXC..." | |
lxc-start \ | |
-n ubuntu-tweaker \ | |
-s lxc.rootfs=squashfs-rw \ | |
-s 'lxc.mount.auto=proc sys' \ | |
-s lxc.network.type=none \ | |
-F \ | |
/custom.sh | |
rm squashfs-rw/custom.sh | |
echo " *** LXC container finished!" | |
} | |
squash() { | |
rm iso-rw/casper/filesystem.squashfs | |
rm iso-rw/isolinux/boot.cat | |
mksquashfs squashfs-rw iso-rw/casper/filesystem.squashfs | |
printf $(du -sx --block-size=1 squashfs-rw | cut -f1) > iso-rw/casper/filesystem.size | |
if [ -e "$DESTISO" ] | |
then | |
echo " *** $DESTISO already exists. Moving to $DESTISO.old..." | |
mv "$DESTISO" "$DESTISO.old" | |
fi | |
mkisofs -D -r -V "$LABEL" -cache-inodes -J -l -b isolinux/isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o $DESTISO iso-rw | |
} | |
run() ( | |
set -e | |
checks | |
mounts | |
enter | |
squash | |
) | |
run | |
cleanup $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment