Update powerwall.sh

This commit is contained in:
2023-12-13 18:50:58 -06:00
parent b6f20da7b1
commit a6472a4bb7

View File

@@ -558,7 +558,7 @@ CHECKPOWER(){
esac esac
shift 1 shift 1
done done
[ "${avgdays}" = "0" ] && unset avgdays [ "${avgdays}" == "0" ] && unset avgdays
[ "${avgdays}" != "" ] && avgdayshdr="${avgdays}-Day-Avg" || avgdayshdr="" [ "${avgdays}" != "" ] && avgdayshdr="${avgdays}-Day-Avg" || avgdayshdr=""
if ([ "${STYPE}" == "" ] || [ "${STYPE}" == "mainsite" ]) && [ "${PTYPE}" != "esxi" ]; then if ([ "${STYPE}" == "" ] || [ "${STYPE}" == "mainsite" ]) && [ "${PTYPE}" != "esxi" ]; then
@@ -1173,16 +1173,16 @@ STARTALL_SERVICES(){
echo echo
} }
SERVICE_MNG(){ SERVICE_MNG(){
if [ "${2}" = "start" ]; then if [ "${2}" == "start" ]; then
sa=Starting sa=Starting
elif [ "${2}" = "stop" ]; then elif [ "${2}" == "stop" ]; then
sa=Stopping sa=Stopping
elif [ "${2}" = "restart" ]; then elif [ "${2}" == "restart" ]; then
sa=Restarting sa=Restarting
elif [ "${2}" = "status" ]; then elif [ "${2}" == "status" ]; then
sa='Status for' sa='Status for'
fi fi
@@ -2377,7 +2377,10 @@ fi
get-snapshots) GET_SNAPSHOTS;; get-snapshots) GET_SNAPSHOTS;;
service) service)
if [ "${2}" = "all" ]; then if [ "${2}" == "status" ]; then
CHECK_SERVICES
elif [ "${2}" == "all" ]; then
if [ "${3}" == "stop" ]; then if [ "${3}" == "stop" ]; then
STOPALL_SERVICES STOPALL_SERVICES
elif [ "${3}" == "start" ]; then elif [ "${3}" == "start" ]; then
@@ -2388,40 +2391,40 @@ fi
CHECK_SERVICES CHECK_SERVICES
fi fi
else else
if [ "${3}" = "start" ] || [ "${3}" = "" ]; then if [ "${3}" == "start" ] || [ "${3}" == "" ]; then
echo "start: ${1}" echo "start: ${1}"
if [ "${2}" = "temp" ]; then if [ "${2}" == "temp" ]; then
# SENDNOTICE "Temp Monitor Startup" "$(DAILYTEMP)" & # SENDNOTICE "Temp Monitor Startup" "$(DAILYTEMP)" &
CHECKTEMP_SERVICE CHECKTEMP_SERVICE
elif [ "${2}" = "power" ]; then elif [ "${2}" == "power" ]; then
CHECKPOWER_SERVICE CHECKPOWER_SERVICE
elif [ "${2}" = "powerlogger" ]; then elif [ "${2}" == "powerlogger" ]; then
POWERLOGGER_SERVICE POWERLOGGER_SERVICE
fi fi
elif [ "${3}" = "stop" ]; then elif [ "${3}" == "stop" ]; then
if [ "${2}" = "temp" ]; then if [ "${2}" == "temp" ]; then
STOP_SERVICE temp STOP_SERVICE temp
for SENSOR in ${!PW_SENSOR_ID[@]}; do for SENSOR in ${!PW_SENSOR_ID[@]}; do
logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR} logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR}
echo "(`date +'%Y-%m-%d %H:%M:%S'`) - ${SENSOR} - Service Stopped" >> ${logtemp} echo "(`date +'%Y-%m-%d %H:%M:%S'`) - ${SENSOR} - Service Stopped" >> ${logtemp}
done done
elif [ "${2}" = "power" ]; then elif [ "${2}" == "power" ]; then
STOP_SERVICE power STOP_SERVICE power
echo "(`date +'%Y-%m-%d %H:%M:%S'`) Service Stopped" >> ${PW_LOGPOWER} echo "(`date +'%Y-%m-%d %H:%M:%S'`) Service Stopped" >> ${PW_LOGPOWER}
elif [ "${2}" = "powerlogger" ]; then elif [ "${2}" == "powerlogger" ]; then
STOP_SERVICE powerlogger STOP_SERVICE powerlogger
fi fi
elif [ "${3}" = "restart" ]; then elif [ "${3}" == "restart" ]; then
SERVICE_MNG ${2} stop SERVICE_MNG ${2} stop
sleep 2s sleep 2s
SERVICE_MNG ${2} start SERVICE_MNG ${2} start
elif [ "${3}" = "status" ]; then elif [ "${3}" == "status" ]; then
srvc=${PW_POWERWALL_SERVICES[${2}]} srvc=${PW_POWERWALL_SERVICES[${2}]}
c=0; spc=''; spc1=`expr 25 - ${#srvc}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done c=0; spc=''; spc1=`expr 25 - ${#srvc}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
echo -e "${idsCL[LightCyan]}${srvc}${spc}: " echo -e "${idsCL[LightCyan]}${srvc}${spc}: "