add verbose option
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2023-01-01 12:07:17 +01:00
parent 82400de042
commit 0ee1015dcb
Signed by: deblan
GPG key ID: 579388D585F70417

12
timeout
View file

@ -17,7 +17,11 @@ create_script() {
}
run_script() {
"$SCRIPT_FILE" >/dev/null 2>&1 &
if [ "$2" -eq 0 ]; then
"$SCRIPT_FILE" >/dev/null 2>&1 &
else
"$SCRIPT_FILE" >&2 &
fi
printf "%d" $!
}
@ -39,16 +43,18 @@ check_pid() {
}
main() {
while getopts "ht:c:" option; do
while getopts "ht:c:v" option; do
case "${option}" in
h) usage; exit 0;;
t) TIMEOUT="$OPTARG";;
c) COMMAND="$OPTARG";;
v) VERBOSE=1;;
*) usage; exit 1;;
esac
done
TIMEOUT="${TIMEOUT:-10}"
VERBOSE="${VERBOSE:-0}"
if [ -z "$COMMAND" ]; then
printf "Command is required!\n"
@ -59,7 +65,7 @@ main() {
create_script "$COMMAND" "$SCRIPT_FILE"
SCRIPT_PID=$(run_script "$SCRIPT_FILE")
SCRIPT_PID=$(run_script "$SCRIPT_FILE" "$VERBOSE")
EXIT_STATUS=$(check_pid "$SCRIPT_PID" "$TIMEOUT")
stop_delete_script "$SCRIPT_PID" "$SCRIPT_FILE"