<?xml version='1.0' standalone='yes'?>

<!DOCTYPE PLUGIN [
<!ENTITY name      "dwstorecast">
<!ENTITY author    "desertwitch">
<!ENTITY version   "2025.02.26">
<!ENTITY launch    "Settings/dwStorecast">
<!ENTITY gitURL    "https://raw.githubusercontent.com/&author;/storecast-unRAID/main">
<!ENTITY pluginURL "&gitURL;/plugin/&name;.plg">
<!ENTITY pkgURL    "&gitURL;/packages">
<!ENTITY plgPATH   "/boot/config/plugins/&name;">
<!ENTITY plgNAME   "dwstorecast-2025.02.26-x86_64-1">
<!ENTITY plgMD5    "2ba09b427424d3bbe9d73006d7ff3149">
<!ENTITY emhttp    "/usr/local/emhttp/plugins/&name;">
]>

<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" support="" min="6.12.1" icon="sun-o">

<CHANGES>
## Storecast for UNRAID
###2025.02.26
- fix: future-proofing changes to base plugin structure
###2025.02.18
- release note: welcome to the first version of the plugin
- release note: please report any issues in the support thread on the forums
</CHANGES>

<!--
stop already running instances before doing anything
-->
<FILE Run="/bin/bash">
<INLINE>
killall storecast >/dev/null 2>&amp;1
killall dwstorecast-poller >/dev/null 2>&amp;1
exit 0
</INLINE>
</FILE>

<!--
install or upgrade the plugin itself
-->
<FILE Name="&plgPATH;/&plgNAME;.txz" Min="6.12.1" Run="upgradepkg --install-new">
<URL>&gitURL;/archive/&plgNAME;.txz</URL>
<MD5>&plgMD5;</MD5>
</FILE>

<!--
run the post-installation scripts
-->
<FILE Run="/bin/bash">
<INLINE>
echo ""
if [ -x &emhttp;/scripts/write_config ]; then
    &emhttp;/scripts/write_config
fi
echo ""
echo "****************************************************************"
echo "!! Please go to the Storecast page to generate the first fore-"
echo "!! cast and/or set up automated generation of future forecasts"
echo "****************************************************************"
echo ""
echo "----------------------------------------------------------------"
echo " Storecast for UNRAID has been installed."
echo " Version: &version; / Plugin Maintainer: &author;"
echo "----------------------------------------------------------------"
echo ""
</INLINE>
</FILE>

<!--
definition for uninstallation of the plugin
-->
<FILE Run="/bin/bash" Method="remove">
<INLINE>
killall storecast >/dev/null 2>&amp;1
killall dwstorecast-poller >/dev/null 2>&amp;1

removepkg &plgPATH;/*.txz
rm -rf &plgPATH;
rm -rf &emhttp;

rm -f /tmp/storecast*
rm -f /etc/cron.hourly/storecast
rm -f /etc/cron.daily/storecast
rm -f /etc/cron.weekly/storecast
rm -f /etc/cron.monthly/storecast
rm -f /etc/cron.daily/dwstorecast-poller >/dev/null 2>&amp;1

echo ""
echo "----------------------------------------------------------------"
echo " Storecast for UNRAID has been removed."
echo " Version: &version; / Plugin Maintainer: &author;"
echo "----------------------------------------------------------------"
echo ""
</INLINE>
</FILE>

</PLUGIN>