#!/bin/sh

# Configures a full development system (or a system preconfigured using
# jffs2-configure is also ok) to be used to generate the installimage.

# Turn of some services started by /etc/rc
for i in ssh hostapd inetd aumix gpsd pcmcia ;
do
        update-rc.d -f ${i} remove
done

# De-activate Xwindows and SSH
rm -f /etc/rc?.d/S*xads.sh
rm -f /etc/rc?.d/S*ssh

if [ "$(dpkg --print-architecture)" = arm ]; then
	# Run cardmgr from inittab instead of /etc/rc
	# (recall pcmcia was turned off above)
	# (armel doesn't use pcmcia-cs)
	{
	echo '/^#cm:23/s/^#//'
	echo 'x'
	} | ex - /etc/inittab
fi

if [ -f /usr/bin/w ]; then
        mv /usr/bin/w /usr/bin/w.orig
        {
        echo '#!/bin/sh'
        echo 'uptime'
        echo 'who'
        } > /usr/bin/w
        chmod a+x /usr/bin/w
fi

# Typical embedded system tricks
rm -rf /var/tmp
ln -s /tmp /var/tmp
ln -sf /proc/mounts /etc/mtab

# Use busybox utilities instead of the Debian ones.
busybox-links enable

echo "System is configured for use as installimage."
echo "Use adsrootbuilder -c ads-installimage.conf to create the installimage."
