#!/bin/bash # load config source ./config cleanup() { kill -TERM $client_pid > /dev/null 2>&1 kill -TERM $hook_pid > /dev/null 2>&1 } # remove receiver data, if any rm -fr $LEECHER_DIR/* > $UTP_RECEIVER_OUT_LOG > $UTP_RECEIVER_LOG_FILE > $UTP_RECEIVER_MONITOR_LOG # start client $UTP_RECEIVER $UTP_RECEIVER_LOG_FILE $UTP_RECEIVER_PORT $LEECHER_DATA >> $UTP_RECEIVER_OUT_LOG 2>&1 & client_pid=$! # start monitoring on pid ./hook_monitor_pid $client_pid >> $UTP_RECEIVER_MONITOR_LOG 2>&1 & hook_pid=$! trap cleanup 0 1 2 3 15 wait