#!/bin/sh
#
# Start pstore-clean
#
# NOTE: recovery system writes console messages
# to the pstore, so we have to clean them before quasar
# starts and sends them.
#

case "$1" in
start)
  echo "Starting pstore-clean"
  reboot_reason=`cat /sys/class/aml_info/reboot_reason`
  echo "pstore-clean: Reboot reason: $reboot_reason"
  if [ "$reboot_reason" = "normal" ]; then
    pstore_files=`ls /sys/fs/pstore`
    rm -r /sys/fs/pstore/*
    echo "pstore-clean: cleaned: $pstore_files"
  else
    echo "pstore-clean: no reason to clean"
  fi
  ;;
stop)
  echo "Stopping pstore-clean"
  ;;
restart)
  "$0" stop
  "$0" start
  ;;
*)
  echo "Usage: $0 {start|stop|restart}"
  exit 1
esac
