#!/bin/sh
# -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
# vim:fileencodings=utf-8:expandtab:tabstop=4:shiftwidth=4:softtabstop=4

set -x

OOBETASKS=/usr/share/volatile/oobetask

fullname=$(readlink -f $0)
fulldir=$(dirname $fullname)
dirname=$(basename $fulldir)

case "$dirname" in
    ('early')
        TASKS=$OOBETASKS/earlytask
        LOGFILE=/var/log/oobe-earlytask.log
        ;;
    ('late')
        TASKS=$OOBETASKS/latetask
        LOGFILE=/var/log/oobe-latetask.log
        ;;
esac

exec > $LOGFILE 2>&1

[ ! -d $TASKS ] && exit 1

echo "run oem-config/${1}_command"

ARGS="--arg=$dirname"
for _a in $@
do
    ARGS=$(echo $ARGS '--arg='$_a)
done

run-parts --report $TASKS $ARGS
