Browse Source

RC 2015 2

Danja Vasiliev 10 years ago
parent
commit
a956b00e6d

+ 6 - 0
openwrt/common/etc/config/superglue

@@ -0,0 +1,6 @@
+config superglue 'dyndns'
+	option disabled '1'
+	option domain ''
+	option token ''
+	option connect 'auto'
+

BIN
openwrt/common/etc/crontabs/.root.swp


+ 1 - 0
openwrt/common/etc/hotplug.d/block/12-sg-btrfs

@@ -0,0 +1 @@
+/opt/lib/scripts/sg-data-mount.sh

BIN
openwrt/common/etc/lighttpd/.lighttpd.conf.swo


BIN
openwrt/common/opt/lib/cgi/.admin2.cgi.swn


BIN
openwrt/common/opt/lib/cgi/.admin2.cgi.swo


BIN
openwrt/common/opt/lib/cgi/.admin2.cgi.swp


BIN
openwrt/common/opt/lib/cgi/.post.cgi.swp


BIN
openwrt/common/opt/lib/resources/admin/.admin.css.swp


BIN
openwrt/common/opt/lib/resources/admin/.admin.js.swo


BIN
openwrt/common/opt/lib/resources/admin/.admin.js.swp


BIN
openwrt/common/opt/lib/scripts/.dyndns-update.sh.swp


BIN
openwrt/common/opt/lib/scripts/.iw-scan.sh.swo


BIN
openwrt/common/opt/lib/scripts/.iw-scan.sh.swp


BIN
openwrt/common/opt/lib/scripts/.jshn-helper.sh.swn


BIN
openwrt/common/opt/lib/scripts/.jshn-helper.sh.swo


BIN
openwrt/common/opt/lib/scripts/.jshn-helper.sh.swp


BIN
openwrt/common/opt/lib/scripts/.sg-data-dirs.sh.swp


BIN
openwrt/common/opt/lib/scripts/.sg-data-mount.sh.swp


BIN
openwrt/common/opt/lib/scripts/.usb-part.sh.swp


+ 12 - 0
openwrt/common/opt/lib/scripts/dyndns-update.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+uci -q get superglue.dyndns.disabled && exit 0
+
+set -e
+_UPDATEURL=$(uci get superglue.dyndns.updateurl)
+_TOKEN=$(uci get superglue.dyndns.token)
+set +e
+
+/usr/bin/wget -q "${_UPDATEURL}${_TOKEN}" -O - >> /www/log/dyndns.log
+
+exit 0

+ 44 - 0
openwrt/common/opt/lib/scripts/sg-data-dirs.sh

@@ -0,0 +1,44 @@
+#!/bin/ash
+
+## 'sg-data' partition should be already mounted here
+_WWW='/www'
+
+## check is /www in mounted 
+## for as long as 30 seconds
+n=0
+while ! mountpoint -q $_WWW; do [ $n -gt 30 ] && exit 1;
+  sleep 1
+  let n++
+done
+unset n
+
+_HTDOCS="$_WWW/htdocs"
+
+## make ./htdocs if there is none
+[ -e $_HTDOCS ] || mkdir $_HTDOCS
+## if not writable chown with httpd
+[ $(stat $_HTDOCS -c %U) == 'httpd' ] || chown -R httpd $_HTDOCS
+[ ! $(stat $_HTDOCS -c %a) -lt '755' ] || chmod -R u+rwX $_HTDOCS
+
+## check if index.html is present
+[ -e $_HTDOCS/index.html ] || (
+  cp /opt/lib/resources/demo.html $_HTDOCS/default.html
+  chown httpd $_HTDOCS/default.html 
+  )
+
+## check for log directory
+[ -e $_WWW/log ] || (
+  mkdir $_WWW/log
+  chown httpd $_WWW/log
+  )
+
+## check for tmp directory
+[ -e $_WWW/tmp ] || (
+  mkdir $_WWW/tmp
+  chown httpd $_WWW/tmp
+  )
+
+## reload Lighttpd since it might have had open files in /www
+killall -HUP lighttpd
+
+exit 0

