Browse Source

new admin and layout changes

Danja Vasiliev 10 years ago
parent
commit
b44db68ae6

+ 1 - 0
openwrt/DIR505A1/bin/ps

@@ -0,0 +1 @@
+/usr/bin/ps

+ 1 - 1
openwrt/DIR505A1/etc/banner

@@ -8,7 +8,7 @@
  based on OpenWRT r40774 (trunk)
  -----------------------------------------------------
  provides now:            will provide:
-   * HTTP (lighthttp)       * SMTP      
+   * HTTP (lighttpd)        * SMTP      
    * Bash CGI               * IMAP
                             * Lua CGI
  -----------------------------------------------------

+ 41 - 9
openwrt/DIR505A1/etc/lighttpd/lighttpd.conf

@@ -4,8 +4,9 @@ server.modules = (
  "mod_compress",
  "mod_accesslog",
  "mod_rewrite",
+ "mod_alias",
  "mod_auth",
-# "mod_setenv",
+ "mod_setenv",
 # "mod_status",
 # "mod_alias",
 # "mod_redirect",
@@ -18,9 +19,14 @@ server.errorlog = "/tmp/lighttpd-error.log"
 accesslog.filename = "/tmp/lighttpd-access.log"
 server.pid-file = "/var/run/lighttpd.pid"
 server.username = "httpd"
-server.groupname = "www-data"
+server.groupname = "nogroup"
 server.port = 80
 
+## defines var.superglueVersion from /etc/superglue_version
+include_shell "/etc/lighttpd/vars.sh"
+
+setenv.add-response-header = ( "X-SuperGlue-Version" => var.superglueVersion )
+
 #debug.log-request-handling = "enable"
 #debug.log-request-header = "enable"
 #debug.log-file-not-found	= "enable"
@@ -28,24 +34,50 @@ server.port = 80
 #debug.log-response-header = "enable"
 #debug.log-condition-handling	= "enable"
 
-auth.backend		= "htdigest"
-auth.backend.htdigest.userfile = "/etc/lighttpd/.htpasswd"
+auth.backend = "htdigest"
+auth.backend.htdigest.userfile = "/www/lib/admin/htpasswd"
 #auth.debug = 2
 
 #setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
 compress.cache-dir = "/tmp/lighttpd/compress"
 compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" )
 
-index-file.names = ( "index.html" )
+index-file.names = ( "index.html, default.html" )
 
 cgi.assign = ( ".sh" => "/bin/bash" )
-url.access-deny = ( "~", ".inc", ".htaccess", ".htpasswd")
+url.access-deny = ( "~", ".inc", ".htaccess", ".htpasswd", "htpasswd")
+
+$HTTP["request-method"] == "GET" {
+  url.rewrite = ( "^/resources/(.*)$" => "resources/$1",
+                  "^/devTools/(.*)$" => "devTools/$1",
+                  "^/templates/(.*)$" => "templates/$1",
+                  "^/admin/(.*)$" => "admin/admin.sh" )
+
+  alias.url = ( "/resources" => "/www/lib/resources",
+                "/devTools" => "/www/lib/devTools",
+                "/templates" => "/www/lib/templates",
+                "/admin" => "/www/lib/admin" )
+}
 
 $HTTP["request-method"] == "POST" {
- server.document-root = "/www/lib/cgi"
- url.rewrite = ( ".*" => "post.sh" )
+  url.rewrite = ( "^(/(?!admin).*)" => "post.sh",
+                  "^(/(admin).*)" => "admin.sh" 
+  )
+  $HTTP["url"] =~ "^/post.sh" {
+    server.document-root = "/www/lib/cgi"
+  }
+  $HTTP["url"] =~ "^/admin.sh" {
+    server.document-root = "/www/lib/admin"
+   }
 }
 
-#auth.require = ( "/post.sh" => ( "method" => "digest", "realm" => "superglue test", "require" => "valid-user" ) )
+auth.require = ( 
+  "/post.sh" => ( "method" => "digest", 
+                  "realm" => "superglue", 
+                  "require" => "valid-user" ),
+  "/admin" => ( "method" => "digest", 
+                  "realm" => "superglue", 
+                  "require" => "valid-user" )
+  )
 
 include "/etc/lighttpd/mime.conf"

+ 2 - 3
openwrt/DIR505A1/etc/lighttpd/mime.conf

@@ -67,10 +67,9 @@ mimetype.assign             = (
   ".tbz"          =>      "application/x-bzip-compressed-tar",
   ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
   ".rpm"          =>      "application/x-rpm",
-  ".ttf"          =>      "application/font-sfnt",
-  ".otf"          =>      "application/font-sfnt",
   # make the default mime type application/octet-stream.
-  ""              =>      "application/octet-stream",
+  # ""              =>      "application/octet-stream",
+  ""              =>      "text/html",
  )
 
 

+ 3 - 0
openwrt/DIR505A1/etc/lighttpd/vars.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo 'var.superglueVersion="'$(cat /etc/superglue_version)'"'

+ 5 - 5
openwrt/DIR505A1/etc/rc.local

@@ -15,14 +15,14 @@ mountpoint -q $_SG && (
 
   ## check if index.html is present
   [ -e $_SG/index.html ] || (
-    cp /www/lib/resources/index.html $_SG
-    chown httpd $_SG/index.html
+    cp /www/lib/resources/index.html $_SG/default.html
+    chown httpd $_SG/default.html
     )
 
   ## check symlinking
-  for i in devTools resources templates; do
-    [ -L $_SG/$i ] || ln -s /www/lib/$i $_SG/$i
-  done
+#  for i in devTools resources templates; do
+#    [ -L $_SG/$i ] || ln -s /www/lib/$i $_SG/$i
+#  done
 
   ## if /www/tmp does not exist
 #  [ -d $_SG/tmp ] || (

+ 1 - 1
openwrt/DIR505A1/etc/uci-defaults/20-set-ssid

@@ -6,4 +6,4 @@ _MAC="SuperGlue-"$_MAC
   uci commit
   )
 
-exit 1
+exit 0

+ 69 - 0
openwrt/DIR505A1/www/htdocs/default.html

@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html lang="de">
+	<head class="html5">
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+		<meta name="generator" content="SuperGlue">
+		<meta name="generator-version" content="0.1">
+		<title>SuperGlue Rocks!</title>
+		<link rel="stylesheet" href="../resources/default/css/normalize.css">
+		<link rel="stylesheet" href="../resources/default/css/style.css">
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+	</head>
+	<body class="space root" data-type="AbsoluteSpace" data-grid-size="29" style="height: 370px; width: 868px; background-color: rgb(153, 151, 161); overflow: visible;"><div class="spaceContent" style="">
+		<div class="shape" data-type="TextShape" style="position: absolute; left: 431px; top: 222px; width: 407px; height: 88px; z-index: 2; margin-left: inherit;"><div class="shapeContent" style="border-width: 0px; border-color: transparent; background-color: transparent; background-image: none; padding: 0px; display: block; background-repeat: repeat repeat;"><b style="font-family: Dosis; font-size: 32px;"><span style="font-family: Montserrat; font-size: 14px; color: rgb(213, 1, 1);">NO STORAGE IS&nbsp;AVAILABLE !!!<br>PLEASE MAKE SURE YOUR USB DRIVE IS CONNECTED<br></span></b><span style="font-family: Dosis; font-size: 32px;"><b><br></b></span></div></div>
+		<div class="shape" data-type="TextShape" style="position: absolute; left: 427px; top: 177px; width: 252px; height: 43px; z-index: 1; margin-left: inherit;"><div class="shapeContent" style="border-width: 0px; border-color: transparent; background-color: transparent; background-image: none; padding: 0px; display: block; background-repeat: repeat repeat;"><span style="font-size: 32px;"><b><span style="font-size: 40px; font-family: Montserrat;">SUPERGLUE</span><br><br></b></span></div></div>
+		<div class="shape" data-type="ImageShape" style="position: absolute; left: 315px; top: 75px; width: 120px; height: 227px; z-index: 0; margin-left: inherit;"><img class="shapeContent" src="../resources/default/img/placeholder.png"></div>
+	</div></body>
+</html>

+ 0 - 7
openwrt/DIR505A1/www/htdocs/index.html

@@ -1,7 +0,0 @@
-<html>
-<head><title>Storage unavailable | SuperGlue</title></head>
-<body style='background-color:#777; color:#eee'>
-<h1>Storage unavailable..</h1>
-<h2>Please make sure that USB storage device is attached to the unit</h2>
-</body>
-</html>

+ 365 - 0
openwrt/DIR505A1/www/lib/admin/admin.sh

@@ -0,0 +1,365 @@
+#!/bin/bash
+
+_PWDFILE='/www/lib/admin/htpasswd'
+
+_TMP='/tmp'
+_LOG="${_TMP}/admin.log"
+
+_DEBUG=1
+
+## logging
+logThis() {
+  [[ $_DEBUG -gt 0 ]] || return 0
+  [[ $_ERR -gt 0 ]] && _TYPE='E:' || _TYPE='I:'  ## Info or Error indication
+  local _TIME=$(printf '%(%d.%m.%Y %H:%M:%S)T' -1)
+  printf '%b\n' "$_TIME  $_TYPE ${1} " >> $_LOG
+  [[ $_DEBUG -gt 1 ]] && printf '%b\n' "[verbose] $_TYPE ${1}"
+  return 0
+}
+
+## http response
+headerPrint() {
+  case ${1} in
+    200) printf '%b' 'HTTP/1.1 200 OK\nAccess-Control-Allow-Origin: *\n\n';;
+    301) printf '%b' "HTTP/1.1 301 Moved Permanently\nLocation: ${HTTP_REFERER}\n\n";;
+    403) printf '%b' 'HTTP/1.1 403 Forbidden\n\n';;
+    405) printf '%b' 'HTTP/1.1 405 Method Not Allowed\n\n';;
+    406) printf '%b' 'HTTP/1.1 406 Not Acceptable\n\n';;
+  esac
+  return 0
+}
+
+htDigest() {
+  _USER='admin'
+  _PWD=$1
+  _REALM='superglue'
+  _HASH=$(echo -n "$_USER:$_REALM:$_PWD" | md5sum | cut -b -32)
+  echo -n "$_USER:$_REALM:$_HASH"
+}
+
+urlDec() {
+  local value=${*//+/%20}
+  for part in ${value//%/ \\x}; do
+    printf "%b%s" "${part:0:4}" "${part:4}"
+  done
+}
+
+setQueryVars() {
+  local _POST=$(cat)
+  local vars=${_POST//\*/%2A}
+  for var in ${vars//&/ }; do
+    local value=$(urlDec "${var#*=}")
+    value=${value//\\/\\\\}
+    eval "_${var%=*}=\"${value//\"/\\\"}\""
+  done
+}
+
+getQueryFile() {
+  _POST_TMP=$(mktemp -p $_TMP)  ## make tmp POST file
+  cat > $_POST_TMP  ## cautiously storing entire POST in a file
+  logThis "'multipart': decoding stream"
+  local _BND=$(findPostOpt 'boundary')
+  ## bash is binary unsafe and eats away precious lines
+  ## thus using gawk
+  function cutFile() {
+    gawk -v "want=$1" -v "bnd=$_BND" '
+      BEGIN { RS="\r\n"; ORS="\r\n" }
+
+      # reset based on boundaries
+      $0 == "--"bnd""     { st=1; next; }
+      $0 == "--"bnd"--"   { st=0; next; }
+      $0 == "--"bnd"--\r" { st=0; next; }
+
+      # search for wanted file
+      st == 1 && $0 ~  "^Content-Disposition:.* name=\""want"\"" { st=2; next; }
+      st == 1 && $0 == "" { st=9; next; }
+
+      # wait for newline, then start printing
+      st == 2 && $0 == "" { st=3; next; }
+      st == 3 { print $0 }
+      ' 2>&1
+  }
+  cutFile 'fwupload' < "${_POST_TMP}" > "${_TMP}/fwupload.bin"
+}
+
+## find arbitrary option supplied in Content-Type header
+## eg: "Content-Type:application/octet-stream; verbose=1"
+findPostOpt() {
+  for i in "${CONTENT_TYPE[@]:1}"; do
+    case "${i/=*}" in 
+      "$1") printf '%b' "${i/*=}" ;;
+    esac
+  done
+  return 0
+}
+
+runSuid() {
+  local _SID=$(ps -p $$ -o sid=)  ## pass session id to the child
+  local _CMD=$@
+  sudo ./suid.sh $_CMD $_SID 2>&1
+}
+
+pwdChange() {
+  if [[ ! -z "${_pwd##$_pwdd}" ]]; then 
+    _ERR=1
+    showMesg 'Passwords did not match'
+  fi
+
+  if [[ ${#_pwd} -lt 6 ]]; then
+    _ERR=1
+    showMesg 'Password must be at least 6 characters long'
+  fi
+
+  runSuid "echo -e '$_pwd\n$_pwd' | passwd root"
+  runSuid "echo $(htDigest $_pwd) > $_PWDFILE"
+  _ERR=$?
+  if [[ $_ERR -gt 0 ]]; then
+    showMesg 'Password change failed'
+  else
+    showMesg 'Password is changed'
+  fi
+
+}
+
+ssidChange() {
+  ## default enc for now
+  local _enc='psk2'
+  logThis "new ssid is: $_ssid"
+  logThis "new key is: $_key"
+
+  if [[ $_ssid != $_pssid ]]; then
+    if [[ ${#_ssid} -lt 4 ]]; then
+     _ERR=1
+     showMesg 'SSID must be at least 4 characters long'
+    fi
+    setUci ssid $_ssid
+    _ERR=$?
+    [[ $_ERR -gt 0 ]] && showMesg 'New SSID is not set'
+  fi
+
+  if [[ $_key != $_pkey ]]; then 
+    if [[ -z $_key ]]; then
+      ## if key is empty set encryption to none and remove key
+      setUci key && setUci enc 'none'
+      _ERR=$?
+    else
+      if [[ ${#_key} -lt 8 ]]; then
+       _ERR=1
+        showMesg 'Passphrase must be at least 8 characters long'
+      fi
+      setUci key $_key && setUci enc $_enc
+      _ERR=$?
+      [[ $_ERR -gt 0 ]] && showMesg 'Passphrase is not set'
+    fi
+  fi
+
+  [[ $_ERR -gt 0 ]] && showMesg 'Wireless changes failed'
+  commitUci && showMesg 'Wireless changes applied'
+}
+
+#showError() {
+#  headerPrint 406
+#  logThis "$@"
+#  echo "ERROR: $@"
+#  exit 1
+#}
+
+showMesg() {
+  logThis "$@"
+  local _MSG=$1
+  local _SUBMSG=$2
+  _MSG=${_MSG:='Not defined'}
+  _SUBMSG=${_SUBMSG:='back to control panel in a second..'}
+  if [[ $_ERR -gt 0 ]]; then
+    local _TYPE='ERROR: '
+    headerPrint 406
+  else
+    local _TYPE='OK: '
+    headerPrint 200
+  fi
+  htmlHead "<meta http-equiv='refresh' content='5;url=${HTTP_REFERER}'>"
+  echo "<body>
+<img src='/resources/default/img/placeholder.png' class='logo'>
+<hr>
+<h2 style='display:inline'>$_TYPE $_MSG</h2>
+<span style='display:inline; margin-left: 50px;'>$_SUBMSG</span>
+<hr>
+</body></html>"
+  exit 0
+}
+
+updateFw() {
+  logThis "updating fw"
+  _FWFILE="${_TMP}/fwupload.bin"
+  logThis "fwfile is: $(ls -lad $_FWFILE)"
+  _OUT="$(/sbin/sysupgrade -T $_FWFILE 2>&1)"
+  _ERR=$?
+  [[ $_ERR -gt 0 ]] && showMesg "$_OUT"
+#  _OUT="$(runSuid /sbin/mtd -q write $_FWFILE firmware)"
+  _OUT=$(runSuid "ls /root")
+  _ERR=$?
+  [[ $_ERR -gt 0 ]] && showMesg "mtd failed, $_OUT"
+  showMesg 'Firmware update is completed, rebooting..' 'this might take up to 60 seconds'
+  runSuid reboot -w
+}
+
+rebootNow() {
+  logThis "reboot: now!"
+  showMesg 'Rebooting..' 'this might take up to 60 seconds'
+  runSuid reboot -w
+}
+
+getUci() {
+  local _ARG=''
+  case $1 in
+    ssid) _ARG='wireless.@wifi-iface[0].ssid';;
+    enc) _ARG='wireless.@wifi-iface[0].encryption';;
+    key) _ARG='wireless.@wifi-iface[0].key';;
+    *) logThis 'bad uci command'; headerPrint 405; echo 'no such uci command'; exit 1;;
+  esac
+
+  if [ ! -z $_ARG ]; then
+    /sbin/uci get $_ARG
+  fi
+}
+
+setUci() {
+  local _ARG=''
+  case $1 in
+    ssid) _ARG='wireless.@wifi-iface[0].ssid';;
+    enc) _ARG='wireless.@wifi-iface[0].encryption';;
+    key) _ARG='wireless.@wifi-iface[0].key';;
+   *) logThis 'bad uci command'; headerPrint 405; echo 'no such uci command'; exit 1;;
+  esac
+
+  if [ -z $2 ]; then
+    logThis "empty $_ARG value, removing record"
+    runSuid /sbin/uci delete $_ARG || ( echo "uci delete $_ARG: error"; exit 1; )
+  fi
+
+  if [ ! -z $_ARG ]; then
+    logThis "setting $_ARG value"
+    runSuid /sbin/uci set $_ARG=$2 || ( echo "uci set $_ARG: error"; exit 1; )
+  fi
+}
+
+commitUci() {
+  runSuid /sbin/uci commit || echo "uci commit $_ARG: error"
+  runSuid /sbin/wifi || echo 'wifi: error'
+}
+
+htmlHead() {
+echo "<!doctype html>
+<html>
+<head><title>SuperGlue | Administration</title>
+$@
+<script type='text/javascript' src='/resources/default/js/jquery.js'></script>
+<style> 
+body { background:#ccc; color:#000; margin: 20px 0 0 200px; font-family: TitilliumWeb;}
+input { display: block; }
+.inline { display: inline; }
+img.logo { position: absolute; left:50px; top: 20px;}
+pre { white-space: pre-wrap; }
+@font-face { font-family: TitilliumWeb; src: url('/resources/default/fonts/Titillium_Web/TitilliumWeb-Regular.ttf') format('truetype'); }
+@font-face { font-family: TitilliumWeb; font-weight: bold; src: url('/resources/default/fonts/Titillium_Web/TitilliumWeb-Bold.ttf') format('truetype'); }
+</style>
+</head>"
+}
+
+## unless auth is disabled in lighttpd
+## it should never come to this, 
+if [[ -z $HTTP_AUTHORIZATION ]]; then
+  logThis 'no auth'
+  headerPrint 403
+  echo 'no is no'
+  exit 1
+else logThis 'auth OK'
+fi
+
+if [[ $REQUEST_METHOD == 'POST' ]]; then
+  if [[ $CONTENT_LENGTH -gt 0 ]]; then
+    CONTENT_TYPE=( ${CONTENT_TYPE} )
+    _CONTENT_TYPE="${CONTENT_TYPE[0]/;}"
+    _ENC="${HTTP_CONTENT_ENCODING}"
+    logThis $REQUEST_URI
+    logThis $CONTENT_TYPE
+    case "${_CONTENT_TYPE}" in
+      application/x-www-form-urlencoded) setQueryVars;;
+      multipart/form-data) getQueryFile;;
+      *) _ERR=1; _OUT='this is not a post' ;;
+    esac
+
+    case $REQUEST_URI in
+      /admin/pwdchange) pwdChange;;
+      /admin/ssidchange) ssidChange;;
+      /admin/updatefw) updateFw;;
+      /admin/rebootnow) rebootNow;;
+      *) logThis 'bad action'; headerPrint 405; echo 'no such thing'; exit 1;;
+    esac
+  fi
+  headerPrint 301
+fi
+
+
+
+headerPrint 200
+## html head
+htmlHead
+echo "<body>
+<img src='/resources/default/img/placeholder.png' class='logo'>
+<hr>
+<h2 style='display:inline'>Superglue server control panel</h2>
+<span style='display:inline; margin-left: 50px;'>$(uptime)</span>
+<hr>
+
+Change password:
+<form method='post' action='/admin/pwdchange'>
+<input type='text' name='usr' value='admin' readonly>
+<input type='password' name='pwd'>
+<input type='password' name='pwdd'>
+<input type='submit' value='Apply'>
+</form>
+<hr>
+
+Configure wireless network:
+<form method='post' action='/admin/ssidchange'>
+<input type='text' name='ssid' value='$(getUci ssid)'>
+<input type='text' name='key' value='$(getUci key)'>
+<input type='hidden' name='pssid' value='$(getUci ssid)'>
+<input type='hidden' name='pkey' value='$(getUci key)'>
+<input type='submit' value='Apply'>
+</form>
+
+<hr>
+
+Update firmware:
+<form method='post' action='/admin/updatefw' enctype='multipart/form-data'>
+<input type='file' name='fwupload'>
+<input type='submit' id='upload' value='Upload'>
+</form>
+
+<hr>
+
+<form action='/admin/rebootnow' method='post' class='inline'>
+<input type='hidden' name='reboot' value='now' class='inline'>
+<input type='submit' value='Reboot' class='inline'>
+</form>
+
+<form action='http://logout@${HTTP_HOST}/admin' method='get' class='inline'>
+<input type='submit' value='Logout' class='inline'>
+</form>
+
+<hr>
+
+$_POST
+
+Environment:
+<pre>$(env)</pre>
+Memory:
+<pre>$(free)</pre>
+Storage:
+<pre>$(df -h)</pre>
+
+</body></html>"
+
+exit 0

