#!/bin/sh

update() {
  if [ -f /home/system.tgz ]; then
    echo -- Update system --
    cd / || return

    if ( gunzip -c /home/system.tgz | tar -x ); then
      echo Unpacked
    fi

    rm /home/system.tgz
    reboot
  fi
}

case "$1" in
  start)
    update
  ;;
  stop)
  ;;
  *)
    echo "Do or do not. There is no try"
    exit 1
  ;;
esac
