#!/bin/bash

trap 'exit' SIGTERM

FLAG=/linuxcash/cash/data/tmp/artix45-tools-firstrun
if [ -f $FLAG ] ; then
    DIST_CODENAME="$(lsb_release -s -c)"
    if [ "$DIST_CODENAME" != "trusty" ] && [ "$DIST_CODENAME" != "bionic" ] ; then
        cloud-init status --wait  > /dev/null 2>&1
    fi
    script=`sudo /linuxcash/cash/tools/tools_avail/get_next_executed.py /linuxcash/cash/tools/tools_firstrun /linuxcash/cash/data/tmp/first-run-executed-scripts`
    while [ -f $script ]; do
        . $script
        sync
        script=`sudo /linuxcash/cash/tools/tools_avail/get_next_executed.py /linuxcash/cash/tools/tools_firstrun /linuxcash/cash/data/tmp/first-run-executed-scripts`
    done
    rm -f $FLAG
fi