#!/bin/bash # ARCH detection and check if [ "$(uname -m)" = "x86_64" ]; then QUEUE=mockx REDISCLI="valkey-cli" else QUEUE=mocka REDISCLI="valkey-cli -h remi" fi CHECK=$($REDISCLI ping) [ "$CHECK" = "PONG" ] || exit 1 if [ "$1" = "-h" -o "$1" = "--help" ]; then echo "Usage $0 [ option ]" echo " -e --erase to empty the queue" echo " -l --list to list the queue" echo " -p --perm to run permanently" exit 0 elif [ "$1" = "-l" -o "$1" = "--list" ]; then $REDISCLI smembers $QUEUE exit 0 elif [ "$1" = "-e" -o "$1" = "--erase" ]; then $REDISCLI del $QUEUE exit 0 fi while true do CMD=$($REDISCLI spop $QUEUE) if [ -z "$CMD" ]; then if [ "$1" = "-p" -o "$1" = "--perm" ]; then echo -n . sleep 1 continue else break fi fi TXT="$(echo $CMD | sed -e 's/^.*-r //;s/ .*$//') " RPM="$(echo $CMD | sed -e 's:\.rpm.*$:.rpm:;s:^.*/::')" echo -en "\r$(date +%X) $RPM ${TXT:0:10} " $CMD --uniqueext=$PPID && echo " Ok." || echo " Error !" done echo "$(date +%X) Done"