#!/command/with-contenv bash
cd /var/lib/xaseco
XML_HEADER='\n\n'
XML_FOOTER=''
if ls plugins/custom/* &>/dev/null; then
for i in plugins/custom/*
do
ln -sf ${i#*/} plugins/
done
fi
PLUGINS_LIST=($(ls -d plugins/*.php | sed -e 's/plugins\///g'))
[[ -w ./blacklist.txt ]] && dos2unix ./blacklist || {
echo "Can't convert blacklist to Unix line breaks. Check file permissions..."
exit 1
}
[[ -r ./blacklist.txt ]] && \
PLUGINS_LIST=($(echo ${PLUGINS_LIST[@]} | tr ' ' '\n' | grep -vf blacklist))
{
# open with header -- \n interpreted
printf "%b" "$XML_HEADER"
# main block -- parse plugin list
{
[[ "${PLUGINS_LIST[@]}" =~ "plugin.localdatabase.php" ]] && printf " plugin.localdatabase.php\n"
for plugin in "${PLUGINS_LIST[@]}"
do
case "${plugin}" in
"plugin.localdatabase.php")
;;
"plugin.records_eyepiece.php")
;;
*)
printf " %s\n" "${plugin}"
;;
esac
done
[[ "${PLUGINS_LIST[@]}" =~ "plugin.records_eyepiece.php" ]] && printf " plugin.records_eyepiece.php\n"
}
# finish with footer -- \n interpreted
printf "%b" "$XML_FOOTER"
} > plugins.xml