#!/bin/sh export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/installer export PATH=$PATH:util/ MUSICPID="" cleanup() { echo Installer cleaning up... if [ ! -z "$MUSICPID" ]; then echo "killing music ($MUSICPID)" kill %1 fi gzip -d -c fb.snap.gz > $FBDEVICE && rm fb.snap.gz if [ -x util/xrefresh ]; then util/xrefresh 2>/dev/null ; fi rm -rf /tmp/util rm -rf /tmp/pics rm -rf /tmp/sound exit 1 } get_file() { if [ -x util/led ]; then util/led 1 0 1 1 ; fi FNAME=`basename $1` echo -n "Getting $FNAME ..." wget --quiet http://intimate.handhelds.org/installer/$1 if [ $? -ne 0 ]; then echo "Failed to wget $FNAME" return 1 fi echo -n "Checking the md5sum... " wget --quiet http://intimate.handhelds.org/installer/$1.md5sum if [ $? -ne 0 ]; then echo "Failed to wget the md5sum" if [ -x util/led ]; then util/led 0 0 1 1 ; fi return 1 fi VALIDMD5SUM=`cat ${FNAME}.md5sum` OURMD5SUM=`md5sum $FNAME` if [ "$OURMD5SUM" != "$VALIDMD5SUM" ]; then echo "BAD... " rm $FNAME ${FNAME}.md5sum if [ -x util/led ]; then util/led 0 0 1 1 ; fi return 1 else echo -n "OK... " rm ${FNAME}.md5sum mkdir -p `dirname $1` odir=`pwd` cd `dirname $1` tar zxf ${odir}/${FNAME} 2>/dev/null rm ${odir}/${FNAME} cd ${odir} if [ -x util/led ]; then util/led 0 0 1 1 ; fi return 0 fi return 0 } trap cleanup INT TERM cd /tmp echo #Check the MD5sum for the isntaller echo -n "Checking the md5sum for the installer... " wget --quiet http://intimate.handhelds.org/installer/beta-installer.md5sum if [ $? -ne 0 ]; then echo "Failed to wget the md5sum... exiting" exit 1 fi VALIDMD5SUM=`cat beta-installer.md5sum` OURMD5SUM=`md5sum $0` if [ "$OURMD5SUM" != "$VALIDMD5SUM" ]; then echo "Bad... exiting." rm beta-installer.md5sum exit 1 else echo "OK.. proceeding with install" rm beta-installer.md5sum fi # Save a copy of the framebuffer if [ -b /dev/mtdblock/0 ] ; then BOOTBLOCK="/dev/mtdblock/0" ; else BOOTBLOCK="/dev/mtdblock0" ; fi if [ -b /dev/mtdblock/1 ] ; then PARAMSBLOCK="/dev/mtdblock/1" ; else PARAMSBLOCK="/dev/mtdblock1" ; fi if [ -e /dev/fb/0 ] ; then FBDEVICE="/dev/fb/0" ; else FBDEVICE="/dev/fb0" ; fi gzip > fb.snap.gz < $FBDEVICE # Display first picture here.. get_file util/installerfiles.tgz && util/lcd 1 && get_file pics/install_0.pnm.tgz && util/pnmtofb pics/install_0.pnm >/dev/null 2>&1 && util/lcd 0 && rm pics/*pnm echo # set the date echo -n "Setting time with ntpdate..." util/ntpdate -b ntp2.ja.net echo "Done." echo #Ask about music MUSIC="" while [ "$MUSIC" != "y" ] && [ "$MUSIC" != "n" ]; do read -p "Would you like music during the install [Y/n]? " MUSIC if [ "$MUSIC" = "" ]; then MUSIC="y" ; fi done if [ "$MUSIC" = "y" ] && get_file sound/player.tgz; then ./sound/music & MUSICPID=$! echo $MUSICPID fi #Ask about fdisk echo echo echo "The intimate installer expects /dev/hda1 to be the install partition, and /dev/hda2 to be a swap partition. If your partitions are not correctly configured then the boot procedure for intimate will fail, and you will have to manually configure your linuxrc and fstab." echo RUNFDISK="" while [ "$RUNFDISK" != "y" ] && [ "$RUNFDISK" != "n" ]; do read -p "Would you like run FDISK to partition your drive? [y/N]? " RUNFDISK if [ "$RUNFDISK" = "" ]; then RUNFDISK="n" ; fi done if [ "$RUNFDISK" = "y" ]; then get_file util/fdisk.tgz && util/fdisk /dev/hda && rm util/fdisk fi echo echo echo "The intimate boot process assumes that you will be using a reiserfs filesystem. If you are not, then you will have to manually configure your linuxrc and fstab." echo #Ask about mkreiserfs MAKEFILESYSTEM="" while [ "$MAKEFILESYSTEM" != "y" ] && [ "$MAKEFILESYSTEM" != "n" ]; do read -p "Would you like to perform mkreiserfs on /dev/hda1? [Y/n]? " MAKEFILESYSTEM if [ "$MAKEFILESYSTEM" = "" ]; then MAKEFILESYSTEM="y" ; fi done if [ "$MAKEFILESYSTEM" = "y" ]; then get_file util/mkreiserfs.tgz && util/mkreiserfs /dev/hda1 && rm util/mkreiserfs fi #Ask about mkswap echo echo echo "The fstab used on the intimate base images assume that /dev/hda2 will be a swap partition." echo "The system should boot, even if swap is not correctly configured." echo MAKESWAP="" while [ "$MAKESWAP" != "y" ] && [ "$MAKESWAP" != "n" ]; do read -p "Would you like to perform mkswap on /dev/hda2? [y/n]? " MAKESWAP done if [ "$MAKESWAP" = "y" ]; then get_file util/mkswap.tgz && util/mkswap /dev/hda2 && rm util/mkswap fi # Install the reiserfs-module.. echo echo echo "Now it's time to install the reiserfs module." echo "You'll want to do this unless you've already got it installed." echo INSTALLREISERFS="" while [ "$INSTALLREISERFS" != "y" ] && [ "$INSTALLREISERFS" != "n" ]; do read -p "Would you like install the reiserfs module? [y/n]? " INSTALLREISERFS done if [ "$INSTALLREISERFS" = "y" ]; then get_file pics/install_1.pnm.tgz util/pnmtofb pics/install_1.pnm >/dev/null 2>&1 && rm pics/*pnm wget -q http://intimate.handhelds.org/installer/reiserfs-module_2.4.3-rmk2-np1-arm.ipk && ipkg install ./reiserfs-module_2.4.3-rmk2-np1-arm.ipk && rm reiserfs-module_2.4.3-rmk2-np1-arm.ipk fi #mount the drive echo echo echo "OK.. going to mount the microdrive on /mnt/hda1..." echo "Again.. if it's already mounted, you needn't do this bit..." echo MOUNTUDRIVE="" while [ "$MOUNTUDRIVE" != "y" ] && [ "$MOUNTUDRIVE" != "n" ]; do read -p "Would you like to mount /dev/hda1 on /mnt/hda1? [y/n]? " MOUNTUDRIVE done if [ "$MOUNTUDRIVE" = "y" ]; then mkdir -p /mnt/hda1 mount -t reiserfs /dev/hda1 /mnt/hda1 fi #rsync the image.. echo echo echo "Excellent.. now we're made it through to the long hard slog... " echo "It's time to rsync the microdrive with the release distro server..." echo "It's a big download.. I wouldn't fancy doing this on a modem... " echo RSYNCDRIVE="" while [ "$RSYNCDRIVE" != "y" ] && [ "$RSYNCDRIVE" != "n" ]; do read -p "Would you like to rsync /mnt/hda1 with the release server? [Y/n]? " RSYNCDRIVE if [ "$RSYNCDRIVE" = "" ]; then RSYNCDRIVE="y" ; fi done if [ "$RSYNCDRIVE" = "y" ]; then get_file pics/install_4.pnm.tgz util/pnmtofb pics/install_4.pnm > /dev/null 2>&1 && rm pics/*pnm get_file util/rsync.tgz && util/led 1 0 1 1 ; util/rsync -zcurvpl --progress intimate.handhelds.org::intimate-beta /mnt/hda1 && util/led 0 0 1 1 ; rm util/rsync echo ; echo "Phew... rsync complete :)" fi #Install the debian packages we want/need echo echo echo "OK.. now we're going to configure our base, update our package list, and" echo "install a few packages..." echo POSTINST="" while [ "$POSTINST" != "y" ] && [ "$POSTINST" != "n" ]; do read -p "Would you like to install .debs ? [Y/n]? " POSTINST if [ "$POSTINST" = "" ]; then POSTINST="y" ; fi done if [ "$POSTINST" = "y" ]; then mount -t devfs devfs /mnt/hda1/dev #Copy the resolv.conf from familiar echo "Snarfing /etc/resolv.conf from familiar" cp /etc/resolv.conf /mnt/hda1/etc/resolv.conf # Generate some network settings. IFACE=`netstat -nr | grep ^0.0.0.0 | util/awk {'print $8'}` if [ $IFACE != "ppp0" ] ; then DEFGW=`netstat -nr | grep ^0.0.0.0 | util/awk {'print $2'}` ADDR=`ifconfig $IFACE | grep "inet addr" | util/awk {'print $2'} | util/awk -F : {'print $2'}` MASK=`ifconfig $IFACE | grep Mask | util/awk {'print $NF'} | util/awk -F : {'print $2'}` NETWORK=`netstat -nr | grep $IFACE$ | grep $MASK | util/awk {'print $1'}` BROADCAST=`ifconfig $IFACE | grep Bcast: | util/awk {'print $3'} | util/awk -F : {'print $2'}` echo echo echo "# Network settings autodetected by the intimate install process" echo "auto $IFACE" echo "iface $IFACE inet static" echo " address $ADDR" echo " netmask $MASK" echo " network $NETWORK" if [ $BROADCAST ] ; then echo " broadcast $BROADCAST" fi echo " gateway $DEFGW" CONFIGNET="" while [ "$CONFIGNET" != "y" ] && [ "$CONFIGNET" != "n" ]; do read -p "Add the above to /etc/network/interfaces in intimate? [Y/n]" CONFIGNET if [ "$CONFIGNET" = "" ]; then CONFIGNET="y" ; fi done if [ "$CONFIGNET" = "y" ] ; then echo >> /mnt/hda1/etc/network/interfaces echo "# Network settings autodetected by the intimate install process" >>/mnt/hda1/etc/network/interfaces echo "auto $IFACE" >> /mnt/hda1/etc/network/interfaces echo "iface $IFACE inet static" >> /mnt/hda1/etc/network/interfaces echo " address $ADDR" >> /mnt/hda1/etc/network/interfaces echo " netmask $MASK" >> /mnt/hda1/etc/network/interfaces echo " network $NETWORK" >> /mnt/hda1/etc/network/interfaces if [ $BROADCAST ] ; then echo " broadcast $BROADCAST" >> /mnt/hda1/etc/network/interfaces fi echo " gateway $DEFGW" >> /mnt/hda1/etc/network/interfaces fi fi # Set the timezone within intimate /mnt/hda1/usr/sbin/chroot /mnt/hda1/ tzconfig #Copy the lib/modules/ from familiar echo echo "copying /lib/modules/" cp -av /lib/modules/* /mnt/hda1/lib/modules/ # Get the latest package lists echo echo "Getting the latest package lists..." /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get update # # Bring the base image bang up to date # echo # echo "Bringing the base image bang up to date..." # /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get dist-upgrade # rm /mnt/hda1/var/cache/apt/archives/*.deb # Install the menu package.. - Kludge - 2 broken packages later on. /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get install menu rm /mnt/hda1/var/cache/apt/archives/*.deb # Install the tools for compiling kernels. echo echo "Installing the tools for compiling kernels..." /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get install libncurses5-dev gcc gcc-2.95 make cpp cpp-2.95 binutils libc6-dev rm /mnt/hda1/var/cache/apt/archives/*.deb # Install extra command line tools echo echo "Installing extra command line tools..." /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get install strace less ncftp ssh2 wget file ntpdate bzip2 rm /mnt/hda1/var/cache/apt/archives/*.deb # Install the X system. echo echo "Installing the X system...." /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get install xserver-tiny-h3600 blackbox-ipaq cpu-scale xfonts-scalable-nonfree rxvt xstroke xcalibrate xvkbd rm /mnt/hda1/var/cache/apt/archives/*.deb # Install some apps. echo echo "Installing some X apps..." /mnt/hda1/usr/sbin/chroot /mnt/hda1/ apt-get install wmsmixer wmrecord wmmp3 wmapm bubblemon gtktetris mingle rm /mnt/hda1/var/cache/apt/archives/*.deb #Finished installing .debs echo echo "Finished installing .debs... " fi #Install intimateboot and set params.. echo echo echo "OK.. onto the final stage.." echo "This is where we install the intimateboot package and set your bootparams correctly" echo INTIMATEBOOT="" while [ "$INTIMATEBOOT" != "y" ] && [ "$INTIMATEBOOT" != "n" ]; do read -p "Would you like to install the intimateboot package? [y/n]? " INTIMATEBOOT done if [ "$INTIMATEBOOT" = "y" ]; then #Display the intimateboot splashscreen get_file pics/install_2.pnm.tgz util/pnmtofb pics/install_2.pnm >/dev/null 2>&1 && rm pics/*pnm get_file util/ipaqbb.tgz && wget -q http://intimate.handhelds.org/installer/intimateboot_0.2-2_arm.ipk && ipkg install ./intimateboot_0.2-2_arm.ipk rm intimateboot_0.2-2_arm.ipk fi echo echo "All done.. shutting down installer" cleanup