#!/bin/bash
# -*- mode: sh; tab-width: 8; coding: utf-8-unix -*-

prog=`basename $0 .bash`
ROLE=toxcore
PREFIX=/usr/local

. /usr/local/bin/usr_local_tput.bash
# we install into /usr/local/bin and it takes precedence
# export PATH=$PREFIX/bin:$PATH

. $PREFIX/src/usr_local_src.bash || exit 2
[ `id -u` -eq 0 ] && ERROR $prog should not be run as root && exit 3

if [ "$#" -eq 0 ] ; then
    cd $PREFIX/src || exit 2
    WD=$PWD

    bash c-toxcore.bash # || exit 3$?
    bash tox_profile.bash # || 4$?
#    sh mitogen.bash
    #    sh toxcore_docker.bash || exit 4$?
#    which sdwdate >/dev/null 2>/dev/null || \
#	[ -f $PREFIX/bin/sdwdate.bash ] || \
#	sh sdwdate.bash

    sh gridfire.bash # || exit 6$?
    sh pyassuan.bash #|| exit 7$?
    sh tinfoilhat.shmoo.com.bash
    #    sh negotiator.bash

    [ -d testssl.sh ] || \
	sh testssl.bash || exit 9$?
    
    exit 0

elif [ "$1" = 'check' ] ; then
    exit 0
    msys_run_checks_pip3
    msys_var_local_src_prog_key check || exit 10$?
    exit $?

elif [ "$1" = 'lint' ] ; then
#    ols_run_tests_shellcheck $ROLE || exit 2$?
    msys_var_local_src_prog_key $1 || exit 21$?
#    ols_run_tests_pylint ||  exit 22$?
    exit 0

elif [ "$1" = 'test' ] ; then
    exit 0
    msys_var_local_src_prog_key $1 || exit 30$?
    msys_check_pips_inst 
    msys_gentoo_test_imports  || exit 32$?
    #hangs    /usr/bin/expect gpgkey_test_gpg.exp foobar || exit 31$?

fi
