You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

#!/usr/bin/env bash
3 years ago
if [ $enableAudioScript != true ]; then
echo "Extended Audio script disabled, enable by setting parameter: enableAudioScript=true"
exit
fi
3 years ago
echo "Starting Script...."
processstartid="$(ps -A -o pid,cmd|grep "/config/extended/scripts/start_audio.sh" | grep -v grep | head -n 1 | awk '{print $1}')"
3 years ago
echo "To kill script, use the following command:"
echo "kill -9 $processstartid"
for (( ; ; )); do
let i++
3 years ago
if [ ! -d "/config/logs" ]; then
mkdir -p "/config/logs"
chmod 777 "/config/logs"
chown abc:abc "/config/logs"
3 years ago
fi
if [ -f "/config/extended/logs/log-cleanup" ]; then
rm "/config/extended/logs/log-cleanup"
3 years ago
fi
touch -d "24 hours ago" "/config/extended/logs/log-cleanup"
if find "/config/logs" -type f -iname "extended_audio_script_run_*.txt" -not -newer "/config/extended/logs/log-cleanup" | read; then
find "/config/logs" -type f -iname "*.txt" -not -newer "/config/extended/logs/log-cleanup" -delete
3 years ago
fi
if [ -f "/config/extended/logs/log-cleanup" ]; then
rm "/config/extended/logs/log-cleanup"
3 years ago
fi
bash /config/extended/scripts/audio.sh 2>&1 | tee "/config/logs/extended_audio_script_run_${i}_$(date +"%Y_%m_%d_%I_%M_%p").txt" > /proc/1/fd/1 2>/proc/1/fd/2
3 years ago
if [ -z "$scriptInterval" ]; then
scriptInterval="15m"
fi
3 years ago
echo "Script sleeping for $scriptInterval..."
3 years ago
sleep $scriptInterval
done
exit 0