Last active
          August 29, 2015 13:56 
        
      - 
      
- 
        Save porty/9248106 to your computer and use it in GitHub Desktop. 
    Ubuntu Core Installer
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # | |
| # Ubuntu core filesystem makerer | |
| # | |
| # http://www.omappedia.com/wiki/OMAP_Ubuntu_Core | |
| # | |
| set -e | |
| TEST=1 | |
| if [ $TEST -eq 1 ]; then | |
| TMPDIR=`pwd`/tmp | |
| BOOTFS=`pwd`/boot | |
| ROOTFS=`pwd`/root | |
| mkdir -p $TMPDIR $BOOTFS $ROOTFS | |
| else | |
| TMPDIR=`mktemp -d` | |
| BOOTFS=/media/boot | |
| ROOTFS=/media/root | |
| fi | |
| UBUNAME=saucy | |
| UBUVER=13.10 | |
| die() { | |
| echo $* >&2 | |
| exit 1 | |
| } | |
| [ -d $BOOTFS ] || "Boot FS $BOOTFS doesn't exist!" | |
| [ -d $ROOTFS ] || "Root FS $ROOTFS doesn't exist!" | |
| cd $TMPDIR | |
| # | |
| echo Installing pre-reqs... | |
| # | |
| apt-get install -y u-boot-tools | |
| # | |
| echo Making the boot script... | |
| # | |
| cat > boot.script <<EOF | |
| fatload mmc 0:1 0x80000000 uImage | |
| setenv bootargs rw vram=32M fixrtc mem=1G@0x80000000 root=/dev/mmcblk0p2 console=ttyO2,115200n8 rootwait | |
| bootm 0x80000000 | |
| EOF | |
| # | |
| echo Compiling the .script file in to a usable .scr file? | |
| # | |
| mkimage -A arm -T script -C none -n "Boot Image" -d boot.script boot.scr | |
| # | |
| echo Downloading required files... | |
| # | |
| wget -c http://cdimage.ubuntu.com/ubuntu-core/releases/${UBUVER}/release/ubuntu-core-${UBUVER}-core-armhf.tar.gz | |
| wget -c http://ports.ubuntu.com/ubuntu-ports/dists/${UBUNAME}/main/installer-armhf/current/images/omap4/netboot/MLO | |
| wget -c http://ports.ubuntu.com/ubuntu-ports/dists/${UBUNAME}/main/installer-armhf/current/images/omap4/netboot/u-boot.bin | |
| wget -c http://ports.ubuntu.com/ubuntu-ports/dists/${UBUNAME}/main/installer-armhf/current/images/omap4/netboot/uImage | |
| # | |
| echo Copying boot files... | |
| # | |
| cp MLO u-boot.bin uImage boot.script boot.scr $BOOTFS/ | |
| # | |
| echo Extracting rootfs contents... | |
| # | |
| cd $ROOTFS | |
| TARFILE=$TMPDIR/ubuntu-core-${UBUVER}-core-armhf.tar.gz | |
| [ -f "$TARFILE" ] || die "I was looking for file $TARFILE but I can't find it" | |
| if which pv >/dev/null; then | |
| pv "$TARFILE" | sudo tar --numeric-owner -xz | |
| else | |
| echo "I would show progress if 'pv' was installed..." | |
| tar --numeric-owner -xzf "$TARFILE" | |
| fi | |
| echo You can probably clean up $TMPDIR if you want to | |
| # | |
| echo Enabling serial on boot... | |
| # | |
| cat > $ROOTFS/etc/init/serial-auto-detect-console.conf <<EOF | |
| # serial-auto-detect-console - starts getty on serial console | |
| # | |
| # This service starts a getty on the serial port given in the 'console' kernel argument. | |
| # | |
| start on runlevel [23] | |
| stop on runlevel [!23] | |
| respawn | |
| exec /bin/sh /bin/serial-console | |
| EOF | |
| cat > $ROOTFS/bin/serial-console <<'EOF' | |
| for arg in $(cat /proc/cmdline) | |
| do | |
| case $arg in | |
| console=*) | |
| tty=${arg#console=} | |
| tty=${tty#/dev/} | |
| case $tty in | |
| tty[a-zA-Z]* ) | |
| PORT=${tty%%,*} | |
| # check for service which do something on this port | |
| if [ -f /etc/init/$PORT.conf ];then continue;fi | |
| tmp=${tty##$PORT,} | |
| SPEED=${tmp%%n*} | |
| BITS=${tmp##${SPEED}n} | |
| # 8bit serial is default | |
| [ -z $BITS ] && BITS=8 | |
| [ 8 -eq $BITS ] && GETTY_ARGS="$GETTY_ARGS -8 " | |
| [ -z $SPEED ] && SPEED='115200,57600,38400,19200,9600' | |
| GETTY_ARGS="$GETTY_ARGS $SPEED $PORT" | |
| exec /sbin/getty $GETTY_ARGS | |
| esac | |
| esac | |
| done | |
| EOF | |
| chmod 0755 $ROOTFS/bin/serial-console | |
| # | |
| echo Blanking out the root password in $ROOTFS/etc/shadow ... | |
| # | |
| sed -i 's/root:\*:/root::/' $ROOTFS/etc/shadow | |
| # | |
| echo Setting up networking in $ROOTFS/etc/network/interfaces.d ... | |
| # | |
| cat > $ROOTFS/etc/network/interfaces.d/eth0-dhcp <<EOF | |
| auto eth0 | |
| iface eth0 inet dhcp | |
| EOF | |
| # | |
| echo Flushing buffers... | |
| # | |
| sync | |
| echo Done | 
http://qt-project.org/wiki/TIPandaBoard
Fucking serial isn't working - firmware/kernel/getty is all displayed, I just can't fucking log in!
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Card needs to be partitioned, formatted and mounted before this is run:
fdisk /dev/sdX # ... mount /dev/sdX1 boot mount /dev/sdX2 root wget -o installer.sh https://gist.githubusercontent.com/porty/9248106/raw chmod +x installer.sh ./installer.sh umount /dev/sdX1 /dev/sdX2 eject /dev/sdX