Initial commit

This commit is contained in:
Markus Birth 2013-03-21 01:54:15 +01:00
commit 8c8798b036
86 changed files with 1864 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -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

7
CONFIG.example Normal file
View File

@ -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"

7
X11-dual-screen-fix.sh Executable file
View File

@ -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

3
X11-ext-refresh-rate.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo Setting refresh rate to 75 Hz
xrandr --output VGA-0 --mode 1280x1024 --rate 75 --left-of LVDS

3
X11-int-refresh-rate.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo Setting refresh rate to 60 Hz
xrandr --output LVDS --mode 1024x768 --rate 60

7
and-backup.sh Executable file
View File

@ -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"

4
and-market-chrome.sh Executable file
View File

@ -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

111
and-rename-apks.php Executable file
View File

@ -0,0 +1,111 @@
#!/usr/bin/php -q
<?php
class APKInfo {
const AAPT_BIN = '/opt/android-sdk/platform-tools/aapt';
private $dir;
private $icon_dir;
private $xml_file;
private $dom;
private $dom_root;
public static function saveIcon( $apk, $filename ) {
$info = self::getInfo( $apk );
if ( $info === false ) return false;
$ext = substr( $info['application']['icon'], strrpos( $info['application']['icon'], '.' ) );
$src = 'zip://' . $info['file'] . '#' . $info['application']['icon'];
copy( $src, $filename );
return true;
}
public static function getInfo( $file ) {
if ( !file_exists( $file ) ) return false;
exec( self::AAPT_BIN . ' d badging "' . $file . '"', $out );
$ainfo = array(
'file' => $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<strlen($data);$i++) {
if ( $data{$i} == "'" ) {
$in_string = !$in_string;
$part .= $data{$i};
} elseif ( $data{$i} == ' ' && !$in_string ) {
if ( !empty($part) ) $data_parts[] = $part;
$part = '';
} else {
$part .= $data{$i};
}
}
if ( !empty( $part ) ) $data_parts[] = $part;
$data = array();
foreach ( $data_parts as $dp ) {
if ( empty( $dp ) ) continue;
if ( $dp{0} == "'" ) {
// array: 'val1' 'val2' 'val3'
$data[] = substr( $dp, 1, -1 );
} else {
if ( strpos( $dp, '=' ) === false ) continue;
// hash: name1='val1' name2='val2' name3='val3'
list( $dp_name, $dp_value ) = explode( '=', $dp, 2 );
$data[ $dp_name ] = substr( $dp_value, 1, -1 );
}
}
}
if ( isset( $ainfo[ $label ] ) ) {
// key already defined
if ( !is_array( $ainfo[ $label ] ) ) {
// convert current value to array
$ainfo[ $label ] = array( $ainfo[ $label ] );
}
if ( is_array( $data ) ) {
// merge arrays
$ainfo[ $label ] = array_merge( $ainfo[ $label ], $data );
} else {
// just add new value
$ainfo[ $label ][] = $data;
}
} else {
// new key=value pair
$ainfo[ $label ] = $data;
}
}
return $ainfo;
}
}
$files = glob( './*.apk' );
foreach ( $files as $file ) {
$info = APKInfo::getInfo( $file );
$bname = basename( $file );
$newname = $info['package']['name'] . '-' . $info['package']['versionCode'] . '-v' . $info['package']['versionName'] . '.apk';
if ( $newname != $bname ) {
echo $bname . ' -> ' . $newname . ' ';
$result = rename( $file, dirname($file) . '/' . $newname );
if ( $result ) echo '[OK]'; else echo '[ERROR!]';
echo PHP_EOL;
} else {
echo $bname . ' skipped.' . PHP_EOL;
}
}
exit;
?>

8
apedel.py Executable file
View File

@ -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

13
apt-getkey.sh Executable file
View File

@ -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

BIN
asfbin Executable file

Binary file not shown.

2
beep.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
beep -f 400 -l 100 -r 3 -d 50

BIN
binoffset Executable file

Binary file not shown.

