#!/bin/bash

# unmount mounted devices
if [ -e "/opt/bin/usb-mount.sh" ]; then
  for mount in `ls /media`; do
    dev=`echo $mount | cut -f2 -d-`

    if [ "$dev" != "" ]; then
      /opt/bin/usb-mount.sh remove $dev
    fi
  done
fi

/sbin/shutdown -h now "Power button pressed"

