Update power.inc.sh
This commit is contained in:
@@ -889,40 +889,47 @@ PDUCONTROL(){
|
|||||||
|
|
||||||
[ "${PORTSEL^^}" == "E" ] && exit 0
|
[ "${PORTSEL^^}" == "E" ] && exit 0
|
||||||
|
|
||||||
portsel_power=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.${PORTSEL} -O vq 2> /dev/null | sed -e 's/"//g')
|
|
||||||
[ ${portsel_power} -eq 1 ] && portsel_power_disp="${idsCL[Green]}ON" || portsel_power_disp="${idsCL[LightRed]}OFF"
|
|
||||||
[ ${portsel_power} -eq 2 ] && portsel_change_power_disp="${idsCL[Green]}ON" || portsel_change_power_disp="${idsCL[LightRed]}OFF"
|
|
||||||
|
|
||||||
if [ "${PORTSEL}" != "" ]; then
|
if [ "${PORTSEL}" != "" ]; then
|
||||||
|
portsel_power=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.${PORTSEL} -O vq 2> /dev/null | sed -e 's/"//g')
|
||||||
|
[ ${portsel_power} -eq 1 ] && portsel_power_disp="${idsCL[Green]}ON" || portsel_power_disp="${idsCL[LightRed]}OFF"
|
||||||
|
[ ${portsel_power} -eq 2 ] && portsel_change_power_disp="${idsCL[Green]}ON" || portsel_change_power_disp="${idsCL[LightRed]}OFF"
|
||||||
|
|
||||||
portdesc=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.2.${PORTSEL} -O vq 2> /dev/null | sed -e 's/"//g')
|
portdesc=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.2.${PORTSEL} -O vq 2> /dev/null | sed -e 's/"//g')
|
||||||
DIVIDER . yellow 60
|
DIVIDER . yellow 60
|
||||||
echo -e "${idsCL[Yellow]}Port ${idsCL[LightYellow]}${PORTSEL}${idsCL[Default]}) ${idsCL[LightCyan]}${portdesc} ${idsCL[Default]}: ${portsel_power_disp}${idsCL[Default]}\n"
|
echo -e "${idsCL[Yellow]}Port ${idsCL[LightYellow]}${PORTSEL}${idsCL[Default]}) ${idsCL[LightCyan]}${portdesc} ${idsCL[Default]}: ${portsel_power_disp}${idsCL[Default]}\n"
|
||||||
|
|
||||||
|
echo -en "${idsCL[LightCyan]}Are you sure you wish to turn ${portsel_change_power_disp}${idsCL[LightCyan]} port ${idsCL[Yellow]}${PORTSEL}${idsCL[Default]} (y/N): "
|
||||||
|
read -n 1 portchange_confirm
|
||||||
|
case "${portchange_confirm}" in
|
||||||
|
[Yy])
|
||||||
|
[ ${portsel_power} -eq 1 ] && portsel_change=2 || portsel_change=1
|
||||||
|
echo -en "\n\n${idsCL[LightCyan]}Turning ${portsel_change_power_disp}${idsCL[LightCyan]} port ${idsCL[Yellow]}${PORTSEL}${idsCL[Default]} ... "
|
||||||
|
run=$(snmpset -v 1 -c private ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.${PORTSEL} i ${portsel_change} >/dev/null 2>&1)
|
||||||
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
|
echo
|
||||||
|
if [ "${PORT_SEL}" == "" ]; then
|
||||||
|
sleep 1s
|
||||||
|
unset PORTSEL
|
||||||
|
PDUCONTROL
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ "${PORT_SEL}" == "" ]; then
|
||||||
|
unset PORTSEL
|
||||||
|
PDUCONTROL
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
if [ "${PORT_SEL}" == "" ]; then
|
||||||
|
unset PORTSEL
|
||||||
|
PDUCONTROL
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -en "${idsCL[LightCyan]}Are you sure you wish to turn ${portsel_change_power_disp}${idsCL[LightCyan]} port ${idsCL[Yellow]}${PORTSEL}${idsCL[Default]} (y/N): "
|
|
||||||
read -n 1 portchange_confirm
|
|
||||||
case "${portchange_confirm}" in
|
|
||||||
[Yy])
|
|
||||||
[ ${portsel_power} -eq 1 ] && portsel_change=2 || portsel_change=1
|
|
||||||
echo -en "\n\n${idsCL[LightCyan]}Turning ${portsel_change_power_disp}${idsCL[LightCyan]} port ${idsCL[Yellow]}${PORTSEL}${idsCL[Default]} ... "
|
|
||||||
run=$(snmpset -v 1 -c private ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.${PORTSEL} i ${portsel_change} >/dev/null 2>&1)
|
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
|
||||||
echo
|
|
||||||
if [ "${PORT_SEL}" == "" ]; then
|
|
||||||
sleep 1s
|
|
||||||
unset PORTSEL
|
|
||||||
PDUCONTROL
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ "${PORT_SEL}" == "" ]; then
|
|
||||||
unset PORTSEL
|
|
||||||
PDUCONTROL
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SENDPOWER(){
|
SENDPOWER(){
|
||||||
|
|||||||
Reference in New Issue
Block a user