From 925c00e41d5634e702f32e85165db739280680d8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 21 Nov 2016 21:57:28 +0100 Subject: [PATCH] initial import --- archupdates | 12 ++++++++++++ container | 3 +++ gmail | 25 +++++++++++++++++++++++++ whatismyip | 11 +++++++++++ 4 files changed, 51 insertions(+) create mode 100755 archupdates create mode 100755 container create mode 100755 gmail create mode 100755 whatismyip diff --git a/archupdates b/archupdates new file mode 100755 index 0000000..b6ceee1 --- /dev/null +++ b/archupdates @@ -0,0 +1,12 @@ +#!/bin/sh +# Arch upgradeable packages + +list=`pacman -Sup 2> /dev/null` + +if [ "$list" == ":: Starting full system upgrade..." ]; then + count="" +else + count=`echo "$list" | wc -l` +fi + +echo "$count" diff --git a/container b/container new file mode 100755 index 0000000..fd54121 --- /dev/null +++ b/container @@ -0,0 +1,3 @@ +#!/bin/sh + +docker ps -q | wc -l | sed -r 's/^0$//g' diff --git a/gmail b/gmail new file mode 100755 index 0000000..ddeabde --- /dev/null +++ b/gmail @@ -0,0 +1,25 @@ +#!/bin/bash + +# Requires https://www.google.com/settings/security/lesssecureapps for gmail. + +CONFIG_FILE="${BLOCK_INSTANCE}" +CONFIG_FILE=${CONFIG_FILE/\~/$HOME} + +# Config file needs the following settings: +#MAIL_USER="user@domain.tld" +#MAIL_PASSWORD="secret" + +if [[ ! -f "${CONFIG_FILE}" ]]; then + echo "${CONFIG_FILE}" + exit 33 +fi + +source "${CONFIG_FILE}" + +COUNT=`curl -su $MAIL_USER:$MAIL_PASSWORD https://mail.google.com/mail/feed/atom || echo "unknown number of"` +COUNT=`echo "$COUNT" | grep -oPm1 "(?<=)[^<]+" ` +if [ "$COUNT" = "0" ]; then + echo "" +else + echo $COUNT +fi diff --git a/whatismyip b/whatismyip new file mode 100755 index 0000000..ffcb0bb --- /dev/null +++ b/whatismyip @@ -0,0 +1,11 @@ +#!/bin/sh + +ip=$(curl -s icanhazip.com); + +if [[ "$BLOCK_BUTTON" -eq 1 ]]; +then + netname=$(whois $ip | grep '^netname:' | awk '{print $2}' | tail -1); + echo "$netname" +else + echo "$ip" +fi