Скрипт ubuntu-iso-customization.sh предназначен для кастомизации Ubuntu LiveCD. Включает в себя:
#!/bin/bash # get configuration from the file [ -n "$1" ] && [ -f "$1" ] && source "$1" || exit 1 # prepare trap "exit 1" INT ISOMNTDIR=$LIVEDIR/mnt EXTRACTDIR=$LIVEDIR/extract-cd EDITDIR=$LIVEDIR/edit ENV_KEEP="http_proxy https_proxy ftp_proxy" sudo aptitude install -y squashfs-tools genisoimage || exit 1 # mount livecd mkdir $LIVEDIR && cd $LIVEDIR || exit 1 mkdir $ISOMNTDIR || exit 1 sudo mount -o loop $ISODIR/ubuntu-${VERSION}.iso $ISOMNTDIR || exit 1 # extract squashfs mkdir $EXTRACTDIR || exit 1 rsync --exclude=/casper/filesystem.squashfs -a $ISOMNTDIR/ $EXTRACTDIR sudo unsquashfs $ISOMNTDIR/casper/filesystem.squashfs || exit 1 sudo mv squashfs-root $EDITDIR # umount livecd sudo umount $ISOMNTDIR # copy resolv.conf sudo cp /etc/resolv.conf $EDITDIR/etc/ # mount dev sudo mount --bind /dev/ $EDITDIR/dev # configure new live cd [ -n "$PROXY" ] && echo -en "$PROXY" | sudo tee -a $EDITDIR/etc/environment && \ echo -e "\nDefaults env_keep = \"$ENV_KEEP\"" | sudo tee -a $EDITDIR/etc/sudoers [ -n "$TIMEZONE" ] && echo "TZ=$TIMEZONE" | sudo tee -a $EDITDIR/etc/environment # create customization script and run it in chroot cat > $EDITDIR/tmp/customize.sh << EOF #!/bin/bash # mount proc, sysfs, devpts mount -t proc none /proc mount -t sysfs none /sys mount -t devpts none /dev/pts # prepare choot export HOME=/root export LC_ALL=en_US.UTF-8 dpkg-divert --local --rename --add /sbin/initctl ln -s /bin/true /sbin/initctl # install packages ( which software-properties-gtk && software-properties-gtk -e universe && software-properties-gtk -e multiverse ) || \ ( which software-properties-kde && software-properties-kde -e universe && software-properties-kde -e multiverse ) || \ sudoedit /etc/apt/sources.list aptitude update [ "$UPTODATE" -eq "1" ] && DEBIAN_FRONTEND=noninteractive aptitude full-upgrade -y aptitude install -Ry $PACKAGES # clean aptitude clean rm -rf /tmp/* ~/.bash_history rm /etc/resolv.conf rm /sbin/initctl dpkg-divert --rename --remove /sbin/initctl # umount proc, sysfs, devpts umount /proc umount /sys umount /dev/pts # exit from chroot exit EOF # make customization script executable chmod +x $EDITDIR/tmp/customize.sh # chroot and run customization script sudo chroot $EDITDIR su -lc /tmp/customize.sh # umount dev sudo umount $EDITDIR/dev # regenerate manifest chmod +w $EXTRACTDIR/casper/filesystem.manifest sudo chroot $EDITDIR dpkg-query -W --showformat='${Package} ${Version}\n' > $EXTRACTDIR/casper/filesystem.manifest sudo cp $EXTRACTDIR/casper/filesystem.manifest $EXTRACTDIR/casper/filesystem.manifest-desktop sudo sed -i '/ubiquity/d' $EXTRACTDIR/casper/filesystem.manifest-desktop sudo sed -i '/casper/d' $EXTRACTDIR/casper/filesystem.manifest-desktop # compress filesystem [ -f $EXTRACTDIR/casper/filesystem.squashfs ] && \ sudo rm $EXTRACTDIR/casper/filesystem.squashs sudo mksquashfs $EDITDIR $EXTRACTDIR/casper/filesystem.squashfs # set an image name in $EXTRACTDIR/README.diskdefines sudo sed -ri "s/(#define DISKNAME .*)/\1 $RELEASE_NAME/" $EXTRACTDIR/README.diskdefines # remove old md5sum.txt and calculate new md5 sums cd $EXTRACTDIR sudo rm md5sum.txt find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt # create iso sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b \ isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -boot-info-table -o \ "../ubuntu-$VERSION-$RELEASE_NAME-$(date +%F).iso" .
VERSION=10.04-desktop-i386 # Ubuntu LiveCD version RELEASE_NAME=MYTOOLSDISK # Name of the Custom release ISODIR=/mnt/iso # Path to original ISO LIVEDIR=/mnt/live # Directory for building # Packages that have to be installed PACKAGES="mc htop testdisk chntpw" # Whether "aptitude full-upgrade" have to be done UPTODATE=0 # (optional) Time Zone TIMEZONE="Europe/Moscow" # (optional) Proxy server configuration PROXY="\ http_proxy=http://172.18.0.1:3128\n\ ftp_proxy=http://172.18.0.1:3128\n\ "
Тема на Хабре: http://habrahabr.ru/blogs/ubuntu/93095/
Проверено в Ubuntu 10.04 Desktop i386