#!/bin/sh
set -e

PREREQS=""
case $1 in
    prereqs) echo "${PREREQS}"; exit 0;;
esac

. /scripts/functions

# Parse command-line arguments for mobile-specific ones
for x in $(cat /proc/cmdline); do
    case $x in
        mobile.ro)
            # Android bootloaders might append "ro" or "rw" after our own
            # command-line, this makes sure we can force one of those
            # regardless of what the bootloader does
            REALRO=y
            ;;
        mobile.rw)
            REALRO=n
            ;;
        mobile.root=*)
            REALROOT=${x#mobile.root=}
            ;;
    esac
done

if [ -n "${REALROOT}" ]; then
    log_success_msg "Changing ROOT to ${REALROOT}"
    echo "ROOT=${REALROOT}" >> /conf/param.conf
    echo "MOBILE_ROOT=y" >> /conf/param.conf
fi

if [ -n "${REALRO}" ]; then
    echo "readonly=${REALRO}" >> /conf/param.conf
fi
