%post CREATE_USERNAME=liveuser # FIXME: this script should go away unless we are going to support read-only media cat > /etc/rc.d/init.d/livesys << EOF #!/bin/bash # # live: Init script for live image # # chkconfig: 345 00 99 # description: Init script for live image. . /etc/init.d/functions if ! strstr "\`cat /proc/cmdline\`" liveimg || [ "\$1" != "start" ]; then exit 0 fi if [ -e /.liveimg-configured ] ; then configdone=1 fi exists() { which \$1 >/dev/null 2>&1 || return \$* } touch /.liveimg-configured # mount live image if [ -b \`readlink -f /dev/live\` ]; then mkdir -p /mnt/live mount -o ro /dev/live /mnt/live 2>/dev/null || mount /dev/live /mnt/live fi livedir="LiveOS" for arg in \`cat /proc/cmdline\` ; do if [ "\${arg##live_dir=}" != "\${arg}" ]; then livedir=\${arg##live_dir=} return fi done # enable swaps unless requested otherwise swaps=\`blkid -t TYPE=swap -o device\` if ! strstr "\`cat /proc/cmdline\`" noswap && [ -n "\$swaps" ] ; then for s in \$swaps ; do action "Enabling swap partition \$s" swapon \$s done fi if ! strstr "\`cat /proc/cmdline\`" noswap && [ -f /mnt/live/\${livedir}/swap.img ] ; then action "Enabling swap file" swapon /mnt/live/\${livedir}/swap.img fi mountPersistentHome() { # support label/uuid if [ "\${homedev##LABEL=}" != "\${homedev}" -o "\${homedev##UUID=}" != "\${homedev}" ]; then homedev=\`/sbin/blkid -o device -t "\$homedev"\` fi # if we're given a file rather than a blockdev, loopback it if [ "\${homedev##mtd}" != "\${homedev}" ]; then # mtd devs don't have a block device but get magic-mounted with -t jffs2 mountopts="-t jffs2" elif [ ! -b "\$homedev" ]; then loopdev=\`losetup -f\` if [ "\${homedev##/mnt/live}" != "\${homedev}" ]; then action "Remounting live store r/w" mount -o remount,rw /mnt/live fi losetup \$loopdev \$homedev homedev=\$loopdev fi # if it's encrypted, we need to unlock it if [ "\$(/lib/udev/vol_id -t \$homedev 2>/dev/null)" = "crypto_LUKS" ]; then echo echo "Setting up encrypted /home device" plymouth ask-for-password --command="cryptsetup luksOpen \$homedev EncHome" homedev=/dev/mapper/EncHome fi # and finally do the mount mount \$mountopts \$homedev /home # if we have /home under what's passed for persistent home, then # we should make that the real /home. useful for mtd device on $CREATE_USERNAME if [ -d /home/home ]; then mount --bind /home/home /home ; fi [ -x /sbin/restorecon ] && /sbin/restorecon /home if [ -d /home/$CREATE_USERNAME ]; then USERADDARGS="-M" ; fi } findPersistentHome() { for arg in \`cat /proc/cmdline\` ; do if [ "\${arg##persistenthome=}" != "\${arg}" ]; then homedev=\${arg##persistenthome=} return fi done } if strstr "\`cat /proc/cmdline\`" persistenthome= ; then findPersistentHome elif [ -e /mnt/live/\${livedir}/home.img ]; then homedev=/mnt/live/\${livedir}/home.img fi # if we have a persistent /home, then we want to go ahead and mount it if ! strstr "\`cat /proc/cmdline\`" nopersistenthome && [ -n "\$homedev" ] ; then action "Mounting persistent /home" mountPersistentHome fi # make it so that we don't do writing to the overlay for things which # are just tmpdirs/caches mount -t tmpfs -o mode=0755 varcacheyum /var/cache/yum mount -t tmpfs tmp /tmp mount -t tmpfs vartmp /var/tmp [ -x /sbin/restorecon ] && /sbin/restorecon /var/cache/yum /tmp /var/tmp >/dev/null 2>&1 if [ -n "\$configdone" ]; then exit 0 fi # BEGIN set up auto-login cat >> /etc/gdm/custom.conf << FOE [daemon] AutomaticLoginEnable=true AutomaticLogin=$CREATE_USERNAME FOE EOF # workaround hal starting late cat > /etc/rc.d/init.d/livesys-late << EOF #!/bin/bash # # live: Late init script for live image # # chkconfig: 345 99 01 # description: Late init script for live image. . /etc/init.d/functions if ! strstr "\`cat /proc/cmdline\`" liveimg || [ "\$1" != "start" ] || [ -e /.liveimg-late-configured ] ; then exit 0 fi exists() { which \$1 >/dev/null 2>&1 || return \$* } touch /.liveimg-late-configured # read some variables out of /proc/cmdline for o in \`cat /proc/cmdline\` ; do case \$o in ks=*) ks="\${o#ks=}" ;; xdriver=*) xdriver="--set-driver=\${o#xdriver=}" ;; esac done # if liveinst or textinst is given, start anaconda if strstr "\`cat /proc/cmdline\`" liveinst ; then plymouth --quit /usr/sbin/liveinst \$ks fi if strstr "\`cat /proc/cmdline\`" textinst ; then plymouth --quit /usr/sbin/liveinst --text \$ks fi # configure X, allowing user to override xdriver if [ -n "\$xdriver" ]; then exists system-config-display --noui --reconfig --set-depth=24 \$xdriver fi EOF chmod 755 /etc/rc.d/init.d/livesys [ -x /sbin/restorecon ] && /sbin/restorecon /etc/rc.d/init.d/livesys /sbin/chkconfig --add livesys chmod 755 /etc/rc.d/init.d/livesys-late [ -x /sbin/restorecon ] && /sbin/restorecon /etc/rc.d/init.d/livesys-late /sbin/chkconfig --add livesys-late ################## # BEGIN avoid livesys script at every boot touch /.liveimg-configured # put /tmp on tmpfs # FIXME: should be unnecessary cat >> /etc/fstab <> /etc/sudoers # don't do packagekit checking by default # FIXME: check whether this is still useful - mtd 20090907 gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t string /apps/gnome-packagekit/frequency_get_updates never >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t string /apps/gnome-packagekit/frequency_get_upgrades never >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t string /apps/gnome-packagekit/frequency_refresh_cache never >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/notify_available false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/notify_distro_upgrades false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/enable_check_firmware false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/enable_check_hardware false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/enable_codec_helper false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/enable_font_helper false >/dev/null gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-packagekit/enable_mime_type_helper false >/dev/null # Stopgap fix for RH #217966; should be fixed in HAL instead touch /media/.hal-mtab # make sure the fonts are not too big in Sugar # FIXME: remove when http://dev.laptop.org/ticket/9331 is fixed echo "Xft.dpi: 150" > /home/$CREATE_USERNAME/.Xresources chown $CREATE_USERNAME:$CREATE_USERNAME /home/$CREATE_USERNAME/.Xresources # make sure the fonts are not too big in GNOME # FIXME: remove when http://dev.laptop.org/ticket/9331 is fixed gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t float /desktop/gnome/font_rendering/dpi 150 >/dev/null # install activities BUNDLES_DIR=/usr/share/sugar/bundles ACTIVITIES_DIR=/home/$CREATE_USERNAME/Activities chown -R $CREATE_USERNAME:$CREATE_USERNAME $BUNDLES_DIR mkdir /home/$CREATE_USERNAME/Activities chown -R $CREATE_USERNAME:$CREATE_USERNAME $ACTIVITIES_DIR cd $BUNDLES_DIR for file in *.xo; do su $CREATE_USERNAME -c "./install-activity.py $file" done rm -f install-activity.py # change bug report page in browse sed -i -e 's/dev.sugarlabs.org/launchpad.net\/soas/' /home/$CREATE_USERNAME/Activities/Browse.activity/data/index.html # and do so for the e-book page too sed -i -e 's/schoolserver\//wiki.sugarlabs.org\/go\/Sugar_on_a_Stick\/E-Books/' /home/$CREATE_USERNAME/Activities/Browse.activity/data/index.html sed -i -e 's/school/books/' /home/$CREATE_USERNAME/Activities/Browse.activity/data/index.html # execute sample content script and clean up afterwards su $CREATE_USERNAME -c ./copy-to-datastore.py rm -f *.pdf copy-to-datastore.py # END avoid livesys scripts at every boot ################## ################## # BEGIN set sugar scaling # FIXME: this needs an upstream bug SCALING_FILE=/etc/X11/xinit/xinitrc.d/70-sugar-scaling.sh cat >> $SCALING_FILE < # # All rights reserved. This copyrighted material is made available to anyone # wishing to use, modify, copy, or redistribute it subject to the terms and # conditions of the GNU General Public License version 2 or later. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Thanks to Chris Ball for the XO-detection logic if [ -z "\$SUGAR_SCALING" ]; then DMI_PATH=/sys/clas/dmi/id/product_name OFW_PATH=/ofw/mfg-data/MN IS_XO=\$( ( [ -e \$DMI_PATH ] && cat \$DMI_PATH ) || ( [ -e \$OFW_PATH ] && cut -c -2 < \$OFW_PATH ) ) export SUGAR_SCALING=72 if [ "\$IS_XO" = "XO" ]; then SUGAR_SCALING=100 fi fi FOE chmod 755 $SCALING_FILE # END set sugar scaling ################## ################## # BEGIN make sugar default cat > /home/$CREATE_USERNAME/.dmrc <> /etc/gdm/custom.conf << FOE [daemon] AutomaticLoginEnable=true AutomaticLogin=$CREATE_USERNAME FOE # END set up auto-login ################## ################## # BEGIN setup services for service in auditd cpuspeed dnsmasq firstboot iptables ip6tables mdmonitor netfs network nscd ; do /sbin/chkconfig --level 2345 $service off done for service in avahi-daemon sshd ; do /sbin/chkconfig --level 2345 $service on done # something triggers prompting, so just turn it off with a big hammer sed -i -e 's/PROMPT=yes/PROMPT=no/;' /etc/sysconfig/init # END setup services ################## %end