#!/bin/sh /etc/rc.common
# Copyright (C) 2017 Onion Corporation
START=99

USE_PROCD=1

BIN="/usr/bin/ort"
FILE1="/usr/bin/js/mcu.js"
FILE2="/usr/bin/js/weather.js"
FILE3="/usr/bin/js/timer.js"
FILE4="/usr/bin/js/audio.js"
FILE5="/usr/bin/js/music.js"
FILE6="/usr/bin/js/system.js"
FILE7="/usr/bin/js/calendar.js"

start_service_function () {
        procd_open_instance
        procd_set_param command "$1"
        procd_append_param command "$2"
        procd_set_param respawn
        procd_set_param stdout 1 # forward stdout of the command to logd
        procd_set_param stderr 1 # same for stderr
        procd_close_instance
}

start_service() {
        start_service_function "$BIN" "$FILE1"
        start_service_function "$BIN" "$FILE2"
        start_service_function "$BIN" "$FILE3"
        start_service_function "$BIN" "$FILE4"
        start_service_function "$BIN" "$FILE5"
        start_service_function "$BIN" "$FILE6"
        start_service_function "$BIN" "$FILE7"
}