163
binoffset.c Normal file
View File

@ -0,0 +1,163 @@
/***************************************************************************
* binoffset.c
* (C) 2002 Randy Dunlap <rdunlap@xenotime.net>
# 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#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 */

10
bp_lock.sh Executable file
View File

@ -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

8
bp_ssl_lock.sh Executable file
View File

@ -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

8
bp_ssl_unlock.sh Executable file
View File

@ -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

10
bp_unlock.sh Executable file
View File

@ -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

8
bridge-remove.sh Executable file
View File

@ -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

12
bridge.sh Executable file
View File

@ -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

17
bzIunpack.sh Executable file
View File

@ -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

10
checkinst.sh Executable file
View File

@ -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"

10
chromeclean.sh Executable file
View File

@ -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

28
clamscan.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# Fred Blaise <chapeaurouge AT madpenguin DOT org>
# 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

5
db-dump Executable file
View File

@ -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

5
db-fulldump Executable file
View File

@ -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

4
db-import Executable file
View File

@ -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 "$@"

40
deb-edit-control.py Executable file
View File

@ -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:], "<file.deb>")
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))

42
deb-edit-control.sh Executable file
View File

@ -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"

4
delayrun.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
sleep $1
shift
$@

136
dmg2iso.pl Executable file
View File

@ -0,0 +1,136 @@
#!/usr/bin/perl
#
# dmg2iso - dmg to iso convert tool
# Copyright (C) 2004 vu1tur <to@vu1tur.eu.org>
# 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 <jeff.mahoney@gmail.com>
# * 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 =~ /(.*)<plist version=\"1.0\">/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/.*<key>blkx<\/key>.*?\s*<array>(.*?)<\/array>.*/$1/s)
{
while ($tmp =~ s/.*?<data>(.*?)<\/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";

117
dmg2iso_pod.pl Executable file
View File

@ -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 =~ /(.*)<plist version=\"1.0\">/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/.*<key>blkx<\/key>.*?\s*<array>(.*?)<\/array>.*/$1/s)
{
while ($tmp =~ s/.*?<data>(.*?)<\/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";

4
espeak_now.sh Executable file
View File

@ -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

4
espeak_time.sh Executable file
View File

@ -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

View File

@ -0,0 +1,3 @@
08000330000 Telekom Hotline
0123456789 Testanrufer
09831358533 Arno Nym

42
fbclient/callclient.py Executable file
View File

@ -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." )

7
fbclient/callclient.sh Executable file
View File

@ -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

24
ffm2mp4.sh Executable file
View File

@ -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"

5
find_orphans.sh Executable file
View File

@ -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\$"

15
hardlink_break.sh Executable file
View File

@ -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

5
ip.sh Executable file
View File

@ -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"

51
m3u2pls.pl Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env perl
# @(#) convert .m3u playlists to .pls
# Copyright (c) 2006 Dirk Jagdmann <doj@cubic.org>
#
# 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";

4
mailto_gmail.sh Executable file
View File

@ -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' `"

2
mp3gain_album.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
mp3gain -k -p -a -s i *.mp3

2
mp3gain_track.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
mp3gain -k -p -r -s i "$*"

2
mp3gain_tracks.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
mp3gain -k -p -r -s i *.mp3

12
mp3lame.sh Executable file
View File

@ -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

32
notify-nma.sh Executable file
View File

@ -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

6
ocr.sh Executable file
View File

@ -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"

11
operaclean.sh Executable file
View File

@ -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

41
pcb-mb.sh Executable file
View File

@ -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 \

41
pcb.sh Executable file
View File

@ -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 \

BIN
phpCB Executable file

Binary file not shown.

73
pls2m3u.pl Executable file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env perl
# @(#) convert .pls playlists to .m3u
# Copyright (c) 2006 Dirk Jagdmann <doj@cubic.org>
#
# 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";
}
}

147
procwatch.php Executable file
View File

@ -0,0 +1,147 @@
#!/usr/bin/php
<?php
define('TRESHOLD', 80); // %CPU above which to log
define('INTERVAL', 2); // Interval between 2 analysis runs
define('KEEPLOGS', 150); // How many runs to detect overload (if a PID appears in ALL logs, it gets killed)
$restartProcs = array( // list of commandlines to restart (pregexps)
// 'java',
);
$ignoreProcs = array( // list of commandlines to ignore (pregexps)
'\/usr\/bin\/X',
'VirtualBox',
);
$verbose = true;
/*****************************************************************************/
$status = array();
echo 'silver.threadwatcher starting up...' . PHP_EOL;
echo 'Measuring interval: ' . INTERVAL . ' seconds.' . PHP_EOL;
echo 'Usage treshold : ' . TRESHOLD . ' %cpu.' . PHP_EOL;
echo 'Measurements : ' . KEEPLOGS . ' time(s).' . PHP_EOL;
while (1==1) {
$thisstatus = getProcesses(array('%CPU' => 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<strlen($headers);$i++) {
if ($headers{$i} == ' ') $spaces[] = $i;
}
// check for constant separators, sieve all non-constant ones
foreach ($pslist as $line) {
foreach ($spaces as $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;
}
?>

8
prowl-torrentdone.sh Executable file
View File

@ -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"

31
prowl.sh Executable file
View File

@ -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

17
prowl.wanup Executable file
View File

@ -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

44
prowl_proxy.sh Executable file
View File

@ -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

11
rip-dvd-track.sh Executable file
View File

@ -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

5
rmtmp.sh Executable file
View File

@ -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 "{}" \;

5
rstmod.sh Executable file
View File

@ -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 {} \;

12
rsync.sh Executable file
View File

@ -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"

21
rsync_ez.sh Executable file
View File

@ -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

27
silversol_init.sh Executable file
View File

@ -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"

7
spacehog-dirs Executable file
View File

@ -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

7
spacehogs Executable file
View File

@ -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

53
spdif_hdd_led.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
VERSION=01
if [ "$1" == "--help" ]; then
echo "
MacBook LED indicator (v$VERSION) Jason Parekh <jasonparekh@gmail.com>
Put that SPDIF-out to use! http://jasonparekh.com/linux-on-macbook
Usage: $0 <type> [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

24
sqlite_cleanup.sh Executable file
View File

@ -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 -

5
sqlite_cleanup_recursive.sh Executable file
View File

@ -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

3
svn_ci_added.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
svn status | egrep '^A.*$' | sed -e 's/^. *//' > /tmp/svn_ci.txt
svn ci --targets /tmp/svn_ci.txt

20
swfe_all.sh Executable file
View File

@ -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

11
syslog-tts.sh Executable file
View File

@ -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

3
ts2date.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
#date --date "1970-01-01 $1 sec UTC"
date --date "@$1"

6
um Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
if [ -z "$1" ]; then
echo "Syntax: $0 <mountpoint> [-z]"
exit 0;
fi
fusermount -u "`readlink -f "$1"`" $2

33
urlencode.sed Normal file
View File

@ -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

19
urlopen.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
BROWSERS="x-www-browser opera firefox chromium-browser w3m epiphany-browser midori"
URL=`echo $1 | sed 's/&/&amp;/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

20
vbox_starttun.sh Executable file
View File

@ -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

20
vbox_starttun_ssl.sh Executable file
View File

@ -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

14
vbox_stoptun.sh Executable file
View File

@ -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

14
vbox_stoptun_ssl.sh Executable file
View File

@ -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

16
vlc2avi.sh Executable file
View File

@ -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

16
vlc2mp4.sh Executable file
View File

@ -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

4
wake.sh Executable file
View File

@ -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`

6
webcam-snapshot.sh Executable file
View File

@ -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"

37
wgauth.sh Executable file
View File

@ -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 "<reqId>(.*)</reqId>" | sed 's/<reqId>\(.*\)<\/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 "<logon_status>(.*)</logon_status>" | sed 's/<logon_status>\(.*\)<\/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