Reboot NC450
Jump to navigation
Jump to search
Reboot NC450 Camera bash scriptas
#!/bin/bash
cookies1=/etc/mods/cookies
sslconf=/etc/mods/openssl_allow_tls1.0.cnf
camera="https://192.168.1.15/"
username="admin"
password="admin"
hashed_password=$(python3 -c "import base64, hashlib; encoded = base64.b64encode('$password'.encode()).decode(); print(hashlib.md5(encoded.encode()).hexdigest())")
token=$(OPENSSL_CONF=$sslconf curl -c $cookies1 -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "Username=$username&Password=$hashed_password" \
${camera}login.fcgi --insecure -s| jq -r '.token')
if [[ "$token" == "" ]]; then
echo "Unable to get authorization token!"
echo "There must be error in username/password combination!"
exit 1
fi
json=$(OPENSSL_CONF=$sslconf curl -b $cookies1 -X POST -d "token=$token" -H "Content-Type: application/x-www-form-urlencoded" ${camera}reboot.fcgi \
-e "${camera}index.html" --insecure -s)
if [[ "$json" == *"Code\":0"* ]]; then
echo "Reboot success!"
else
echo "Reboot fail!"
fi
Failas openssl_allow_tls1.0.cnf
openssl_conf = openssl_init
[openssl_init]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
CipherString = DEFAULT@SECLEVEL=0