commit 8c8798b0362e1609e491618bbc73ef159694c8c6 Author: Markus Birth Date: Thu Mar 21 01:54:15 2013 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..135d120 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# files with sensible data +fbclient/callclient.log +fbclient/callclient.list +CONFIG +notify-xmpp.py +*.mac + + +# files pointing to scripts outside +trid diff --git a/CONFIG.example b/CONFIG.example new file mode 100644 index 0000000..3d31051 --- /dev/null +++ b/CONFIG.example @@ -0,0 +1,7 @@ +# enter settings and rename to CONFIG + +NMA_RECIPIENT=012345...NotifyMyAndroid-API-KEY...6789abcdef +PROWL_RECIPIENT=012345...Prowl API Key...6789abcdef + +# URL to WatchGuard auth page +WATCHGUARD_URL="https://192.168.1.1:4100" diff --git a/X11-dual-screen-fix.sh b/X11-dual-screen-fix.sh new file mode 100755 index 0000000..efdfdb9 --- /dev/null +++ b/X11-dual-screen-fix.sh @@ -0,0 +1,7 @@ +#!/bin/sh +echo Switching position of displays +xrandr --output VGA-0 --right-of LVDS +echo Switching off ext. display +xrandr --output VGA-0 --off +echo Switching back to normal +xrandr --output VGA-0 --mode 1280x1024 --rate 75 --left-of LVDS diff --git a/X11-ext-refresh-rate.sh b/X11-ext-refresh-rate.sh new file mode 100755 index 0000000..83a1bb7 --- /dev/null +++ b/X11-ext-refresh-rate.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo Setting refresh rate to 75 Hz +xrandr --output VGA-0 --mode 1280x1024 --rate 75 --left-of LVDS diff --git a/X11-int-refresh-rate.sh b/X11-int-refresh-rate.sh new file mode 100755 index 0000000..b6039ea --- /dev/null +++ b/X11-int-refresh-rate.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo Setting refresh rate to 60 Hz +xrandr --output LVDS --mode 1024x768 --rate 60 diff --git a/and-backup.sh b/and-backup.sh new file mode 100755 index 0000000..a794ea5 --- /dev/null +++ b/and-backup.sh @@ -0,0 +1,7 @@ +#!/bin/sh +ANDROID_SDK=/opt/android-sdk +if [ -z "$1" ]; then + echo "Syntax: $0 PACKAGE" + exit 1; +fi +$ANDROID_SDK/platform-tools/adb backup -f "$1.ab" -apk "$1" diff --git a/and-market-chrome.sh b/and-market-chrome.sh new file mode 100755 index 0000000..055abe5 --- /dev/null +++ b/and-market-chrome.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# Make sure you installed the Chrome Extension +# from: http://codekiem.com/2012/02/24/apk-downloader/ +chromium-browser --ignore-certificate-errors --allow-running-insecure-content diff --git a/and-rename-apks.php b/and-rename-apks.php new file mode 100755 index 0000000..eab9c24 --- /dev/null +++ b/and-rename-apks.php @@ -0,0 +1,111 @@ +#!/usr/bin/php -q + $file, + 'size' => filesize( $file ), + 'md5' => md5_file( $file ), + 'date' => date( 'Y-m-d', filemtime( $file ) ), + ); + foreach ( $out as $line ) { + if ( strpos( $line, ':' ) === false ) continue; // skip empty data keys + list( $label, $data ) = explode( ':', $line, 2 ); + if ( $data{0} == "'" ) { + // simple string + $data = substr( $data, 1, -1 ); + } elseif ( $data{0} == ' ' ) { + // looks like array + + // parse array parts + $data_parts = array(); + $part = ''; + $in_string = false; + for ($i=0;$i ' . $newname . ' '; + $result = rename( $file, dirname($file) . '/' . $newname ); + if ( $result ) echo '[OK]'; else echo '[ERROR!]'; + echo PHP_EOL; + } else { + echo $bname . ' skipped.' . PHP_EOL; + } +} + +exit; + +?> \ No newline at end of file diff --git a/apedel.py b/apedel.py new file mode 100755 index 0000000..bbdf3ca --- /dev/null +++ b/apedel.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +import sys +import mutagen.apev2 +for p in sys.argv: + try: + mutagen.apev2.delete(p) + except Exception, e: + print e diff --git a/apt-getkey.sh b/apt-getkey.sh new file mode 100755 index 0000000..cbb6223 --- /dev/null +++ b/apt-getkey.sh @@ -0,0 +1,13 @@ +#!/bin/bash +while [ "$1" ]; do + KEYID=${1:-8} + #echo Fetching key $KEYID ... + #gpg --keyserver keyserver.ubuntu.com --recv $KEYID + #echo Importing into apt-key ... + #gpg --export --armor $KEYID | sudo apt-key add - + echo Importing key $KEYID into apt-key ... + sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com $KEYID + #sudo apt-key adv --recv-keys --keyserver wwwkeys.de.pgp.net $KEYID + shift +done + diff --git a/asfbin b/asfbin new file mode 100755 index 0000000..1bcd40d Binary files /dev/null and b/asfbin differ diff --git a/beep.sh b/beep.sh new file mode 100755 index 0000000..f1be607 --- /dev/null +++ b/beep.sh @@ -0,0 +1,2 @@ +#!/bin/sh +beep -f 400 -l 100 -r 3 -d 50 diff --git a/binoffset b/binoffset new file mode 100755 index 0000000..62ac7ed Binary files /dev/null and b/binoffset differ diff --git a/binoffset.c b/binoffset.c new file mode 100644 index 0000000..1a2e39b --- /dev/null +++ b/binoffset.c @@ -0,0 +1,163 @@ +/*************************************************************************** + * binoffset.c + * (C) 2002 Randy Dunlap + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# binoffset.c: +# - searches a (binary) file for a specified (binary) pattern +# - returns the offset of the located pattern or ~0 if not found +# - exits with exit status 0 normally or non-0 if pattern is not found +# or any other error occurs. + +****************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VERSION "0.1" +#define BUF_SIZE (16 * 1024) +#define PAT_SIZE 100 + +char *progname; +char *inputname; +int inputfd; +unsigned int bix; /* buf index */ +unsigned char patterns [PAT_SIZE] = {0}; /* byte-sized pattern array */ +int pat_len; /* actual number of pattern bytes */ +unsigned char *madr; /* mmap address */ +size_t filesize; +int num_matches = 0; +off_t firstloc = 0; + +void usage (void) +{ + fprintf (stderr, "%s ver. %s\n", progname, VERSION); + fprintf (stderr, "usage: %s filename pattern_bytes\n", + progname); + fprintf (stderr, " [prints location of pattern_bytes in file]\n"); + exit (1); +} + +void get_pattern (int pat_count, char *pats []) +{ + int ix, err, tmp; + +#ifdef DEBUG + fprintf (stderr,"get_pattern: count = %d\n", pat_count); + for (ix = 0; ix < pat_count; ix++) + fprintf (stderr, " pat # %d: [%s]\n", ix, pats[ix]); +#endif + + for (ix = 0; ix < pat_count; ix++) { + tmp = 0; + err = sscanf (pats[ix], "%5i", &tmp); + if (err != 1 || tmp > 0xff) { + fprintf (stderr, "pattern or value error in pattern # %d [%s]\n", + ix, pats[ix]); + usage (); + } + patterns [ix] = tmp; + } + pat_len = pat_count; +} + +void search_pattern (void) +{ + for (bix = 0; bix < filesize; bix++) { + if (madr[bix] == patterns[0]) { + if (memcmp (&madr[bix], patterns, pat_len) == 0) { + if (num_matches == 0) + firstloc = bix; + num_matches++; + } + } + } +} + +#ifdef NOTDEF +size_t get_filesize (int fd) +{ + off_t end_off = lseek (fd, 0, SEEK_END); + lseek (fd, 0, SEEK_SET); + return (size_t) end_off; +} +#endif + +size_t get_filesize (int fd) +{ + int err; + struct stat stat; + + err = fstat (fd, &stat); + fprintf (stderr, "filesize: %ld\n", err < 0 ? (long)err : stat.st_size); + if (err < 0) + return err; + return (size_t) stat.st_size; +} + +int main (int argc, char *argv []) +{ + progname = argv[0]; + + if (argc < 3) + usage (); + + get_pattern (argc - 2, argv + 2); + + inputname = argv[1]; + + inputfd = open (inputname, O_RDONLY); + if (inputfd == -1) { + fprintf (stderr, "%s: cannot open '%s'\n", + progname, inputname); + exit (3); + } + + filesize = get_filesize (inputfd); + + madr = mmap (0, filesize, PROT_READ, MAP_PRIVATE, inputfd, 0); + if (madr == MAP_FAILED) { + fprintf (stderr, "mmap error = %d\n", errno); + close (inputfd); + exit (4); + } + + search_pattern (); + + if (munmap (madr, filesize)) + fprintf (stderr, "munmap error = %d\n", errno); + + if (close (inputfd)) + fprintf (stderr, "%s: error %d closing '%s'\n", + progname, errno, inputname); + + fprintf (stderr, "number of pattern matches = %d\n", num_matches); + if (num_matches == 0) + firstloc = ~0; + printf ("%ld\n", firstloc); + fprintf (stderr, "%ld\n", firstloc); + + exit (num_matches ? 0 : 2); +} + +/* end binoffset.c */ diff --git a/bp_lock.sh b/bp_lock.sh new file mode 100755 index 0000000..05df8cd --- /dev/null +++ b/bp_lock.sh @@ -0,0 +1,10 @@ +#!/bin/sh +beep -f 1200 -d 50 -l 100 -r 3 -n -f 800 -l 100 +amixer -c 0 set Master Playback mute +rhythmbox-client --no-start --pause +MPC_SONG=`mpc current` +if [ -n "$MPC_SONG" ]; then + mpc pause +fi +motion >/dev/null 2>&1 & +gnome-screensaver-command -l diff --git a/bp_ssl_lock.sh b/bp_ssl_lock.sh new file mode 100755 index 0000000..0f01a9b --- /dev/null +++ b/bp_ssl_lock.sh @@ -0,0 +1,8 @@ +#!/bin/sh +amixer -c 0 set Master Playback mute +rhythmbox-client --no-start --pause +MPC_SONG=`mpc current` +if [ -n "$MPC_SONG" ]; then + mpc pause +fi +gnome-screensaver-command -l diff --git a/bp_ssl_unlock.sh b/bp_ssl_unlock.sh new file mode 100755 index 0000000..a64bbb9 --- /dev/null +++ b/bp_ssl_unlock.sh @@ -0,0 +1,8 @@ +#!/bin/sh +gnome-screensaver-command -d +amixer -c 0 set Master Playback unmute +rhythmbox-client --no-start --play --no-present --notify +#MPC_SONG=`mpc current` +#if [ -n "$MPC_SONG" ]; then +# mpc play +#fi diff --git a/bp_unlock.sh b/bp_unlock.sh new file mode 100755 index 0000000..8ac0f88 --- /dev/null +++ b/bp_unlock.sh @@ -0,0 +1,10 @@ +#!/bin/sh +gnome-screensaver-command -d +killall motion +amixer -c 0 set Master Playback unmute +rhythmbox-client --no-start --play --no-present --notify +MPC_SONG=`mpc current` +if [ -n "$MPC_SONG" ]; then + mpc play +fi +beep -f 800 -d 50 -l 100 -r 3 -n -f 1200 -l 100 diff --git a/bridge-remove.sh b/bridge-remove.sh new file mode 100755 index 0000000..f0b902d --- /dev/null +++ b/bridge-remove.sh @@ -0,0 +1,8 @@ +#!/bin/sh +ifconfig br0 down +brctl delif br0 wlan0 +brctl delif br0 eth0 +brctl delbr br0 +ifconfig wlan0 -promisc up +ifconfig eth0 -promisc up +dhclient wlan0 diff --git a/bridge.sh b/bridge.sh new file mode 100755 index 0000000..702016c --- /dev/null +++ b/bridge.sh @@ -0,0 +1,12 @@ +#!/bin/sh +ifconfig eth0 0.0.0.0 promisc up +ifconfig wlan0 0.0.0.0 promisc up +brctl addbr br0 +brctl addif br0 eth0 +brctl addif br0 wlan0 +#ip link set br0 up +#ip addr add 192.168.0.235/24 brd + dev br0 +#route add default gw 192.168.0.40 dev br0 +ifconfig br0 up +echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding +dhclient br0 diff --git a/bzIunpack.sh b/bzIunpack.sh new file mode 100755 index 0000000..efe48c0 --- /dev/null +++ b/bzIunpack.sh @@ -0,0 +1,17 @@ +#! /bin/bash -x +# extracts .config info from a [b]zImage file +# uses: binoffset (new), dd, zcat, strings, grep +# $arg1 is [b]zImage filename + +HDR=`./binoffset $1 0x1f 0x8b 0x08 0x0` +PID=$$ +TMPFILE="$1.vmlin.$PID" + +# dd if=$1 bs=1 skip=$HDR | zcat - | strings /dev/stdin \ +# | grep "[A-Za-z_0-9]=[ynm]$" | sed "s/^/CONFIG_/" > $1.oldconfig.$PID +# exit + +dd if=$1 bs=1 skip=$HDR | zcat - > $TMPFILE +#strings $TMPFILE | grep "^[\#[:blank:]]*CONFIG_[A-Za-z_0-9]*" > $1.oldconfig.$PID +#wc $1.oldconfig.$PID +#rm $TMPFILE \ No newline at end of file diff --git a/checkinst.sh b/checkinst.sh new file mode 100755 index 0000000..e465882 --- /dev/null +++ b/checkinst.sh @@ -0,0 +1,10 @@ +#!/bin/sh +#cat configure | grep PACKAGE_NAME | sed + +PKG_NAME=`cat configure | grep "PACKAGE_NAME=" | sed -r "s/^.*=['\"]?([^'\"]*)['\"]?$/\1/g"` +PKG_VERSION=`cat configure | grep "PACKAGE_VERSION=" | sed -r "s/^.*=['\"]?([^'\"]*)['\"]?$/\1/g"` +PKG_OLDCODE=`ls -1vr ./${PKG_NAME}_${PKG_VERSION}* | head -n 1 | sed -r "s/^.*${PKG_NAME}_${PKG_VERSION}-(.*)_.*$/\1/g"` +PKG_CODE=`expr $PKG_OLDCODE + 1` +SPEC_FILE=`ls -1r ./*.spec` +echo "Package: ${PKG_NAME}_${PKG_VERSION}-${PKG_CODE}" +checkinstall --maintainer="markus@birth-online.de" --pkgname="$PKG_NAME" --pkgversion="$PKG_VERSION" --pkgrelease="$PKG_CODE" --requires="xsel" diff --git a/chromeclean.sh b/chromeclean.sh new file mode 100755 index 0000000..9bbe163 --- /dev/null +++ b/chromeclean.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +CHROMEDIR=~/.cache/chromium +CHROMECLEANDIRS="Cache" + +for CHROMECDIR in $CHROMECLEANDIRS; do + DIR=$CHROMEDIR/$CHROMECDIR + echo $DIR + find $DIR -atime +14 -exec rm {} \; +done diff --git a/clamscan.sh b/clamscan.sh new file mode 100755 index 0000000..743a1da --- /dev/null +++ b/clamscan.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Fred Blaise +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA + +FILE=/tmp/$$_outclam.tmp +clamdscan - 1>$FILE + +if [ $? -eq 1 ]; then + STRING=$(grep "FOUND" $FILE |cut -d: -f2) + zenity --warning --title="Evolution: Virus detected" --text="$STRING" & + + exit 1 +fi + +exit 0 diff --git a/db-dump b/db-dump new file mode 100755 index 0000000..0914122 --- /dev/null +++ b/db-dump @@ -0,0 +1,5 @@ +#!/bin/sh +STAMP=`date +"%Y%m%d-%H%M%S"` +OUTPUT=mysql-$1_$STAMP.sql.gz +echo "Dumping database $1 to $OUTPUT ..." +mysqldump -e "$@" | gzip -f --rsyncable >$OUTPUT diff --git a/db-fulldump b/db-fulldump new file mode 100755 index 0000000..ae4be39 --- /dev/null +++ b/db-fulldump @@ -0,0 +1,5 @@ +#!/bin/sh +STAMP=`date +"%Y%m%d-%H%M%S"` +OUTPUT=mysql-ALL_$STAMP.sql.gz +echo "Dumping COMPLETE SQL STORE to $OUTPUT ..." +mysqldump -A -e "$@" | gzip -f --rsyncable >$OUTPUT diff --git a/db-import b/db-import new file mode 100755 index 0000000..168587d --- /dev/null +++ b/db-import @@ -0,0 +1,4 @@ +#!/bin/sh +NEWEST=`ls -1r mysql-$1_*.sql.gz | head -1` +echo "Importing newest backup $NEWEST to database $1 ..." +gunzip -f -c "$NEWEST" | mysql "$@" diff --git a/deb-edit-control.py b/deb-edit-control.py new file mode 100755 index 0000000..deacbaf --- /dev/null +++ b/deb-edit-control.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +# Text editor to use (uncomment only one, if more the last one will be used): +# editor = "gedit" +# editor = "kate" +# editor = "kwrite" +# editor = "mousepad" +editor = "mcedit" + + + +### STOP HERE ### + +import sys, os + +def checkDeb(s): + if s.find(".deb") != -1: + try: + f = open(s) + f.close() + except IOError: + return False + return True + return False + +if len(sys.argv) != 2 or not checkDeb(sys.argv[1]): + print "__DEB Dependencies Hacker__ by RickDesantis" + print "Give me the name of the existing deb file:" + print "\t%s %s" % (sys.argv[0][sys.argv[0].rfind("/")+1:], "") + exit(-1) + +deb = sys.argv[1] +ftmp = "tmpdir" +hdeb = "%s.modified.deb" % deb[0:deb.find(".deb")] + +os.system("dpkg-deb -x %s %s" % (deb, ftmp)) +os.system("dpkg-deb --control %s %s/DEBIAN" % (deb, ftmp)) +os.system("%s %s/DEBIAN/control" % (editor, ftmp)) +os.system("dpkg -b %s %s" % (ftmp, hdeb)) diff --git a/deb-edit-control.sh b/deb-edit-control.sh new file mode 100755 index 0000000..f6d280e --- /dev/null +++ b/deb-edit-control.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +EDITOR=mcedit + +if [[ -z "$1" ]]; then + echo "Syntax: $0 debfile" + exit 1 +fi + +DEBFILE="$1" +TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1 +OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb + +if [[ -e "$OUTPUT" ]]; then + echo "$OUTPUT exists." + rm -r "$TMPDIR" + exit 1 +fi + +dpkg-deb -x "$DEBFILE" "$TMPDIR" +dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN + +if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then + echo DEBIAN/control not found. + + rm -r "$TMPDIR" + exit 1 +fi + +CONTROL="$TMPDIR"/DEBIAN/control + +MOD=`stat -c "%y" "$CONTROL"` +$EDITOR "$CONTROL" + +if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then + echo Not modfied. +else + echo Building new deb... + dpkg -b "$TMPDIR" "$OUTPUT" +fi + +rm -r "$TMPDIR" diff --git a/delayrun.sh b/delayrun.sh new file mode 100755 index 0000000..9a0f0bc --- /dev/null +++ b/delayrun.sh @@ -0,0 +1,4 @@ +#!/bin/sh +sleep $1 +shift +$@ diff --git a/dmg2iso.pl b/dmg2iso.pl new file mode 100755 index 0000000..dd23a8a --- /dev/null +++ b/dmg2iso.pl @@ -0,0 +1,136 @@ +#!/usr/bin/perl +# +# dmg2iso - dmg to iso convert tool +# Copyright (C) 2004 vu1tur + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Changes: +# +# Tue Apr 26 15:49:53 EDT 2005 Jeff Mahoney +# * read/writes now do so in 4k blocks rather than allocate +# huge chunks of memory + +use MIME::Base64; +use strict ; +local ($^W) = 1; #use warnings ; +use Compress::Zlib ; +my $x = inflateInit() + or die "ERROR: Cannot create inflation stream. Is Compress::zlib installed?\n" ; +my $zfblock="\x00"; for (0..8) { $zfblock.=$zfblock; } +my $indxbeg=0; +my $indxend=0; +my $blocksz = 4096; +my @plist; +print "dmg2iso v0.2a by vu1tur (vu1tur.eu.org)\n\n"; +if (@ARGV."" != 2) { die "Syntax: dmg2iso.pl filename.dmg filename.iso\n"; } +my $zeroblock = "\x00"; +for (0..8) { $zeroblock.=$zeroblock; } +my $tmp; +my ($output,$status); +my $buffer; +open(FINPUT,$ARGV[0]) or die "ERROR: Can't open input file\n"; + +binmode FINPUT; +sysseek(FINPUT,-0x200000,2); +print "reading property list..."; +my $fpos = sysseek(FINPUT,0,1); +while(my $ar = sysread(FINPUT,$buffer,0x10000)) +{ + my $fpos = sysseek(FINPUT,0,1)-$ar; + if ($buffer =~ /(.*)/s) + { + $indxbeg = $fpos+length($1); + } + if ($buffer =~ /(.*)<\/plist>/s) + { + $indxend = $fpos+length($1)+8; + } +} +open(FOUTPUT,">".$ARGV[1]) or die "ERROR: Can't open output file\n"; +binmode FOUTPUT; +my $indxcur = $indxbeg + 0x28; +sysseek(FINPUT,$indxbeg,0); +sysread(FINPUT,$tmp,$indxend-$indxbeg); + +if ($tmp =~ s/.*blkx<\/key>.*?\s*(.*?)<\/array>.*/$1/s) +{ + while ($tmp =~ s/.*?(.*?)<\/data>//s) + { + my $t = $1; + $t =~ s/\t//g; + $t =~ s/^\n//g; + push @plist,decode_base64($t); + } +} else { +die "PropertyList is corrupted\n"; +} +print "found ".@plist." partitions\n"; +print "decompressing:\n"; + +my $t=0; +my $zoffs = 0; +my $tempzoffs = 0; +foreach (@plist) +{ + print "partition ".$t++."\n"; + s/^.{204}//s; + while (s/^(.{8})(.{8})(.{8})(.{8})(.{8})//s) + { + $x = inflateInit(); + my $block_type = unpack("H*",$1); + my $out_offs = 0x200*hex(unpack("H*",$2)); + my $out_size = 0x200*hex(unpack("H*",$3)); + my $in_offs = hex(unpack("H*",$4)); + my $in_size = hex(unpack("H*",$5)); + # $1 - block type, $2 - output offs $3 - output size $4 input offset $5 - input size + sysseek(FINPUT,$in_offs+$zoffs,0); + + if ($block_type =~ /^80000005/ or $block_type =~ /^00000001/) + { + do { + my ($toread, $res); + $toread = $blocksz; + $toread = $in_size if ($in_size < $blocksz); + + $res = sysread (FINPUT, $tmp, $toread); + die "read failure" if ($res != $toread); + $output = $tmp; + + # If compressed, inflate it + if ($block_type =~ /^80000005/) { + ($output,$status) = $x->inflate($tmp); + die "\nConversion failed.File may be corrupted.\n" + if (!($status == Z_OK or $status == Z_STREAM_END)); + } + print FOUTPUT $output; + $in_size -= $toread; + } while ($in_size > 0); + } + if ($block_type =~ /^00000002/) + { + for(1..$out_size/0x200) + { + syswrite(FOUTPUT,$zeroblock,0x200); + } + } + if ($block_type =~ /^FFFFFFFF/i) + { + $zoffs += $tempzoffs; + } + $tempzoffs = $in_offs+$in_size; + } +} + +print "\nconversion successful\n"; \ No newline at end of file diff --git a/dmg2iso_pod.pl b/dmg2iso_pod.pl new file mode 100755 index 0000000..6559606 --- /dev/null +++ b/dmg2iso_pod.pl @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# +# Downloaded from http://blinkenlights.ch/gnupod/dmg2iso.pl +# +# dmg2iso.pl was written by vu1tur, license ?!? +# +# Note: This doesn't look like the Version 0.2a provided at +# http://vu1tur.eu.org/tools/ . But this version works with Apples iPod-Firmware dmg images.. +# ... +# +# +use MIME::Base64; +use strict ; +local ($^W) = 1; #use warnings ; +use Compress::Zlib ; +my $x = inflateInit() + or die "ERROR: Cannot create inflation stream. Is Compress::zlib installed?\n" ; +my $zfblock="\x00"; for (0..8) { $zfblock.=$zfblock; } +my $indxbeg=0; +my $indxend=0; +my @plist; +print "dmg2iso v0.2a by vu1tur (vu1tur\@gmx.de)\n\n"; +if (@ARGV."" != 2) { die "Syntax: dmg2iso.pl filename.dmg filename.iso\n"; } +my $zeroblock = "\x00"; +for (0..8) { $zeroblock.=$zeroblock; } +my $tmp; +my ($output,$status); +my $buffer; +open(FINPUT,$ARGV[0]) or die "ERROR: Can't open input file\n"; + +binmode FINPUT; +sysseek(FINPUT,-0x200000,2); +print "reading property list..."; +my $fpos = sysseek(FINPUT,0,1); +while(my $ar = sysread(FINPUT,$buffer,0x10000)) +{ + my $fpos = sysseek(FINPUT,0,1)-$ar; + if ($buffer =~ /(.*)/s) + { + $indxbeg = $fpos+length($1); + } + if ($buffer =~ /(.*)<\/plist>/s) + { + $indxend = $fpos+length($1)+8; + } +} +open(FOUTPUT,">".$ARGV[1]) or die "ERROR: Can't open output file\n"; +binmode FOUTPUT; +my $indxcur = $indxbeg + 0x28; +sysseek(FINPUT,$indxbeg,0); +sysread(FINPUT,$tmp,$indxend-$indxbeg); + +if ($tmp =~ s/.*blkx<\/key>.*?\s*(.*?)<\/array>.*/$1/s) +{ + while ($tmp =~ s/.*?(.*?)<\/data>//s) + { + my $t = $1; + $t =~ s/\t//g; + $t =~ s/^\n//g; + push @plist,decode_base64($t); + } +} else { +die "PropertyList is corrupted\n"; +} +print "found ".@plist." partitions\n"; +print "decompressing:\n"; + +my $t=0; +my $zoffs = 0; +my $tempzoffs = 0; +foreach (@plist) +{ + print "partition ".$t++."\n"; + s/^.{204}//s; + while (s/^(.{8})(.{8})(.{8})(.{8})(.{8})//s) + { + $x = inflateInit(); + my $block_type = unpack("H*",$1); + my $out_offs = 0x200*hex(unpack("H*",$2)); + my $out_size = 0x200*hex(unpack("H*",$3)); + my $in_offs = hex(unpack("H*",$4)); + my $in_size = hex(unpack("H*",$5)); + # $1 - block type, $2 - output offs $3 - output size $4 input offset $5 - input size + sysseek(FINPUT,$in_offs+$zoffs,0); + sysread(FINPUT,$tmp,$in_size); + + if ($block_type =~ /^80000005/) + { + ($output,$status) = $x->inflate($tmp); + if ($status == Z_OK or $status == Z_STREAM_END) + { + syswrite(FOUTPUT,$output,$out_size); + } else { die "\nConversion failed. File may be corrupted.\n"; } + } + if ($block_type =~ /^00000001/) + { + sysseek(FINPUT,$in_offs+$zoffs,0); + sysread(FINPUT,$tmp,$in_size); + syswrite(FOUTPUT,$tmp,$out_size); + } + if ($block_type =~ /^00000002/) + { + for(1..$out_size/0x200) + { + syswrite(FOUTPUT,$zeroblock,0x200); + } + } + if ($block_type =~ /^FFFFFFFF/i) + { + $zoffs += $tempzoffs; + } + $tempzoffs = $in_offs+$in_size; + } +} + +print "\nconversion successful\n"; + diff --git a/espeak_now.sh b/espeak_now.sh new file mode 100755 index 0000000..f1abcf5 --- /dev/null +++ b/espeak_now.sh @@ -0,0 +1,4 @@ +#!/bin/sh +HERE=`dirname $0` +#/usr/bin/espeak -v english-us "It is `date +\"%-M\"` past `date +\"%k\"`." >$HERE/espeak.log 2>&1 +/usr/bin/espeak -v german "Es ist `date +\"%k\"` Uhr `date +\"%-M\"`." >$HERE/espeak.log 2>&1 diff --git a/espeak_time.sh b/espeak_time.sh new file mode 100755 index 0000000..f8b71e1 --- /dev/null +++ b/espeak_time.sh @@ -0,0 +1,4 @@ +#!/bin/sh +HERE=`dirname $0` +#/usr/bin/espeak -v english-us+f2 "It is `date +\"%k\"` o'clock." >$HERE/espeak.log 2>&1 +/usr/bin/espeak -v german+f2 "Es ist `date +\"%k\"` Uhr." >$HERE/espeak.log 2>&1 diff --git a/fbclient/callclient.list-example b/fbclient/callclient.list-example new file mode 100644 index 0000000..e104142 --- /dev/null +++ b/fbclient/callclient.list-example @@ -0,0 +1,3 @@ +08000330000 Telekom Hotline +0123456789 Testanrufer +09831358533 Arno Nym diff --git a/fbclient/callclient.py b/fbclient/callclient.py new file mode 100755 index 0000000..366ea14 --- /dev/null +++ b/fbclient/callclient.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import telnetlib +import os +import sys + +HOST = "172.16.254.254" # "fritz.box" +PORT = 1012 +ESPEAK_BINARY = "/usr/bin/espeak -v german+f2" + +print( "Started in %s" % sys.path[0] ) +f = open( sys.path[0] + "/callclient.list", "rt" ) + +pb = {} +for line in f: + line = line.strip(" \n") + ( number, sep, name ) = line.partition(' ') + name = name.strip() + pb[number] = name +print( "Loaded %s entries from local phonebook." % len( pb ) ) +print( pb ) + +tn = telnetlib.Telnet( HOST, PORT ) +try: + while True: + event = tn.read_until( b"\n" ).decode( "utf-8" ) + edata = event.split( ';' ) + print( edata ) + if edata[1] == "RING": + caller = edata[3] + print( "Incoming call from %s" % caller ) + if caller in pb: + caller = pb[caller] + print( "Caller found in phonebook: %s" % caller ) +# os.system( "/usr/bin/play /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg" ) + os.system( ESPEAK_BINARY + " \"Anruf von " + caller + ".\"" ) + +except EOFError as eof: + print( "Connection closed by remote host." ) + +print( "All done." ) diff --git a/fbclient/callclient.sh b/fbclient/callclient.sh new file mode 100755 index 0000000..4361c7f --- /dev/null +++ b/fbclient/callclient.sh @@ -0,0 +1,7 @@ +#!/bin/sh +export LC_CTYPE="en_US.UTF-8" +export LANG="en_US.UTF-8" +export LANGUAGE="en_US:en" +HERE=`dirname $0` +env > $HERE/callclient.log +/usr/bin/python3 $HERE/callclient.py >>$HERE/callclient.log 2>&1 diff --git a/ffm2mp4.sh b/ffm2mp4.sh new file mode 100755 index 0000000..5f66a87 --- /dev/null +++ b/ffm2mp4.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +FFMPEG=/usr/bin/ffmpeg + +VCODEC=h264 +VBITRATE=384 + +ACODEC=mp3 +ABITRATE=32 +CHANNELS=1 + +$FFMPEG \ +-map 0:0 \ +-map 0:1 \ +-i "$1" \ +-r 24 \ +-s 512x384 \ +-b $VBITRATE \ +-vcodec $VCODEC \ +#-aspect 1.0 \ +-ac $CHANNELS \ +-ab $ABITRATE \ +-acodec $ACODEC \ +"$2" diff --git a/find_orphans.sh b/find_orphans.sh new file mode 100755 index 0000000..b467d8c --- /dev/null +++ b/find_orphans.sh @@ -0,0 +1,5 @@ +#!/bin/bash +SEARCH=/usr +join -t '' -v1 <(find $SEARCH | sort) \ + <(grep -h $SEARCH /var/lib/dpkg/info/*.list | sort -u) \ + | grep -v ".pyc\$" diff --git a/hardlink_break.sh b/hardlink_break.sh new file mode 100755 index 0000000..3de8b89 --- /dev/null +++ b/hardlink_break.sh @@ -0,0 +1,15 @@ +#!/bin/bash +#cat hardlinked.lst | while read file; do +for file in "$@"; do + if [ ! -f "$file" ]; then + echo "ERROR: $file not found." + continue + fi + echo -n "File: $file ... " + mv "$file" "${file}-breaking" + echo -n "Moved ..." + cp "${file}-breaking" "$file" + echo -n "Copied ..." + rm "${file}-breaking" + echo "Cleanup. DONE." +done diff --git a/ip.sh b/ip.sh new file mode 100755 index 0000000..1878a3d --- /dev/null +++ b/ip.sh @@ -0,0 +1,5 @@ +#!/bin/sh +IP1=`wget http://media.silversolutions.de/webco/ip.php -O - -q --no-cache` +IP2=`wget http://admin.birth-online.de/ip.php -O - -q --no-cache` + echo "$IP1" | grep REMOTE_ADDR | cut -c 22- + echo "$IP2" diff --git a/m3u2pls.pl b/m3u2pls.pl new file mode 100755 index 0000000..91531c7 --- /dev/null +++ b/m3u2pls.pl @@ -0,0 +1,51 @@ +#!/usr/bin/env perl +# @(#) convert .m3u playlists to .pls +# Copyright (c) 2006 Dirk Jagdmann +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you +# must not claim that you wrote the original software. If you use +# this software in a product, an acknowledgment in the product +# documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and +# must not be misrepresented as being the original software. +# +# 3. This notice may not be removed or altered from any source +# distribution. +# +# http://llg.cubic.org/tools/#m3upls + +use strict; + +my $i=0; +my $title=''; +my $length=-1; + +print "[playlist]\n"; +while(<>) +{ + chomp; + next if /^\#EXTM3U/; + if(/^\#EXTINF:(\d+),(.*)/) + { + $title=$2; + $length=$1; + next; + } + print "File$i=$_\n"; + print "Title$i=$title\n"; + print "Length$i=$length\n"; + $title=''; + $length=-1; + $i++; +} + +print "NumberOfEntries=$i\nVersion=2\n"; \ No newline at end of file diff --git a/mailto_gmail.sh b/mailto_gmail.sh new file mode 100755 index 0000000..d57dc6b --- /dev/null +++ b/mailto_gmail.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# found at: http://www.google.com/support/forum/p/Chrome/thread?tid=0c3beab0fef1bf34&hl=en +# Opens a compose with the input mailto. Strip the protocol and convert the subject to google's format. +gnome-open "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://' | sed 's/?subject=/\&su=/g' `" diff --git a/mp3gain_album.sh b/mp3gain_album.sh new file mode 100755 index 0000000..68ce039 --- /dev/null +++ b/mp3gain_album.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mp3gain -k -p -a -s i *.mp3 diff --git a/mp3gain_track.sh b/mp3gain_track.sh new file mode 100755 index 0000000..9eb1d39 --- /dev/null +++ b/mp3gain_track.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mp3gain -k -p -r -s i "$*" diff --git a/mp3gain_tracks.sh b/mp3gain_tracks.sh new file mode 100755 index 0000000..b6477b0 --- /dev/null +++ b/mp3gain_tracks.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mp3gain -k -p -r -s i *.mp3 diff --git a/mp3lame.sh b/mp3lame.sh new file mode 100755 index 0000000..a0b0e05 --- /dev/null +++ b/mp3lame.sh @@ -0,0 +1,12 @@ +#!/bin/sh +if [ "$#" = "0" ]; then + echo "Usage: $0 file1 [file2 file3 ... fileN]" + exit 1 +fi + +while [ "$#" -gt 0 ]; do + echo "Processing $1 ($# more left)..." + #lame -m j --replaygain-fast --preset extreme -q 2 --vbr-new -V 2 -o --id3v2-only "$1" "$1.mp3" + lame -m j --replaygain-fast --vbr-new -V 2 -o --id3v2-only --resample 44.1 "$1" "$1.mp3" + shift +done diff --git a/notify-nma.sh b/notify-nma.sh new file mode 100755 index 0000000..ddf4385 --- /dev/null +++ b/notify-nma.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Use: $0 \"event\" prio \"message\"" + exit 1 +fi + +HERE=`dirname $0` + +. $0/CONFIG + +SEDSCRIPT=$HERE/urlencode.sed + +EVENT=`echo "$1" | sed -f $SEDSCRIPT` +# Priority can be -2 .. 2 (-2 = lowest, 2 = highest) +PRIORITY=$2 +MESSAGE=`echo "$3" | sed -f $SEDSCRIPT` +APP=`echo "Revo" | sed -f $SEDSCRIPT` + +# API documentation: https://www.notifymyandroid.com/api.jsp +BASE_URI="https://www.notifymyandroid.com/publicapi" +POST_DATA="apikey=$NMA_RECIPIENT&priority=$PRIORITY&application=$APP&event=$EVENT&description=$MESSAGE" + +RESULT=`wget --post-data="$POST_DATA" -q -O - "$BASE_URI/notify"` +OK=`echo "$RESULT" | grep "code=\"200\""` + +if [ -n "$OK" ]; then + exit 0 +else + echo "The following message could not be sent: $3" >&2 + exit 2 +fi diff --git a/ocr.sh b/ocr.sh new file mode 100755 index 0000000..683826b --- /dev/null +++ b/ocr.sh @@ -0,0 +1,6 @@ +#!/bin/sh +TMPFILE=`tempfile -p OCR -s ".txt"` +TMPBASE=`echo "$TMPFILE" | sed 's/\.txt//g'` +tesseract -l deu+eng "$1" "$TMPBASE" +cat "$TMPFILE" +rm "$TMPFILE" diff --git a/operaclean.sh b/operaclean.sh new file mode 100755 index 0000000..f6df37c --- /dev/null +++ b/operaclean.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +OPERADIR=~/.opera +OPERACLEANDIRS="cache icons opcache" + +for OPERACDIR in $OPERACLEANDIRS; do + DIR=$OPERADIR/$OPERACDIR + echo $DIR + find $DIR -atime +14 -exec rm {} \; + +done \ No newline at end of file diff --git a/pcb-mb.sh b/pcb-mb.sh new file mode 100755 index 0000000..a05ef21 --- /dev/null +++ b/pcb-mb.sh @@ -0,0 +1,41 @@ +#!/bin/sh +INFILE="$1" +if [ ! -f "$1" ]; then + echo "File ${INFILE} does not exist." + exit 1 +fi + +TMPFILE=`tempfile -p pCB` + +# This produces mbirth style PHP + +/opt/mbirth/phpCB \ +--space-after-start-bracket \ +--space-before-end-bracket \ +--space-after-if \ +--space-after-switch \ +--space-after-while \ +--space-before-start-angle-bracket \ +--space-after-end-angle-bracket \ +--extra-padding-for-case-statement \ +--glue-amperscore \ +--glue-arrow \ +--change-shell-comment-to-double-slashes-comment \ +--force-large-php-code-tag \ +--align-equal-statements \ +--comment-rendering-style PEAR \ +--padding-char-count 4 \ +--optimize-eol \ +"$INFILE" > "$TMPFILE" +mv "$INFILE" "${INFILE}~" +mv "$TMPFILE" "$INFILE" + +# more options: +# --one-true-brace \ +# --one-true-brace-function-declaration \ +# --indent-with-tab \ +# --remove-comments \ +# --force-true-false-null-contant-lowercase \ +# --align-equal-statements-to-fixed-pos \ +# --equal-align-position 50 \ +# --comment-rendering-style PHPDoc \ diff --git a/pcb.sh b/pcb.sh new file mode 100755 index 0000000..e75d1b3 --- /dev/null +++ b/pcb.sh @@ -0,0 +1,41 @@ +#!/bin/sh +INFILE="$1" +if [ ! -f "$1" ]; then + echo "File ${INFILE} does not exist." + exit 1 +fi + +TMPFILE=`tempfile -p pCB` + +# This produces SSL style PHP + +/opt/mbirth/phpCB \ +--space-after-start-bracket \ +--space-before-end-bracket \ +--space-after-if \ +--space-after-switch \ +--space-after-while \ +--space-before-start-angle-bracket \ +--space-after-end-angle-bracket \ +--extra-padding-for-case-statement \ +--glue-amperscore \ +--glue-arrow \ +--change-shell-comment-to-double-slashes-comment \ +--force-large-php-code-tag \ +--align-equal-statements \ +--comment-rendering-style PEAR \ +--padding-char-count 4 \ +--optimize-eol \ +--one-true-brace \ +--one-true-brace-function-declaration \ +"$INFILE" > "$TMPFILE" +mv "$INFILE" "${INFILE}~" +mv "$TMPFILE" "$INFILE" + +# more options: +# --indent-with-tab \ +# --force-true-false-null-contant-lowercase \ +# --remove-comments \ +# --align-equal-statements-to-fixed-pos \ +# --equal-align-position 50 \ +# --comment-rendering-style PHPDoc \ diff --git a/phpCB b/phpCB new file mode 100755 index 0000000..55cd2b9 Binary files /dev/null and b/phpCB differ diff --git a/pls2m3u.pl b/pls2m3u.pl new file mode 100755 index 0000000..f0ecd6f --- /dev/null +++ b/pls2m3u.pl @@ -0,0 +1,73 @@ +#!/usr/bin/env perl +# @(#) convert .pls playlists to .m3u +# Copyright (c) 2006 Dirk Jagdmann +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you +# must not claim that you wrote the original software. If you use +# this software in a product, an acknowledgment in the product +# documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and +# must not be misrepresented as being the original software. +# +# 3. This notice may not be removed or altered from any source +# distribution. +# +# http://llg.cubic.org/tools/#m3upls + +use strict; + +$_=<>; +chomp; +die "not a valid .pls file" unless $_ eq "[playlist]"; + +my $total=0; +my @a; +while(<>) +{ + chomp; + next if /^\s*$/; + + if(/NumberOfEntries=(\d+)/) + { + $total=$1; + next; + } + if(/Version=(\d+)/) + { + warn "unknown pls version : $1" unless $1 == 2; + next; + } + + next unless /^(File|Title|Length)(\d+)=(.*)/; + my $tag=$1; + my $num=$2; + my $str=$3; + unless($a[$num]) + { + $a[$num]={ }; + } + $a[$num]->{$tag}=$str; +} + +warn "NumberOfEntries does not match number of entries: $#a != $total" if $total != $#a; + +print "#EXTM3U\n"; +foreach my $r (@a) +{ + $r->{Length}=-1 unless $r->{Length}; + $r->{Title}='' unless $r->{Title}; + if($r->{File}) + { + print "#EXTINF:$r->{Length},$r->{Title}\n"; + print "$r->{File}\n"; + } +} \ No newline at end of file diff --git a/procwatch.php b/procwatch.php new file mode 100755 index 0000000..ceb740b --- /dev/null +++ b/procwatch.php @@ -0,0 +1,147 @@ +#!/usr/bin/php + TRESHOLD)); + + $status[] = $thisstatus; + $status = array_slice( $status, -KEEPLOGS ); + + if ($verbose) echo '[' . date('r') . '] ' . count($thisstatus) . ' process(es) over threshold: ' . implode(', ', array_keys($thisstatus)) . '.' . PHP_EOL; + + if (count($status) >= KEEPLOGS) { + $bad = reset($status); + foreach ($status as $i=>$s) { + if ($i==0) continue; + foreach ($bad as $pid=>$data) { + if (!isset($s[$pid])) unset($bad[$pid]); + elseif ($s[$pid]['%CPU'] > $bad[$pid]['%CPU']) $bad[$pid] = $s[$pid]; + } + } + foreach ($bad as $pid=>$data) { + echo '[' . date('r') . '] BAD PROCESS DETECTED: [' . $pid . '] max ' . $data['%CPU'] . '% --- ' . $data['COMMAND'] . PHP_EOL; + foreach ($ignoreProcs as $ipregexp) { + if (preg_match('/'.$ipregexp.'/i', $data['COMMAND']) > 0) { + echo 'Process is on ignore list. Doing nothing...' . PHP_EOL; + continue 2; + } + } + $cmd = 'kill -TERM ' . $pid; + echo 'DO: ' . $cmd . PHP_EOL; + system($cmd, $retval); + if ($retval != 0) { + $cmd = 'kill -KILL ' . $pid; + echo 'DO: ' . $cmd . PHP_EOL; + system($cmd, $retval); + if ($retval != 0) { + echo 'Process could not be killed! Aborting for now...' . PHP_EOL; + continue; + } + } + foreach ($restartProcs as $rpregexp) { + if (preg_match('/'.$rpregexp.'/i', $data['COMMAND']) > 0) { + echo 'Process is flagged for restart-wanted. Restarting...' . PHP_EOL; + $cmd = $data['COMMAND'] . ' >/dev/null 2>&1 &'; + echo 'DO: ' . $cmd . PHP_EOL; + // XXX: Process might get killed when restarting the webserver + // so one might create a file at this point with the CMDL to run + // and a dispatcher which runs in the background in parallel to this script and + // handles running the CMDL from the file created. + system($cmd); + } + } + } + } + + sleep(INTERVAL); +} + + +/** + * Runs a ps-call to get a list of running processes and returns + * a 2d associative array holding all processes with details + * @param array $treshold If specified, only return processes $key above treshold $value + * @return array Array of all processes and details + */ +function getProcesses( $treshold = false ) { + $pslist = array(); + // args should be last column to have the whole line + exec( 'ps -ewwo pcpu,pid,user,group,args --sort -pcpu', $pslist ); + // $pslist looks something like: + // %CPU PID USER GROUP COMMAND + // 0.0 1 root root /sbin/init + + $headers = array_shift($pslist); + + // collect separating spaces + $spaces = array(); + for ($i=0;$i$idx) { + if ($line{$idx} != ' ') unset($spaces[$i]); + } + } + + // XXX: Assume, there are no consecutive separators (i.e. 2 spaces together) + + $headers = splitLine($headers, $spaces); + + $result = array(); + foreach ($pslist as $line) { + $values = splitLine($line, $spaces); + $mapped = array_combine($headers, $values); + foreach ($treshold as $key=>$value) { + if (!isset($mapped[$key]) || $mapped[$key] < $value) { + continue 2; + } + } + $result[$mapped['PID']] = $mapped; + } + return $result; +} + +/** + * Splits a line of text based on splitter-positions from $splitters + * @param string $line The text to split. + * @param array $splitters An array containing the positions on which to split (these do not belong the the result!) + * @return array An array containing the splitted data + */ +function splitLine($line, $splitters) { + $result = array(); + $lastidx = 0; + foreach ($splitters as $idx) { + $result[] = trim(substr($line, $lastidx, $idx-$lastidx)); + $lastidx = $idx+1; + } + $result[] = trim(substr($line, $lastidx)); + return $result; +} + +?> diff --git a/prowl-torrentdone.sh b/prowl-torrentdone.sh new file mode 100755 index 0000000..99346b4 --- /dev/null +++ b/prowl-torrentdone.sh @@ -0,0 +1,8 @@ +#!/bin/sh +PROWL_UP="" +PROWL_DISH="" +PROWL_FINISHFLAG="" + +HERE=`dirname $0` + +$HERE/prowl.sh "Torrent downloaded $PROWL_FINISHFLAG" -2 "Parameters are: $1 | $2 | $3 | $4 | $5" diff --git a/prowl.sh b/prowl.sh new file mode 100755 index 0000000..e4ae524 --- /dev/null +++ b/prowl.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Use: $0 \"event\" prio \"message\"" + exit 1 +fi + +HERE=`dirname $0` + +. $HERE/CONFIG + +SEDSCRIPT=$HERE/urlencode.sed + +EVENT=`echo "$1" | sed -f $SEDSCRIPT` +# Priority can be -2 .. 2 (-2 = lowest, 2 = highest) +PRIORITY=$2 +MESSAGE=`echo "$3" | sed -f $SEDSCRIPT` +APP=`echo "Revo" | sed -f $SEDSCRIPT` + +BASE_URI="https://prowl.weks.net/publicapi" +POST_DATA="apikey=$PROWL_RECIPIENT&priority=$PRIORITY&application=$APP&event=$EVENT&description=$MESSAGE" + +RESULT=`wget --post-data="$POST_DATA" -q -O - "$BASE_URI/add"` +OK=`echo "$RESULT" | grep "code=\"200\""` + +if [ -n "$OK" ]; then + exit 0 +else + echo "The following message could now be Prowled: $3" + exit 2 +fi diff --git a/prowl.wanup b/prowl.wanup new file mode 100755 index 0000000..56f7b83 --- /dev/null +++ b/prowl.wanup @@ -0,0 +1,17 @@ +#!/bin/sh +IFACE=ppp0 +OLDFILE=/tmp/ipaddr.cache + +HERE=`dirname $0` + +OLD_IP=`cat $OLDFILE` +NEW_IP=`ifconfig ${IFACE} | sed '/.*inet addr:/!d;s///;s/ .*//'` + +PROWL_UP="" +PROWL_DISH="" + +if [ "$NEW_IP" != "$OLD_IP" ]; then + $HERE/prowl.sh "ppp0 is $PROWL_UP" -2 "IP is $NEW_IP $PROWL_DISH" + echo $NEW_IP > $OLDFILE + echo Updated IP to $NEW_IP +fi diff --git a/prowl_proxy.sh b/prowl_proxy.sh new file mode 100755 index 0000000..4664869 --- /dev/null +++ b/prowl_proxy.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Use: $0 \"event\" prio \"message\"" + exit 1 +fi + +HERE=`dirname $0` + +. $HERE/CONFIG + +SEDSCRIPT=$HERE/urlencode.sed + +EVENT=`echo "$1" | sed -f $SEDSCRIPT` +MESSAGE=`echo "$3" | sed -f $SEDSCRIPT` +APP=`echo "NSLU2" | sed -f $SEDSCRIPT` + +# Priority can be -2 .. 2 (-2 = lowest, 2 = highest) +PRIORITY=$2 + +HOST="files.birth-online.de" +PORT="80" +URI="/prowlProxy.php?add" + +POST_DATA="apikey=$PROWL_RECIPIENT&priority=$PRIORITY&application=$APP&event=$EVENT&description=$MESSAGE" + +POST_LEN=`echo "$POST_DATA" | wc -c` + +HTTP_QUERY="POST $URI HTTP/1.1 +Host: $HOST +Content-Length: $POST_LEN +Content-Type: application/x-www-form-urlencoded + +$POST_DATA" + +# echo "$HTTP_QUERY" + +echo "$HTTP_QUERY" | nc -w 10 $HOST $PORT > /dev/null + +if [ $? -eq "0" ]; then + exit 0 +else + exit 2 +fi diff --git a/rip-dvd-track.sh b/rip-dvd-track.sh new file mode 100755 index 0000000..7e7b2de --- /dev/null +++ b/rip-dvd-track.sh @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -z "$1" -o -z "$2" ]; then + echo "Syntax: $0 track-number output-file.mp4" + echo "Get track numbers with lsdvd." + exit 1 +fi +TEMPFILE=`tempfile -s '.vob'` +mplayer dvd://$1 -v -dumpstream -dumpfile $TEMPFILE +avconv -i $TEMPFILE -qscale:0 8 -qscale:2 2 $2 +rm $TEMPFILE +exit 0 diff --git a/rmtmp.sh b/rmtmp.sh new file mode 100755 index 0000000..8737047 --- /dev/null +++ b/rmtmp.sh @@ -0,0 +1,5 @@ +#!/bin/sh +RM="rm" +find -type d \( -name "__MACOSX" -or -name ".TemporaryItems" -or -name ".Spotlight-*" -or -name ".Trashes" -or -name ".fseventsd" \) -print -exec $RM -rf "{}" \; +find -type f \( -name ".DS_Store" -or -iname "Thumbs.db" -or -name "._*" -or -name ".fseventsd" -or -name ".VolumeIcon.icns" -or -name ".vbt5" \) -print -exec $RM -f "{}" \; + diff --git a/rstmod.sh b/rstmod.sh new file mode 100755 index 0000000..7f73f96 --- /dev/null +++ b/rstmod.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Resetting directory permissions..." +find -type d -exec chmod 755 {} \; +echo "Resetting file permissions..." +find -type f -exec chmod 644 {} \; diff --git a/rsync.sh b/rsync.sh new file mode 100755 index 0000000..b23483b --- /dev/null +++ b/rsync.sh @@ -0,0 +1,12 @@ +#!/bin/sh +SOURCE_DIR=/home/mbirth/WualaDrive +TARGET_DIR=/mnt/box.com +if [ ! -d "$SOURCE_DIR" ]; then + echo "ERROR: Source directory $SOURCE_DIR does not exist." + exit 10 +fi +if [ ! -d "$TARGET_DIR" ]; then + echo "ERROR: Target directory $TARGET_DIR does not exist." + exit 11 +fi +rsync -KWuvr --size-only --delete --copy-unsafe-links --progress "$SOURCE_DIR" "$TARGET_DIR" | tee "/tmp/$0.log" diff --git a/rsync_ez.sh b/rsync_ez.sh new file mode 100755 index 0000000..3a29b2e --- /dev/null +++ b/rsync_ez.sh @@ -0,0 +1,21 @@ +#!/bin/sh +EZ_ROOT_LOCAL=/home/euro-01/live/ +EZ_ROOT_REMOTE=eurohost:/home/silver/public_html/ +if [ -z $1 ]; then + echo "Bitte Pfad (ausgehend vom eZ root $EZ_ROOT_LOCAL) angeben." + exit 1 +fi +SRC_DIR=$EZ_ROOT_LOCAL$1 +if [ ! -d $SRC_DIR -a ! -f $SRC_DIR ]; then + echo "$SRC_DIR ist weder ein Verzeichnis noch eine Datei." + exit 2 +fi +if [ -d $SRC_DIR ]; then + echo "$SRC_DIR ist ein Verzeichnis." +fi +if [ -f $SRC_DIR ]; then + echo "$SRC_DIR ist eine Datei." +fi +TRG_DIR=$EZ_ROOT_REMOTE$1 +echo "Sync: $SRC_DIR --> $TRG_DIR" +rsync -uvrLtp8 --progress --stats --bwlimit=1000 $SRC_DIR $TRG_DIR diff --git a/silversol_init.sh b/silversol_init.sh new file mode 100755 index 0000000..9403f14 --- /dev/null +++ b/silversol_init.sh @@ -0,0 +1,27 @@ +#!/bin/bash +( + echo "#Waiting for things to settle down ..." + sleep 40 + echo 0 + echo "#Mounting nextgen2 ..." + mount /mnt/nextgen2 + echo 16 + echo "#Mounting extranet ..." + mount /mnt/extranet + echo 33 + echo "#Mounting intranet ..." + mount /mnt/intranet + echo 50 + echo "#Mounting web2 ..." + mount /mnt/web2 + echo 66 + echo "#Mounting gemeinschaft ..." + mount /mnt/gemeinschaft + echo 83 + #mount /mnt/web3 + + echo "#Setting mouse button order ..." + #/usr/bin/xinput set-button-map "Kingsis Peripherals Evoluent VerticalMouse 3" 1 9 2 4 5 6 7 3 8 + /usr/bin/xinput set-button-map 12 1 9 2 4 5 6 7 3 8 + echo 100 +) | zenity --progress --auto-close --text "SSL Startup Actions" --title "silver.solutions gmbh" diff --git a/spacehog-dirs b/spacehog-dirs new file mode 100755 index 0000000..1b3b469 --- /dev/null +++ b/spacehog-dirs @@ -0,0 +1,7 @@ +#!/bin/bash +echo Top 10 directory space hogs +set DIR="$1" +if [ -z $DIR ]; then + set DIR = "." +fi +du -k $DIR | sort -n -r | head -n 10 diff --git a/spacehogs b/spacehogs new file mode 100755 index 0000000..11358f1 --- /dev/null +++ b/spacehogs @@ -0,0 +1,7 @@ +#!/bin/bash +echo Top 10 space hogs +set DIR="$1" +if [ -z $DIR ]; then + set DIR = "." +fi +find $DIR -type f -ls | sort -k 7 -r -n | head -10 diff --git a/spdif_hdd_led.sh b/spdif_hdd_led.sh new file mode 100755 index 0000000..9452a1e --- /dev/null +++ b/spdif_hdd_led.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +VERSION=01 + +if [ "$1" == "--help" ]; then + echo " +MacBook LED indicator (v$VERSION) Jason Parekh +Put that SPDIF-out to use! http://jasonparekh.com/linux-on-macbook + +Usage: $0 [dev] + +type Choose between 'disk' (default) or 'net' indicator +dev Use the 'dev' device (eg: 'sda1' or even just 'sda' for all partitions) + +Examples: + $0 Monitors all block devices activity (disk and CD/DVD drives) + $0 disk sda Monitors all disk drives activity + $0 net eth0 Monitors LAN activity + $0 net Monitors all network activity (WARNING: wlan0 will pickup ANY wifi activity) + $0 net ath0 Monitors wireless activity +" + exit +fi + +STATS_FILE="/proc/diskstats" + +if [ "$1" == "net" ]; then + STATS_FILE="/proc/net/dev" +fi + +STATS_CMD="cat $STATS_FILE" +if [ "$2" != "" ]; then + STATS_CMD="grep $2 $STATS_FILE" +fi + +renice 19 -p $$ >/dev/null 2>&1 + +while [ 1 ]; do + CUR_STATS=`$STATS_CMD` + if [ "$CUR_STATS" != "$LAST_STATS" ]; then + if [ "$LAST_OP" != "ACTIVE" ]; then + amixer set IEC958 on >/dev/null 2>&1 + fi + LAST_OP="ACTIVE" + else + if [ "$LAST_OP" != "IDLE" ]; then + amixer set IEC958 off >/dev/null 2>&1 + fi + LAST_OP="IDLE" + fi + LAST_STATS="$CUR_STATS" + sleep 0.2 +done diff --git a/sqlite_cleanup.sh b/sqlite_cleanup.sh new file mode 100755 index 0000000..abc4761 --- /dev/null +++ b/sqlite_cleanup.sh @@ -0,0 +1,24 @@ +#!/bin/bash +SUBDIR="$1" +if [ -z "$SUBDIR" ]; then + SUBDIR="." +fi +#default: JOURNAL_MODE=DELETE +#JOURNAL_MODE=TRUNCATE +JOURNAL_MODE=WAL +#JOURNAL_MODE=DELETE +cd "$SUBDIR" +for i in *; do + if [ ! -f "$i" ]; then + continue + fi + HDR=`head --bytes=15 "$i"` + if [ "$HDR" != "SQLite format 3" ]; then + continue + fi +# echo "Processing $i and setting journal mode to $JOURNAL_MODE ..." +# echo "PRAGMA journal_mode; PRAGMA journal_mode=$JOURNAL_MODE; VACUUM;" | sqlite3 "$i" + echo "Processing $i ..." + echo "VACUUM;" | sqlite3 "$i" +done +cd - diff --git a/sqlite_cleanup_recursive.sh b/sqlite_cleanup_recursive.sh new file mode 100755 index 0000000..a662c1f --- /dev/null +++ b/sqlite_cleanup_recursive.sh @@ -0,0 +1,5 @@ +#!/bin/bash +HERE=`dirname $0` +find $1 -type d -print0 | while read -d $'\0' i; do + $HERE/sqlite_cleanup.sh "$i" +done diff --git a/svn_ci_added.sh b/svn_ci_added.sh new file mode 100755 index 0000000..b2db35a --- /dev/null +++ b/svn_ci_added.sh @@ -0,0 +1,3 @@ +#!/bin/sh +svn status | egrep '^A.*$' | sed -e 's/^. *//' > /tmp/svn_ci.txt +svn ci --targets /tmp/svn_ci.txt diff --git a/swfe_all.sh b/swfe_all.sh new file mode 100755 index 0000000..9a86df5 --- /dev/null +++ b/swfe_all.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# found on: http://www.mail-archive.com/swftools-common@nongnu.org/msg02159.html +for i in ./*.swf ; do + for j in `swfextract $i | grep -E PNGs.* -o | grep -E [0-9]+ -o` ; do + echo "$i -> extract png $j"; + swfextract -p "$j" "$i" -o "$i"_"$j".png + done + for j in `swfextract $i | grep -E JPEGs.* -o | grep -E [0-9]+ -o` ; do + echo "$i -> extract jpeg $j"; + swfextract -j "$j" "$i" -o "$i"_"$j".jpg + done + for j in `swfextract $i | grep -E Shapes.* -o | grep -E [0-9]+ -o` ; do + echo "$i -> extract shapes $j"; + swfextract -i "$j" "$i" -o "$i"_"$j".swf + done +for j in `swfextract $i | grep -E MovieClips.* -o | grep -E [0-9]+ -o` ; do + echo "$i -> extract movieclips $j"; + swfextract -i "$j" "$i" -o "$i"_"$j".swf + done +done diff --git a/syslog-tts.sh b/syslog-tts.sh new file mode 100755 index 0000000..a583044 --- /dev/null +++ b/syslog-tts.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# found: http://dailypackage.fedorabook.com/index.php?/archives/42-Productive-Monday-Festival-Speech-synthesis.html +tail -0f /var/log/messages | sed "s/^[^:]*:[^:]*:[^:]*: //" | while read LINE +#tail -0f /var/log/syslog | sed "s/^[^:]*:[^:]*:[^:]*: //" | while read LINE +#tail -0f /var/log/auth.log | sed "s/^[^:]*:[^:]*:[^:]*: //" | while read LINE +#tail -0f /var/log/user.log | sed "s/^[^:]*:[^:]*:[^:]*: //" | while read LINE +do + echo $LINE + echo $LINE | festival --tts + sleep 0.75 +done \ No newline at end of file diff --git a/ts2date.sh b/ts2date.sh new file mode 100755 index 0000000..75ecd76 --- /dev/null +++ b/ts2date.sh @@ -0,0 +1,3 @@ +#!/bin/sh +#date --date "1970-01-01 $1 sec UTC" +date --date "@$1" diff --git a/um b/um new file mode 100755 index 0000000..0679d67 --- /dev/null +++ b/um @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -z "$1" ]; then + echo "Syntax: $0 [-z]" + exit 0; +fi +fusermount -u "`readlink -f "$1"`" $2 diff --git a/urlencode.sed b/urlencode.sed new file mode 100644 index 0000000..bce57c4 --- /dev/null +++ b/urlencode.sed @@ -0,0 +1,33 @@ +s/%/%25/g +s/ /%20/g +s/ /%09/g +s/!/%21/g +s/"/%22/g +s/#/%23/g +s/\$/%24/g +s/\&/%26/g +s/'\''/%27/g +s/(/%28/g +s/)/%29/g +s/\*/%2a/g +s/+/%2b/g +s/,/%2c/g +s/-/%2d/g +s/\./%2e/g +s/\//%2f/g +s/:/%3a/g +s/;/%3b/g +s//%3e/g +s/?/%3f/g +s/@/%40/g +s/\[/%5b/g +s/\\/%5c/g +s/\]/%5d/g +s/\^/%5e/g +s/_/%5f/g +s/`/%60/g +s/{/%7b/g +s/|/%7c/g +s/}/%7d/g +s/~/%7e/g +s/ /%09/g diff --git a/urlopen.sh b/urlopen.sh new file mode 100755 index 0000000..e92a870 --- /dev/null +++ b/urlopen.sh @@ -0,0 +1,19 @@ +#!/bin/bash +BROWSERS="x-www-browser opera firefox chromium-browser w3m epiphany-browser midori" +URL=`echo $1 | sed 's/&/&/g'` +BROWSER=`zenity --list --title "Open URL" --text "Choose desired browser to open\n${URL}" --height 400 --column "Browser" ${BROWSERS}` +if [ -n "$BROWSER" ]; then + case "$BROWSER" in + chromium-browser) + BROWSER="$BROWSER" + ;; + opera) + BROWSER="$BROWSER -notrayicon -nomail -nolirc" + ;; + esac + if [ -n "$1" ]; then + BROWSER="$BROWSER $1" + fi + echo $BROWSER + $BROWSER +fi diff --git a/vbox_starttun.sh b/vbox_starttun.sh new file mode 100755 index 0000000..dcb8942 --- /dev/null +++ b/vbox_starttun.sh @@ -0,0 +1,20 @@ +#!/bin/bash +brctl addbr br0 +ifconfig eth0 0.0.0.0 +brctl addif br0 eth0 + +#if you have a dhcp-server uncomment this line: +#dhclient3 br0 + +#If you have a static IP uncomment the following lines and +#change the IP accordingly to your subnet: +ifconfig br0 192.168.0.235 up +route add default gw 192.168.0.40 + +#Now we will create the tap device for the vm,! +# change your username accordingly +tunctl -t tap0 -u mbirth + +#Now add the tap-device to the bridge: +ifconfig tap0 up +brctl addif br0 tap0 \ No newline at end of file diff --git a/vbox_starttun_ssl.sh b/vbox_starttun_ssl.sh new file mode 100755 index 0000000..8e8a48c --- /dev/null +++ b/vbox_starttun_ssl.sh @@ -0,0 +1,20 @@ +#!/bin/bash +brctl addbr br0 +ifconfig eth0 0.0.0.0 +brctl addif br0 eth0 + +#if you have a dhcp-server uncomment this line: +#dhclient3 br0 + +#If you have a static IP uncomment the following lines and +#change the IP accordingly to your subnet: +ifconfig br0 192.168.1.162 up +route add default gw 192.168.1.249 + +#Now we will create the tap device for the vm,! +# change your username accordingly +tunctl -t tap0 -u mab + +#Now add the tap-device to the bridge: +ifconfig tap0 up +brctl addif br0 tap0 \ No newline at end of file diff --git a/vbox_stoptun.sh b/vbox_stoptun.sh new file mode 100755 index 0000000..c5317f6 --- /dev/null +++ b/vbox_stoptun.sh @@ -0,0 +1,14 @@ +#!/bin/bash +#bring the interfaces down +ifconfig tap0 down +ifconfig br0 down +brctl delif br0 tap0 +brctl delbr br0 + +#now setup your network-interface again +#for dhcp uncomment the following line +#dhclient3 eth0 + +#For a static IP uncomment the following lines and change them accordingly: +ifconfig eth0 192.168.0.235 +route add default gw 192.168.0.40 dev eth0 \ No newline at end of file diff --git a/vbox_stoptun_ssl.sh b/vbox_stoptun_ssl.sh new file mode 100755 index 0000000..353d1e1 --- /dev/null +++ b/vbox_stoptun_ssl.sh @@ -0,0 +1,14 @@ +#!/bin/bash +#bring the interfaces down +ifconfig tap0 down +ifconfig br0 down +brctl delif br0 tap0 +brctl delbr br0 + +#now setup your network-interface again +#for dhcp uncomment the following line +#dhclient3 eth0 + +#For a static IP uncomment the following lines and change them accordingly: +ifconfig eth0 192.168.1.162 +route add default gw 192.168.1.249 dev eth0 \ No newline at end of file diff --git a/vlc2avi.sh b/vlc2avi.sh new file mode 100755 index 0000000..d4a8b41 --- /dev/null +++ b/vlc2avi.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +VLC=/usr/bin/vlc + +VCODEC=DX50 +VBITRATE=512 + +ACODEC=mpga +ABITRATE=96 + +$VLC \ +-v \ +-I dummy \ +"$1" \ +--sout "#transcode{width=224,height=176,vcodec=$VCODEC,acodec=$ACODEC,vb=$VBITRATE,ab=$ABITRATE}:std{access=file,mux=avi,dst=\"$2\"}" \ +--sout-all \ No newline at end of file diff --git a/vlc2mp4.sh b/vlc2mp4.sh new file mode 100755 index 0000000..69a72d0 --- /dev/null +++ b/vlc2mp4.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +VLC=/usr/bin/vlc + +VCODEC=mp4v +VBITRATE=384 + +ACODEC=mp3 +ABITRATE=64 + +$VLC \ +-v \ +-I dummy \ +"$1" \ +--sout "#transcode{width=512,height=384,vcodec=$VCODEC,acodec=$ACODEC,vb=$VBITRATE,ab=$ABITRATE}:std{access=file,mux=ts,dst=\"$2\"}" \ +--sout-all \ No newline at end of file diff --git a/wake.sh b/wake.sh new file mode 100755 index 0000000..095c788 --- /dev/null +++ b/wake.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# To use this, create files with the MAC addresses (1 MAC per file) +beep -f 1200 -l 500 -n -f 1200 -l 500 -n -f 1200 -l 500 +wakeonlan `cat $1.mac` diff --git a/webcam-snapshot.sh b/webcam-snapshot.sh new file mode 100755 index 0000000..a7d1bd4 --- /dev/null +++ b/webcam-snapshot.sh @@ -0,0 +1,6 @@ +#!/bin/sh +STAMP=`date +"%Y%m%d-%H%M%S"` +FILENAME="cam_$STAMP.jpeg" +DEVICE="/dev/video0" +echo "Capturing $DEVICE into file $FILENAME ..." +streamer -c "$DEVICE" -b 16 -o "$FILENAME" diff --git a/wgauth.sh b/wgauth.sh new file mode 100755 index 0000000..fb7a53a --- /dev/null +++ b/wgauth.sh @@ -0,0 +1,37 @@ +#!/bin/sh +HERE=`dirname $0` + +. $HERE/CONFIG + +read -p "Enter username: " USER +echo -n "Enter password: " +/bin/stty -echo +read PASS +/bin/stty echo +echo "" +DOMAIN=Firebox-DB +#DOMAIN=RADIUS + +# POST with multipart/form-data (form name: user_auth_form) +TMP=`tempfile -p WG` +POST="fw_username=${USER}&fw_password=${PASS}&fw_domain=${DOMAIN}&submit=Login&action=fw_logon&style=fw_logon_progress.xsl&fw_logon_type=logon" +echo "Sending login data..." +wget --quiet -S -O "$TMP" --no-check-certificate --post-data="$POST" "$WATCHGUARD_URL/?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status" + +REQID=`cat "$TMP" | egrep -o "(.*)" | sed 's/\(.*\)<\/reqId>/\1/g'` +rm "$TMP" +echo "Got Request ID: $REQID" + +sleep 2 +URI="/?action=fw_logon&style=fw_logon_progress.xsl&fw_logon_type=progress&fw_reqId=${REQID}" +echo "Requesting login status..." +wget --quiet -S -O "$TMP" --no-check-certificate "${WATCHGUARD_URL}${URI}" + +STATUS=`cat "$TMP" | egrep -o "(.*)" | sed 's/\(.*\)<\/logon_status>/\1/g'` +echo "Status: $STATUS" +rm "$TMP" +if [ $STATUS = "1" ]; then + echo "Logged in successfully." +else + echo "Login failed for some reason. Please try again." +fi \ No newline at end of file