#!/bin/sh

fetch() {

for tok in $(cat /proc/cmdline)
do
    export $tok
done

PASS=$(cat /tmp/passwd)

if curl -k --header "X-Auth-Token: $token" $url?key=$PASS; then
    echo "Notify baremetal-agent successfully"
else
    echo "Fail to notify baremetal-agent, reset root password to default"
    PASS=mosbaremetal

    passwd root << EOF
$PASS
$PASS
EOF

fi
}

case "$1" in
    start)
        fetch
        ;;
    stop|restart|reload)
        ;;
    *)
        echo "Usage: $0 {start}"
        exit 1
esac

exit $?