+ 57 - 0
openwrt/common/opt/lib/scripts/sg-data-mount.sh

@@ -0,0 +1,57 @@
+#!/bin/ash
+
+## handling of Btrfs partition
+##
+## parse blkid output 
+## find Btrfs partition with 'sg-data' label
+## mount it to /www
+
+_TARGET_LABEL='sg-data'
+_TARGET_MOUNT='/www'
+_MOUNT_PARAMS='rw,noatime,nodiratime,sync'
+
+detectBtrfs() {
+  IFS=$'\n'
+  local _P _L
+  for _L in $(blkid); do
+    IFS=' '
+    for _P in $_L; do
+      if [ "${_P//dev/}" != "${_P}" ]; then
+        _DEV="${_P/:}"
+      else 
+        eval "_${_P/=*}=\"${_P/*=/}\""
+      fi
+      if [ "$_TYPE" != "" ] && [ -z "${_TYPE/btrfs}" ] && [ -z "${_LABEL/$1}" ]; then
+        #echo "$_DEV $_UUID"
+        return 0
+      fi
+    done
+  done
+  IFS=$OFS
+  return 1
+}
+
+if mountpoint -q $_TARGET_MOUNT; then
+  echo "/www is already a mountpoint"
+  exit 1
+fi
+
+if ! detectBtrfs $_TARGET_LABEL; then 
+  echo "no Btrfs partition with label $_TARGET_LABEL was found"
+  exit 1
+fi
+
+if ! mount -o $_MOUNT_PARAMS $_DEV $_TARGET_MOUNT; then
+  echo "error mounting $_DEV partition"
+  exit 1
+fi
+
+if ! mountpoint -q $_TARGET_MOUNT; then
+  echo "$_TARGET_MOUNT is not a mountpoint.."
+  exit 1
+fi
+
+## reload Lighttpd since it might have had open files in /www
+killall -HUP lighttpd
+
+exit 0

+ 107 - 0
openwrt/common/opt/lib/scripts/usb-part.sh

