If poking around a strange server helps, I can set up an ssh account for temp access.
Gerald
If poking around a strange server helps, I can set up an ssh account for temp access.
Code: Select all
#!/bin/sh
username="USER"
password="PASSWORD"
host="http://localhost:PORT/zm"
file="/etc/zm/cookie.txt"
case "$1" in
'statusid')
if [ -e $file ]; then
echo "WARNING: Cookie file: $file already exist... Using it!"
else
echo "WARNING: Cookie file: $file does not exist... Creating it!"
curl -d "username=$username&password=$password&action=login&view=console" -c $file $host/index.php
sleep 1
chmod 600 $file
echo Cookie file: $file created.
fi
curl -b $file -XPOST $host/api/monitors/$2.json -d "Monitor[Function]=$3&Monitor[Enabled]=$4"
echo Changed ID $2 ZoneMinder monitor status to $3 now.
;;
'makecookie')
if [ -e $file ]; then
echo "WARNING: Cookie file: $file already exist... Overwriting it!"
else
echo "WARNING: Cookie file: $file does not exist... Creating it!"
fi
curl -d "username=$username&password=$password&action=login&view=console" -c $file $host/index.php
sleep 1
chmod 600 $file
echo Cookie file: $file created.
;;
'deletecookie')
if [ -e $file ]; then
echo "WARNING: Cookie file: $file exist... Deleting it!"
rm $file
echo Cookie file: $file deleted.
else
echo "WARNING: Cookie file: $file does not exist... Can't delete it!"
fi
;;
'info')
echo "Use statusid <ID> <None|Monitor|Modect|Record|Mocord|Nodect> <0|1> parameters to change monitor status or makecookie\deletecookie to manage cookie file manually"
;;
*)
echo "Usage: $0 {statusid|makecookie|deletecookie|info}"
exit 1
;;
esac
exit 0