init III
This commit is contained in:
133
Perl Ubiquiti mpower steuerung/device control/switch_port.sh
Normal file
133
Perl Ubiquiti mpower steuerung/device control/switch_port.sh
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
sleep 5
|
||||
|
||||
export USER="andre"
|
||||
export PASS="mesh-assort2"
|
||||
export HOST="power.andregeissler.de"
|
||||
export DEVICE="Test"
|
||||
export DEVICEIP="192.168.100.7"
|
||||
export DEVICEUSER="admin"
|
||||
export DEVICEPASS="admin"
|
||||
|
||||
export STATUS=`curl -s 'http://andre:mesh-assort2@power.andregeissler.de/Test/api.php?action=getstatus'`
|
||||
s1=`echo $STATUS | awk -F';' '{print $1}' | grep -o checked`
|
||||
s2=`echo $STATUS | awk -F';' '{print $2}' | grep -o checked`
|
||||
s3=`echo $STATUS | awk -F';' '{print $3}' | grep -o checked`
|
||||
s4=`echo $STATUS | awk -F';' '{print $4}' | grep -o checked`
|
||||
s5=`echo $STATUS | awk -F';' '{print $5}' | grep -o checked`
|
||||
s6=`echo $STATUS | awk -F';' '{print $6}' | grep -o checked`
|
||||
|
||||
if [ "$s1" == "checked" ]
|
||||
then
|
||||
s1=on
|
||||
fi
|
||||
|
||||
if [ "$s2" == "checked" ]
|
||||
then
|
||||
s2=on
|
||||
fi
|
||||
|
||||
if [ "$s3" == "checked" ]
|
||||
then
|
||||
s3=on
|
||||
fi
|
||||
|
||||
if [ "$s4" == "checked" ]
|
||||
then
|
||||
s4=on
|
||||
fi
|
||||
|
||||
if [ "$s5" == "checked" ]
|
||||
then
|
||||
s5=on
|
||||
fi
|
||||
|
||||
if [ "$s6" == "checked" ]
|
||||
then
|
||||
s6=on
|
||||
fi
|
||||
|
||||
if [ "$1" == "1" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output1"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output1"
|
||||
fi
|
||||
s1=$val
|
||||
fi
|
||||
|
||||
if [ "$1" == "2" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output2"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output2"
|
||||
fi
|
||||
s2=$val
|
||||
fi
|
||||
|
||||
if [ "$1" == "3" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output3"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output3"
|
||||
fi
|
||||
s3=$val
|
||||
fi
|
||||
|
||||
if [ "$1" == "4" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output4"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output4"
|
||||
fi
|
||||
s4=$val
|
||||
fi
|
||||
|
||||
if [ "$1" == "5" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output5"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output5"
|
||||
fi
|
||||
s5=$val
|
||||
fi
|
||||
|
||||
if [ "$1" == "6" ]
|
||||
then
|
||||
if [ "$2" == "off" ]
|
||||
then
|
||||
val=""
|
||||
comm="echo 0 > /dev/output6"
|
||||
else
|
||||
val="on"
|
||||
comm="echo 1 > /dev/output6"
|
||||
fi
|
||||
s6=$val
|
||||
fi
|
||||
|
||||
str="&oos1=$s1&oos2=$s2&oos3=$s3&oos4=$s4&oos5=$s5&oos6=$s6"
|
||||
export cmd="/usr/bin/curl -s 'http://andre:mesh-assort2@power.andregeissler.de/Test/api.php?action=setstatus$str'"
|
||||
/bin/bash -c "$cmd"
|
||||
expect /scripts/mFi/port.exp $DEVICEUSER $DEVICEIP $DEVICEPASS '$comm'
|
||||
|
||||
Reference in New Issue
Block a user