use /data as workdir, so /config can be immutable

This commit is contained in:
hnrd 2023-02-17 15:32:11 +01:00
parent 2901b87d87
commit 5be901062b

View file

@ -1,7 +1,7 @@
#!/bin/bash
echo > /config/urls.txt
echo > /config/hosts
echo > /data/urls.txt
echo > /data/hosts
# Get federated hosts and begin to stream them
cat /config/domains-federated | grep -v "##" | while read -r line
@ -23,15 +23,15 @@ do
if [[ $tag != "" ]]; then
echo "[INFO] Found tag $tag"
# Create a url to fetch for each tag
echo "https://$host/api/v1/streaming/hashtag?tag=$tag $host" >> /config/urls.txt
echo "https://$host/api/v1/streaming/hashtag?tag=$tag $host" >> /data/urls.txt
fi
done
elif [[ "$line" != *" #"* ]]; then
echo "[INFO] $line didn't have hashtags"
host=$line
echo "https://$line/api/v1/streaming/public $line" >> /config/urls.txt
fi
echo $host >> /config/hosts
echo "https://$line/api/v1/streaming/public $line" >> /data/urls.txt
fi
echo $host >> /data/hosts
fi
done
@ -56,30 +56,30 @@ do
if [[ $tag != "" ]]; then
echo "[INFO] Found tag $tag"
# Create a url to fetch for each tag
echo "https://$host/api/v1/streaming/hashtag/local?tag=$tag $host" >> /config/urls.txt
echo "https://$host/api/v1/streaming/hashtag/local?tag=$tag $host" >> /data/urls.txt
fi
done
elif [[ "$line" != *" #"* ]]; then
echo "[INFO] $line didn't have hashtags"
host=$line
echo "https://$line/api/v1/streaming/public/local $line" >> /config/urls.txt
echo "https://$line/api/v1/streaming/public/local $line" >> /data/urls.txt
fi
echo $host >> /config/hosts
echo $host >> /data/hosts
fi
done
cat /config/hashtags | grep -v "##" | while read -r hashtag; do
hashtag=`echo $hashtag | cut -d "#" -f 2`
sort /config/hosts | uniq -u |while read -r host; do
sort /data/hosts | uniq -u |while read -r host; do
if [[ $hashtag != "" && "$host" != "" ]]; then
echo "https://$host/api/v1/streaming/hashtag?tag=$hashtag $host" >> /config/hashtag-urls.txt
echo "https://$host/api/v1/streaming/hashtag?tag=$hashtag $host" >> /data/hashtag-urls.txt
fi
done
done
cat /config/hashtag-urls.txt >> /config/urls.txt
cat /data/hashtag-urls.txt >> /data/urls.txt
cat /config/urls.txt | while read -r url
cat /data/urls.txt | while read -r url
do
echo "[INFO] Opening $url to stream"
sleep $streamDelay
@ -96,4 +96,4 @@ fi
# then restart
echo "[INFO] Container restart timoe is $restartTimeout"
sleep $restartTimeout
exit 0
exit 0