Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
171 lines (133 sloc) 5.24 KB
#!/bin/sh
# WebUI icon used from http://icons8.com
ADDON_NAME=`basename "$0"`
source /usr/local/addons/${ADDON_NAME}/params 2>/dev/null
source /usr/local/addons/${ADDON_NAME}/functions 2>/dev/null
ADDON_DIR=/usr/local/addons/${ADDON_NAME}
WWW_DIR=/etc/config/addons/www/${ADDON_NAME}
RC_DIR=/usr/local/etc/config/rc.d
CUSTOM_FIRMWARE_DIR=${ADDON_DIR}/custom_firmware
LOGFILE=$ADDON_DIR/inst.log
ERRFILE=$ADDON_DIR/inst.err
case "$1" in
""|init|start)
if [ ! -f ${ADDON_DIR}/installed ] || [ ! -f ${FIRMWARE_FILE} ]; then
logToFile $LOGFILE "($1) Installing $ADDON_NAME $ADDON_VERSION"
# Prepare
#----------------------------------------------
mount -o remount,rw /
check_ccu_fw_version
logToFile $LOGFILE "Found firmware version $FW_VERSION - using patchversion $PATCHVERSION"
check_monit
logToFile $LOGFILE "Found $MONIT monit process(es)"
check_rega
logToFile $LOGFILE "Found $REGA ReGaHss process(es)"
check_rfd
logToFile $LOGFILE "Found $RFD rfd process(es)"
# ! to stop ReGaHss/RFD services below, we need to stop the new service watchdog Monit with firmwares >= 3.45 !
if [ $MONIT -ge 1 ]; then
logToFile $LOGFILE "Stopping monitoring service for ReGaHss and RFD"
/usr/bin/monit unmonitor ReGaHss
/usr/bin/monit unmonitor rfd
fi
if [ $REGA -ge 1 ]; then
logToFile $LOGFILE "Stopping ReGaHss"
/etc/init.d/S70ReGaHss stop >> $LOGFILE
fi
if [ $RFD -ge 1 ]; then
logToFile $LOGFILE "Stopping rfd"
/etc/init.d/S61rfd stop >> $LOGFILE
fi
# Action
#----------------------------------------------
cd ${ADDON_DIR}
# run AddOn spezific install script
./install >> $LOGFILE 2>>$ERRFILE
# copy/overwrite default firmware with custom firmware files if they exist
for file in ${CUSTOM_FIRMWARE_DIR}/*.xml ; do
[ -f "$file" ] || continue # processing für *.xml verhindern falls nichts gefunden, 'shopt -s nullglob' nicht verfügbar
logToFile $LOGFILE "Copy custom firmware file: $(basename $file)"
cp -f $file ${ADDON_DIR}${FIRMWARE_DIR}
done
# Unprepare
#----------------------------------------------
sync
mount -o remount,ro /
touch ${ADDON_DIR}/installed
if [ $RFD -ge 1 ]; then
logToFile $LOGFILE "Starting rfd"
/etc/init.d/S61rfd start >> $LOGFILE
fi
if [ $REGA -ge 1 ]; then
logToFile $LOGFILE "Starting ReGaHss"
/etc/init.d/S70ReGaHss start >> $LOGFILE
fi
if [ $MONIT -ge 1 ]; then
logToFile $LOGFILE "Starting monitoring service for ReGaHss and RFD"
/usr/bin/monit monitor ReGaHss
/usr/bin/monit monitor rfd
fi
logToFile $LOGFILE "Installation done."
else
# check for user updated custom firmware files
changed=0
for file in ${ADDON_DIR}${FIRMWARE_DIR}/*.xml ; do
[ -f "$file" ] || continue # processing für *.xml verhindern falls nichts gefunden, 'shopt -s nullglob' nicht verfügbar
$(cmp -s ${CUSTOM_FIRMWARE_DIR}/$(basename $file) $file)
rc=$?
if [ $rc -eq 1 ]; then
logToFile $LOGFILE "($1) Difference detected for custom firmware file: $(basename $file) => copying"
cp -f ${CUSTOM_FIRMWARE_DIR}/$(basename $file) $file
let changed++
fi
done
if [ $changed -gt 0 ]; then
logToFile $LOGFILE "($1) $changed custom firmware file(s) changed"
check_rfd
if [ $RFD -ge 1 ]; then
logToFile $LOGFILE "Restarting rfd"
/etc/init.d/S61rfd restart >> $LOGFILE
fi
else
logToFile $LOGFILE "($1) Nothing to do for $ADDON_NAME"
fi
fi
;;
stop)
echo "Nothing to stop..."
;;
uninstall)
mount -o remount,rw /
cd ${ADDON_DIR}
# run AddOn spezific uninstall script
./uninstall >> $LOGFILE 2>>$ERRFILE
# copy logfiles to tmp directory because we will delete ADDON_DIR
cp $LOGFILE /usr/local/tmp
cp $ERRFILE /usr/local/tmp
cd /
rm -rf $ADDON_DIR
rm -rf $WWW_DIR
rm -f ${RC_DIR}/${ADDON_NAME}
sync
mount -o remount,ro /
;;
restart|reload)
# Operations to stop and start (restart) the addon
;;
info)
echo "Info: <b>$DEVICE Addon</b><br>"
echo "Info: <b>CCU2/3, RaspberryMatic</b><br>"
echo "Info: (c) 2018-2019 TomMajor<br>"
echo "Info: ${ADDON_INFO_LINK}"
echo "Version: $(cat ${ADDON_DIR}/VERSION)"
echo "Name: $DEVICE"
echo "Operations: uninstall"
#echo "Config-Url: ${CONFIG_URL}"
echo "Update: /addons/$ADDON_NAME/update-check.cgi"
;;
*)
echo "Usage: $ADDON_NAME {start|info|uninstall}" >&2
exit 1
;;
esac
exit $?
You can’t perform that action at this time.