Update powerwall.sh
This commit is contained in:
32
powerwall.sh
32
powerwall.sh
@@ -1571,7 +1571,7 @@ HOSTPOWER(){
|
|||||||
PDUCONTROL(){
|
PDUCONTROL(){
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-port) PORTSEL=${2};;
|
-port) PORT_SEL=${2};;
|
||||||
esac
|
esac
|
||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
@@ -1579,8 +1579,8 @@ PDUCONTROL(){
|
|||||||
DIVIDER . yellow 75
|
DIVIDER . yellow 75
|
||||||
echo -e "${idsCL[Yellow]}APC-PDU Power Control"
|
echo -e "${idsCL[Yellow]}APC-PDU Power Control"
|
||||||
DIVIDER true yellow 75
|
DIVIDER true yellow 75
|
||||||
|
[ "${PORT_SEL}" != "" ] && PORTSEL=${PORT_SEL}
|
||||||
if [ "${PORT}" == "" ]; then
|
if [ "${PORTSEL}" == "" ]; then
|
||||||
PORT_DESC=$(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 -O vq 2> /dev/null | sed -e 's/"//g')
|
PORT_DESC=$(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 -O vq 2> /dev/null | sed -e 's/"//g')
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
read -rd '' -a PORT_DESC <<<"${PORT_DESC}"
|
read -rd '' -a PORT_DESC <<<"${PORT_DESC}"
|
||||||
@@ -1594,7 +1594,33 @@ PDUCONTROL(){
|
|||||||
echo -e "${pp}) ${idsCL[LightCyan]}${port}${spc}${idsCL[Default]}: ${portpower_disp}${idsCL[Default]}"
|
echo -e "${pp}) ${idsCL[LightCyan]}${port}${spc}${idsCL[Default]}: ${portpower_disp}${idsCL[Default]}"
|
||||||
((p++))
|
((p++))
|
||||||
done
|
done
|
||||||
|
until [ "${PORTSEL}" != "" ]; do
|
||||||
|
echo -en "\n${idsCL[LightCyan]}Enter the port number to control: ${idsCL[Default]}"
|
||||||
|
read PORTSEL
|
||||||
|
echo
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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 2 ] && portsel_power_disp="${idsCL[Green]}ON" || portsel_power_disp="${idsCL[LightRed]}OFF"
|
||||||
|
|
||||||
|
echo -en "${idsCL[LightCyan]}Are you sure you wish to turn ${portsel_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_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]}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ "${PORT_SEL}" == "" ]; then
|
||||||
|
PDUCONTROL
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGROTATE(){
|
LOGROTATE(){
|
||||||
|
|||||||
Reference in New Issue
Block a user