#!/bin/bash EXTMEDIA=`ls -la /mnt/*` MMC0=`ls /dev | grep mmcblk0 | wc | awk '{print $1}'` MMC1=`ls /dev | grep mmcblk1 | wc | awk '{print $1}'` USB=`ls /dev | grep sd | wc | awk '{print $1}'` function warn() { echo "######################################################" echo "" echo "" echo "WARNING external SD-card or hard-disk NOT detected" echo "Please insert SD-card or connect your external hard" echo "disk before running bootsrap-xo" echo "" echo "" echo "#####################################################" echo "" read -p "Press [Enter] key to shutdown" echo "" echo "" echo "shutting down in 5 seconds" sleep 5 shutdown now exit 1 } function unsupported() { echo "#####################################################" echo "" echo "" echo "WARNING detected external media partition layout is" echo "unsuppoted. Please try a different SD-card or usbkey" echo "" echo "" echo "#####################################################" echo "" read -p "Press [Enter] key to shutdown" echo "" echo "" echo "shutting down in 5 seconds" sleep 5 shutdown now exit 1 } function library_1st() { echo "#####################################################" echo "" echo "" echo "WARNING detected 2 USB storage units. In order to" echo "protect the data on the one that will not become a" echo "permanent part of the XS server, please ensure the" echo "premanent drive is inserted in a slot when turning." echo "on your XO. Please insert the usb drive containing" echo "the XSCE installaton media before typing 'bootstrap-xo'" echo "" echo "" echo "#####################################################" echo "" echo "" read -p "Press [Enter] key to shutdown" echo "" echo "" echo "shutting down in 5 seconds" sleep 5 shutdown now exit 1 } function get_devices() { FOUNDDEVS= BLKID=`blkid | awk '{split($0,a,":"); print a[1]}'` for blk in $BLKID; do FOUNDDEVS="$FOUNDDEVS $blk" done } function get_root_device() { ROOTDEV= BLKID=`blkid | awk '{split($0,a,":"); print a[1]}'` for blk in $BLKID; do ROOTDEV=`echo $blk | grep root` done } function find_repo() { MNT=`mount | grep dev/sdb | awk '{print $3}'` if ! [ -d $MNT/xs-repo ]; then library_1st fi } function togglepart() { cat <> /etc/fstab echo "mounting $uuid at $MEDIAMNT" mount -a if ! [ -d $MEDIAMNT/swap ]; then mkdir $MEDIAMNT/swap fi echo "creating swap.img" dd if=/dev/zero of=$MEDIAMNT/swap/swap.img bs=1024 count=10480 mkswap $MEDIAMNT/swap/swap.img chown root:root $MEDIAMNT/swap/swap.img echo "$MEDIAMNT/swap/swap.img swap swap defaults 0 0" >> /etc/fstab swapon $MEDIAMNT/swap/swap.img exit 0