@@ -0,0 +1,107 @@
+#!/bin/bash
+
+## SuperGlue project | http://superglue.it | 2014 | GPLv3
+## http://git.superglue.it/superglue/serverfiles
+##
+## usb-part.sh - partition USB storage device
+
+# - detect the last USB attached disk drive
+# - check for sg-data partition
+
+# - if sg-data not mounted but device is present, then
+#   offer to format device
+
+findUsbstor() {
+  local _P='/sys/block/'
+  local _D _DEV
+  for _D in ${_P}sd*; do
+    _DEV=$(readlink -f ${_D}/device)
+    if [[ ${_DEV/usb} != $_DEV ]]; then
+      _USBDEV="/dev/${_D/$_P}"
+    fi
+  done
+  [[ $_USBDEV ]] || return 1
+}
+
+findMount() {
+  local _M
+  IFS=$'\n'
+  for _M in $(mount); do 
+    if [[ "$_M" != "${_M/"$_USBDEV"}" ]]; then 
+      IFS=' ' _M=( $_M )
+      _USBMNT="${_M[0]}"
+    fi
+  done
+  [[ $_USBMNT ]] || return 1
+}
+
+## partitions layout for sfdisk
+## /dev/sdx1 64K, fat32
+## TODO: define swap size according to ram
+## /dev/sdx2 32M, swap v1 
+## /dev/sdx3 rest of the disk, linux partition
+_PARTITIONS="unit: sectors
+
+${_DEV}1 : start=     2048, size=      128, Id= b
+${_DEV}2 : start=     4096, size=    65536, Id=82
+${_DEV}3 : start=    69632, size=         , Id=83
+${_DEV}4 : start=        0, size=        0, Id= 0
+"
+
+## base64 encoded gzip'ed image of /dev/sdx1 FAT32 partition
+_FAT_README='H4sICC5ykVQAA3NkYjEuZGQA7d3PaxNpGMDxp1VQI1FxYcWD+FRB8DJp68KCiFBxXAS1tUn8gSC8
+7bxtZ5vMhJm3pgVxvSzsSezJi3+BePQmiAevPfof2FNFPHra7DtNo1VUSgWL7veTvDzv+z7zPplM
+YCAE8q6cut+cncqDKeOkf3uf9Ev/XXnXJ6f9Q3bKqrty/N7DQ2+q9bFw/I8L9VD13EhtaFhV9xx+
+duP24yPP3e4rT/Y83SFL+26uvB1+tfTr0sGVf2szca7+maROjU6kqTMTDatRnM8GqmMNa3KrcZLb
+7KP8VCNttRbUJFG51Mpsnvvugs7aBXWpusxnpk2caBAEWi4JvkX90btO58PwbefLh+KnxOf//7bu
+pu7v9i9uLYaLYTd288ttafnQ8fbKsc463cnlQDKxYiQSn2/6biBO5n0T38tlORw5ezG8M1S9OqYi
+U+1u/SJuExkUGemtbvr1+frV3frjq+tVa9dqKpFdW/9yfjHcJf8U5/e+/jVff2gtX8StuZ4AAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzExOCV8xf19+C3YrDvw/zlAyKRSf40G6jRbrc39FqVpo1i
+U1ktW3n/x0OVzJqoaQM37zbzBgBsUFlODA8NFr2jRwb0l/31rT4hAAAAAN+Ra/XJXz72r423r8W+
+TyIAAAAAAPhxmUjk+l6Rv30rfv/vff9/7cdLvj3o5QAAAAAAwLdpz8STM8VW6XP5nGk0FlTquc10
+Mk2cTVyRaKSTxtlI00SN5rZlMj/UMy47V1U/cLGL00R6O65X51o2m27MWY2M88e7NDPTVs6O6qXR
+mtaroY6O68iFWjj+ubmBAf16oXKpVC5t6gyLheXSjHOtk5VK3isexI6N3AEAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwJb5D53OGNgAAAEA'
+
+if ! findUsbstor; then
+  echo 'USB device not found'
+  exit 1
+fi
+
+if findMount; then
+  #umount -f ${_USBDEV}[1-9] 2>&1
+  echo 'unmounting'
+  umount -f $_USBMNT 2>&1
+  if [[ $? -gt 0 ]]; then
+    echo 'error unmounting'
+    exit 1
+  fi
+fi
+
+swapoff -a &>/dev/null
+
+sfdisk -D -f -q $_USBDEV <<< "$_PARTITIONS"
+if [[ $? -gt 0 ]]; then
+  echo 'error making partitions'
+  exit 1
+fi
+
+(echo -n "$_FAT_README" | base64 -d | gunzip -c > ${_USBDEV}1)
+if [[ $? -gt 0 ]]; then
+  echo 'error cloning FAT readme partition'
+  exit 1
+fi
+
+mkswap ${_USBDEV}2
+if [[ $? -gt 0 ]]; then
+  echo 'error making swap'
+  exit 1
+fi
+
+mkfs.btrfs -L sg-data ${_USBDEV}3
+if [[ $? -gt 0 ]]; then
+  echo 'error making Btrfs'
+  exit 1
+fi
+
+exit 0

+ 0 - 0
openwrt/md5sums


+ 7 - 0
openwrt/usb_stor.sfdisk

@@ -0,0 +1,7 @@
+# partition table of /dev/sdb
+unit: sectors
+
+/dev/sdb1 : start=     2048, size=      128, Id= b
+/dev/sdb2 : start=     4096, size=    65536, Id=82
+/dev/sdb3 : start=    69632, size=  3862528, Id=83
+/dev/sdb4 : start=        0, size=        0, Id= 0

BIN
openwrt/usb_stor_fat.gz