#!/bin/sh
### BEGIN INIT INFO
# Provides:          apply_noobs_os_config
# Required-Start:
# Required-Stop:
# Default-Start: 2
# Default-Stop:
# Short-Description: Apply config from /boot/os_config.json
# Description:
### END INIT INFO

. /lib/lsb/init-functions

set -e

case "$1" in
  start)
    log_daemon_msg "Applying config from /boot/os_config.json (if it exists)"
    if raspi-config --apply-os-config; then
      update-rc.d apply_noobs_os_config remove
      rm /etc/init.d/apply_noobs_os_config
      log_end_msg 0
    else
      log_end_msg 1
    fi
    ;;
  *)
    echo "Usage: $0 start" >&2
    exit 3
    ;;
esac
