34 lines
666 B
Bash
34 lines
666 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
|
||
|
function collect () {
|
||
|
PREFIX="$1"
|
||
|
VID_TEMPLATE_FILE="templates/vid-template.txt"
|
||
|
TMP_FILE=$( mktemp )
|
||
|
|
||
|
echo "${TMP_FILE}"
|
||
|
|
||
|
cat ${PREFIX}-vids/*.txt | xargs -I{} sed -e "s@###VID###@{}@g" "${VID_TEMPLATE_FILE}" >> "${TMP_FILE}"
|
||
|
cat ${PREFIX}-channels/*.txt | xargs -I{} sed -e "s@###VID###@{}@g" "${VID_TEMPLATE_FILE}" >> "${TMP_FILE}"
|
||
|
|
||
|
diff "${PREFIX}.txt" "${TMP_FILE}"
|
||
|
RES="$?"
|
||
|
|
||
|
if [ "${RES}" -gt "0" ]
|
||
|
then
|
||
|
mv -vf "${PREFIX}.txt" "${PREFIX}.txt.old" && \
|
||
|
cp -vf "${TMP_FILE}" "${PREFIX}.txt" && \
|
||
|
rm -vf "${PREFIX}.txt.old"
|
||
|
fi
|
||
|
|
||
|
rm -vf "${TMP_FILE}"
|
||
|
|
||
|
}
|
||
|
|
||
|
arr=("allowed" "blocked")
|
||
|
|
||
|
for i in "${arr[@]}"
|
||
|
do
|
||
|
collect "$i"
|
||
|
done
|