34 lines
681 B
Bash
34 lines
681 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}-videoids/*.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}" >/dev/null
|
|
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
|