summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Oberkirch2015-08-09 21:52:12 +1200
committerMilan Oberkirch2015-08-09 21:52:12 +1200
commit285a1571b17040ba03402e653cc43633aa0f0725 (patch)
treee63696c0d7024ba6340eb0eb837e9e45bb315522
downloadaur-285a1571b17040ba03402e653cc43633aa0f0725.tar.gz
AUR 4
-rw-r--r--.SRCINFO15
-rw-r--r--PKGBUILD41
-rwxr-xr-xzenbu-login.bash41
3 files changed, 97 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..5ac8abd7d3d5
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,15 @@
+pkgbase = zenbu-login
+ pkgdesc = Automates login to zenbu.net.nz wifi networks.
+ pkgver = 0.01
+ pkgrel = 0
+ url = http://oberkirch.org
+ arch = any
+ license = GPL3
+ makedepends = git
+ depends = curl
+ depends = bash
+ depends = grep
+ backup = etc/zenbu-login
+
+pkgname = zenbu-login
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..bce2c0ef194d
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,41 @@
+# Maintainer: Milan Oberkirch <aur@oberkirch.org>
+pkgname=zenbu-login
+pkgver=0.01
+pkgrel=0
+pkgdesc="Automates login to zenbu.net.nz wifi networks."
+arch=('any')
+url="http://oberkirch.org"
+license=('GPL3')
+depends=('curl' 'bash' 'grep')
+backup=('etc/zenbu-login')
+makedepends=('git')
+md5sums=()
+
+_gitroot="git@github.com:zvyn/zenbu-login.git"
+_gitname=zenbu-login
+
+build() {
+ cd "$srcdir"
+ msg "Connecting to GIT server...."
+
+ if [[ -d "$_gitname" ]]; then
+ cd "$_gitname" && git pull origin
+ msg "The local files are updated."
+ else
+ git clone "$_gitroot" "$_gitname"
+ fi
+
+ msg "GIT checkout done or server timeout"
+}
+
+package() {
+ mkdir -p "${pkgdir}/etc" "${pkgdir}/usr/bin"
+ cp "$srcdir/$_gitname/zenbu-login.bash" "${pkgdir}/usr/bin/zenbu-login"
+ chmod +x "${pkgdir}/usr/bin/zenbu-login"
+ cat <<EndOfFile > "${pkgdir}/etc/zenbu-login"
+username=
+password=
+EndOfFile
+}
+
+# vim:set ts=2 sw=2 et:
diff --git a/zenbu-login.bash b/zenbu-login.bash
new file mode 100755
index 000000000000..d37003164a07
--- /dev/null
+++ b/zenbu-login.bash
@@ -0,0 +1,41 @@
+#!/bin/bash
+set -e
+__NAME__="zenbu-login"
+
+function zenbu-login () {
+ post_data="form_request=login&gw_address=10.10.24.1&gw_port=2060&gw_id=ZenBu10289&mac=EC%3A0E%3AC4%3A1C%3A8E%3A2F&auth_source=default-network&username=$username&password=$password&form_submit=login"
+ url="$(curl\
+ -H 'Content-Type: application/x-www-form-urlencoded'\
+ -d ${post_data}\
+ https://secure.zenbu.net.nz/login/ \
+ 2>/dev/null\
+ | egrep -o 'http://.*url=' -m 1)"
+ curl "$url" &> /dev/null
+}
+
+# execute if called directly
+if grep -q "${__NAME__}" <<< "$0"; then
+ usage="Usage: $0 [[username] [password/code]\n\
+ You can define username and password in /etc/${__NAME__}"
+ if egrep -q "[[:alnum:]]+" <<< "$1"; then
+ if [ "$2" ]; then
+ username="$1"
+ password="$2"
+ else
+ username=""
+ password="$1"
+ fi
+ else
+ if [ "$1" ]; then
+ echo -e ${usage}
+ exit 1
+ fi
+ # the following file should define 2 variables: $username and $password
+ source /etc/"${__NAME__}"
+ if [ -z "$password" ]; then
+ echo -e ${usage}
+ exit 1
+ fi
+ fi
+ ${__NAME__}
+fi