diff options
author | horchi <vdr@jwendel.de> | 2017-03-05 16:39:28 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2017-03-05 16:39:28 +0100 |
commit | e2a48d8701f91b8e24fbe9e99e91eb72a87bb749 (patch) | |
tree | 726f70554b4ca985a09ef6e30a7fdc8df089993c /scripts/epgh-login | |
download | vdr-epg-daemon-e2a48d8701f91b8e24fbe9e99e91eb72a87bb749.tar.gz vdr-epg-daemon-e2a48d8701f91b8e24fbe9e99e91eb72a87bb749.tar.bz2 |
git init1.1.103
Diffstat (limited to 'scripts/epgh-login')
-rwxr-xr-x | scripts/epgh-login | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/epgh-login b/scripts/epgh-login new file mode 100755 index 0000000..b0a8061 --- /dev/null +++ b/scripts/epgh-login @@ -0,0 +1,43 @@ + +if [ -z "$1" ]; then + _USER=nologin +else + _USER="$1" +fi + +if [ -z "$2" ]; then + _PASSWD=nologin +else + _PASSWD="$2" +fi + +if [ -z "$EPGD_HOST" ]; then + EPGD_HOST=localhost +fi + +if [ -z "$EPGD_PORT" ]; then + EPGD_PORT=9999 +fi + +if [ "$_USER" == "logout" ]; then + wget -q -O - $EPGD_HOST:$EPGD_PORT/sid$EPG_HTTPD_SESSION/data/login --post-data="{ \"key\" : \"\" }" > /dev/null + # echo "logout succeeded" + exit +fi + +KEY=`echo -n $_USER$_PASSWD | md5sum | sed s/" .*$"/""/g` +RESULT=`wget -q -O - $EPGD_HOST:$EPGD_PORT/data/login --post-data="{ \"key\" : \"$KEY\" }"` + +if [ ! -z "$RESULT" ]; then + EPG_HTTPD_SESSION=`echo $RESULT | json_pp | grep session | sed s/".*: ."/""/ | sed s/"\".*"/""/` +fi + +IS_JSON=`expr index "$RESULT" "{"` + +if [ ! -z $EPG_HTTPD_SESSION ] && [ $IS_JSON -ne 0 ]; then + export EPGD_PORT EPGD_HOST + export EPG_HTTPD_SESSION + echo "login succeeded, session is \"$EPG_HTTPD_SESSION\"" +else + echo "Error: Login at $EPGD_HOST/$EPGD_PORT failed!" +fi |