+ 1 - 0
openwrt/DIR505A1/www/lib/admin/htpasswd

@@ -0,0 +1 @@
+admin:superglue:3c91654ae312b9f2f492a8409dcb4a84

+ 0 - 0
openwrt/DIR505A1/etc/lighttpd/htpasswd-dist → openwrt/DIR505A1/www/lib/admin/htpasswd-dist


+ 36 - 0
openwrt/DIR505A1/www/lib/admin/suid.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+
+SHELL=/bin/bash
+
+if [[ $EUID -ne 0 ]]; then echo 'root only'; exit 1; fi
+
+## parent process id
+_PPID=$PPID
+
+## grandparent process id (process that called sudo that called us)
+_GPPID=$(ps -p$PPID -o ppid=)
+
+## grandparent command
+_GPCMD=$(ps -f -p$_GPPID)
+
+## check if called by admin.sh
+if [[ ! $_GPCMD =~ 'admin/admin.sh' ]]; then echo 'bad granny'; exit 1; fi
+
+## get lighttpd session id
+_LSID=$(ps -C lighttpd -o sid=)
+
+## parent session id
+_PSID=${@: -1}
+
+## our session id
+_SID=$(ps -p$$ -o sid=)
+
+## check if we belong to group/session of lighty and admin.sh
+if [ $_LSID != $_PSID -o $_SID != $_LSID ]; then echo 'bad session'; exit 1; fi
+
+## remove _PSID from the arguments
+_ARGS=${@//$_PSID}
+
+eval $_ARGS
+
+exit $?

BIN
openwrt/DIR505A1/www/lib/resources/default/img/placeholder.png


+ 55 - 6
openwrt/DIR505A1/www/lib/resources/index.html

@@ -7,11 +7,60 @@
 		<title>SuperGlue Rocks!</title>
 		<link rel="stylesheet" href="../resources/default/css/normalize.css">
 		<link rel="stylesheet" href="../resources/default/css/style.css">
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
+		<style type="text/css"></style>
 	</head>
-	<body class="space root" data-type="AbsoluteSpace" data-grid-size="29" style="height: 540px; width: 787px; background-color: rgb(153, 151, 161); overflow: visible;"><div class="spaceContent" style="undefined">
-		<div class="space" data-type="GridSpace" data-grid-size="50" style="position: absolute; top: 67px; width: 642px; height: 413px; z-index: 0; margin-left: inherit; left: 115px;"><div class="spaceContent" style="overflow: hidden;">
-			<div class="shape" data-type="TextShape" style="position: absolute; left: 400px; top: 50px; width: 150px; height: 100px; z-index: 1; margin-left: 0px;"><div class="shapeContent" style="display: block;"><span style="font-family: 'Courier New';"><b><span style="font-size: 14px;">Welcome to SuperGlue</span></b></span></div></div>
-			<div class="shape" data-type="ImageShape" style="position: absolute; left: 50px; top: 50px; width: 300px; height: 250px; z-index: 0; margin-left: 0px;"><img class="shapeContent" style="undefined" src="/resources/default/img/placeholder.png"></div>
-		</div></div>
+	<body class="space root" data-type="AbsoluteSpace" data-grid-size="29" style="height: 397px; width: 709px; background-color: rgb(153, 151, 161); overflow: visible;"><div class="spaceContent" style="">
+		<div class="shape" data-type="TextShape" style="position: absolute; left: 365px; top: 294px; width: 124px; height: 43px; z-index: 3; margin-left: 0px;"><div class="shapeContent" style="border-width: 0px; border-color: transparent; background-color: transparent; background-image: none; padding: 0px; display: block; background-repeat: repeat repeat;"><b style="font-family: Dosis; font-size: 32px;"><span style="font-family: Montserrat; font-size: 14px;">IMAGINE HOW</span></b><span style="font-family: Dosis; font-size: 32px;"><b><br></b></span></div></div>
+		<div class="shape" data-type="TextShape" style="position: absolute; left: 427px; top: 177px; width: 252px; height: 43px; z-index: 2; margin-left: inherit;"><div class="shapeContent" style="border-width: 0px; border-color: transparent; background-color: transparent; background-image: none; padding: 0px; display: block; background-repeat: repeat repeat;"><span style="font-size: 32px;"><b><span style="font-size: 40px; font-family: Montserrat;">SUPERGLUE</span><br><br></b></span></div></div>
+		<div class="shape" data-type="TextShape" style="position: absolute; left: 433px; top: 122px; width: 124px; height: 43px; z-index: 1; margin-left: inherit;"><div class="shapeContent" style="border-width: 0px; border-color: transparent; background-color: transparent; background-image: none; padding: 0px; display: block; background-repeat: repeat repeat;"><span style="font-family: Dosis; font-size: 32px;"><b><span style="font-family: Montserrat; font-size: 14px;">DO IT NOW</span><br><br></b></span></div></div>
+		<div class="shape" data-type="ImageShape" style="position: absolute; left: 315px; top: 75px; width: 120px; height: 227px; z-index: 0; margin-left: inherit;"><img class="shapeContent" src="../resources/default/img/placeholder.png"></div>
 	</div></body>
-</html>
+</html>