diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5236e1e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ + diff --git a/ExecuteQuery b/ExecuteQuery new file mode 100755 index 0000000..9ccd01e --- /dev/null +++ b/ExecuteQuery @@ -0,0 +1,8 @@ +#!/bin/sh + +# Java heap size, in megabytes +JAVA_HEAP_SIZE=256 + +eq_home=/usr/local/ExecuteQuery + +exec java -mx${JAVA_HEAP_SIZE}m -jar "${eq_home}/eq.jar" diff --git a/Linux/myps b/Linux/myps new file mode 100755 index 0000000..92d41fd --- /dev/null +++ b/Linux/myps @@ -0,0 +1,3 @@ +#!/bin/sh + +ps -A fo pid,ppid,sid,pgid,tty8,stat,user,args diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a25ea3b --- /dev/null +++ b/Makefile @@ -0,0 +1,254 @@ +X11LDFLAGS=-L/usr/X11R6/lib -lX11 + +GLOBALFILES=\ +a2xcf \ +apt-list-contents \ +apt-build \ +audioreset \ +blackscrn.pl \ +cdburn \ +cdburn-rr \ +dvdburn \ +dvdburn-rr \ +dvdvideoburn \ +cdcopy.sh \ +cdcopy_onthefly.sh \ +cddaenc.sh \ +cddamv.pl \ +cddarip.sh \ +cdda-cddbrip \ +cdisoburn \ +create-index-htmls \ +cutv \ +deb-import-signing-key \ +emacs_or_fallback.sh \ +gtetrinet-configure-keyboard \ +gtetrinet-unconfigure-keyboard \ +gnuplot-and-wait \ +gnuplot-eps \ +gnuplot-eps-and-wait \ +gnuplot-png \ +jolietrename \ +jolietrenamecurrdir \ +jolietnamecheckcurrdir \ +chk4rlogins \ +chr \ +chrcodes \ +cpmydir.sh \ +cvs-add-subtree-dirs \ +cvs-add-subtree-files \ +cvs-isstssh \ +cvs-myissthostssh \ +cvslog2kwsubst \ +cvsshowunkn.pl \ +deb-fetch-uris \ +deb-list-pkgs \ +deb-xtract-uris \ +disk2file.sh \ +dos2unixm.sh \ +e \ +eardiff.sh \ +edit-encrypted \ +eol2nul \ +execlogged \ +ExecuteQuery \ +fetchheise-fetcharticles \ +fetchheise-idxpage-fetchallarticles \ +fetchheise-idxpage-idxpageurls \ +fetchheise-idxpage-all-articleurls \ +fetchheise-idxpages-articleurls \ +fetchmail-setup-tunnel.sh \ +firefox-print-stacktraces \ +firefox-print-stacktraces.gdbscript \ +mail.cs.tu-berlin.de.cert \ +fetchmail-shutdown-tunnel.sh \ +ff \ +file2disk.sh \ +fsumup \ +fullpath \ +gal2nsbm.py \ +generate-site-specific-filenames \ +getcdrdev \ +getdvdrdev \ +getpid \ +gianasis \ +grepre \ +grep_instfiles \ +ifaceaddr \ +imagej \ +install-javaplugin \ +instfilelist.pl \ +ip6to4 \ +irexec.pl \ +iriver2m3ufile.pl \ +kill-flashplugin \ +kill-vpn.sh \ +locateme \ +libusers \ +linehist \ +listexecs \ +lnum.sh \ +log-transferrate \ +make-my_configure_help \ +m3u2iriver.pl \ +m3u2iriverfile.pl \ +m3uxmms2unx \ +maestro \ +memeaters.pl \ +memeaters1.pl \ +memusage \ +memusage_for_pid_by_lib \ +memusage-log-for-pid \ +memusage-snapshot \ +mlnet-disksize-watchdog \ +mouseclick \ +mplayerctl \ +mplayer-ctlable \ +mplayer-dump-latest \ +mygdb \ +myhexdump \ +palm-fetchheise \ +pidof \ +pslibs.pl \ +quotelines \ +rfcidx.pl \ +rminst \ +run-if-not-running.sh \ +scp-myissthost \ +sensible-browser \ +settimefromntp \ +showhomeip \ +show-encrypted \ +sleepingsongs \ +slowdown.pl \ +sumsizes \ +sumup \ +syncmp3s \ +thermal-snapshot \ +timedrun.sh \ +timelogger.pl \ +unique-lines \ +unpacksrcrpm.sh \ +unzip2d \ +update_cookiestxts \ +vcr-chilitv \ +vcr-daily \ +videnc \ +videnc.sh \ +wait4time \ +wgetheise.sh \ +wget-completepage \ +wget-withbrowsersettings \ +xmms2iriver \ +zipdir.sh \ +stopwatch \ +showargs \ +jython2bsh \ +mountdata \ +umountdata \ +freemind \ +export-sawfish \ +perl-e-perline \ +perl-e-perline-inplace \ +psfindbywd \ +rspeedway \ +ruby-e-perline \ +show-spurious-listeners \ +spurious-listeners-watchdog \ +svnshowunkn \ +tvbrowser \ +wget-logging \ +xless \ +xmule-continuously \ +xscreensaver-keepaway \ +xterm-fullscreen \ +xy+-plot \ +xy+-average \ +xypairs-derive \ +xypairs-average \ +y+-plot \ +youtubedown \ +myhomedesktop/emacs_or_fallback.sh \ +make-misc \ +misc.make \ +lesscat \ +strace-all + +#GLOBALTARGET=$(HOME)/bin +GLOBALTARGET=/usr/local/bin + +GLOBALUSER=root + +SBINFILES=\ +memusagelogd \ +thermallogd \ +run-ppp-over-ssh \ +myissthost/run-isstsshvpn \ +myissthost/run-isstsshvpn-continuously \ +mysofdhost/run-sofdsshvpn \ +mysofdhost/run-sofdsshvpn-continuously \ +myhomehost/kill-vpn-continuously \ +myhomehost/isstsshvpn-routes \ +myhomehost/sofdsshvpn-routes \ +myhomehost/setup-6to4 \ +myhomehost/shutdown-6to4 \ +myhomehost/wlan-scan \ +myhomehost/wlan-switch-to-ap \ +myhomehost/wlan-switch-to-sta \ +myhomehost/wlan-restartap \ +myissthost/setup-6to4 \ +myissthost/shutdown-6to4 \ +myhomedesktop/setup-6to4 \ +myhomedesktop/shutdown-6to4 \ +mylaptop/wlan-reinit + +SBINTARGET=/usr/local/sbin + +USERFILES=\ +firefox-memusage-log-create.sh \ +firefox-memusage-log-plot.sh \ +irexec.pl \ +ssh-forward-allisst \ +ssh-forward-allisst-continuously \ +ssh-forward-isstcvs \ +ssh-forward-isstica \ +ssh-forward-isstssh \ +ssh-forward-isstwww \ +ssh-forward-myissthostssh \ +ssh-forwarded-isstssh \ +ssh-forwarded-myissthost \ +ssh-isstunixhost \ +ssh-myissthost \ +xmms.sh + +USERTARGET=$(HOME)/bin + +default: install + +install: install-global install-user + +TMP=/tmp/mkinstglobal-$(USER) + +include Makefile.conf + +# TODO: race condition? +install-global: $(GLOBALFILES) + mkdir -p $(GLOBALTARGET) + mkdir -p $(SBINTARGET) + rm -f $(TMP); umask 022; echo >$(TMP) + $(foreach file,$(GLOBALFILES), echo mkdir -p '$(GLOBALTARGET)'/`dirname $(file)` >>$(TMP); \ + echo install $(file) '$(GLOBALTARGET)'/`dirname $(file)` >>$(TMP);) + $(foreach file,$(SBINFILES), echo mkdir -p '$(SBINTARGET)'/`dirname $(file)` >>$(TMP); \ + echo install $(file) '$(SBINTARGET)'/`dirname $(file)` >>$(TMP);) + su $(GLOBALUSER) $(TMP) + rm -f $(TMP) + + +install-user: $(USERFILES) + mkdir -p $(USERTARGET) + $(foreach file,$(USERFILES), mkdir -p '$(USERTARGET)'/`dirname $(file)`; \ + install $(file) '$(USERTARGET)'/`dirname $(file)`;) + + +mouseclick: mouseclick.c + $(CC) $(CFLAGS) $(X11LDFLAGS) -o $@ $< diff --git a/Makefile.conf b/Makefile.conf new file mode 100644 index 0000000..15970f0 --- /dev/null +++ b/Makefile.conf @@ -0,0 +1,6 @@ +SBINTARGET=/usr/local/sbin +GLOBALTARGET=/usr/local/bin +GLOBALUSER=root +# LDFLAGS=-L/usr/X11R6/lib -lX11 +X11LDFLAGS=-L/usr/X11R6/lib -lX11 +CFLAGS:=$(CFLAGS) -I/usr/X11R6/include diff --git a/Makefile.conf.sample b/Makefile.conf.sample new file mode 100644 index 0000000..d71d81f --- /dev/null +++ b/Makefile.conf.sample @@ -0,0 +1,6 @@ +SBINTARGET=$(HOME)/bin +GLOBALTARGET=$(HOME)/bin +GLOBALUSER=$(USER) +# LDFLAGS=-L/usr/X11R6/lib -lX11 +X11LDFLAGS=-L/usr/X11R6/lib -lX11 +CFLAGS:=$(CFLAGS) -I/usr/X11R6/include diff --git a/SunOS/myps b/SunOS/myps new file mode 100755 index 0000000..96875c3 --- /dev/null +++ b/SunOS/myps @@ -0,0 +1,3 @@ +#!/bin/sh + +ps -A -o user,pid,ppid,s,pcpu,pmem,vsz,osz,rss,stime,etime,time,args diff --git a/a2xcf b/a2xcf new file mode 100755 index 0000000..f168910 --- /dev/null +++ b/a2xcf @@ -0,0 +1,26 @@ +#!/bin/sh + +while getopts 'o:' OPTNAME; do + case "$OPTNAME" in + "o") + outfile="$OPTARG" ;; + "?") + exit 1;; + esac +done + +shift $(($OPTIND - 1)) + +for infile in "$@"; do + if [ -z "$outfile" ]; then + outfile=${infile%.*}.xcf; + fi + # TODO: not white-space safe. Didn't find a goddamn way to pass arguments to the scheme code, + # and you don't really want to do the filename iteration/globbing in the scheme code + gimp --no-interface --no-data --batch \ + "(let* + ((image (car (gimp-file-load RUN-NONINTERACTIVE \"$infile\" \"$infile\"))) + (actlayer (car (gimp-image-get-active-layer image)))) + (gimp-file-save RUN-NONINTERACTIVE image actlayer \"$outfile\" \"$outfile\"))" \ + --batch '(gimp-quit TRUE)' +done diff --git a/apt-build b/apt-build new file mode 100755 index 0000000..bd56efd --- /dev/null +++ b/apt-build @@ -0,0 +1,954 @@ +#!/usr/bin/perl -w +# +# $Id: apt-build,v 1.1 2006/12/17 20:20:35 klischat Exp $ +# +# (c) 2002-2005 Julien Danjou +# (c) 2003 Davor Ocelic (apt-build first rewrite) +# (c) 2004 Alexander Ehlert (implemented buildsource) +# 2006 Olaf Klischat (log all run command lines extensively) +# +# +# This package 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; version 2 dated June, 1991. +# +# This package 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 package; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + +# +# The comments in the script have been made verbose on purpose, to help new +# developers get the grip on apt-build and Perl in general. +# + +use strict; +use warnings; +use AppConfig qw/:expand :argcount/; +use Fatal qw/chdir open/; # see Fatal +use Env qw/@PATH $APT_BUILD_WRAPPER/; # perldoc Env +use AptPkg::Config qw/$_config/; # see libapt-pkg-perl +use AptPkg::System qw/$_system/; # +use AptPkg::Version; +use AptPkg::Source; +use AptPkg::Cache; + + +{ + my ($self) = ($0 =~ /([^\/]*)$/); + + sub system_logged { + my $cmdstr = join(' ', map {"'$_'"} @_); + print "$self: executing: $cmdstr\n"; + my $result = system @_; + if ($result) { + print "$self: failed to execute $cmdstr\n"; + } + else { + print "$self: successfully executed $cmdstr\n"; + } + return $result; + } + + + sub chdir_logged { + my $dir = shift; + print "$self: cd $dir\n"; + return chdir $dir; + } +} + +# Initial +my $VERSION = "0.12.24"; +my ($conf, %conf, @builddep, @apt_args); + +@apt_args = qw/--yes/; # and DEFAULT => 1, down in parse_config() + +my @actions = qw/install source remove info update upgrade world build_source update_source + clean_sources build_repository clean_build clean_repository moo find/; # possible actions + +$\ = "\n"; # automatic newline after each print() + +# Ok, we start here... +$_config->init; +parse_config() or die "Can't parse config\n"; # all config-related + +my $cmd = shift or help(); # if no command specified, help is called and we exit +$cmd =~ s/-/_/g; # replace all "-" in command name with "_" +@_ = @ARGV; # For the "&$cmd" call, few lines below + +-d $conf->build_dir or die "--build-dir must be a valid directory!\n"; +chdir_logged $conf->build_dir; # use Fatal qw/chdir/ above takes care for this + +# Initialize libapt now after basic checks were okay +$_system = $_config->system; +$_config->{quiet} = 2; +my $_cache = new AptPkg::Cache; +my $_version = $_system->versioning; +my $_source = new AptPkg::Source $conf->sources_list; +my $_pkg_infos = $_cache->packages; + +# 'no strict' makes it possible that we call "&$cmd" (so, if the user +# specifies command 'source', we call sub source). +# As an additional verification step, command name must be listed in @actions +# (if we didn't check that, the script would break with non-friendly message). +# The whole work is then done in some of the functions listed below. +# Also, the whole block is surrounded by { and }, so that 'no strict' would +# be turned back to 'strict' at the exit of the block automatically. +# And note the way we use to call the function; we say "&$cmd" (prefixed with +# '&' and having no closing parentheses) - that will automatically make contents +# of our @_ variable available to called functions (and we did @_ = @ARGV above) +{ no strict 'refs'; help() unless grep {/^$cmd$/i} @actions; &$cmd } + +exit 0; + +# END # (helpers below) +############################################################################# + + +# Ok, let's serve the simple subroutines first +sub help +{ +print "Usage: apt-build [options] [command] + +Commands: + update - Update package lists + upgrade - Perform an upgrade + install - Build and install new packages + source - Download and extract source in build directory + build-source - Download, extract and build source package + update-source - Update all sources and rebuild them + remove - Remove packages + build-repository - Rebuild the repository + clean-sources - Clean up all object files in source directories + clean-build - Erase downloaded packages and temporary build files + clean-repository - Erase downloaded packages and temporary build files + world - Rebuild and reinstall all packages on your system + info - Build-related package information + +Options: + --reinstall - Re-build and install already installed package + --rebuild - Rebuild package + --remove-builddep - Remove build-dependencies installed by apt-build + --nowrapper - Do not use gcc/g++ wrapper + --purge - Use purge instead of remove + --noupdate - Do not run 'apt-get update' before package installation + --build-command - Use to build package + --patch - Apply patch s before the build + --patch-strip - Striplevel for the patch files + --yes -y - Assume yes + --version -v - Show version and exit + --force-yes - Force yes + --source - Do not download source (sources are extracted already) + --build-only - Do not install any of build dependencies or + --build-dir - Specify build dir + --repository-dir - Specify the repository directory + --target-release - Distribution to fetch packages from + --sources-list - Specify sources.list file + --apt-get - Specify an alternative apt-get application to use + --apt-cache - Specify an alternative apt-cache application to use + --config - Specify an alternative configuration file +"; + exit 1; +} + +# Since shell returns 0 on success, and our script usually uses true values +# for the same, we use "!" here to invert the result - shell's success (0) +# becomes our success (1) +sub patch +{ + print STDERR "-----> Patching (@_) <-----"; + !system_logged("patch -p$conf{patch_strip} < $_") or return !$? while $_ = shift; + return 1; +} + +sub clean_build +{ + print STDERR "-----> Cleaning the build tree <-----"; + !system_logged("rm -rf $conf{build_dir}/*") +} + +sub remove +{ + print STDERR "-----> Removing packages (@_) <-----"; + !system_logged($conf->apt_get . " @apt_args remove @_") +} + +sub update +{ + print STDERR "-----> Updating package lists <-----"; + !system_logged($conf->apt_get . " @apt_args update") +} + +sub move_to_repository +{ + print STDERR "-----> Moving packages to repository <-----"; + !system_logged("mv $conf{build_dir}/*.deb $conf{repository_dir}") +} + + +# Find out [source] package download locations +# If called in void context, print to screen; otherwise return array +sub find +{ + local $" = ", "; + my @res; + for my $pkg (@_) + { + my @seen; # Skip multiple entries for the same pkg version + my @list = $_source->find($pkg); + for (@list) + { + my $ver = $$_{Version}; + grep {/$ver/} @seen and next; # Skip if seen + push @seen, $ver; + unless (defined wantarray) + { # If we're called in void context + print "Source: @$_{'Package','Section','Version','Maintainer'}"; + print "Binaries: @{$$_{Binaries}}"; + } + my @files = @{ $$_{Files} }; + for (@files) + { + my $type = ucfirst $$_{Type}; + !defined wantarray? + print "$type: $$_{ArchiveURI}" : + push @res, $$_{ArchiveURI}; + } + print ''; + } + print ''; + } + return @res if defined wantarray; + return 1; +} + + +sub info +{ + my @size; + + for (@_) + { + my $pkg = $_; + + # (full explanation for read_apt_list is below) + # We invoke apt-get here to determine package size + push @size, + read_apt_list($conf->apt_get . " --print-uris @apt_args source $pkg |", + "^'", \&extract_size); + + # and to determine package dependencies, and their cumulative size + my (@size_deps, @deps); + read_apt_list($conf->apt_get . " --print-uris @apt_args build-dep $pkg |", + "^'", sub { + push @size_deps, extract_size($_); + push @deps, extract_name($_); + }); + + # print summary + my $sumsize = 0; + $sumsize += $_ for @size; + print "Package: $pkg"; + print "Source-size: $sumsize"; + $sumsize = 0; + $sumsize += $_ for @size_deps; + print "Depends-size: $sumsize"; + print "Depends: @deps "; + } + return 1; +} + +sub source_by_package +{ + my $pkg_name = shift or die "Missing package name for source_by_package().\n"; + my ($pkg_version, $src_version, $src_name); + + if (!($src_version = shift)) + { + # no version passed along. + $src_version = &get_src_version($pkg_name); + } + + $src_name = &get_src_name($pkg_name, $src_version); + + return source_by_source ($src_name, $src_version); +} + +sub source_by_source +{ + my $src_name = $_[0] or die "Missing source package name for source_by_source().\n"; + my $src_version = $_[1] or die "Missing version information for source package $src_name in source_by_source().\n"; + + update() if $conf->update; # to be consistent with install() + + print STDERR "-----> Downloading source $src_name ($src_version) <-----"; + return !system_logged($conf->apt_get . " @apt_args source ${src_name}=${src_version}") +} + + +sub source +{ + return &source_by_package(@_); +} + +sub build +{ + @_ == 3 or return; + my ($src_name, $upver, $maintver) = @_; + my ($src_version, $control, @packages, $srcpkg, $srcver, $upverchdir, $new); + + print STDERR "-----> Building $src_name <-----"; + + $upver =~ s/^\d+://; # strip epoch + + chdir_logged $conf{build_dir}; + + chdir_logged "$src_name-$upver"; + + # Add an entry in changelog + system_logged("debchange --append 'Built by apt-build'"); + for (@{$conf->patch}) + { + $_ =~ s[.*/(.*)\n$][$1]gio; # basename + chomp + system_logged("debchange --append 'Patched with $_'"); + } + + # Patch if asked + my $r = 1; + for (@{$conf->patch}) + { + $r = patch($_); + last if (!$r); + } + + if ($r) + { + # Add optimizations infos + my $buildoptions; + $buildoptions = "Build options: ". + $conf->Olevel." ".$conf->mtune." ".$conf->options; + + system_logged("debchange --append \"$buildoptions\""); + + # Now build + $r = !system_logged($conf->build_command); + wait; + } + + if ($conf->cleanup) + { + print STDERR "----> Cleaning up object files <-----"; + system_logged("debclean"); + wait; + } + + chdir_logged $conf{build_dir}; + + return $r; +} + + +sub build_repository +{ + print STDERR "-----> Building repository <-----"; + + chdir_logged $conf->repository_dir; + my $arch = $_config->get("APT::Architecture"); + + system_logged("ln -s . main") unless -e "main"; + system_logged("ln -s . apt-build") unless -e "apt-build"; + system_logged("ln -s . dists") unless -e "dists"; + system_logged("ln -s . binary-$arch") unless -e "binary-$arch"; + make_release_file() unless -e "Release"; + + system_logged("apt-ftparchive packages . | gzip -9 > Packages.gz"); + wait; + chdir_logged $conf->build_dir; + return 1; +} + +sub make_release_file +{ + my $release; + open RELEASE, "< /usr/share/apt-build/Release"; + while () { + my $arch = $_config->get("APT::Architecture"); + s/__arch__/$arch/; + $release .= $_; + } + close RELEASE; + open RELEASEREPO, "> $conf{repository_dir}/Release"; + print RELEASEREPO $release; + close RELEASEREPO; + return 1; +} + +sub clean_repository +{ + print STDERR "-----> Cleaning the repository <-----"; + if($conf->repository_dir) + { + (! system_logged("rm -fr $conf{repository_dir}/*.deb")) or die "Error: $!\n"; + } + else + { + die "Error: what is repository_dir?"; + } +} + +sub builddep +{ + my $pkg = shift or return; + + if ($conf->remove_builddep) + { + read_apt_list($conf->apt_get . " --print-uris @apt_args build-dep $pkg |", + "^'", \&extract_name); + } + + print STDERR "-----> Installing build dependencies (for $pkg) <-----"; + !system_logged($conf->apt_get . " @apt_args build-dep $pkg") +} + + +sub get_src_name +{ + my ($pkg_name, $src_version) = @_; + my $src_name; + foreach (@{$_source->{$pkg_name}}) + { + $src_name = $_->{Package} if($src_version eq $_->{Version}); + } + + return $src_name; +} + +sub get_src_version +{ + my $pkg_name = $_[0] || die; + my $pkg_version = $_[1] || &get_pkg_version($pkg_name); + my ($src_version, $special_srcver); + # By default + $src_version = $pkg_version; + + open APTCIN, $conf->apt_cache . " show $pkg_name |"; + while() + { + $special_srcver = 1 if($pkg_version and /^Version: $pkg_version$/); + if (/^Version: (\S+)$/ and ($special_srcver or not $pkg_version)) + { + $src_version = $1; + last; + } + } + close(APTCIN); + + return $src_version; +} + +sub get_pkg_version +{ + my $pkg_name = shift; + my $pkg_version; + + # Look for candidate version + open APTCIN, "LANGUAGE=C " . $conf->apt_cache . " policy $pkg_name |"; + while() + { $pkg_version = $1 if(/^\s+Candidate: (.*)$/); } + close(APTCIN); + + return $pkg_version; +} + + +sub build_deb_filename +{ + my ($pkg_name, $pkg_version) = @_; + my $deb_file; + + # Build the .deb name + my $arch = $_config->get("APT::Architecture"); + my $pkg_version_file; $pkg_version_file = $pkg_version; + + # dpkg-buildpackage doesn't put epoch in file name, so remove it. + $pkg_version_file =~ s/^\d://; + $deb_file = $pkg_name."_".$pkg_version_file."_".$arch.".deb"; +} + +sub install +{ + my (@packages, @pkgs, $buildpkg); + my (@pkglist) = @_; + my $nopkgs_okay = 0; + my $special_srcver = 0; + + for (@_) + { + my $pkg_name = $_; + my ($pkg_version, $src_name, $src_version, $deb_file); + + $pkg_version = &get_pkg_version($pkg_name); + $src_version = &get_src_version($pkg_name, $pkg_version); + $src_name = &get_src_name($pkg_name, $src_version); + + if (!$src_name && $src_version =~ /\+/) { + $src_version =~ s/\+.*$//; + $src_name = &get_src_name($pkg_name, $src_version); + } + + die "Unable to find binary candidate for $pkg_name" unless ($pkg_version); + die "Unable to find source information for $pkg_name" unless ($src_version && $src_name); + + $deb_file = &build_deb_filename($pkg_name, $pkg_version); + + if (-f "$conf{build_dir}/$deb_file" + && !($conf->rebuild)) + { + print "Package $pkg_name already built."; + push(@pkgs, $deb_file); + move_to_repository(@pkgs); + build_repository(); + } + elsif (-f "$conf{repository_dir}/$deb_file" + && !($conf->rebuild)) + { + print "Package $pkg_name already in repository."; + push @pkgs, $deb_file; + } + else + { + push @pkgs, $deb_file; + + builddep($src_name) unless $conf->build_only; + source_by_package($pkg_name, $src_version) if $conf->source; + + # Now build the package + my $upver = $_version->upstream($src_version); + my $maintver = $1 if $src_version =~ /^$upver-(.*)$/; + if (build($src_name, $upver, $maintver)) + { + &move_to_repository(@pkgs); + &build_repository; + } + else + { + warn "Error while building $pkg_name!\n" ; + pop @pkgs; + } + } + + unless (@pkgs or $nopkgs_okay) + { + print STDERR "Sorry, no package to install."; + } + + # Remove builddep if asked + remove(@builddep) if $conf->remove_builddep && !($conf->build_only); + } + + # If we have something to install, install + if(@pkgs && !($conf->build_only)) + { + update() if $conf->update; + system_logged($conf->apt_get . " -t apt-build @apt_args install @pkglist"); + wait; + } + return 1; +} + +sub build_source +{ + my (@packages, @pkgs, $src_name); + my (@pkglist) = @_; + my $nopkgs_okay = 0; + + for (@_) + { + my $pkg = $_; + open APTIN, $conf->apt_get . " --print-uris @apt_args source $pkg |"; #2>&1 | + + AI: while () + { + if ( /^Package .* is a virtual package provided by/ ) + { + system_logged($conf->apt_get . " @apt_args install $pkg"); + exit 0; + + } elsif ( /^\'(http|ftp|file|cdrom)/ ) { + @packages = split /\s+/; + $packages[1] =~ /^(.*)_(.*)\.dsc$/ or last; # XXX + my ($src_name, $src_version) = ($1, $2); + my $arch=$_config->get("APT::Architecture"); + + my $aptcache = $conf->apt_cache; + my $apcout = qx[$aptcache showsrc $pkg | grep "^Binary:" | head -1]; + chomp $apcout; + my $fullversion = qx[$aptcache showsrc $src_name | grep "^Version:" | head -1]; + chomp $fullversion; + $fullversion =~ s/Version: //; + my $build = 1; + $apcout =~ s/(Binary: |,)//g; + my @genpackages = split / /,$apcout; + print "Building the following packages from source: "; + #my $missing = 0; Some packages are architecture depend, + # so not everything is built + foreach my $gpkg (@genpackages) + { + if ((( -f "$conf{repository_dir}/${gpkg}_${src_version}_${arch}.deb") || + ( -f "$conf{repository_dir}/${gpkg}_${src_version}_all.deb" )) + && !($conf->rebuild) ) + { + print "Package $src_name already in repository."; + $nopkgs_okay++; + $build = 0; + } + # if (!( -f "$conf{repository_dir}/${gpkg}_${src_version}_${arch}.deb") && + # !( -f "$conf{repository_dir}/${gpkg}_${src_version}_all.deb" )) { + # print "Package $src_name missing in repository."; + # print "Trying to rebuild."; + # $missing = 1; + # } + # last if $missing; + } + wait; + #if ($missing) { $build=1; }; + if ($build) { + builddep($src_name) unless $conf->build_only; + source_by_source ($src_name, $src_version) if $conf->source; + + # Now build the package + my ($maintver, $upver); + if ( $fullversion =~ /(.*)(-.*)$/) { + ($upver, $maintver) = ($1, $2) + } else { + ($upver) = ($fullversion) + } + + $upver =~ s/%3a/:/; + if (build($src_name, $upver, $maintver)) { + &move_to_repository; + &build_repository; + $nopkgs_okay++; + } else { + warn "Error while building $pkg!\n" ; + } + } + } + } + close APTIN; + wait; + + unless ($nopkgs_okay) { + print STDERR "Some error occured building package"; + } + } + + wait; + + # Remove builddep if asked + remove(@builddep) if $conf->remove_builddep && !($conf->build_only); + + # If we have something to install, install + if( @pkgs && !($conf->build_only) ) + { + update() if $conf->update; + system_logged($conf->apt_get . " -t apt-build @apt_args install @pkglist"); + } +} + +sub update_source +{ + chdir_logged $conf->build_dir; + + print STDERR "-----> Updating sources <-----"; + + open DSCIN, "find *.dsc|"; + + while () + { + chomp $_; + my $pkg=$_; + $pkg =~ /^(.*)_(.*)\.dsc/ or warn; + my ($buildpkg, $version) = ($1, $2); + my $apt_cache = $conf->apt_cache; + my $newversion = qx[$apt_cache showsrc $buildpkg | grep "^Version:" | head -1]; chomp $newversion; + $newversion =~ s/Version: //; + $newversion =~ s/[0-9]://; + if ($newversion ne $version) + { + print "New version for $pkg available."; + print "Updating from $version to $newversion"; + } + else + { + print "$buildpkg-$version is up to date."; + } + build_source($buildpkg); + } + + close DSCIN; +} + +sub clean_sources +{ + chdir_logged $conf->build_dir; + + print STDERR "-----> Cleaning sources <-----"; + + open DSCIN, "find *.dsc|"; + + while () + { + chomp $_; + my $pkg=$_; + $pkg =~ /^(.*)_(.*)\.dsc/ or warn; + my ($buildpkg, $version) = ($1, $2); + $version =~ s/-[0-9]$//; + + print "${buildpkg}-${version}"; + if (-d "${buildpkg}-${version}") + { + chdir_logged "${buildpkg}-${version}"; + print STDERR "----> Cleaning up object files <-----"; + print STDERR "Package $buildpkg"; + system_logged("debclean"); + chdir_logged $conf->build_dir; + } + } +} + +sub world +{ + print STDERR "-----> Rebuilding the world! <-----"; + print STDERR "-----> Building package list <-----"; + + die "Please read README.Debian first.\n" if ! -e "/etc/apt/apt-build.list"; + + open IGNORELIST, "< /etc/apt/apt-build.list"; + while() + { + my $p = $_; + chomp($p); + install($p); + } + close IGNORELIST; + return 1; +} + +sub upgrade +{ + print STDERR "-----> Upgrading (@_) <-----"; + @_ or @_ = read_apt_list( + $conf->apt_get . " --print-uris @apt_args upgrade |", "^'", \&extract_name); + + @_ ? install(@_) : print STDERR "No packages need to be upgraded"; + return 1; +} + +# the funny characters here are color sequences, to look nice when printed on +# the terminal ;) +sub moo +{ + print << "EOM"; + (__) \e[32m~\e[0m + (oo) / + _____\\/___/ + / /\\ / / + \e[32m~\e[0m / \e[33m*\e[0m / + / ___/ +*----/\\ + / \\ + / / + ~ ~ +..."Have you danced today? Discow!"... +EOM +} + + +# The core of our config is the AppConfig module (available from CPAN). +# The whole $conf = AppConfig->new() block is related to AppConfig. So, see +# perldoc AppConfig for more. (AppConfig is very well documented and the man +# page is easy to understand). +sub parse_config +{ + $conf = AppConfig->new( + { + CASE => 1, + DEBUG => 0, + CREATE => 0, + GLOBAL => { + ARGCOUNT => ARGCOUNT_NONE, + DEFAULT => 0, + } + }, + # ALIAS =>, so imperfect and universe-breaking, and we still need it. + "config|cfg=s", { DEFAULT => "/etc/apt/apt-build.conf", + ALIAS => "config", + ACTION => sub + { + $conf->file ($_[2]) if -r $_[2]; + }, + }, + "remove_builddep!", { ALIAS => "remove-builddep" }, + "wrapper!", { DEFAULT => 1 }, + "purge!", { ACTION => \&apt_args_modify }, + "build_command=s", { DEFAULT=> "dpkg-buildpackage -b -us -uc", + ALIAS => "build-command" }, + "reinstall|r!", { ACTION => \&apt_args_modify }, + "yes|y!", { ACTION => \&apt_args_modify, DEFAULT => 1 }, + "force_yes!", { ACTION => \&apt_args_modify, ALIAS => 'force-yes', DEFAULT => 0 }, + "patch=s@", { }, + "patch_strip=i", { DEFAULT => 1, ALIAS => "patch-strip|p" }, + "target-release|t=s", { ACTION => sub + { + &apt_args_modify(@_); + $_config->set("APT::Default-Release", $_[2]); + }, + }, + "source!", { DEFAULT => 1 }, + "build_only!", { ALIAS => "build-only" }, + "rebuild!", { DEFAULT => 0 }, + "build_dir=s", { DEFAULT => "/var/cache/apt-build/build/", + ALIAS => "build-dir" }, + "repository_dir=s", { DEFAULT => "/var/cache/apt-build/repository/", + ALIAS => "repository-dir" }, + "sources_list=s", { ACTION => \&apt_args_modify, + DEFAULT => "/etc/apt/sources.list", + ALIAS => "sources-list" }, + "update!", { DEFAULT => 1 }, + "cleanup!", { DEFAULT => 1 }, # call debian/rules clean after build + "apt_get|aptget=s", { DEFAULT => "apt-get", + ALIAS => "apt-get" }, + "apt_cache|aptcache=s", { DEFAULT => "apt-cache", + ALIAS => "apt-cache" }, + "Olevel=s", {}, + "mtune=s", {}, + "options=s", {}, + "make_options=s",{}, + "version", { + ACTION => sub { print "apt-build version $VERSION"; exit 0 } + }, + ) or die "Can't initialize the AppConfig object\n"; + + tie %conf, 'AptBuild::ObjHash', \$conf; # see AptBuild::ObjHash below + + $conf->getopt; # parse command line + $conf->file($conf->get("config")); + + $APT_BUILD_WRAPPER++ if $conf->wrapper; # define ENV var + unshift @PATH, "/usr/lib/apt-build" if $conf->wrapper; + return 1; +} + + +# Okay, this is the core of the script. (Note that this will be abandoned +# when we switch to libapt-pkg-perl (since we won't call external commands any +# more), but it's still worth explaining: +# You pass the script three arguments: +# 1 - command to execute +# 2 - output pattern filter +# 3 - subroutine to parse lines +# So basically, read_apt_list runs a command ("apt-get ...something" usually), +# then it discards the output lines which do not match $pattern, and it calls +# &$handler function for each remaining line to extract results. +# Filtering can be done in the handler function as well, but this pre-filter +# step is just a small convenience. +# The trick is that $handler is a function reference, which can be specified +# by either passing \&func_name as argument, or by including the whole +# subroutine directly, in-place as the 3rd argument. +# The info() function has an example of both (passing a reference and specifying +# sub{} in-place). +# This greatly simplifies things because we concentrate on functionality, and +# don't have to bother with opening & closing files, etc. +# The return value of read_apt_list (if you want to use it) is an array +# containing all non-empty results from invocation of $&handler. +sub read_apt_list +{ + my ($line, $pattern, $handler) = @_; + my @results; + open IN, "$line"; + while (local $_ = ) { + if (/$pattern/i) { local $_ = &$handler(); push @results, $_ if $_ } + } + close IN; + return @results +} + + +# self-explanatory, those functions take apt-get output as input and +# try to extract information. +sub extract_name { ($_ = (split /\s+/)[1]) =~ s/_.*// if /_/; $_ } + +sub extract_filename { return (split /\s+/)[1] } + +sub extract_size { return (split /\s+/)[2] } + +# This function modifies @apt_args (either adds or removes arguments +# from it). +sub apt_args_modify +{ + my ($self, $name, $value) = @_; + + if (!( $self->{ARGCOUNT}->{$name} )) # if option takes no argument + { + $name =~ s|\_|\-|g; + if ($value) { push @apt_args, "--$name" } + else { @apt_args = grep {!/^--$name$/} @apt_args } + + } + elsif ($self->{ARGCOUNT}->{$name} == ARGCOUNT_ONE) # or if takes 1 arg + { + @apt_args = grep {!/^--$name /} @apt_args; # just to be sure + + # special parsing for --sources-list + if($name =~ /^sources.list$/) + { $name = "-oDir::Etc::SourceList=$value"; } + else + { $name = "--$name $value"; } + + push @apt_args, "$name"; + + } +} + + +# This fine chunk "extends" the AppConfig object. In addition to doing +# $conf->variable and $conf->variable(value), it's now possible to do: +# $conf{variable} and $conf{variable} = value +# This is very handy inside strings, because this would be invalid: +# print "$c->build_dir" (inside strings, the -> has no special meaning). +# But thanks to AptBuild::ObjHash, we can get the intended results with: +# print "$c{build_dir}" (which is a valid syntax). +# For more info on how it all works, perldoc perltie +package AptBuild::ObjHash; + +use strict; +use warnings; + +use base qw/Tie::Hash/; + +sub TIEHASH +{ + return 0 unless ref $_[1]; + return bless [ $_[1] ] => $_[0] +} + +sub FETCH +{ + my ($self, $key) = @_; + return ${@$self[0]}->get("$key") +} + +sub STORE +{ + my ($self, $key, $val) = @_; + return ${@$self[0]}->set("$key", $val) +} + diff --git a/apt-file b/apt-file new file mode 100755 index 0000000..eabc747 --- /dev/null +++ b/apt-file @@ -0,0 +1,371 @@ +#!/usr/bin/perl -w + +# +# apt-file - APT package searching utility -- command-line interface +# +# (c) 2001 Sebastien J. Gross +# $Id: apt-file,v 1.1 2004/03/22 02:09:01 klischat Exp $ +# +# +# This package 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; version 2 dated June, 1991. +# +# This package 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 package; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + +use strict; +use ConfigFile "read_config_file"; +use Getopt::Long qw/:config no_ignore_case/; +use Data::Dumper; +use File::Basename; +use AptPkg::Config '$_config'; +use constant VERSION => "2.0.3"; + + +my $Conf; +my $Version; + +sub error($) { + print STDERR "E: ", shift, $! ? ": $!" : "" ,"\n"; + undef $!; + exit 1; +} + +sub warning($) { + print STDERR "W: ", shift, $! ? ": $!" : "" ,"\n"; + undef $!; +} + +sub debug($) { + return if ! defined $Conf->{verbose}; + print STDERR "D: ", shift, $! ? ": $!" : "" ,"\n"; + undef $!; +} + +sub debug_line($){ + return if ! defined $Conf->{verbose}; + print STDERR shift; +} + +sub unique($) { + my $seen = (); + return [ grep { ! $seen->{$_}++ } @{(shift)} ]; +} + +sub reverse_hash($) { + my $hash = shift; + my $ret = (); + foreach my $key (keys %$hash) { + foreach (@{$hash->{$key}}) { + push @{$ret->{$_}}, $key; + } + } + return $ret; +} + +sub parse_sources_list($) { + my $file = shift; + my $uri; + my @uri_items; + my @tmp; + my $line; + my $ret; + + my ($cmd, $dest); + + open(SOURCE, "< $file") || error "Can't open $file"; + while() { + next if /^\s*(?:$|\#|(?:deb-|rpm-))/xo; + chomp; + my $line = $_; + debug "got \'$line\'"; + $line =~ s/([^\/])\#.*$/$1/o; + $line =~ s/^(\S+\s+)\[\S+\]/$1/o; + $line =~ s/\s+/ /go; + $line =~ s/^\s+//o; + + # CDROM entry + if (@tmp = $line =~ m/^([^\[]*)\[([^\]]*)\](.*)$/o) { + $tmp[1] =~ s/ /_/g; + $line = $tmp[0].'['.$tmp[1].']'.$tmp[2]; + } + + # Handle $(ARCH) in sources.list + $line =~ s/\$\(ARCH\)/$Conf->{arch}/g; + debug "kept \'$line\'"; + + my( $pkg, $uri, $dist, @extra) = split /\s+/, $line; + my($scheme, $user, $passwd, $host, $port, $path, $query, + $fragment) = + $uri =~ + m|^ + (?:([^:/?\#]+):)? # scheme + (?:// + (?: + ([^:@]*) #username + (?::([^@]*))? #passwd + @)? + ([^:/?\#]*) # host + (?::(\d+))? # port + )? + ([^?\#]*) # path + (?:\?([^\#]*))? # query + (?:\#(.*))? # fragment + |ox; + +# print "$scheme, $user, $passwd, $host, $port, $path, $query, $fragment\n"; + + my $fetch=[]; + + foreach (@extra) { + push @$fetch, m/(.*?)\/(?:.*)/o ? "$dist/$1" : "$dist"; + } + + foreach (@{(unique $fetch)}) { + if (!defined $Conf->{"${scheme}"}) { + warning "Don't know how to handle $scheme"; + next; + } + $dist = $_; + $cmd = $Conf->{"${scheme}"}; + $dest = $Conf->{destination}; + my $cache = $Conf->{cache}; + my $arch = $Conf->{arch}; + my $cdrom = $Conf->{cdrom_mount}; + foreach my $var (qw/host port user passwd path dist pkg + cache arch uri cdrom/) { + map { + $_ =~ s{<$var(?:\|(.+?))?>}{ + defined eval "\$$var" ? eval "\$$var" : + defined $1 ? $1 : ""; + }gsex; + } ($cmd, $dest) + } + $dest =~ s/(\/|_)+/_/go; + $cmd =~ s//$dest/g; + my $hash; + foreach (qw/host port user passwd path dist pkg uri line + dest cmd/) { + $hash->{$_} = eval "\$$_"; + } + push @$ret, $hash; + }; + } + close SOURCE; + return $ret; +} + +sub fetch_files ($) { + mkdir $Conf->{cache} if ! -d $Conf->{cache}; + error "Can't write in $Conf->{cache}" if ! -w $Conf->{cache}; + foreach (@{(shift)}) { + debug $_->{cmd}; + qx|$_->{cmd}| if ! defined $Conf->{dummy}; + } +} + +sub do_grep($$) { + my ($data, $pattern) = @_; + my $ret; + my ($pack, $file); + debug "regexp: $pattern"; + $|=1; + my $regexp = eval { $Conf->{ignore_case} ? qr/$pattern/i : qr/$pattern/ }; + error($@) if $@; + foreach(@$data) { + my $file = "$Conf->{cache}/$_->{dest}"; + next if (! -f $file); + $file = quotemeta $file; + debug "Search in $file"; + open (ZCAT, "zcat $file |") || + warning "Can't zcat $file"; + while() { + next if ! (($pack, $file) = /$regexp/); + debug_line "."; + foreach (split /,/, $file) { + push @{$ret->{$pack}}, basename $_; + } + } + close ZCAT; + debug_line "\n"; + } + $ret = reverse_hash($ret); + if (!defined $Conf->{package_only}) { + foreach my $key (sort keys %$ret) { + foreach (sort @{$ret->{$key}}) { + print "$key: $_\n"; + } + } + } else { + print map {"$_\n"} (sort keys %$ret); + } + exit 0; +} + +sub grep_file($) { + my $data = shift; + my $pattern = join "", ( + '^(.*?', + $Conf->{pattern}, + defined $Conf->{fixed_strings} ? + ")" : '[^\s]*)', + '\s+(\S+)\s*$', + ); + do_grep $data, $pattern; +} + +sub grep_package($) { + my $data = shift; + my $pattern = join "", ( + '^(\S+)\s+', + '(\S*/', + $Conf->{pattern}, + defined $Conf->{fixed_strings} ? + "" : ".*", + ")", + '$', + ); + do_grep $data, $pattern; +} + +sub purge_cache($) { + my $data = shift; + foreach (@$data) { + debug "Purging $Conf->{cache}/$_->{dest}"; + next if defined $Conf->{dummy}; + unlink "$Conf->{cache}/$_->{dest}" || + warning "Can't remove $Conf->{cache}/$_->{dest}"; + } +} + +sub print_version { + print < + +EOF + ; +} + +sub print_help { + my $err_code = shift || 0; + + print_version; + print <<"EOF"; + +apt-file [options] action [pattern] + +Configuration options: + --sources-list -s sources.list location + --cache -c Cache directory + --architecture -a Use specific architecture + --cdrom-mount -d Use specific cdrom mountpoint + --package-only -l Only display packages name + --fixed-string -F Do not expand pattern + --ignore-case -i Ignore case distinctions + --regexp -x pattern is a regular expression + --verbose -v run in verbose mode + --dummy -y run in dummy mode (no action) + --help -h Show this help. + --version -V Show version number + +Action: + update Fetch Contents files from apt-sources. + search Search files in packages + list List files in packages + purge Remove cache files +EOF +; + exit $err_code; +} + +sub get_options() { + my %options = ( + "sources-list|s=s" => \$Conf->{sources_list}, + "cache|c=s" => \$Conf->{cache}, + "architecture|a=s" => \$Conf->{architecture}, + "cdrom-mount|d=s" => \$Conf->{cdrom_mount}, + "verbose|v" => \$Conf->{verbose}, + "ignore-case|i" => \$Conf->{ignore_case}, + "regexp|x" => \$Conf->{is_regexp}, + "dummy|y" => \$Conf->{dummy}, + "package-only|l" => \$Conf->{package_only}, + "fixed-string|F" => \$Conf->{fixed_strings}, + "help|h" => \$Conf->{help}, + "version|V" => \$Conf->{version}, + ); + GetOptions(%options) || print_help 1; +} + +sub main { + my $conf_file; + map { $conf_file = $_ if -f $_ } ("/etc/apt/apt-file.conf", + "apt-file.conf", + "$ENV{HOME}/.apt-file.conf"); + + error "No config file found\n" if ! defined $conf_file; + debug "Using $conf_file"; + + $Conf=read_config_file $conf_file; + get_options(); + if (defined $Conf->{version}) { + print_version; + exit 0; + } + + $_config->init; + $Conf->{arch} ||= $_config->{'APT::Architecture'}; + $Conf->{sources_list} ||= $_config->{'Dir'} . + $_config->{'Dir::Etc'} . $_config->{'Dir::Etc::sourcelist'}; + $Conf->{cache} ||= $_config->{'Dir'} . $_config->{'Dir::Cache'}; + $Conf->{cache} =~ s/\/\s*$//; + $Conf->{cdrom_mount} ||= $_config->{'Acquire::cdrom::Mount'} || + "/cdrom"; + + $Conf->{action} = shift @ARGV || "none"; + $Conf->{pattern} = shift @ARGV; + if(defined $Conf->{pattern}) { + $Conf->{pattern} =~ s/^\///; + $Conf->{pattern} = quotemeta($Conf->{pattern}) unless $Conf->{is_regexp}; + } + undef $!; + + my $actions = { + update => \&fetch_files, + search => \&grep_file, + list => \&grep_package, + purge => \&purge_cache, + }; + + $Conf->{help}=2 if $Conf->{action} =~ m/search|list/ && + ! defined $Conf->{pattern}; + $Conf->{help}=2 if ! defined $actions->{$Conf->{action}} && + ! defined $Conf->{help}; + print_help($Conf->{help}-1) if defined $Conf->{help}; + + my $sources = parse_sources_list $Conf->{sources_list}; + error "No valid sources in $Conf->{sources_list}" if ! defined + $sources; + + $actions->{$Conf->{action}}->($sources); +} + +BEGIN { + $Version = VERSION; + main(); +} + +END { + +} + +__END__ diff --git a/apt-file-x.diff b/apt-file-x.diff new file mode 100644 index 0000000..6a541ed --- /dev/null +++ b/apt-file-x.diff @@ -0,0 +1,37 @@ +--- apt-file-2.0.3-5 2004-03-14 23:46:05.000000000 +0100 ++++ apt-file 2004-03-14 12:23:20.000000000 +0100 +@@ -179,7 +179,8 @@ + my ($pack, $file); + debug "regexp: $pattern"; + $|=1; +- my $regexp = $Conf->{ignore_case} ? qr/$pattern/i : qr/$pattern/; ++ my $regexp = eval { $Conf->{ignore_case} ? qr/$pattern/i : qr/$pattern/ }; ++ error($@) if $@; + foreach(@$data) { + my $file = "$Conf->{cache}/$_->{dest}"; + next if (! -f $file); +@@ -271,6 +272,7 @@ + --package-only -l Only display packages name + --fixed-string -F Do not expand pattern + --ignore-case -i Ignore case distinctions ++ --regexp -x pattern is a regular expression + --verbose -v run in verbose mode + --dummy -y run in dummy mode (no action) + --help -h Show this help. +@@ -294,6 +296,7 @@ + "cdrom-mount|d=s" => \$Conf->{cdrom_mount}, + "verbose|v" => \$Conf->{verbose}, + "ignore-case|i" => \$Conf->{ignore_case}, ++ "regexp|x" => \$Conf->{is_regexp}, + "dummy|y" => \$Conf->{dummy}, + "package-only|l" => \$Conf->{package_only}, + "fixed-string|F" => \$Conf->{fixed_strings}, +@@ -332,7 +335,7 @@ + $Conf->{pattern} = shift @ARGV; + if(defined $Conf->{pattern}) { + $Conf->{pattern} =~ s/^\///; +- $Conf->{pattern} = quotemeta($Conf->{pattern}); ++ $Conf->{pattern} = quotemeta($Conf->{pattern}) unless $Conf->{is_regexp}; + } + undef $!; + diff --git a/apt-list-contents b/apt-list-contents new file mode 100755 index 0000000..3fbdd40 --- /dev/null +++ b/apt-list-contents @@ -0,0 +1,3 @@ +#!/bin/sh + +zcat /var/cache/apt/*Contents* diff --git a/audioreset b/audioreset new file mode 100755 index 0000000..7a3a5c5 --- /dev/null +++ b/audioreset @@ -0,0 +1,43 @@ +#!/bin/sh + +# erst OSS probieren +aumix -L + + +# dann Alsa-Einstellungen +# das längliche Argument direkt nach cset ist das zu setzende +# "Control", dann folgt der Wert, auf den es gesetzt werden +# soll. Liste aller Controls: "amixer controls". Jedes Control hat +# einen Wertebereich, aus dem sein Wert sein muss (z.B. boolean oder +# Ganzzahl 0..100). "amixer cget " zeigt den Wertebereich +# sowie den aktuellen Wert des Controls an + +amixer cset iface=MIXER,name='Front Playback Volume' 65% +amixer cset iface=MIXER,name='Front Playback Switch' on + +amixer cset iface=MIXER,name='PCM Playback Volume' 70% + +amixer cset iface=MIXER,name='Line Playback Volume' 70% +amixer cset iface=MIXER,name='Line Playback Switch' on + +amixer cset iface=MIXER,name='Mic Playback Volume' 70% +amixer cset iface=MIXER,name='Mic Playback Switch' on + +amixer cset iface=MIXER,name='CD Playback Volume' 70% +amixer cset iface=MIXER,name='CD Playback Switch' on + +# Input-Source (index) 1 auf 1 (Line-In) setzen +# aus irgendeinem Grund nimmt er (tack, ASRock-Board Onboard-Sound +# snd_hda_intel) nur die Input-Source 1 auf und ignoriert +# Input-Source 0. Mgf. Werte: 0 - Mikro, 1 - Line-In, 2 - CD (siehe +# "amixer cget iface=MIXER,name='Input Source',index=1"). Der +# Aufnahmepegel wird verwirrenderweise über iface=MIXER,name='Capture +# Volume' (ohne index=1) gesetzt +amixer cset iface=MIXER,name='Input Source',index=1 1 + +amixer cset iface=MIXER,name='Capture Volume' 80% + +# v4lctl volume 95% +v4lctl volume 70% + +# TODO: dieses Skript ist jetzt spezifisch fuer tack diff --git a/benchmark_read.c b/benchmark_read.c new file mode 100644 index 0000000..4d9b6f7 --- /dev/null +++ b/benchmark_read.c @@ -0,0 +1,176 @@ +/** + * Benchmark program for linear reading from files or block devices + * (hard drives, CDs, DVDs, USB storage etc.). Sample output for a HD: + * http://user.cs.tu-berlin.de/~klischat/hdabench.png + * + * (c) Olaf Klischat 2007 + * + * 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. + */ + +//probably Linux-specific parts: BLKGETSIZE ioctl, + +#define _GNU_SOURCE +// http://www.titov.net/2006/01/02/using-o_largefile-or-o_direct-on-linux/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static void usage() { + fprintf(stderr, "usage: benchmark_read [-s] [-l] [-b] filename\n\n"); + fprintf(stderr, "benchmark linear reading in file (or block device) named filename\n"); + fprintf(stderr, "from start to start+length-1.\n"); + fprintf(stderr, "size is the size (in bytes) of the memory buffer to be allocated internally\n"); + fprintf(stderr, "for reading from the file. Defaults to 1MiB; must be a multiple\n"); + fprintf(stderr, "of the system's page size.\n"); + fprintf(stderr, "start defaults to 0, length to (length of the file)-start.\n"); + fprintf(stderr, "start must be a multiple of the sector size (512).\n"); + fprintf(stderr, "length will automatically be aligned to the next smaller multiple of size.\n"); + fprintf(stderr, "\nOutput data to stdout as a gnuplot-compatible script\n"); + fprintf(stderr, "\nWhen redirecting the output to a file, make sure that file\n"); + fprintf(stderr, "does not reside on the physical device you're benchmarking\n"); + exit(1); +} + +typedef u_int64_t usecs_t; +typedef u_int64_t fileoffset_t; + +static fileoffset_t get_file_size(int fd); + +int main(int argc, char **argv) { + fileoffset_t start = 0; + fileoffset_t length = 0; + unsigned bufsize = 1024*1024; + char *filename = NULL; + + char **opt; + int iopt; + for (iopt=1, opt=argv+1; iopt=size) { + fprintf(stderr, "error: start >= file size\n"); exit(1); + } + if (length==0) length = size-start; + if (start+length-1 >= size) { + fprintf(stderr, "error: start+length-1 >= file size (would read past end of file)\n"); exit(1); + } + + unsigned pagesize = getpagesize(); + if (bufsizenew(-title => "Black", -background => "black", -width=>2000, height=>2000); + + +MainLoop; diff --git a/cc/test/Meins.cc b/cc/test/Meins.cc new file mode 100644 index 0000000..b0aba95 --- /dev/null +++ b/cc/test/Meins.cc @@ -0,0 +1,24 @@ +#include +#include + +class Meins; + +class Meins{ +public: + std::string val; + Meins() {} + Meins( const Meins& other) + : val(other.val) {} + Meins( const std::string& other) + : val(other) {} + const Meins& operator=( const char* other ) + { val = other; return *this; } + + static std::map meine; +}; + + + +int main() { +} + diff --git a/cc/test/constr.cc b/cc/test/constr.cc new file mode 100644 index 0000000..5eafb38 --- /dev/null +++ b/cc/test/constr.cc @@ -0,0 +1,33 @@ +#include + +class A { +public: + virtual void f(); +}; + +void A::f() { + printf("A::f\n"); +} + + +class B { +public: + B(); + virtual void f(); +}; + +B::B() { + f(); +} + +void B::f() { + printf("B::f\n"); +} + + + +int main() { + B *b = new B; + B b2; + return 0; +} diff --git a/cc/test/consttest.cc b/cc/test/consttest.cc new file mode 100644 index 0000000..05f443c --- /dev/null +++ b/cc/test/consttest.cc @@ -0,0 +1,50 @@ +#include + + +class Integer { + int i; +public: + void set(int ii) { + i = ii; + } + + int get() const { + return i; + } +}; + + +class IntPair { + + Integer a,b; + +public: + int getA() const { + return a.get(); + } + + Integer getB() const { + return b; + } + + void setA(int i) { + a.set(i); + } + + void setB(int i) { + b.set(i); + } + +}; + + +int main() { + IntPair ip; + + ip.setA(27); + ip.setB(100); + + printf("%i\n\n",ip.getB().get()); + + return 0; +} diff --git a/cc/test/consttest2.cc b/cc/test/consttest2.cc new file mode 100644 index 0000000..e9ca663 --- /dev/null +++ b/cc/test/consttest2.cc @@ -0,0 +1,5 @@ +#include + +const double pi = 1.570796327; + +//const double M_PI_2 = 1.570796327; diff --git a/cc/test/hashmap.cc b/cc/test/hashmap.cc new file mode 100644 index 0000000..d089e6c --- /dev/null +++ b/cc/test/hashmap.cc @@ -0,0 +1,82 @@ +//siehe http://www.heise.de/foren/go.shtml?read=1&msg_id=5241951&forum_id=44546 + +#include +#include // Muss in "ext/" liegen. + +struct FileInfo {}; + +/* +//geht nicht, offenbar wg. der "&"s in der Signatur von hash::operator()?? + +namespace __gnu_cxx { + template<> + struct hash + { + + size_t operator()(std::string &str) const + { + __gnu_cxx::hash H; + return H(str.c_str() ); + } + }; +} + +int main() { + // Den "__gnu_cxx" namespace muss ich hier auch angeben. + // (huh?) + __gnu_cxx::hash_map cache; + FileInfo *info = cache["filename"]; +} +*/ + +/* +//geht +namespace __gnu_cxx { + + template<> struct hash { + size_t operator()(std::string s) const { + //return hash::operator()(s.c_str()); + __gnu_cxx::hash h; + return h(s.c_str()); + } + }; + +} + +int main() { + __gnu_cxx::hash_map cache; + FileInfo *info = cache["filename"]; +} +*/ + + +struct myhash { + size_t operator()(const std::string &str) const { + __gnu_cxx::hash H; + return H(str.c_str() ); + } + +}; + +int main() { + __gnu_cxx::hash_map cache; + FileInfo *info = cache["filename"]; +} + +/* +//das geht nicht, weil "Hash Function" ein refinement +//von "assignable" ist. Normale C++-Funktionen sind nicht "assignable". + +size_t myhash(const std::string &str) { + __gnu_cxx::hash H; + return H(str.c_str() ); +} + +int main() { + __gnu_cxx::hash_map cache; + FileInfo *info = cache["filename"]; +} +*/ + + +//krank... diff --git a/cc/test/methptr-sigc.cc b/cc/test/methptr-sigc.cc new file mode 100644 index 0000000..eab18ad --- /dev/null +++ b/cc/test/methptr-sigc.cc @@ -0,0 +1,26 @@ +#include +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +using namespace SigC; +#endif + + +class TheClass : public Object { +public: + + void theMethod(int i) { + cout << this << "theMethod" << i << endl; + } +}; + +main() +{ + TheClass theInstance; + + Signal1 MyMethPointer; + MyMethPointer.connect(slot(theInstance,&TheClass::theMethod)); + + MyMethPointer(42); +} diff --git a/cc/test/methptr.cc b/cc/test/methptr.cc new file mode 100644 index 0000000..59322c9 --- /dev/null +++ b/cc/test/methptr.cc @@ -0,0 +1,20 @@ +#include + +using namespace std; + + +class TheClass { +public: + + void theMethod(int i) { + cout << this << "theMethod" << i << endl; + } +}; + +int main() { + void (TheClass::*MyMethPointer) (int); + MyMethPointer = &TheClass::theMethod; + + TheClass theInstance; + (theInstance.*MyMethPointer)(42); +} diff --git a/cc/test/mixintest.cc b/cc/test/mixintest.cc new file mode 100644 index 0000000..44c890c --- /dev/null +++ b/cc/test/mixintest.cc @@ -0,0 +1,73 @@ +#include + + +class Enum { + +public: + virtual int elemCount() = 0; + virtual int elemAt(int i) = 0; + + void printAllElements(); +}; + + +void Enum::printAllElements() { + for (int i=0; iarr = arr; + this->size = size; +} + +int MyImpl::elemCount() { + return size; +} + +int MyImpl::elemAt(int i) { + return arr[i]; +} + + + +int main() { + MyImpl myimpl1; + int arr[] = {5,7,2,4,1,2}; + myimpl1.setIntArray(arr, sizeof(arr)/sizeof(arr[0])); + myimpl1.printAllElements(); +} diff --git a/cc/test/mixintest2.cc b/cc/test/mixintest2.cc new file mode 100644 index 0000000..f93412d --- /dev/null +++ b/cc/test/mixintest2.cc @@ -0,0 +1,38 @@ +#include + +using namespace std; + +template class ConstrainedCollection: public Superclass { +public: + virtual void push_back(T x) { + if (Superclass::size() > 5) { + throw 42; + } + cout << "fuege Element hinzu: " << x << endl; + Superclass::push_back(x); + } +}; + + +#include + + + + +int main() { + try { + ConstrainedCollection > arr; + arr.push_back(1); + arr.push_back(2); + arr.push_back(3); + arr.push_back(4); + arr.push_back(5); + arr.push_back(6); + arr.push_back(7); + arr.push_back(8); + arr.push_back(9); + } + catch (int err) { + cout << "Fehler: " << err << endl; + } +} diff --git a/cc/test/mixintest2.rb b/cc/test/mixintest2.rb new file mode 100644 index 0000000..2e4866f --- /dev/null +++ b/cc/test/mixintest2.rb @@ -0,0 +1,30 @@ +module ConstrainedCollection + + def push(x) + if size() > 5 + raise "Collection wird zu gross!" + end + print "fuege Element hinzu: #{x}\n"; + super(x) + end + +end + + + + +arr=[1,2] +arr.push 3 +=> [1, 2, 3] +irb(main):004:0> arr.extend ConstrainedCollection +=> [1, 2, 3] +irb(main):005:0> arr.push 4 +fuege Element hinzu: 4 +=> [1, 2, 3, 4] +irb(main):006:0> arr.push 5 +fuege Element hinzu: 5 +=> [1, 2, 3, 4, 5] +irb(main):007:0> arr.push 6 +fuege Element hinzu: 6 +=> [1, 2, 3, 4, 5, 6] +irb(main):008:0> arr.push 7 diff --git a/cc/test/rbtest.rb b/cc/test/rbtest.rb new file mode 100644 index 0000000..4c65514 --- /dev/null +++ b/cc/test/rbtest.rb @@ -0,0 +1,7 @@ +class Array + + def superpush(x) + super.push(x) + end + +end diff --git a/cc/test/ss.cc b/cc/test/ss.cc new file mode 100644 index 0000000..b5841cc --- /dev/null +++ b/cc/test/ss.cc @@ -0,0 +1,9 @@ +#include +#include + +using namespace std; + +int main() { + cout << "hallo!" << endl; + stringstream ss; +} diff --git a/cc/test/stddtest.cc b/cc/test/stddtest.cc new file mode 100644 index 0000000..f029eed --- /dev/null +++ b/cc/test/stddtest.cc @@ -0,0 +1,3 @@ +#include + +std::ios_base::failure f; diff --git a/cdburn b/cdburn new file mode 100755 index 0000000..4f789a0 --- /dev/null +++ b/cdburn @@ -0,0 +1,20 @@ +#!/bin/sh + +speed=4 + +while getopts 's:' OPTNAME; do +case "$OPTNAME" in + "s") + speed="$OPTARG" ;; + "?") + exit 1;; +esac +done + +shift $(($OPTIND - 1)) + +if [ -z "$CDR_DEVICE" ]; then + CDR_DEVICE="`getcdrdev`"; +fi + +mkisofs -f -J "$1" | cdrecord -v "-speed=$speed" dev="$CDR_DEVICE" -data - diff --git a/cdburn-rr b/cdburn-rr new file mode 100755 index 0000000..0e308a4 --- /dev/null +++ b/cdburn-rr @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -z "$CDR_DEVICE" ]; then + CDR_DEVICE="`getcdrdev`"; +fi + +mkisofs -R "$1" | cdrecord -v -speed=4 dev="$CDR_DEVICE" -data - diff --git a/cdcopy.sh b/cdcopy.sh new file mode 100755 index 0000000..b1a8e76 --- /dev/null +++ b/cdcopy.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +free="`df /tmp | tail -1 | awk '{print $4}'`"; + +if [ "$free" -lt 750000 ]; then + echo "not enough space on /tmp (nedd at least 750000 K)"; + exit -1; +fi + +cd /tmp && +cdrdao copy --source-device /dev/cdcopy-src --device /dev/cdcopy-dest --driver generic-mmc --source-driver generic-mmc --speed 4 diff --git a/cdcopy_onthefly.sh b/cdcopy_onthefly.sh new file mode 100755 index 0000000..154c434 --- /dev/null +++ b/cdcopy_onthefly.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +#cdrdao copy --source-device /dev/cdcopy-src --device /dev/cdcopy-dest --driver generic-mmc-raw --speed 20 --source-driver generic-mmc-raw --on-the-fly + +cdrdao copy --source-device /dev/cdcopy-src --device /dev/cdcopy-dest --driver generic-mmc --source-driver generic-mmc --on-the-fly diff --git a/cdda-cddbrip b/cdda-cddbrip new file mode 100755 index 0000000..6a21dd8 --- /dev/null +++ b/cdda-cddbrip @@ -0,0 +1,176 @@ +#!/usr/bin/perl -w +# +# input: - audio CD in /dev/cdrom, (optional) internet connection freedb.freedb.org +# - (optional) command line: -encoders=encoder1[,encoder2,...] +# encoders to use +# default: -encoders=ogg,mp3 +# existing encoders: ogg, mp3, wav +# -start=num -stop=num +# first and last track to encode (numbers 1-based) +# default: entire CD +# +# output: ripped files, named "--.<wav|ogg|mp3>" + +package Encoders; + + +{ + use File::Temp qw/ tempfile tempdir /; + + #my ($fh, $tmpfile) = tempfile( DIR => tempdir( CLEANUP => 1 ) ); + my ($fh, $tmpfile) = tempfile(); + $tmpfile .= '.wav'; + + ##private + sub mysystem { + my $cmdstr = join ' ', (map {"'$_'"} @_); + print "cdda-cddbrip: running: $cmdstr\n"; + system(@_) and die "couldn't execute: $cmdstr: $!"; + } + + + ## private + sub tofilename { + my ($artist, $title) = @_; + my $fn = ($artist?"${artist}--":"") . $title; + $fn =~ s![/ ,;:\'\"]!_!g; + $fn; + } + + + my $ripped_wav; # cache for rip_wav + + ## private + # rip($num) -- rip track $num to wav file, return filename + sub rip_wav { + my ($num) = @_; + return $tmpfile if ($num eq $ripped_wav); + $ripped_wav = $num; + mysystem("cdparanoia --output-wav $num $tmpfile"); + + $tmpfile; + } + + + sub encode_wav { + my ($num,$artist,$title,$album) = @_; + my $wavfile = rip_wav($num); + my $fn = tofilename($artist, $title); + mysystem ("cp", "-f", $wavfile, "${fn}.wav"); + } + + + sub encode_mp3 { + my ($num,$artist,$title,$album) = @_; + my $wavfile = rip_wav($num); + my $fn = tofilename($artist, $title); + mysystem ( qw/lame -h -b 192/, + '--tt', $title, + ($artist? ('--ta',$artist): ()), + ($album? ('--tl',$album): ()), + $wavfile, + "${fn}.mp3" ); + } + + + sub encode_ogg { + my ($num,$artist,$title,$album) = @_; + my $wavfile = rip_wav($num); + my $fn = tofilename($artist, $title); + mysystem ( qw/oggenc -b 160/, + '-t', $title, + ($artist? ('-a',$artist): ()), + ($album? ('-l',$album): ()), + "-o", "${fn}.ogg", + $wavfile ); + } + + + + sub encode_echo { + my ($num,$artist,$title,$album) = @_; + print "encode_echo: ", join ' ', (map {"'$_'"} (@_, tofilename($artist, $title))), "\n"; + } + + + sub cleanup { + mysystem("rm","-f",$tmpfile); + } +} + + + +# main prg + +package main; + +use strict; +no strict 'refs'; +use Getopt::Long; + +my (@encoders, $start, $stop); + +$start=1; $stop=100000; +exit(1) unless GetOptions ("encoders=s" => \@encoders, + "start=s" => \$start, + "stop=s" => \$stop); + +@encoders = qw/mp3 ogg/ unless (@encoders); # default + +print "start: $start, stop: $stop, encoders: ",join(',',@encoders),"\n"; + +@encoders = map {"Encoders::encode_${_}"} @encoders; + +foreach (@encoders) { + die "undefined encoder: $_" unless defined *{$_}{CODE}; +} + + + +use CDDB_get qw( get_cddb ); + +my %config; + +# following variables just need to be declared if different from defaults + +#$config{CDDB_HOST}="freedb.freedb.org"; # set cddb host +#$config{CDDB_PORT}=8880; # set cddb port +#$config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http +#$config{CD_DEVICE}="/dev/cdrom"; # set cd device + +# user interaction welcome? + +$config{input}=1; # 1: ask user if more than one possibility + # 0: no user interaction + +# get it on + +my %cd=get_cddb(\%config); + +my $cdalbum = $cd{title}; +my $cdartist = $cd{artist} unless ($cd{artist} =~ /^various/i); + +# precaution against some buggy cddb entries... +{ + local $/="\r"; + chomp($cdalbum); chomp($cdartist); + $/="\n"; + chomp($cdalbum); chomp($cdartist); +} + +my $n=1; +foreach (@{$cd{track}}) { + next if ($n<$start); + last if ($n>$stop); + my ($artist, $title) = $cdartist? ($cdartist, $_) : + (m!\s*(.*?)\s*/\s*(.*)\s*!? ($1,$2) : (undef, $_)); + foreach my $enc (@encoders) { + $enc->($n, $artist, $title, $cdalbum); + } +} +continue { + $n++; +} + +# TODO: finally +Encoders::cleanup(); diff --git a/cddaenc.sh b/cddaenc.sh new file mode 100755 index 0000000..b12f733 --- /dev/null +++ b/cddaenc.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +files="*wav"; +if [ "$@" ]; then + files="$@"; +fi + +for f in $files; do + oggenc -b 160 "$f"; + lame -h -b 192 "$f" "`basename "$f" .wav`".mp3; +done diff --git a/cddamv.pl b/cddamv.pl new file mode 100755 index 0000000..b0761cc --- /dev/null +++ b/cddamv.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl -w + +open(CDDB, "<" . shift @ARGV); + + +my @titles = map { /TTITLE\d+=(.*)/ } (grep /^TTITLE\d/, <CDDB>); + +for my $title (@titles) { + my $wavfile = shift @ARGV or die "unmatched number of titles in cddb file and .wav files on cmd line (too few wav files)"; + $title =~ s/[ ,'"\.]/_/g; + if (my ($num) = +($wavfile =~ /(\d+)\.wav$/)) { + $title = "$num-$title"; + } + + print "renaming $wavfile to $title.wav\n"; + rename $wavfile, "$title.wav"; + if (my $base = ($wavfile=~/(.*).wav$/)[0]) { + rename "$base.mp3", "$title.mp3"; + rename "$base.ogg", "$title.ogg"; + } +} + +if (@ARGV) { + die "unmatched number of titles in cddb file and .wav files on cmd line (too many wav files)" +} diff --git a/cddarip.sh b/cddarip.sh new file mode 100755 index 0000000..7ae5dd8 --- /dev/null +++ b/cddarip.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -z "$*" ]; then + nTracks=25; + echo "no. of tracks not given on cmdline, assuming $nTracks\n"; +else + nTracks=$1; +fi + +for i in `seq -w 1 $nTracks`; do + cdda2wav -t "$i+$i" "track-$i.wav"; +done diff --git a/cdisoburn b/cdisoburn new file mode 100755 index 0000000..6bd8b51 --- /dev/null +++ b/cdisoburn @@ -0,0 +1,26 @@ +#!/bin/sh + +speed=4 + +while getopts 's:' OPTNAME; do +case "$OPTNAME" in + "s") + speed="$OPTARG" ;; + "?") + exit 1;; +esac +done + +shift $(($OPTIND - 1)) + +if [ -z "$CDR_DEVICE" ]; then + CDR_DEVICE="`getcdrdev`"; +fi + +if [ -z "$1" ]; then + file="-"; +else + file="$1"; +fi + +cdrecord -v -speed=4 dev="$CDR_DEVICE" -data "$file" diff --git a/chk4rlogins b/chk4rlogins new file mode 100755 index 0000000..1f1ef13 --- /dev/null +++ b/chk4rlogins @@ -0,0 +1,24 @@ +#!/bin/sh + +#letzte Zeile von /var/log/secure ueberwachen +tail -f -n 1 /var/log/secure | +while read line; do + #irgendwas verdaechtiges entahlten? + echo $line|egrep 'rlogin|telnetd|sshd|pop|finger' >/dev/null && + ( + #aufgeregtes Gepiepe + ( + for i in a a a a a a a a a; do + printf '\a'; usleep 200000; + done; + ) & + + #Warntext auf die Console mit der kleinsten Idle-Zeit ausgeben + who --idle | egrep '^(olaf|root)' | awk '{print $6 " " $2}' | sort | head -1 | awk '{print $2}' | + printf "chk4rlogins: Remote access detected:\n$line\n" >/dev/`cat`; + + #Warntext auch noch nach /dev/console + printf "chk4rlogins: Remote access detected:\n$line\n" >/dev/console + ) +done + diff --git a/chr b/chr new file mode 100755 index 0000000..19457ea --- /dev/null +++ b/chr @@ -0,0 +1,3 @@ +#!/bin/sh + +printf \\x`printf '%x' $@` diff --git a/chrcodes b/chrcodes new file mode 100755 index 0000000..ef635b9 --- /dev/null +++ b/chrcodes @@ -0,0 +1,8 @@ +#!/bin/sh + +i=0; +while [ $i -ne 256 ]; do + printf "$i: \\x`printf '%x' $i`\n" + i=$[ $i + 1 ] +done + diff --git a/cpmydir.sh b/cpmydir.sh new file mode 100755 index 0000000..d89412c --- /dev/null +++ b/cpmydir.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SRCDIR=mydir +#FILES=`eval echo "$SRCDIR/$1"`; +FILES="$SRCDIR/$1"; + +echo FILES=$FILES; + +cp $FILES some_other_dir; diff --git a/create-index-htmls b/create-index-htmls new file mode 100755 index 0000000..67c411e --- /dev/null +++ b/create-index-htmls @@ -0,0 +1,23 @@ +#!/bin/sh + +self="`basename $0`" +header='<html>\n<body>\n' +footer='</body>\n</html>' + + +if [ ! -f index.html -o -f ".index_html_created_by_$self" ]; then + (printf "$header"; + if [ -n "$1" ]; then + printf '<a href="..">../</a><br>\n'; + fi + find . -maxdepth 1 -mindepth 1 -type d | sort | sed 's!^.*$!<a href="&">&/</a><br>!'; + printf '<br>'; + find . -maxdepth 1 -mindepth 1 -type f | grep -v index.html | sort | sed 's!^..\(.*\)$!<a href="\1">\1</a><br>!' + printf "$footer") >index.html + touch ".index_html_created_by_$self" +fi + +find . -maxdepth 1 -mindepth 1 -type d | +while read d; do + (cd "$d" && "$self" 1;) +done diff --git a/cutv b/cutv new file mode 100755 index 0000000..2afa981 --- /dev/null +++ b/cutv @@ -0,0 +1,62 @@ +#!/usr/bin/perl -w + +use strict; +use Getopt::Std; + +our($opt_l, $opt_d, $opt_f); + +$opt_d='^\s*$'; +getopt('ldf'); + +$opt_d = eval { qr/$opt_d/ }; +die "invalid regexp for -d: $@" if $@; + +for($opt_f, $opt_l) { + $_ = [sort {$a <=> $b} split(/,/, $_)] if ($_); +} + +my $l_idx; +my $l_next; +if ($opt_l) { + $l_idx=0; $l_next=$$opt_l[0]; +} +my $f_idx; +my $f_next; +if ($opt_f) { + $f_idx=0; $f_next=$$opt_f[0]; +} + +my $ln=1; +my $fn=1; +while (<STDIN>) { + my $on_sep = /$opt_d/; + if (defined($l_idx) and $ln==$l_next) { + print; + ++$l_idx; + if ($l_idx <= $#$opt_l) { + $l_next = $$opt_l[$l_idx]; + } else { + $l_idx = undef; + } + } elsif (defined($f_idx) and $fn==$f_next and !$on_sep) { + print; + } + + if ($on_sep) { + if (defined($f_idx) and $fn==$f_next) { + ++$f_idx; + if ($f_idx <= $#$opt_f) { + $f_next = $$opt_f[$f_idx]; + } else { + $f_idx = undef; + } + } + ++$fn; + } + + ++$ln; +} + + +# TODO: multi-line delimiters +# TODO: start and end delimiters diff --git a/cutv-test b/cutv-test new file mode 100755 index 0000000..0bdcc9b --- /dev/null +++ b/cutv-test @@ -0,0 +1,47 @@ +#!/bin/sh + +input="`mktemp /tmp/cutv-test.XXXXXX`" +expected="`mktemp /tmp/cutv-test.XXXXXX`" +output="`mktemp /tmp/cutv-test.XXXXXX`" + +cat <<EOF >$input +l1 +l2 +=== +l4 +l5 +=== +l7 +l8 +l9 +l10 +=== +l12 +l13 +l14 +EOF + +./cutv -d '===' -l 5,3,13 -f 1,3 <$input >$output + +cat <<EOF >$expected +l1 +l2 +=== +l5 +l7 +l8 +l9 +l10 +l13 +EOF + +diff $expected $output + +if [ $? -eq 0 ]; then + echo "test SUCCEEDED!" + rm -f $output $input $expected + exit 0 +fi + +echo "test FAILED!" +exit 1 diff --git a/cvs-add-subtree-dirs b/cvs-add-subtree-dirs new file mode 100755 index 0000000..83a0e3b --- /dev/null +++ b/cvs-add-subtree-dirs @@ -0,0 +1,3 @@ +#!/bin/sh + +find . -type d ! -name '*~' ! -path '*/CVS*' -mindepth 1 | sort | xargs -i execlogged cvs add {} diff --git a/cvs-add-subtree-files b/cvs-add-subtree-files new file mode 100755 index 0000000..476e735 --- /dev/null +++ b/cvs-add-subtree-files @@ -0,0 +1,3 @@ +#!/bin/sh + +find . -type f ! -name '*~' ! -path '*/CVS/*' | xargs -i execlogged cvs add {} diff --git a/cvs-isstssh b/cvs-isstssh new file mode 100755 index 0000000..f2cfbea --- /dev/null +++ b/cvs-isstssh @@ -0,0 +1,3 @@ +#!/bin/sh + +CVS_RSH=ssh-forwarded-isstssh cvs "$@" diff --git a/cvs-myissthostssh b/cvs-myissthostssh new file mode 100755 index 0000000..54048d2 --- /dev/null +++ b/cvs-myissthostssh @@ -0,0 +1,3 @@ +#!/bin/sh + +CVS_RSH=ssh-forwarded-myissthost cvs "$@" diff --git a/cvslog2kwsubst b/cvslog2kwsubst new file mode 100755 index 0000000..be7f339 --- /dev/null +++ b/cvslog2kwsubst @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + + +my ($state,$rev,$date,$time,$author,$comment); + +$state=0; +my $lineno=0; +while (<>) { + ++$lineno; + + if ($state==0 and (($rev) = /^revision (.*)$/)) { + $state=1; next; + } + if ($state==1) { + if (($date,$time,$author) = /date: (.*?) +(.*?); +author: (.*?);/) { + $comment=''; $state=2; next; + } + else { + die "${lineno}: parse error: expected ^date: xxxx/xx/xx xx:xx:xx; author: xxxx;"; + } + } + if ($state==2) { + if (/^-----------------------/ or /^=======================/) { + print "Revision $rev $date $time $author\n$comment\n"; + $state=0; next; + } + else { + $comment .= $_; + } + } +} + +#---------------------------- +#revision 1.17 +#date: 2003/06/09 10:00:14; author: oklischa; state: Exp; lines: +12 -13 +#ContentMessageSlotExtractor als Implementation von +#TagExpander. Übernimmt somit alle Daten, von denen eine Tag-Epansion +#abhängen kann, inkl. bool isHTML. +#---------------------------- + +# Revision 1.20 2003/06/12 13:11:57 sbaatar +# erweiterung. diff --git a/cvsshowunkn.pl b/cvsshowunkn.pl new file mode 100755 index 0000000..75e9937 --- /dev/null +++ b/cvsshowunkn.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w +# +# author Olaf Klischat + +use strict; +use Getopt::Long; + +my $cvscmd = "cvs"; +my $quiet = 0; + +exit(1) unless GetOptions ("cvs=s" => \$cvscmd, + "quiet|q" => \$quiet); + +sub infoMsg { + ! $quiet and print STDERR "cvsshowunkn.pl: @_\n"; +} + + +infoMsg("running $cvscmd status..."); + +open(CVSSTATUS,"$cvscmd status 2>&1 |") or die "$!"; + +my @knownFiles; +my $currDir; +while (<CVSSTATUS>) { + if (/^cvs .*: Examining (.*)/) { + $currDir = "${1}"; + $currDir ne "." and $currDir = "./$currDir"; + } + elsif (/^File: (\S+).+Status:/) { # TODO: file names containing whitespaces won't be recognized this way + push @knownFiles, "${currDir}/$1"; + } +} + + +infoMsg("finding unknown files..."); + +use File::Find; + +find(\&findCallback, '.'); + +sub findCallback { + -f && $File::Find::name !~ /\/CVS\// && ! ( grep {$_ eq $File::Find::name} @knownFiles ) && print "$File::Find::name\n"; +} diff --git a/deb-fetch-uris b/deb-fetch-uris new file mode 100755 index 0000000..dc06a76 --- /dev/null +++ b/deb-fetch-uris @@ -0,0 +1,3 @@ +#!/bin/sh + +deb-xtract-uris | xargs -l ncftpget diff --git a/deb-import-signing-key b/deb-import-signing-key new file mode 100755 index 0000000..d9b33d2 --- /dev/null +++ b/deb-import-signing-key @@ -0,0 +1,5 @@ +#!/bin/sh + +gpg --keyserver gpg-keyserver.de --recv-keys "0x$1" && +( gpg --armor --export "$1" | apt-key add - ) && +echo "SUCCESS." || echo "FAILURE." diff --git a/deb-list-pkgs b/deb-list-pkgs new file mode 100755 index 0000000..9fe0eed --- /dev/null +++ b/deb-list-pkgs @@ -0,0 +1,3 @@ +#!/bin/sh + +COLUMNS=200 dpkg -l '*' | awk '/^[hi]i/{print $2}' diff --git a/deb-xtract-uris b/deb-xtract-uris new file mode 100755 index 0000000..1392c11 --- /dev/null +++ b/deb-xtract-uris @@ -0,0 +1,3 @@ +#!/bin/sh + +grepre "^'(.*?)'" diff --git a/disk2file.sh b/disk2file.sh new file mode 100755 index 0000000..bb242c0 --- /dev/null +++ b/disk2file.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +if [ -z "$1" ]; then + echo "usage: disk2file <file>" >&2 + echo " => copy contents of 1.44k floppy at /dev/fd0 to <file>" >&2 + exit 1 +fi + +dd bs=1k count=1423 if=/dev/fd0 of=$1 diff --git a/dos2unixm.sh b/dos2unixm.sh new file mode 100755 index 0000000..15fd212 --- /dev/null +++ b/dos2unixm.sh @@ -0,0 +1,7 @@ +#! /bin/bash + + +for f in "$@"; do + dos2unix $f >$f.new; + mv $f.new $f +done diff --git a/dvdburn b/dvdburn new file mode 100755 index 0000000..2b34fcb --- /dev/null +++ b/dvdburn @@ -0,0 +1,29 @@ +#!/bin/sh + +#if [ -z "$DVDR_DEVICE" ]; then +# DVDR_DEVICE="`getdvdrdev`"; +#fi + +#mkisofs -f -J "$1" | dvdrecord -v -speed=1 dev="$DVDR_DEVICE" -dao -data - + +speed=2 + +while getopts 's:' OPTNAME; do +case "$OPTNAME" in + "s") + speed="$OPTARG" ;; + "?") + exit 1;; +esac +done + +shift $(($OPTIND - 1)) + +if [ -z "$1" ]; then + echo "usage: dvdburn [-s speed] dir" >&2 + exit 1 +fi + +( cd "$1" && jolietnamecheckcurrdir || exit 1 ) || exit 1 + +growisofs -Z /dev/cdrw -speed="$speed" -f -J "$1" diff --git a/dvdburn-rr b/dvdburn-rr new file mode 100755 index 0000000..de4bd94 --- /dev/null +++ b/dvdburn-rr @@ -0,0 +1,22 @@ +#!/bin/sh + +#if [ -z "$DVDR_DEVICE" ]; then +# DVDR_DEVICE="`getdvdrdev`"; +#fi + +#mkisofs -f -J "$1" | dvdrecord -v -speed=1 dev="$DVDR_DEVICE" -dao -data - + +speed=2 + +while getopts 's:' OPTNAME; do +case "$OPTNAME" in + "s") + speed="$OPTARG" ;; + "?") + exit 1;; +esac +done + +shift $(($OPTIND - 1)) + +growisofs -Z /dev/cdrw -speed="$speed" -R "$1" diff --git a/dvdvideoburn b/dvdvideoburn new file mode 100755 index 0000000..6ac9329 --- /dev/null +++ b/dvdvideoburn @@ -0,0 +1,27 @@ +#!/bin/sh + +#if [ -z "$DVDR_DEVICE" ]; then +# DVDR_DEVICE="`getdvdrdev`"; +#fi + +#mkisofs -f -J "$1" | dvdrecord -v -speed=1 dev="$DVDR_DEVICE" -dao -data - + +speed=2 + +while getopts 's:' OPTNAME; do +case "$OPTNAME" in + "s") + speed="$OPTARG" ;; + "?") + exit 1;; +esac +done + +shift $(($OPTIND - 1)) + +if ! [ -f "$1/VIDEO_TS/VIDEO_TS.IFO" ] ; then + echo "file $1/VIDEO_TS/VIDEO_TS.IFO expected" + exit 1 +fi + +growisofs -dvd-video -Z /dev/cdrw -speed="$speed" -f -J "$1" diff --git a/e b/e new file mode 100755 index 0000000..f18c7d1 --- /dev/null +++ b/e @@ -0,0 +1,6 @@ +#!/bin/sh + +ed="$EDITOR" || vi; +[ -x "`which $ed`" ] || { echo "no such executable: $ed. Using vi." >&2; ed=vi; } + +"$ed" "$@" diff --git a/eardiff.sh b/eardiff.sh new file mode 100755 index 0000000..c3e7eaa --- /dev/null +++ b/eardiff.sh @@ -0,0 +1,62 @@ +#! /bin/bash + +unpackjar () +{ + FILE=$1; + DESTDIR=$2; + + FILEBASE="`basename $FILE`"; + mkdir $DESTDIR/$FILEBASE; + cp $FILE $DESTDIR/$FILEBASE/$FILEBASE; + ( cd $DESTDIR/$FILEBASE; jar xf $FILEBASE; ) + rm -f $DESTDIR/$FILEBASE/$FILEBASE; + + for SUBJAR in `find $DESTDIR/$FILEBASE/ -name '*.jar'`; do + SUBJNAME=`basename $SUBJAR`; + SUBJDIR=`dirname $SUBJAR`; + mkdir $SUBJDIR/$SUBJNAME.d + unpackjar $SUBJAR $SUBJDIR/$SUBJNAME.d; + rm -f $SUBJDIR/$SUBJNAME; + mv $SUBJDIR/$SUBJNAME.d/$SUBJNAME $SUBJDIR/; + rm -rf $SUBJDIR/$SUBJNAME.d; + done +} + +if [ "$#" -ne 2 ]; then + echo "usage: eardiff file1.ear file2.ear" >&2; + exit 1; +fi + +FILE1=$1; +FILE2=$2; + +if [ ! -r $FILE1 ]; then + echo "can't read $FILE1. Aborting."; + exit 1; +fi + +if [ ! -r $FILE2 ]; then + echo "can't read $FILE2. Aborting."; + exit 1; +fi + +mkdir $TEMP/eardiff1; +mkdir $TEMP/eardiff2; + +unpackjar $FILE1 $TEMP/eardiff1; +unpackjar $FILE2 $TEMP/eardiff2; + +FILE1_BASE=`basename $FILE1`; +FILE2_BASE=`basename $FILE2`; + +FILE1_XMLS=`cd $TEMP/eardiff1/$FILE1_BASE; find . -name '*.xml'`; +FILE2_XMLS=`cd $TEMP/eardiff2/$FILE2_BASE; find . -name '*.xml'`; + +for xmlfile in $FILE1_XMLS; do + if echo $FILE2_XMLS | grep "$xmlfile" >/dev/null 2>&1; then # TODO: dieser Test funktioniert nicht korrekt, wenn ein XML-Dateiname aus der einen ear-Datei in einem aus der anderen ear-Datei enthalten ist. + echo ">>>>>>>>>>>>> diffing $xmlfile in $FILE1_BASE <-> $FILE2_BASE"; + diff -C 3 $TEMP/eardiff1/$FILE1_BASE/$xmlfile $TEMP/eardiff2/$FILE2_BASE/$xmlfile; + fi +done + +rm -rf $TEMP/eardiff1 $TEMP/eardiff2; diff --git a/edit-encrypted b/edit-encrypted new file mode 100755 index 0000000..c6e838e --- /dev/null +++ b/edit-encrypted @@ -0,0 +1,23 @@ +#!/bin/sh + +encrfile="$1" +if [ -z "$encrfile" ]; then + echo "usage: `basename $0` <encrfile>"; + exit 1; +fi + +tmpfile=/tmp/$$ +umask 077; +if [ -z "$EDITOR" ]; then + EDITOR="vi"; +fi + +cp -f "$encrfile" "$encrfile.bak" + +echo "decrypting..." && +gpg -o "$tmpfile" --decrypt "$encrfile" && +$EDITOR $tmpfile && +echo "encrypting..." && +gpg --yes -o "$encrfile" --symmetric -a "$tmpfile" + +shred -u $tmpfile diff --git a/emacs_or_fallback.sh b/emacs_or_fallback.sh new file mode 100755 index 0000000..d2decde --- /dev/null +++ b/emacs_or_fallback.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if gnuclient -h localhost -batch -eval 'nil' >/dev/null 2>&1; then + exec gnuclient -h localhost "$@"; +else + if emacsclient --eval 'nil' >/dev/null 2>&1; then + exec emacsclient "$@"; + else + exec jed "$@"; + fi +fi diff --git a/eol2nul b/eol2nul new file mode 100755 index 0000000..8e6f88a --- /dev/null +++ b/eol2nul @@ -0,0 +1,7 @@ +#!/usr/bin/perl + +while (<STDIN>) { + chomp; + print; + print "\0"; +} diff --git a/execlogged b/execlogged new file mode 100755 index 0000000..2368a81 --- /dev/null +++ b/execlogged @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +use POSIX qw(strftime); + +sub datestr { + strftime "%a %b %e %H:%M:%S %Y", localtime; +} + +my $cmdstr = join(' ', map {"'$_'"} @ARGV); + +print "$0: " . datestr . ": executing: $cmdstr\n"; + +open(STDERR, ">&STDOUT"); +if (system @ARGV) { + print "$0: " . datestr . ": failed to execute $cmdstr\n"; + exit 1; +} +else { + print "$0: " . datestr . ": successfully executed $cmdstr\n"; + exit 0; +} diff --git a/export-sawfish b/export-sawfish new file mode 100755 index 0000000..bbe6136 --- /dev/null +++ b/export-sawfish @@ -0,0 +1,13 @@ +#!/bin/sh +# export environment variables into a sawfish window manager +# running on $DISPLAY. The variables are seen by programs +# subsequently started from that sawfish instance + +if [ $# != 2 ]; then + echo "usage: $0 variable value" 1>&2; + exit 1; +fi + +var="$1"; val="$2"; + +sawfish-client -e "(setenv \"$var\" \"$val\")" diff --git a/fetchheise-article.html b/fetchheise-article.html new file mode 100644 index 0000000..326d2e6 --- /dev/null +++ b/fetchheise-article.html @@ -0,0 +1,714 @@ + + + + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> + +<html> +<head> + +<!-- Site Navigation Bar --> + +<link rel="copyright" title="Heise Zeitschriften Verlag" href="/kontakt/impressum.shtml"> +<link rel="start" title="Start" href="/"> +<link rel="author" title="Kontakt" href="mailto:kontakt%40heise.de?subject=heise%20online"> + +<link rel="alternate" type="application/atom+xml" title="Aktuelle News von heise online" href="http://www.heise.de/newsticker/heise-atom.xml"> +<link rel="alternate" type="application/rss+xml" title="Aktuelle News von heise online (für ältere RSS-Reader)" href="http://www.heise.de/newsticker/heise.rdf"> + + + + + +<!-- Allgemeines Standard-Stylesheet --> +<link href="/stil/standard.css" rel="stylesheet" type="text/css" media="screen, projection, print"> + +<!-- heise online Standard-Stylesheet --> +<link href="/stil/ho/standard.css" rel="stylesheet" type="text/css" media="screen, projection, print"> + +<!-- heise online weitere Stylesheets --> + +<link href="/stil/ho/foren.css" rel="stylesheet" type="text/css" media="screen, projection, print"> +<link href="/stil/foren_all.css" rel="stylesheet" type="text/css" media="screen, projection, print"> +<!--[if IE]> + <style type="text/css">@import url(/stil/foren_ie.css);</style> +<![endif]--> + + + + + + +<!-- Allgemeines Druck-Stylesheet --> +<link href="/stil/drucken.css" rel="stylesheet" type="text/css" media="print"> + +<!-- heise online Druck-Stylesheet --> +<link href="/stil/ho/drucken.css" rel="stylesheet" type="text/css" media="print"> + + +<!-- Seitenname --> +<title>Re: Könnt ihr endlich mal aufhören Soft und Hardware durcheinander zu bringen? | Linux-Treiber für TCPA Version 1.1b von ... | News-Foren + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + +
+
+ +
+ + + + + + + + +
+ + + + + + + + + + + +
heise online
+ + +
+ + + +
+ + + + +
+ + + + + + + +
+ + + +
+
+
+ + + + + + + + + + + + + +
+ + +
+ + + + +
+
+
+
+ + + + +
+
Sie sind Gast
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
15. August 2003 20:10
+

+Re: Könnt ihr endlich mal aufhören Soft und Hardware durcheinander zu bringen? + +

+ +

Henryk Plötz schrieb am 15. August 2003 19:10
+
+> Moin,
+>
+> Holger Voss schrieb am 15. August 2003 16:52
+>
+> > Du verfügst über hellseherische Fähigkeiten???
+>
+> Nein, es steht lediglich so im Standard drin.
+
+Also verfügst du über hellseherische Fähigkeiten (bist du
+"BigBlue"?).
+
+[...]
+> Du kannst bereits heute problemlos eine Software schreiben die nur
+> zur Wintersonnenwende funktioniert wenn Jupiter und Saturn im dritten
+> Haus des Uranus stehen.
+
+Nein, kannst du nicht. Das ist ja der Punkt. Beachte, dass du ein
+offenes System vor dir hast, das du notfalls beliebig patchen kannst
+(im von dir genannten Fall würde es schon reichen, die Systemzeit zu
+verstellen).
+
+> Dazu brauchst du keine zusätzliche Hardware.
+
+Doch. (ich weiß allerdings nicht, ob der TCPA-Chip in den IBM-Laptops
+die zur Verfügung stellt)
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +

+ + + + + + + + + + + + +
+
+
+ + + + +
+Anzeige
+ + + +
+
+
+
+
+ + +
+ + + + + + + + + + diff --git a/fetchheise-fetcharticles b/fetchheise-fetcharticles new file mode 100755 index 0000000..62c7331 --- /dev/null +++ b/fetchheise-fetcharticles @@ -0,0 +1,59 @@ +#!/usr/bin/perl -w +# in: URLs of article pages on stdin, one per line +# out: those articles, including subject, time, author, msgid, and body, +# as plain text, encoded in ISO latin1 + +sub unquote($) { + $_[0] =~ s/\n//g; + $_[0] =~ s/
/\n/g; + $_[0] =~ s!
!\n!g; + $_[0] =~ s!
!\n!g; + $_[0] =~ s/ ?/ /g; + $_[0] =~ s/<.*?>//g; + $_[0] =~ s/>?/>/g; + $_[0] =~ s/<?/ \$outfilebase, + ); + +while () { + chomp; $url=$_; + ($msgid) = ($url =~ /msg-(\d+)/); + open(WGET, "wget-withbrowsersettings -q -O- '$url' |") or die "couldn't run wget-withbrowsersettings: $!"; + local $/ = undef; + my ($time,$subject,$author,$body) = =~ m!class="posting_date">(.*?).*?class="posting_subject">(.*?)<.*?(.*?).*?

(.*?)

!si; + unquote($subject); unquote($author); unquote($body); + if (defined($outfilebase)) { + open(OUT, ">$outfilebase$msgid"); + } else { + *OUT = *STDOUT; + } + print OUT <}" | xargs fetchheise-idxpages-articleurls diff --git a/fetchheise-idxpage-fetchallarticles b/fetchheise-idxpage-fetchallarticles new file mode 100755 index 0000000..52d8baa --- /dev/null +++ b/fetchheise-idxpage-fetchallarticles @@ -0,0 +1,7 @@ +#!/bin/sh +# in: URL of an index page on cmdline +# out: all articles in that page's forum/"Beitragsübersicht", +# including subject, time, author, msgid, and body, as plain +# text, encoded in ISO latin1 + +fetchheise-idxpage-all-articleurls "${1:?usage: $0 }" | fetchheise-fetcharticles diff --git a/fetchheise-idxpage-idxpageurls b/fetchheise-idxpage-idxpageurls new file mode 100755 index 0000000..ec0790c --- /dev/null +++ b/fetchheise-idxpage-idxpageurls @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# in: URL of index page on cmdline +# out: URLs of all index pages in that forum/"Beitragsübersicht" on stdout, +# one URL per line + +use URI; + +$url=$ARGV[0] or die "usage: $0 "; + +#print $url,"\n"; + +open(WGET, "wget-withbrowsersettings -q -O- '$url' |") or die "couldn't run wget-withbrowsersettings: $!"; + +($hsmin,$hsmax)=(999999999,0); + +while() { + chomp; + foreach (m!a href="/(.*?)"!gi) { + ($prenew,$hs,$postnew) = m!^(.*?)hs-(.*?)([/$\&].*)!; + next unless defined($hs); + if (defined($pre) and (not($pre eq $prenew) or not($post eq $postnew))) { + print STDERR "$0: warning: found 'out-of-sequence' url: $_\n"; + print URI->new_abs($_,$url)->as_string, "\n"; + } + else { + ($pre,$post) = ($prenew,$postnew); + $hsmin=$hs if ($hs<$hsmin); + $hsmax=$hs if ($hs>$hsmax); + } + }; +} + +close(WGET); + +$hsmin=0 if ($hsmin==16); + +for ($hs=$hsmin; $hs<=$hsmax; $hs+=16) { + # print URI->new_abs("${pre}hs-${hs}${post}",$url)->as_string, "\n"; + print "http://www.heise.de/${pre}hs-${hs}${post}\n"; +} diff --git a/fetchheise-idxpage.html b/fetchheise-idxpage.html new file mode 100644 index 0000000..ec55b5e --- /dev/null +++ b/fetchheise-idxpage.html @@ -0,0 +1,1241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +user2user-Foren + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + +
+
+ +
+ + + + + + + + +
+ + + + + + + + + + + +
heise online
+ + +
+ + + +
+ + + + +
+ + + + + + + +
+ + + +
+
+
+ + + + + + + + + + + + + +
+ + +
+ + + + +
+
+
+
+ + + +
+
Sie sind eingeloggt
+ + + + + + + +
+ + +

Alle Beiträge des Users

+ + + + + + +
+ + + + + + + + + + + + + +
    + + + +
  • Seite
  • + + + + + +
  • 1
  • + + + + +
  • 2
  • + + + +
  • 3
  • + + + +
  • 4
  • + + + + +
  • ...
  • + + + + +
  • 219
  • + + + + +
  • Neuere
  • + + + + +
  • Ältere
  • + + + +
+ + + + + + + + + +
+ + + + + + + + +
    + + + +
  • Seite
  • + + + + + +
  • 1
  • + + + + +
  • 2
  • + + + +
  • 3
  • + + + +
  • 4
  • + + + + +
  • ...
  • + + + + +
  • 219
  • + + + + +
  • Neuere
  • + + + + +
  • Ältere
  • + + + +
+ + + + + + + + + + + + + + + +

+ +

+ + + + + + + + + + + + +
+
+
+ + + + +
+Anzeige
+ + + +
+
+
+
+
+ + +
+ + + + + + + + + + diff --git a/fetchheise-idxpages-articleurls b/fetchheise-idxpages-articleurls new file mode 100755 index 0000000..5f2065e --- /dev/null +++ b/fetchheise-idxpages-articleurls @@ -0,0 +1,26 @@ +#!/usr/bin/perl +# in: URLs of one or more index pages on cmdline +# out: URLs of all articles referenced in those pages on stdout, one per line + +use URI; + +foreach $url (@ARGV) { + # print "URL: $url\n"; + open(WGET, "wget-withbrowsersettings -q -O- '$url' |") or die "couldn't run wget-withbrowsersettings: $!"; + while() { + if (m!a href="/(.*?/read/)"!gi) { + print "http://www.heise.de/$1\n"; + }; + } + close(WGET); +} + +# TODO: optionally extract date/time and author name of each article +# TODO: generally, one would want to pipe sequences of real "article +# records" with slots like "date", "author", "contents" (only +# some of which may have to be filled) etc. between the +# fetchheise-* processes instead of line-oriented URL lists +# +# As a more limited solution, we could output the pieces of +# article data on one line, separated by TAB characters. Or use +# a page-oriented output (pages separated by \f) diff --git a/fetchmail-setup-tunnel.sh b/fetchmail-setup-tunnel.sh new file mode 100755 index 0000000..afeee75 --- /dev/null +++ b/fetchmail-setup-tunnel.sh @@ -0,0 +1,22 @@ +#! /bin/sh + +set -e + +# SSH-Tunnel +# echo "$0: setting up ssh tunnel from localhost:8011 to mail.cs.tu-berlin.de:110" +# ssh -L 8011:mail.cs.tu-berlin.de:110 basta.cs.tu-berlin.de sleep 1000000 & +# echo $! >/tmp/fetchmail-tunnel.$UID.pid +# echo "$0: sleeping 15 secs, waiting for SSH to set up the tunnel" +# echo "$0: TODO: this is a race condition" +# # TODO: tja... wie teilt der laufende ssh-Prozess nach außen mit, dass +# # die Verbindung hergestellt wurde? Shellscripting saugt! +# sleep 15; + +# mit SSL +# Zur stunnel-Installation (as root): chgrp users /var/run/stunnel; chmod g+rwx /var/run/stunnel +echo "$0: setting up stunnel from localhost:8011 to mail.cs.tu-berlin.de POP3 service" +/usr/bin/stunnel -c -d localhost:8011 -r mail.cs.tu-berlin.de:995 -v 3 -A "`dirname $0`/mail.cs.tu-berlin.de.cert" -P /var/run/stunnel/ +echo "$0: sleeping 3 secs, waiting for stunnel to set up the tunnel" +sleep 3; + +echo "$0: done" diff --git a/fetchmail-shutdown-tunnel.sh b/fetchmail-shutdown-tunnel.sh new file mode 100755 index 0000000..ff47bcf --- /dev/null +++ b/fetchmail-shutdown-tunnel.sh @@ -0,0 +1,10 @@ +#! /bin/sh + + +# fuer SSH-Tunnel +# echo "$0: shutting down ssh tunnel" +# kill -TERM `cat /tmp/fetchmail-tunnel.$UID.pid` + +# fuer stunnel +echo "$0: shutting down stunnel" +kill `cat /var/run/stunnel/stunnel.mail.cs.tu.berlin.de.995.pid ` diff --git a/ff b/ff new file mode 100755 index 0000000..52b1cbb --- /dev/null +++ b/ff @@ -0,0 +1,33 @@ +#!/bin/sh + +if [ $# -le 2 ] +then + echo "Aufruf: ff [GrepArgs] +sucht nach in allen Dateien, die in (meistens '.') +oder dessen Unterverzeichnissen sind und entsprechen. + und evtl. sollten in Apostrophs (') eingeschlossen sein, +damit sie nicht von der Shell expandiert werden! +[GrepArgs] sind beliebige Argumente, die intern an grep uebergeben werden. +Zum Beispiel (siehe man grep): +-i : Gross-/Kleinschreibung ignorieren +-E : nach \"richtigen\" (erweiterten) regulaeren Ausdruecken suchen +-n : Zeilennummern der Fundstellen ausgeben" + exit +fi + +GrepArgs= +nGrepArgs=$[ $# - 3 ] + +n=1 +while [ $n -le $nGrepArgs ]; do + GrepArgs="$GrepArgs $1"; + shift; + n=$[ $n + 1 ]; +done + +find $1 -iname "$3" -type f | +while read file; do + # " und ' rausfiltern, da xargs sonst irgendwas von "unmatched single/double quote" faselt + # ==> Bug in (Redhat-) xargs ? + grep $GrepArgs "$2" "$file" | sed -e 's/"//g' -e s/\'//g | xargs -irepl echo $file: repl +done diff --git a/file2disk.sh b/file2disk.sh new file mode 100755 index 0000000..b65d489 --- /dev/null +++ b/file2disk.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +if [ -z "$1" ]; then + echo "usage: file2disk " >&2 + echo " => copy to 1.44k floppy at /dev/fd0" >&2 + exit 1 +fi + +dd bs=1k count=1423 if=$1 of=/dev/fd0 diff --git a/firefox-memusage-log-create.sh b/firefox-memusage-log-create.sh new file mode 100755 index 0000000..9c5cd48 --- /dev/null +++ b/firefox-memusage-log-create.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +while true; do ps -ao user,rss,size,vsz,args | grep "$USER" | grep /usr/lib/firefox/firefox-bin | grep -v grep | awk '{print systime() " " $2 " " $4}'; sleep 60; done >>firefox-memusage-log.txt + diff --git a/firefox-memusage-log-plot.sh b/firefox-memusage-log-plot.sh new file mode 100755 index 0000000..6b5b135 --- /dev/null +++ b/firefox-memusage-log-plot.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cat firefox-memusage-log.txt | awk "{print \$1-`head -1 firefox-memusage-log.txt | awk '{print $1}'` \" \" \$2 \" \" \$3}" | xy+-plot | gnuplot-and-wait + diff --git a/firefox-print-stacktraces b/firefox-print-stacktraces new file mode 100755 index 0000000..bb76458 --- /dev/null +++ b/firefox-print-stacktraces @@ -0,0 +1,19 @@ +#!/bin/sh + +myname="`basename $0`" + +FFPID="`ps axu | grep firefox | grep -v grep | grep -v "$myname" | grep $USER | head -1 | awk '{print $2}'`" + +if [ -z "$FFPID" ]; then + echo "no running firefox instance found" + exit 1 +fi + +EXE="`ls -l /proc/$FFPID/exe | grepre '-> (.*)'`" + +if [ -z "$EXE" ]; then + echo "executable for firefox instance $FFPID not found" + exit 1 +fi + +gdb -x "`dirname $0`/firefox-print-stacktraces.gdbscript" "$EXE" "$FFPID" diff --git a/firefox-print-stacktraces.gdbscript b/firefox-print-stacktraces.gdbscript new file mode 100644 index 0000000..d9d4e07 --- /dev/null +++ b/firefox-print-stacktraces.gdbscript @@ -0,0 +1,4 @@ +info threads +bt +detach +quit diff --git a/freemind b/freemind new file mode 100755 index 0000000..0453e1a --- /dev/null +++ b/freemind @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/local/src/bin/dist/freemind.sh "$@" diff --git a/fsumup b/fsumup new file mode 100755 index 0000000..d45e980 --- /dev/null +++ b/fsumup @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w + +$sum = 0.0; + +while (<>) +{ + foreach (split(/ +/,$_)) + { + $sum += $_; + } +} + +print "$sum\n"; diff --git a/fullpath b/fullpath new file mode 100755 index 0000000..4205f54 --- /dev/null +++ b/fullpath @@ -0,0 +1,17 @@ +#!/bin/sh + +RESULT=$1; + +if echo $RESULT | egrep -q '^\./'; then + RESULT=`echo $RESULT | sed 's/^\.\///'`; + RESULT="${PWD}/${RESULT}"; +fi + +if echo $RESULT | egrep -q '^/'; then + true; +else + RESULT="${PWD}/${RESULT}"; +fi + + +echo $RESULT; diff --git a/gal2nsbm.py b/gal2nsbm.py new file mode 100755 index 0000000..512449d --- /dev/null +++ b/gal2nsbm.py @@ -0,0 +1,120 @@ +#!/usr/bin/python + +## 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 + +# Copyright 2001 by Lennart Poettering +# adapted to Netscape Bookmarks by Olaf Klischat +# This script will create a HTML page of your Galeon XML Bookmarks + +# Further information, usage examples and current versions may be found on +# http://www.stud.uni-hamburg.de/users/lennart/projects/galmark/ + +# You might want to change the first line to adapt it to your local +# python installation + +import sys, string, re, time, locale +from xml.sax import make_parser, handler +from xml.sax.saxutils import * + +def get_uniqe_id(): + import random + return 'NC:BookmarksRoot#$%08x' % (random.random() * 0x7fffffff) + +class myHandler(handler.ContentHandler): + + def startDocument(self): + + #print '' + #print '\n\nGaleon Bookmarks for %s\n\n' % os.environ['USER'] + print '' + print '' + print '' + print 'Bookmarks' + print '

Bookmarks

' + print "

" + self._level = 0 + self._num = [0] + + def endDocument(self): + + #print 'Produced with galmark.py by Lennart Poettering 2001' + #print '\n\n' + print "

" + + def startElement(self, name, attrs): + + if name == "folder" and attrs.has_key("name"): + + self._num[self._level] += 1 + self._level += 1 + self._num.append(0) + + if (self._level > 1): + print '

%s

' % (get_uniqe_id(), self.rape_name(attrs["name"])) + print '

' + + elif name == "site" and attrs.has_key("name") and attrs.has_key("url"): + + u = attrs["url"].encode("iso8859-1") + + #d = "" + #if attrs.has_key("time_added") : + # d = " - %s" % time.strftime("%x", time.gmtime(int(attrs["time_added"]))) + + print '

%s' % (escape(u), self.rape_name(attrs["name"])) + #print '%s\n  %s%s
' % (escape(u), self.rape_name(attrs["name"]), escape(u2), d) + + def endElement(self, name): + + if (name == "folder"): + self._level -= 1 + self._num.pop() + #print "
" + + if self._level >= 1: + print "

" + #print 'top
\n'; + + def level_str(self): + + s = `self._num[1]` + + for i in range(2, self._level): + s = "%s.%i" % (s, self._num[i]) + + return s + + def rape_name(self, s): + + s = s.replace("__", "_") + + while (1): + m = re.search(r'%([0-9A-F][0-9A-F])', s) + + if m == None: + break + + s = s[:m.start()] + unichr(int(m.group(1), 16)) + s[m.end():] + + return escape(unicode(s.encode("iso8859-1"), "utf-8").encode("iso-8859-1")) + + +locale.setlocale(locale.LC_ALL, '') + +parser = make_parser() +parser.setContentHandler(myHandler()) +parser.parse("file://%s/.galeon/bookmarks.xml" % os.environ['HOME']) diff --git a/generate-site-specific-filenames b/generate-site-specific-filenames new file mode 100755 index 0000000..e44a4c3 --- /dev/null +++ b/generate-site-specific-filenames @@ -0,0 +1,21 @@ +#!/bin/sh + +myecho() { + printf $1'\n' +} + +if test "$1" = -n; then + myecho() { + printf $1' ' + } + shift +fi + +base="$1" + +for ext in "`locateme place`" \ + "`locateme osname`" \ + "`locateme place`-`locateme osname`"; do + fn="$base$ext" + ( test -f "$fn" || test -d "$fn" || test -h "$fn" ) && myecho $fn +done diff --git a/getcdrdev b/getcdrdev new file mode 100755 index 0000000..d4729ec --- /dev/null +++ b/getcdrdev @@ -0,0 +1,5 @@ +#!/bin/sh + +cdrecord -scanbus 2>/dev/null | grep DVDRAM | grepre '^\s*(\S+)' || \ + cdrecord -scanbus dev=ATAPI 2>/dev/null | grep DVDRAM | grepre '^\s*(\S+)' | sed 's/^/ATAPI:/' || \ + exit 1 diff --git a/getdeja b/getdeja new file mode 100644 index 0000000..de380cd --- /dev/null +++ b/getdeja @@ -0,0 +1,379 @@ + + + + + + + + 09/02/99 + + + Re: Disabling control-alt-de + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 09/01/99 + + + Re: Disabling control-alt-de + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 09/01/99 + + + Re: Programming under XWindo + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 08/31/99 + + + Re: development enviroment f + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 08/30/99 + + + Re: Making Modal Dialogs in + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 08/23/99 + + + Re: why netscape sucks? + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 08/23/99 + + + Re: why netscape sucks? + + + comp.os.linux.develop + Olaf Klischat + + + + + + + + 08/19/99 + + + Re: Wie ernst ist der Artike + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/23/99 + + + Re: Installation einer Anwen + + + microsoft.public.de.v + Olaf Klischat + + + + + + + + 06/23/99 + + + Re: theoretische frage: schw + + + de.sci.physik + Olaf Klischat + + + + + + + + 06/22/99 + + + Re: VC++ 6 & MFC & ASSERT-Ma + + + de.comp.os.ms-windows + Olaf Klischat + + + + + + + + 06/22/99 + + + Re: Mondorbit Stabilitaet? + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/21/99 + + + Re: Zeit + + + de.rec.sf.startrek.vo + Olaf Klischat + + + + + + + + 06/21/99 + + + Re: Wie Applet in MS IE5.0 ? + + + de.comp.lang.java + Olaf Klischat + + + + + + + + 06/21/99 + + + Re: antidecompiler + + + de.comp.lang.java + Olaf Klischat + + + + + + + + 06/20/99 + + + Re: Mondorbit Stabilitaet? + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/20/99 + + + Re: Newbie Frage: 'Handling' + + + microsoft.public.de.v + Olaf Klischat + + + + + + + + 06/20/99 + + + Re: Frage zu potentieller Gl + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/19/99 + + + Re: Mondorbit Stabilitaet? + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/19/99 + + + Re: Mondorbit Stabilitaet? + + + de.sci.raumfahrt + Olaf Klischat + + + + + + + + 06/17/99 + + + Re: C++ Graphikprog. + + + de.comp.os.ms-windows + Olaf Klischat + + + + + + + + 06/16/99 + + + Re: Graph.h + + + de.comp.os.ms-windows + Olaf Klischat + + + + + + + + 06/16/99 + + + Re: Windows Scripting Host F + + + de.comp.os.ms-windows + Olaf Klischat + + + + + + + + 06/16/99 + + + Re: Login-Programm in Delphi + + + de.comp.os.ms-windows + Olaf Klischat + + + + + + + + 06/16/99 + + + Re: Design-Frage + + + de.comp.lang.iso-c++ + Olaf Klischat + + + + diff --git a/getdvdrdev b/getdvdrdev new file mode 100755 index 0000000..78adba6 --- /dev/null +++ b/getdvdrdev @@ -0,0 +1,3 @@ +#!/bin/sh + +cdrecord -scanbus 2>/dev/null | grep DVDRAM | grepre '^\s*(\S+)' diff --git a/getpid b/getpid new file mode 100755 index 0000000..be2d126 --- /dev/null +++ b/getpid @@ -0,0 +1,18 @@ +#!/bin/sh + +RESULT= +for entry in `ps axh | sed 's/ \+/@/g' | sed 's/^@\+//g' | cut -d @ -f1,5`; do + PID=`echo $entry | cut -d @ -f1`; + NAME=`echo $entry | cut -d @ -f2`; + if [ "$1" = "$PID" -o -n "`echo $NAME | grep $1`" ]; then + RESULT=$PID; + break; + fi +done + +if [ -n "$RESULT" ]; then + echo $RESULT +else + echo getpid: no such PID or process name: $1 >&2 + exit -1 +fi diff --git a/gianasis b/gianasis new file mode 100755 index 0000000..28a429c --- /dev/null +++ b/gianasis @@ -0,0 +1,3 @@ +#!/bin/sh + +exec x64 /home/olaf/c64/games/giana.start.vsf diff --git a/gnuplot-and-wait b/gnuplot-and-wait new file mode 100755 index 0000000..4de68b2 --- /dev/null +++ b/gnuplot-and-wait @@ -0,0 +1,3 @@ +#!/bin/sh + +(cat; sleep 9999999999) | gnuplot diff --git a/gnuplot-eps b/gnuplot-eps new file mode 100755 index 0000000..9d8a9d7 --- /dev/null +++ b/gnuplot-eps @@ -0,0 +1,3 @@ +#!/bin/sh + +(echo 'set terminal postscript eps'; cat ) | gnuplot diff --git a/gnuplot-eps-and-wait b/gnuplot-eps-and-wait new file mode 100755 index 0000000..a7adae7 --- /dev/null +++ b/gnuplot-eps-and-wait @@ -0,0 +1,6 @@ +#!/bin/sh + +TMP=`mktemp /tmp/gnuplot-eps-and-wait.XXXXXXXXXX` || exit 1 +(echo 'set terminal postscript eps'; cat ) | gnuplot >$TMP +gv $TMP +rm -f $TMP diff --git a/gnuplot-png b/gnuplot-png new file mode 100755 index 0000000..17d6b46 --- /dev/null +++ b/gnuplot-png @@ -0,0 +1,4 @@ +#!/bin/sh + +TMP=`mktemp /tmp/gnuplot-eps-and-wait.XXXXXXXXXX` || exit 1 +(echo 'set terminal png'; cat ) | gnuplot diff --git a/gnus.sh b/gnus.sh new file mode 100755 index 0000000..cab2876 --- /dev/null +++ b/gnus.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +export GNU_PORT="$GNUS_GNUSERV_PORT"; +if [ -z "$GNU_PORT" ]; then + echo "$0: Warning: \$GNUS_GNUSERV_PORT not set. Using default port (30000+uid) for communicating with gnuserv" >&2; + export GNU_PORT=$[ 30000 + $UID ]; +fi + +if gnuclient -h localhost -batch -eval 'nil' >/dev/null 2>&1; then + # Gnus is already running in an Emacs instance + # If an email address was given on the cmd line, + # pass it to the running Gnus + # else do nothing + if [ "$1" ]; then + gnuclient -h localhost -eval "(mygnus-mail-to \"$1\" \"$2\")"; + else + gnuclient -h localhost -eval '(progn (switch-to-buffer "*Group*") (delete-other-windows))'; + fi +else + # Gnus isn't running yet, start it (along with its Emacs instance) + echo "starting new gnus..."; + if [ "$1" ]; then + exec xemacs -eval "(gnus) (mygnus-mail-to \"$1\" \"$2\")"; + else + exec xemacs -eval "(gnus)"; + fi +fi + diff --git a/grep_instfiles b/grep_instfiles new file mode 100755 index 0000000..9a119e3 --- /dev/null +++ b/grep_instfiles @@ -0,0 +1,24 @@ +#!/usr/bin/perl -w + +my %openfiles; + +while () { + SWITCH: { + if(/^\S+\s+f?open(?:64)?\s+(\S+)\s+(#success)/) { + $openfiles{$1} = 1; last SWITCH; + } + if(/^\S+\s+unlink\s+(\S+)\s+(#success)/) { + delete $openfiles{$1}; last SWITCH; + } + if(/^\S+\s+rename\s+(\S+)\s+(\S+)\s(#success)/) { + delete $openfiles{$1}; + $openfiles{$2} = 1; + last SWITCH; + } + } +} + + +for my $f (keys %openfiles) { + print "$f\n"; +} diff --git a/grepre b/grepre new file mode 100755 index 0000000..08d958d --- /dev/null +++ b/grepre @@ -0,0 +1,18 @@ +#!/usr/bin/perl -w + +my $re = $ARGV[0]; +die "usage: grepre \n" + unless defined($re); + +$re = eval { qr/$re/ }; +die "invalid regexp: $@" if $@; + +my $exitcode=1; +while () { + while (/$re/g) { + print "$1\n"; + $exitcode=0; + } +} + +exit $exitcode; diff --git a/gtetrinet-configure-keyboard b/gtetrinet-configure-keyboard new file mode 100755 index 0000000..bda6b63 --- /dev/null +++ b/gtetrinet-configure-keyboard @@ -0,0 +1,6 @@ +#!/bin/sh + +# Scancodes: Crsr left: 100 Crsr right: 102 +# nicht einzeln setzbar :-( + +xset r rate 150 30 diff --git a/gtetrinet-unconfigure-keyboard b/gtetrinet-unconfigure-keyboard new file mode 100755 index 0000000..7d0817b --- /dev/null +++ b/gtetrinet-unconfigure-keyboard @@ -0,0 +1,3 @@ +#!/bin/sh + +xset r rate diff --git a/ifaceaddr b/ifaceaddr new file mode 100755 index 0000000..5714a7f --- /dev/null +++ b/ifaceaddr @@ -0,0 +1,6 @@ +#!/bin/sh + +# /sbin/ifconfig "$1" | grepre 'inet.* addr: *(.*?)[/ ]' # apparently ifconfig sometimes doesn't display IPv6 addresses... + +ip addr show "$1" | grepre 'inet.*? +(.*?)[/ ]' + \ No newline at end of file diff --git a/imagej b/imagej new file mode 100755 index 0000000..c83156e --- /dev/null +++ b/imagej @@ -0,0 +1,3 @@ +#!/bin/sh + +java -jar /usr/local/ImageJ/ij.jar "$@" diff --git a/install-javaplugin b/install-javaplugin new file mode 100755 index 0000000..3c9cc7e --- /dev/null +++ b/install-javaplugin @@ -0,0 +1,17 @@ +#!/bin/sh +#adapted from "update-flashplugin" + +# TODO: list orderd by priority... +srcdir=/usr/local/jdk/jre/plugin/i386/ns610-gcc32 + +cd "$srcdir" || { echo "couldn't cd to $srcdir"; exit 1; } +f="`echo $srcdir/libjavaplugin*.so`"; +[ -z "$f" ] && { echo "no libjavaplugin... in $srcdir"; exit 1; } + +echo "found file: $f"; + +for destdir in /usr/lib/mozilla/plugins /usr/lib/mozilla-snapshot/plugins /usr/lib/mozilla-firebird/plugins /usr/lib/mozilla-firefox/plugins; do + mkdir --parents "$destdir"; + rm -f "$destdir/libjavaplugin*.so"; + ln -sf "$f" "$destdir/`basename $f`"; +done diff --git a/instfilelist.pl b/instfilelist.pl new file mode 100755 index 0000000..c070a88 --- /dev/null +++ b/instfilelist.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl -w +# in: 'make install' output on stdin +# out: list of installed files on stdout + +# beware: heuristic, unreliable + +my %files = (); + +while (<>) { + + if (m!^\s*(?:(?:/bin/sh\s+)?[^\s]*libtool.*?--mode=install\s+)?(?:/usr/bin/)?install\s.*?\s(/.*?)\s*$!) { +# if (m!^\s*(?:/usr/bin/)?install.*?\s(/.*?)\s*$! || +# m!libtool.*?--mode=install.*?\s(/[^\s]*?)\s*$!) { + + $files{$1} = 1; + } +} + +foreach my $file (sort keys %files) { + print $file . "\n"; +} + + diff --git a/ip6to4 b/ip6to4 new file mode 100755 index 0000000..21c6c54 --- /dev/null +++ b/ip6to4 @@ -0,0 +1,10 @@ +#!/bin/sh +# in: interface name on cmdline or ipv4 ip on stdin +# out: prefix of 6to4 ipv6 ip of the input ip on stdout + +{ if [ $# = 1 ]; then + ifaceaddr "$1" | head -1 + else + cat + fi +} | printf '2002:%02x%02x:%02x%02x' `tr '.' ' '` diff --git a/irexec.pl b/irexec.pl new file mode 100755 index 0000000..48cee33 --- /dev/null +++ b/irexec.pl @@ -0,0 +1,164 @@ +#!/usr/bin/perl -w + +# The lirc (http://www.lirc.org/) kernel module and lircd daemon are +# nice and sane, irexec/liblircclient are an inflexible mess of +# interdependent internal states interacting in numerous +# half-undocumented, fully-unconfigurable ways. This is a +# replacement... + +use strict; +use warnings; + +use Proc::ProcessTable; + + +{ + my $procs = undef; + my $lasttime = -1; + + sub getProcs() { + my $t = Time::HiRes::time(); + unless ($t-$lasttime <= 2 and defined($procs)) { + $procs = [ map {$_->cmndline} @{(new Proc::ProcessTable)->table} ]; + $lasttime = Time::HiRes::time(); + } + $procs; + } +} + + +sub isRunning($) { + my $proc = shift; + grep {$_ eq $proc} @{getProcs()}; +} + +$SIG{CHLD} = 'IGNORE'; + +sub spawn(@) { + my $pid=fork(); + if (0==$pid) { + exec @_ or die "couldn't exec " . join(' ',@_) . ": $!"; + } + $pid; +} + +sub spawnUnlessRunning($@) { + my ($test,@proc) = @_; + spawn @proc unless isRunning($test); +} + +my $modes = { + 'xmms' => { START=>sub{ spawnUnlessRunning "xmms", "xmms.sh" } }, + 'xawtv' => { START=>sub{ + system "audioreset"; + spawnUnlessRunning "xawtv", "xawtv"; + sleep 5; + system "xawtv-remote fullscreen"; + sleep 1; + }, + STOP=>sub{ system "xawtv-remote quit"; } }, + 'mplayer' => { }, + 'sleeper' => { START=>sub{ + our ($sleeper_pid); + print STDERR "starting sleeper\n"; + $sleeper_pid = spawn("sleepingsongs"); + }, + STOP=>sub{ + our ($sleeper_pid); + kill 'SIGTERM', $sleeper_pid if (defined($sleeper_pid)); + } } +}; + + +my $mode = ''; + +sub setMode($) { + my $newmode = shift; + return if $newmode eq $mode; + &{$modes->{$mode}->{STOP}} if defined($modes->{$mode}->{STOP}); + &{$modes->{$newmode}->{START}} if defined($modes->{$newmode}->{START}); + $mode = $newmode; + print STDERR "new mode: $mode\n"; +} + + +my $actions = +{ + 'xmms' => {'CH+' => sub {system "xmms.sh --fwd"}, + 'CH-' => sub {system "xmms.sh --rew"}, + '5' => sub {system "xmms.sh --stop"}, + '6' => sub {print STDERR "play!\n"; system "xmms.sh --play-pause"} + }, + + 'xawtv' => {'CH+' => sub {system "xawtv-remote setstation next"}, + 'CH-' => sub {system "xawtv-remote setstation prev"}, + 'FULL_SCREEN' => sub {system "xawtv-remote fullscreen"}, + 'TV' => sub { setMode("sleeper"); }, + map { my $key=$_; ("$key" => sub {system (sprintf "xawtv-remote setstation %02u", $key-1)}) } (1..9) + }, + + 'mplayer' => {'CH+' => sub {system "mplayerctl fwd"}, + 'CH-' => sub {system "mplayerctl rew"}, + 'FULL_SCREEN' => sub {system "mplayerctl fullscreen"}, + '6' => sub {system "mplayerctl playpause"}, + '9' => sub {system "mplayerctl subsvisibility"} + }, + + 'sleeper' => {'TV' => sub { setMode("xawtv"); } }, + + 'default' => {'RADIO' => sub { setMode "xmms"; }, + 'TV' => sub { setMode "xawtv"; }, + 'MUTE' => sub { setMode "mplayer"; }, + '0' => sub { system "killall mplayer"; }, +# 'VOL+' => sub {system "echo '+' | aumix" }, +# 'VOL-' => sub {system "echo '-' | aumix" }, + } + +}; + + + + +### main loop -- receive and process keys + +# receive keys in a separate sub-process so we can keep track +# of the exact time each keypress happened regardless of the +# time some running action takes to complete. This is to ensure +# we don't process a keypress multiple times if the key was held +# down just a bit longer. +use IO::Handle; + +pipe KEYS_IN, KEYS_OUT; +KEYS_OUT->autoflush(1); +if (0==fork()) { + # child + close KEYS_IN; + + use Socket; + use Time::HiRes; + socket(LIRCD, PF_UNIX, SOCK_STREAM, PF_UNSPEC); + connect(LIRCD, sockaddr_un('/dev/lircd')) or die "couldn't connect() to /dev/lircd: $!"; + while() { + my ($key) = /.+? .+? (.*?) /; + my $time = Time::HiRes::time(); + print KEYS_OUT "${key}\t${time}\n"; + } + exit 0; +} +else { + # parent + close KEYS_OUT; +} + + + +my $lasttime = -1; +while() { + my ($key,$time) = /^(.*?)\t(.*)/; + + next if ($time - $lasttime < 0.3); # avoid accidentally pressing a key multiple times + $lasttime = $time; + + my $action = $actions->{$mode}->{$key} || $actions->{'default'}->{$key}; + &$action if $action; +} diff --git a/iriver2m3ufile.pl b/iriver2m3ufile.pl new file mode 100755 index 0000000..58b6e1c --- /dev/null +++ b/iriver2m3ufile.pl @@ -0,0 +1,4 @@ +#!/usr/bin/perl -w -pi -- + +s!\\!/!g; +s!\x{d}\x{a}!\x{a}!s; diff --git a/javaws b/javaws new file mode 100755 index 0000000..70f7065 --- /dev/null +++ b/javaws @@ -0,0 +1,3 @@ +#!/bin/sh + +exec /usr/local/jdk/jre/javaws/javaws "$@" diff --git a/jolietnamecheckcurrdir b/jolietnamecheckcurrdir new file mode 100755 index 0000000..eded066 --- /dev/null +++ b/jolietnamecheckcurrdir @@ -0,0 +1,18 @@ +#!/usr/bin/perl -w + +use constant MAXLENGTH => 64; + +use File::Find; + +my $exitcode=0; + +find({ no_chdir=>1, + wanted => sub { + return unless -f; + if (length $File::Find::name > MAXLENGTH+2) { + print STDERR "file path longer than ".MAXLENGTH." chars: $File::Find::name\n"; + $exitcode = 1; + } + }}, '.'); + +exit $exitcode; diff --git a/jolietrename b/jolietrename new file mode 100755 index 0000000..a548d14 --- /dev/null +++ b/jolietrename @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +use constant MAXLENGTH => 64; + +for my $fn (@ARGV) { + my ($base,$ext); + ($base,$ext) = ($fn =~ /(.*?)(\.[^\.]*)$/) or ($base,$ext) = ($fn,''); + if (length $ext > MAXLENGTH) { + print STDERR "$fn: extension too long."; next; + } + $base = substr $base, 0, (MAXLENGTH - length $ext); + my $newfn = "$base$ext"; + unless ($fn eq $newfn) { + if (-f $newfn) { + print STDERR "mv $fn $newfn: target already exists\n"; + } + else { + rename $fn, $newfn or print STDERR "mv $fn $newfn: unsuccessful: $!\n"; + } + } +} diff --git a/jolietrenamecurrdir b/jolietrenamecurrdir new file mode 100755 index 0000000..b3ad9f7 --- /dev/null +++ b/jolietrenamecurrdir @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w + +use constant MAXLENGTH => 64; + +use File::Find; + +find({ no_chdir=>1, + wanted => sub { + return unless -f; + ($dir,$base,$ext) = ($File::Find::name =~ m!^\./(.*/)?(.*?)(\.[^\.]*)?$!); + $dir='' unless defined($dir); + $ext='' unless defined($ext); + if (length "$dir$ext" > MAXLENGTH) { + print STDERR "$File::Find::name: dir+extension combined longer than ".MAXLENGTH." chars\n"; return; + } + $base = substr $base, 0, (MAXLENGTH - length "$dir$ext"); + $newfn = './' . ($dir eq ''? '':$dir) . "$base$ext"; + unless ($File::Find::name eq $newfn) { + my $n=1; + while (-f $newfn) { + print STDERR "mv $File::Find::name $newfn: target already exists, appending number...\n"; + $base =~ s/.{${\(length $n)}}$/$n/; + $n++; + $newfn = './' . ($dir eq ''? '':$dir) . "$base$ext"; + } + rename $File::Find::name, $newfn or print STDERR "mv $File::Find::name $newfn: unsuccessful: $!\n"; + } + }}, '.'); diff --git a/jython2bsh b/jython2bsh new file mode 100755 index 0000000..9979499 --- /dev/null +++ b/jython2bsh @@ -0,0 +1,24 @@ +#!/usr/bin/perl -w + +# unkorrekt, unvollstaendig + + +while () { + next if (/^\s*$/); + + my $comment = ""; + if (/^(.*?)\#(.*)/) { + $_ = $1; $comment = "//$2"; + } + s/^from +(.*?) +import +(\S+)/import $1.$2;/ && next; + + s/^(\s*)def (.*?):/$1$2 {/ and next; + + s/([A-Z]\w*?\s*\()/new $1/g; + + chomp; + $_ = $_?"$_;$comment\n":"$comment\n"; + +} continue { + print; +} diff --git a/kill-flashplugin b/kill-flashplugin new file mode 100644 index 0000000..69c11e1 --- /dev/null +++ b/kill-flashplugin @@ -0,0 +1,4 @@ +#!/bin/sh + +ps axu | grep libflashplayer | grep $LOGNAME | grep -v grep | awk '{print $2}' | xargs kill + diff --git a/kill-vpn.sh b/kill-vpn.sh new file mode 100644 index 0000000..2e728ac --- /dev/null +++ b/kill-vpn.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +ps ax | grep pppd | grep -v grep | grep -v pppoe | grep notty | awk '{print $1}' | xargs kill + diff --git a/lesscat b/lesscat new file mode 100755 index 0000000..0fe97dc --- /dev/null +++ b/lesscat @@ -0,0 +1,29 @@ +#!/usr/bin/ruby -w +# lesscat file... +# +# pipe files through lesspipe like less does, if that didn't work out, cat them + +cmdline = ((ENV['LESSOPEN'] || raise('$LESSOPEN unset')) \ + .match(/^\|(.*)/) || raise('$LESSOPEN must be "| cmd args"'))[1].split + +argidx = cmdline.index('%s') || raise('$LESSOPEN command line must contain a %s') + +ARGV.each do |fn| + rd,wr = IO.pipe + if fork + #parent + wr.close + n_read=0 + while (buf=rd.read(100)) != nil + STDOUT.write buf + n_read += buf.length + end + system "cat", fn if n_read==0 + else + #child + rd.close + STDOUT.reopen wr + cmdline[argidx] = fn + exec(*cmdline) + end +end diff --git a/libusers b/libusers new file mode 100755 index 0000000..036ee3b --- /dev/null +++ b/libusers @@ -0,0 +1,7 @@ +#!/bin/sh + +for f in `listexecs`; do + if ldd $f | grep $1 >/dev/null; then + echo $f; + fi +done diff --git a/linehist b/linehist new file mode 100755 index 0000000..2a80e4e --- /dev/null +++ b/linehist @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w + +while (<>) { + chomp; ++$num{$_}; +} + + +for (keys %num) { print "$_: $num{$_}\n" } diff --git a/listexecs b/listexecs new file mode 100755 index 0000000..a423714 --- /dev/null +++ b/listexecs @@ -0,0 +1,4 @@ +#!/bin/sh + +find `echo $PATH | sed 's/:/ /g'` -maxdepth 1 -type f -perm -u+x 2>/dev/null + diff --git a/lnum.sh b/lnum.sh new file mode 100755 index 0000000..5b32f69 --- /dev/null +++ b/lnum.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +IFS=`printf '\n'` + +if [ $# == 1 ]; then + width=$1; +else + width=3; +fi + +num=1; + +while read line; do + printf "%${width}i: " $num; + echo $line; + num=$[ $num + 1 ]; +done diff --git a/locateme b/locateme new file mode 100755 index 0000000..e037a3f --- /dev/null +++ b/locateme @@ -0,0 +1,52 @@ +#!/bin/sh +# should probably be named "whereami", but a program with that name already exists + +if [ $# -gt 0 ]; then + for attr in "$@"; do + $0 | grep "^$attr:" | sed "s/^$attr://" + done + exit 0 +fi + +hostname="`hostname 2>/dev/null`" +domainname="`domainname 2>/dev/null`" + +case "$domainname" in + cs.tu-berlin.de) + place=cs + ;; + isst.fhg.de) + place=isst + ;; + *) + place="[unknown]" + ;; +esac + + +case "$hostname" in + tick) + place=myhomehost + ;; + tack) + place=myhomedesktop + ;; + teck) + place=mylaptop + ;; + swangoose) + place=myissthost + ;; +esac + + +osname="`uname`" +osversion="`uname -r`" +arch="`uname -m`" + +cat < + or die "no entry for $iface found in /proc/net/dev"; +} + +my ($in0,$out0,$in1,$out1); + +($in0,$out0) = getInOut(); + +my $sleepTime=5; + +while (1) { + sleep $sleepTime; + ($in1,$out1) = getInOut(); + + print "in: ", ($in1-$in0)/$sleepTime, " bytes/s, out: ", ($out1-$out0)/$sleepTime, " bytes/s\n"; + ($in0,$out0) = ($in1,$out1); +} diff --git a/m3u2iriver.pl b/m3u2iriver.pl new file mode 100755 index 0000000..329c978 --- /dev/null +++ b/m3u2iriver.pl @@ -0,0 +1,7 @@ +#!/usr/bin/perl -w + +while () { + chomp; + s!/!\\!g; + print "$_\x{d}\x{a}"; +} diff --git a/m3u2iriverfile.pl b/m3u2iriverfile.pl new file mode 100755 index 0000000..4902803 --- /dev/null +++ b/m3u2iriverfile.pl @@ -0,0 +1,5 @@ +#!/usr/bin/perl -w -pi -- + +chomp; +s!/!\\!g; +s!$!\x{d}\x{a}!; diff --git a/m3uxmms2unx b/m3uxmms2unx new file mode 100755 index 0000000..2cbc04a --- /dev/null +++ b/m3uxmms2unx @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w + +die < ... + + expect .m3u file on stdin. Write to + stdout that file, minus comment lines (^#.*) + and path name prefixes equal to any of the + s. +EOF + unless defined(@ARGV); + +my $re = '(' . join '|', @ARGV . ')'; + +while () { + unless (/^\s*\#/) { + s!^/usr/local/mp3s/|/usr/local/ntbackup/mp3s/!!; + print; + } +} diff --git a/maestro b/maestro new file mode 100755 index 0000000..bc7dca7 --- /dev/null +++ b/maestro @@ -0,0 +1,4 @@ +#!/bin/sh + +export LD_LIBRARY_PATH=/usr/local/maestro/JPL/SAP/bin +/usr/local/maestro/JPL/SAP/bin/SAP diff --git a/mail.cs.tu-berlin.de.cert b/mail.cs.tu-berlin.de.cert new file mode 100644 index 0000000..20ad883 --- /dev/null +++ b/mail.cs.tu-berlin.de.cert @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICrzCCAhgCAQYwDQYJKoZIhvcNAQEFBQAwgZ8xCzAJBgNVBAYTAkRFMQ8wDQYD +VQQIEwZCZXJsaW4xFzAVBgNVBAcTDkNoYXJsb3R0ZW5idXJnMSYwJAYDVQQKFB1U +ZWNobmlzY2hlIFVuaXZlcnNpdOR0IEJlcmxpbjEiMCAGA1UECxMZSW5mb3JtYXRp +ay1SZWNobmVyYmV0cmllYjEaMBgGA1UEAxQRKi5jcy50dS1iZXJsaW4uZGUwHhcN +MDUxMDI4MDg0NzU2WhcNMDYxMDIzMDg0NzU2WjCBnzELMAkGA1UEBhMCREUxDzAN +BgNVBAgTBkJlcmxpbjEXMBUGA1UEBxMOQ2hhcmxvdHRlbmJ1cmcxJjAkBgNVBAoU +HVRlY2huaXNjaGUgVW5pdmVyc2l05HQgQmVybGluMSIwIAYDVQQLExlJbmZvcm1h +dGlrLVJlY2huZXJiZXRyaWViMRowGAYDVQQDFBEqLmNzLnR1LWJlcmxpbi5kZTCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYBwBrVEifZBZn9/L/TQGnexiN3TusBQ +zBlVh/XXqR2s+g8hDS1zOuRtp3zKOEuCf5D+6Jib20/NifwG1onQA0gbxmLf+/Ti +fr7mj0MU8XCB/aPGz8rUarn6tjGcbUWIBS3ztLAgRzJ6gJya/J5ukmsTXglGYIj8 +dnkvJ6Mot8bhUwIEJ/tHaTANBgkqhkiG9w0BAQUFAAOBgQBQ/rUpm6sbSZGxrmsn +6zq3i0rfRnr6JxsnkbNOciE5W5MlJ9aADl6PAbipt7qT0+WKZw2Ei85KPQmwhek9 +Z1PB4wOY4YuvR20m6o7JuFHpin6Y4e2tK4nZP/4jOthkWj372VXxfl4c78v4MuAd +95Nas8hzpQGmk1JZkQkjkxt8Dg== +-----END CERTIFICATE----- diff --git a/make-misc b/make-misc new file mode 100755 index 0000000..1231594 --- /dev/null +++ b/make-misc @@ -0,0 +1,3 @@ +#!/bin/sh + +make -f "`dirname $0`/misc.make" "$@" diff --git a/make-my_configure_help b/make-my_configure_help new file mode 100755 index 0000000..8616ae8 --- /dev/null +++ b/make-my_configure_help @@ -0,0 +1,3 @@ +#!/bin/sh + +find . -name Kconfig | xargs cat >my_configure_help.txt diff --git a/memeaters.pl b/memeaters.pl new file mode 100755 index 0000000..a239b31 --- /dev/null +++ b/memeaters.pl @@ -0,0 +1,7 @@ +#! /usr/bin/perl -w + +open (PS, "ps laxw |"); + +map { printf " %7s %7s %7s %s\n", $_->[2], $_->[6], $_->[7], join(' ',@$_[12 .. $#$_]); } + grep { $_->[6] =~ "VSZ|[0-9]{5,}" } + map { [ split ] } ; diff --git a/memeaters1.pl b/memeaters1.pl new file mode 100755 index 0000000..d25f4f1 --- /dev/null +++ b/memeaters1.pl @@ -0,0 +1,4 @@ +#! /usr/bin/perl -w + +open (PS, "ps laxw |"); +print grep { (split(/\s+/,$_))[6] =~ "[0-9]{5,}" } ; diff --git a/memusage b/memusage new file mode 100755 index 0000000..9687f00 --- /dev/null +++ b/memusage @@ -0,0 +1,12 @@ +#!/bin/sh + +PID=`getpid $1` || exit -1; + +LASTSIZE=0; +while true; do + CURSIZE=`ps hl $PID | sed 's/^ \+//g' | sed 's/ \+/@/g' |cut -d @ -f7`; + if [ $CURSIZE -ne $LASTSIZE ]; then printf '\x7'; fi + clear; echo $CURSIZE; + LASTSIZE=$CURSIZE; + usleep 150000; +done diff --git a/memusage-log-for-pid b/memusage-log-for-pid new file mode 100755 index 0000000..2e0e04e --- /dev/null +++ b/memusage-log-for-pid @@ -0,0 +1,6 @@ +#!/bin/sh + +while true; do + echo `date +%s; ps -p "$1" ho rss,size,vsz` + sleep 30 +done diff --git a/memusage-snapshot b/memusage-snapshot new file mode 100755 index 0000000..aebb84b --- /dev/null +++ b/memusage-snapshot @@ -0,0 +1,6 @@ +#!/bin/sh + +date +'TIME: %x %X (%s)' +ps ax -o pid,size,vsz,comm --sort -size | head -20 +free +cat /proc/loadavg diff --git a/memusage_for_pid_by_lib b/memusage_for_pid_by_lib new file mode 100755 index 0000000..4dc5396 --- /dev/null +++ b/memusage_for_pid_by_lib @@ -0,0 +1,21 @@ +#!/usr/bin/ruby + +pid=Integer(ARGV[0]) + +File.open("/proc/#{pid}/maps") do |mapsfile| + mapsfile.readlines.map do |l| + fields = l.split + (lower,upper) = fields[0].split("-") + mem = Integer("0x"+upper)-Integer("0x"+lower) + libname = fields[5]||"[unknown]" + [libname,mem] + end.inject({}) do |usage,(libname,mem)| + usage[libname] ||= 0 + usage[libname] += mem + usage["[TOTAL]"] ||= 0 + usage["[TOTAL]"] += mem + usage + end.to_a.sort_by{|(libname,mem)|mem}.each do |(libname,mem)| + puts "#{libname}: #{mem}" + end +end diff --git a/memusagelogd b/memusagelogd new file mode 100755 index 0000000..d2be564 --- /dev/null +++ b/memusagelogd @@ -0,0 +1,8 @@ +#!/bin/sh + +exec >>/var/log/memusage.log 2>&1 + +while true; do + /usr/local/bin/memusage-snapshot; + sleep 120; +done diff --git a/misc.make b/misc.make new file mode 100644 index 0000000..6b52026 --- /dev/null +++ b/misc.make @@ -0,0 +1,112 @@ +#########TeX, dvips +%.dvi: %.tex + latex $< && latex $< || ( rm $@ && false ) # TODO: wie outputfilenamen an latex uebergeben? + +%.pdf: %.tex + pdflatex $< && pdflatex $< || ( rm $@ && false ) # TODO: wie outputfilenamen an pdflatex uebergeben? + +%.ps: %.dvi + dvips $< -o $@ + +%.eps: %.fig + fig2dev -L eps $< $@ + +%.eps: %.dia + dia -n -e $@ -t eps $< + +%.pdf: %.eps + epstopdf --outfile=$@ $< + +%.ps: %.pdf + pdf2ps $< $@ + +%.pdf: %.ps + ps2pdf $< + +#########PostScript +%.2.ps: %.ps + psnup -2 $< >$@ + +%.4.ps: %.ps + psnup -4 $< >$@ + + +######### + +%.ps: %.glabels + glabels-batch -l -o $@ $< # DOESNT WORK: glabels ignores "-o" and outputs to output.ps + +######### + +%.eps: %.gplot + (echo 'set terminal postscript eps'; cat $<) | gnuplot >$@ + +%.eps: %.gnuplot + (echo 'set terminal postscript eps'; cat $<) | gnuplot >$@ + +#########image conversion + + +%.pnm: %.xpm + xpmtoppm <$< >$@ + +%.pnm_alpha: %.xpm + xpmtoppm --alphaout=- <$< >$@ + +%.pnm: %.gif + giftopnm <$< >$@ + +%.pnm_alpha: %.gif + giftopnm --alphaout=- <$< >$@ + +%.png: %.pnm %.pnm_alpha + pnmtopng -alpha $*.pnm_alpha <$*.pnm >$@ + +# fallback when no .pnm_alpha is available +%.png: %.pnm + pnmtopng <$< >$@ + +%.pnm: %.xwd + xwdtopnm <$< >$@ + +%.ppm: %.xpm + xpmtoppm <$< >$@ + +%.ppm: %.png + pngtopnm <$< >$@ + +%.gif: %.ppm + ppmtogif <$< >$@ + +%.ppm: %.bmp + bmptoppm <$< >$@ + +%.bmp: %.ppm + ppmtobmp <$< >$@ + +%.xpm: %.ppm + ppmtoxpm <$< >$@ + +%.jpg %.png %.gif: %.xcf + convert -flatten -background transparent $< $@ + +#########CD writing + +%.iso: % + mkisofs -J $< -o $@ + + +#########audio + +%.wav: %.mp3 + mpg123 -w $@ $< + +%.mp3: %.wav + lame -h -b 192 $< $@ + +%.ogg: %.wav + oggenc -b 160 $< + +#########some "catch-all" last resorts +%.ps: % + a2ps -o $@ $< diff --git a/mlnet-disksize-watchdog b/mlnet-disksize-watchdog new file mode 100755 index 0000000..1920f33 --- /dev/null +++ b/mlnet-disksize-watchdog @@ -0,0 +1,8 @@ +#!/bin/sh + +while true; do + if [ "`df | grep '/var$' | awk '{ print $3 }'`" -lt 40000 ]; then + killall -TERM mlnet 2>/dev/null; + fi + sleep 60; +done diff --git a/modprobe b/modprobe new file mode 100755 index 0000000..28e22f8 --- /dev/null +++ b/modprobe @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w + +use Sys::Syslog; + +eval { + openlog("modprobe wrapper", "pid,ndelay", "LOG_USER"); + syslog(LOG_DEBUG, "running: modprobe " . join(" ",@ARGV) . " --- MODPROBE_OPTIONS=" . $ENV{"MODPROBE_OPTIONS"}); + closelog; +}; + +exec {"/sbin/modprobe-wrapped/modprobe"} "/sbin/modprobe", @ARGV; +die "error: $!"; diff --git a/mountdata b/mountdata new file mode 100755 index 0000000..c2a969c --- /dev/null +++ b/mountdata @@ -0,0 +1,3 @@ +#!/bin/sh + +for i in `seq 1 15`; do mount /mnt/data$i; done diff --git a/mouseclick b/mouseclick new file mode 100755 index 0000000..32bd9fd Binary files /dev/null and b/mouseclick differ diff --git a/mouseclick.c b/mouseclick.c new file mode 100644 index 0000000..ca77dcb --- /dev/null +++ b/mouseclick.c @@ -0,0 +1,52 @@ +//http://groups.google.de/groups?hl=de&lr=&threadm=1992May27.141519.246452%40cs.cmu.edu&rnum=2&prev=/groups%3Fhl%3Dde%26lr%3D%26q%3DXSendEvent%2BButtonPress%26btnG%3DSuche + +#include +#include + + +int main() { + XEvent event; + Display *display = XOpenDisplay(getenv("DISPLAY")); + + bzero(&event,sizeof(XEvent)); + event.type = ButtonPress; + event.xbutton.button = Button1; + event.xbutton.same_screen = True; + + /* get info about current pointer position */ + XQueryPointer(display, RootWindow(display, DefaultScreen(display)), + &event.xbutton.root, &event.xbutton.window, + &event.xbutton.x_root, &event.xbutton.y_root, + &event.xbutton.x, &event.xbutton.y, + &event.xbutton.state); + + event.xbutton.subwindow = event.xbutton.window; + + /* walk down through window hierachy to find youngest child */ + while (event.xbutton.subwindow) { + event.xbutton.window = event.xbutton.subwindow; + XQueryPointer(display, event.xbutton.window, + &event.xbutton.root, &event.xbutton.subwindow, + &event.xbutton.x_root, &event.xbutton.y_root, + &event.xbutton.x, &event.xbutton.y, + &event.xbutton.state); + } + + /* send ButtonPress event to youngest child */ + if (XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) + printf("XSendEvent Failed\n"); + XFlush(display); + + /* sleep for a little while */ + usleep(100000); + + /* set up ButtonRelease event */ + event.type = ButtonRelease; + event.xbutton.state = 0x100; + + /* send ButtonRelease event to youngest child */ + if (XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) + printf("XSendEvent Failed\n"); + XFlush(display); + +} diff --git a/mplayer-ctlable b/mplayer-ctlable new file mode 100755 index 0000000..27059fb --- /dev/null +++ b/mplayer-ctlable @@ -0,0 +1,24 @@ +#!/usr/bin/perl -w + +my $clientfifoname = "$ENV{HOME}/bin/mplayerctlclientfifo"; + +open(MPLAYERFIFO, "| mplayer " .join ' ', map {"'$_'"} @ARGV) + or die "couldn't run mplayer: $!"; + +my $cmd; + +LOOP: +while(1) { + $cmd = `cat $clientfifoname`; + chomp $cmd; + SW: { + # TODO: Cursor-Controlstrings terminalabhaengig -- curses benutzen (macht mplayer auch)? + $cmd eq "fwd" and do { print MPLAYERFIFO "\x1b\x5b\x43"; last; }; + $cmd eq "rew" and do { print MPLAYERFIFO "\x1b\x5b\x44"; last; }; + $cmd eq "playpause" and do { print MPLAYERFIFO " "; last; }; + $cmd eq "fullscreen" and do { print MPLAYERFIFO "f"; last; }; + $cmd eq "quit" and do { print MPLAYERFIFO "q"; last LOOP; }; + } +} + +# MPLAYERFIFO flushen? diff --git a/mplayer-dump-latest b/mplayer-dump-latest new file mode 100755 index 0000000..3e224df --- /dev/null +++ b/mplayer-dump-latest @@ -0,0 +1,3 @@ +#!/bin/sh + +find /tmp/ -name '*asx' -cmin -30 | tail -1 | xargs cat | grepre '"(mms:.*?)"' | xargs mplayer -dumpstream -dumpfile "`date +%F-%R`.asf" diff --git a/mplayerctl b/mplayerctl new file mode 100755 index 0000000..8419afd --- /dev/null +++ b/mplayerctl @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "$1" >~/bin/mplayerctlclientfifo diff --git a/mygdb b/mygdb new file mode 100755 index 0000000..f31383d --- /dev/null +++ b/mygdb @@ -0,0 +1,3 @@ +#!/bin/sh + +gdb -d /usr/local/src/deb/source/gtk+2.0-2.2.1/build-tree/gtk+-2.2.1/gtk "$@" diff --git a/myhexdump b/myhexdump new file mode 100755 index 0000000..df46b49 --- /dev/null +++ b/myhexdump @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ $# != 0 ] && ( [ $1 = '-h' ] || [ $1 = '--help' ] ); then + echo "Aufruf: myhexdump [-no] [file ...] +file oder stdin als hexdump ausgeben (16 Bytes pro Zeile, ganz links Offset, +dann Hexbytes, dann ASCII). +Falls -no angegeben wird, Offset weglassen." + exit +fi + +SHOW_OFFSET=yes +if [ "$1" = "-no" ]; then + SHOW_OFFSET= + shift +fi + +hexdump -v ${SHOW_OFFSET:+-e '"%07.7_ax "'} -e '16/1 "%02x "' -e '" "' -e '16/1 "%_p"' -e '"\n"' $* + diff --git a/myhomedesktop/emacs_or_fallback.sh b/myhomedesktop/emacs_or_fallback.sh new file mode 100755 index 0000000..bc8199e --- /dev/null +++ b/myhomedesktop/emacs_or_fallback.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if gnuclient -batch -eval 'nil' >/dev/null 2>&1; then + exec gnuclient "$@"; +else + exec jed "$@"; +fi + diff --git a/myhomedesktop/setup-6to4 b/myhomedesktop/setup-6to4 new file mode 100755 index 0000000..aeb5c07 --- /dev/null +++ b/myhomedesktop/setup-6to4 @@ -0,0 +1,6 @@ +#!/bin/sh + +ip -6 addr add "`ssh tick ip6to4 ppp0`::2:2" dev eth0 +ip -6 route add "`ssh tick ip6to4 ppp0`::2:0/112" dev eth0 + +ip -6 route add 2000::/3 via "`ssh tick ip6to4 ppp0`::2:1" dev eth0 diff --git a/myhomedesktop/shutdown-6to4 b/myhomedesktop/shutdown-6to4 new file mode 100755 index 0000000..dd61f9d --- /dev/null +++ b/myhomedesktop/shutdown-6to4 @@ -0,0 +1,10 @@ +#!/bin/sh + +ifaceaddr eth0 | egrep '^2002' | \ + while read addr; do + ip addr del "$addr" dev eth0; + done +route -6 | grepre '^(2002.*?) ' | xargs -i ip -6 route del {} +while route -6 | grep -q '^2000::/3'; do + ip -6 route del 2000::/3 +done diff --git a/myhomedesktop/ssh-forward-mldonkey b/myhomedesktop/ssh-forward-mldonkey new file mode 100755 index 0000000..ff33216 --- /dev/null +++ b/myhomedesktop/ssh-forward-mldonkey @@ -0,0 +1,6 @@ +#!/bin/sh + +ssh -2 -N -L 4000:localhost:4000 tick & # telnet +ssh -2 -N -L 4080:localhost:4080 tick & # web +ssh -2 -N -L 4001:localhost:4001 tick & # gui +ssh -2 -N -L 1213:localhost:1213 tick & # GiFT (?) diff --git a/myhomehost/isstsshvpn-routes b/myhomehost/isstsshvpn-routes new file mode 100755 index 0000000..57c5f4e --- /dev/null +++ b/myhomehost/isstsshvpn-routes @@ -0,0 +1,14 @@ +#!/bin/sh + +dev="`ifconfig | grepre '^(ppp\d+)' | tail -1`" + +if [ "$dev" = "ppp0" -o -z "$dev" ]; then + echo "$0: no VPN interface running" + exit 1 +fi + +route add -host 153.97.73.127 dev ppp0 +route add -net 192.102.0.0 netmask 255.255.0.0 gw 192.168.3.2 dev $dev +route add -net 153.97.0.0 netmask 255.255.0.0 gw 192.168.3.2 dev $dev +route add -host 129.26.8.213 gw 192.168.3.2 dev $dev # news.fhg.de +route add -host ftp.isst.fhg.de dev ppp0 # ssh-Loginserver im ISST (direkt von außen erreichbar => schneller) diff --git a/myhomehost/kill-vpn-continuously b/myhomehost/kill-vpn-continuously new file mode 100755 index 0000000..7c681f5 --- /dev/null +++ b/myhomehost/kill-vpn-continuously @@ -0,0 +1,21 @@ +#!/bin/sh + +log_msg() { + date "+%c: $*" >&2 +} + +get_ip() { + ifconfig ppp0 | grepre 'inet addr:(.*?)\s' +} + +oldip="`get_ip`" +while true; do + ip="`get_ip`" + if ! [ "$ip" = "$oldip" ]; then + log_msg "DSL IP change detected: $oldip -> $ip. Killing VPN"; + kill-vpn.sh + fi + oldip="$ip" + + sleep 60 +done diff --git a/myhomehost/setup-6to4 b/myhomehost/setup-6to4 new file mode 100755 index 0000000..a4cb2b3 --- /dev/null +++ b/myhomehost/setup-6to4 @@ -0,0 +1,33 @@ +#!/bin/sh +# pre: - ppp0 up and connected to the IPv4 internet +# +# - lanif up and connected to the local LAN +# +# +# post: - tun6to4 up and connected to the IPv6 internet, with IPv6 +# address = 2002:::1:2 +# +# - local LAN accessible via IPv6 over lanif, lanif's IPv6 address +# 2002:::2:1, local LAN's network +# address 2002:::2:0/112. Local +# host forwards IPv6 between LAN and IPv6 internet + +set -e + +execlogged() { + echo "executing: $@" && eval "$@" + +} + +echo "setting up IPv6..." + +# set up ppp0 +execlogged ip tunnel add tun6to4 mode sit remote any local "`ifaceaddr ppp0`" +execlogged ip link set dev tun6to4 up +execlogged ip -6 addr add "`ip6to4 ppp0`::1:2" dev tun6to4 +execlogged ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1 + +# set up LAN +execlogged ip -6 addr add "`ip6to4 ppp0`::2:1" dev lanif +execlogged ip -6 route add "`ip6to4 ppp0`::2:0/112" dev lanif +execlogged 'echo 1 >/proc/sys/net/ipv6/conf/all/forwarding' diff --git a/myhomehost/shutdown-6to4 b/myhomehost/shutdown-6to4 new file mode 100755 index 0000000..3f09ebd --- /dev/null +++ b/myhomehost/shutdown-6to4 @@ -0,0 +1,15 @@ +#!/bin/sh +# post: no global IPv6 addresses on either lanif or tun6to4 + +addr="`ifaceaddr lanif | egrep '^2002' | head -1`" +while [ -n "$addr" ]; do + ip addr del "$addr" dev lanif + addr="`ifaceaddr lanif | egrep '^2002' | head -1`" +done + +route="`route -6 | awk '/^2002/ {print $1}' | head -1`" +while [ -n "$route" ]; do + ip -6 route del "$route" + route="`route -6 | awk '/^2002/ {print $1}' | head -1`" +done +ip tunnel del tun6to4 diff --git a/myhomehost/sofdsshvpn-routes b/myhomehost/sofdsshvpn-routes new file mode 100755 index 0000000..05d2484 --- /dev/null +++ b/myhomehost/sofdsshvpn-routes @@ -0,0 +1,17 @@ +#!/bin/sh + +dev="`ifconfig | grepre '^(ppp\d+)' | tail -1`" + +if [ "$dev" = "ppp0" -o -z "$dev" ]; then + echo "$0: no VPN interface running" + exit 1 +fi + +#route add -host 153.97.73.127 dev ppp0 +#route add -net 192.102.0.0 netmask 255.255.0.0 gw 192.168.3.2 dev $dev +#route add -net 153.97.0.0 netmask 255.255.0.0 gw 192.168.3.2 dev $dev +#route add -host 129.26.8.213 gw 192.168.3.2 dev $dev # news.fhg.de +#route add -host ftp.isst.fhg.de dev ppp0 # ssh-Loginserver im ISST (direkt von außen erreichbar => schneller) + +route add -net 192.168.0.0/24 dev $dev # Route ins sofd-Intranet + diff --git a/myhomehost/wlan-restartap b/myhomehost/wlan-restartap new file mode 100755 index 0000000..436bd5f --- /dev/null +++ b/myhomehost/wlan-restartap @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +/etc/init.d/hostapd stop +ifconfig ath0 down +wlanconfig ath0 destroy + +sleep 5 + +wlanconfig ath0 create wlandev wifi0 wlanmode ap +ifconfig ath0 up +brctl addif lanif ath0 +sleep 2 +/etc/init.d/hostapd start + +# TODO: wenn im Syslog was von "lanif: port 2(ath0) entering disabled state" steht, hilft +# es wohl, hostapd nochmal zu stoppen und zu starten?? + diff --git a/myhomehost/wlan-scan b/myhomehost/wlan-scan new file mode 100755 index 0000000..eeb2613 --- /dev/null +++ b/myhomehost/wlan-scan @@ -0,0 +1,3 @@ +#!/bin/sh + +iwlist ath0 scan diff --git a/myhomehost/wlan-switch-to-ap b/myhomehost/wlan-switch-to-ap new file mode 100755 index 0000000..cbf5e35 --- /dev/null +++ b/myhomehost/wlan-switch-to-ap @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +ifconfig ath0 down +wlanconfig ath0 destroy +wlanconfig ath0 create wlandev wifi0 wlanmode ap +ifconfig ath0 up +brctl addif lanif ath0 +/etc/init.d/hostapd start diff --git a/myhomehost/wlan-switch-to-sta b/myhomehost/wlan-switch-to-sta new file mode 100755 index 0000000..0ae8bca --- /dev/null +++ b/myhomehost/wlan-switch-to-sta @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +/etc/init.d/hostapd stop +ifconfig ath0 down +wlanconfig ath0 destroy +wlanconfig ath0 create wlandev wifi0 wlanmode sta +ifconfig ath0 up diff --git a/myissthost/rmspammail b/myissthost/rmspammail new file mode 100755 index 0000000..1316c6f --- /dev/null +++ b/myissthost/rmspammail @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +my ($host, $user, $password) = + (`cat ~/.authinfo` =~ /machine\s+(.*?)\s+login\s+(.*?)\s+password\s+(.*)/) + or die "unable to read ~/.authinfo: $! $@"; + +use Net::IMAP::Simple; + +my $server = new Net::IMAP::Simple( $host ) or die "error: $@"; +# $server->Debug(1); +$server->login( $user, $password ) or die "error: $@"; + +for my $folder ('INBOX', 'INBOX.spam') { + my $nmsgs = $server->select($folder); + for my $i (1..$nmsgs) { + if (grep {/^X-Spam-Status: Yes/ or /^X-Virus: YES/} @{$server->get($i)}) { + print "deleting: $folder/$i\n"; + $server->delete($i); + } + } +} diff --git a/myissthost/run-isstsshvpn b/myissthost/run-isstsshvpn new file mode 100755 index 0000000..f9a1cd3 --- /dev/null +++ b/myissthost/run-isstsshvpn @@ -0,0 +1,102 @@ +#!/usr/bin/perl -w + +sub log_msg($) { + my $text = shift; + print STDERR localtime() . ": ${text}\n"; +} + + +sub get_ip_and_age { + my @remote_hosts = qw{basta.cs.tu-berlin.de + butterfly.cs.tu-berlin.de + conde.cs.tu-berlin.de}; + my $remote_ipaddrfile = '/home/k/klischat/ipaddress.txt'; + + local $/=undef; + foreach my $host (@remote_hosts) { + # open(SSH, qq{ssh $host 'printf "ip: "; cat $remote_ipaddrfile; stat $remote_ipaddrfile' |}); + #open(SSH, qq{ssh $host 'printf ip:; cat $remote_ipaddrfile; stat $remote_ipaddrfile' |}); + open(SSH, qq{su - olaf -c "ssh $host 'printf ip:; cat $remote_ipaddrfile; stat $remote_ipaddrfile'" |}); + + my $ssh = ; + close SSH; + + my ($ip, $age) = $ssh =~ m!ip:(.*?)\n.*?Modify:.*?\((.*?)\)!si; + if ($ip) { + my ($days,$hrs,$mins,$secs) = $age=~/(.*?)\.(.*?):(.*?):(.*)/; + $age = $secs+$mins*60+$hrs*3600+$days*3600*24; + return ($ip,$age); + } + } + die "unparseable ip/age"; +} + + + +{ + my $running = 0; + + sub setup_tunnel($) { + return if $running; + + my $remoteip = shift; + log_msg "setting up tunnel to $remoteip..."; + + system("/usr/local/sbin/run-ppp-over-ssh $remoteip start") and + die "couldn't exec run-ppp-over-ssh $remoteip: $!"; + system("ssh $remoteip /usr/local/sbin/myhomehost/isstsshvpn-routes"); + + log_msg "PPP connection established, setting up routes..."; + system < 650) { + log_msg "last remote IP change $age secs ago; assuming remote side is down"; + teardown_tunnel($ip); + $ip = ""; + } + elsif ($oldip ne $ip) { + log_msg "remote IP change detected: $oldip -> $ip"; + teardown_tunnel($oldip); + log_msg "waiting 120 sec for remote side to kill its VPN interface"; + sleep 120; + if ($interrupted) { + log_msg "interrupted."; + exit(0); + } + setup_tunnel($ip); + } + + sleep 610; + if ($interrupted) { + log_msg "interrupted."; + teardown_tunnel($oldip); + exit(0); + } + $oldip = $ip; + ($ip,$age) = get_ip_and_age(); +} diff --git a/myissthost/run-isstsshvpn-continuously b/myissthost/run-isstsshvpn-continuously new file mode 100755 index 0000000..46463ae --- /dev/null +++ b/myissthost/run-isstsshvpn-continuously @@ -0,0 +1,9 @@ +#!/bin/sh +# vorher (als root): +# eval `ssh-agent -s` +# ssh-add ~/.ssh/id_dsa + +while true; do + /usr/local/sbin/myissthost/run-isstsshvpn; + sleep 620; +done 2>&1 | tee -a /var/log/run-isstsshvpn.log diff --git a/myissthost/setup-6to4 b/myissthost/setup-6to4 new file mode 100755 index 0000000..5da785c --- /dev/null +++ b/myissthost/setup-6to4 @@ -0,0 +1,20 @@ +#!/bin/sh +# pre: - eth0 up and connected to the IPv4 internet +# +# post: - tun6to4 up and connected to the IPv6 internet, with IPv6 +# address = 2002:::1:2 + +set -e + +execlogged() { + echo "executing: $@" && eval "$@" + +} + +echo "IPv6 aktivieren..." + +# set up eth0 +execlogged ip tunnel add tun6to4 mode sit remote any local "`ifaceaddr eth0`" +execlogged ip link set dev tun6to4 up +execlogged ip -6 addr add "`ip6to4 eth0`::1:2" dev tun6to4 +execlogged ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1 diff --git a/myissthost/shutdown-6to4 b/myissthost/shutdown-6to4 new file mode 100755 index 0000000..4ab64e2 --- /dev/null +++ b/myissthost/shutdown-6to4 @@ -0,0 +1,4 @@ +#!/bin/sh +# post: no global IPv6 addresses on tun6to4 + +ip tunnel del tun6to4 diff --git a/myissthost/ssh-forward-mldonkey b/myissthost/ssh-forward-mldonkey new file mode 100755 index 0000000..18d61b4 --- /dev/null +++ b/myissthost/ssh-forward-mldonkey @@ -0,0 +1,6 @@ +#!/bin/sh + +ssh -2 -N -L 4000:`showhomeip`:4000 tick & # telnet +ssh -2 -N -L 4080:`showhomeip`:4080 tick & # web +ssh -2 -N -L 4001:`showhomeip`:4001 tick & # gui +ssh -2 -N -L 1213:`showhomeip`:1213 tick & # GiFT (?) diff --git a/mylaptop/wlan-reinit b/mylaptop/wlan-reinit new file mode 100755 index 0000000..8027f62 --- /dev/null +++ b/mylaptop/wlan-reinit @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +modprobe -r iwlagn +sleep 2 +modprobe iwlagn diff --git a/mysofdhost/run-sofdsshvpn b/mysofdhost/run-sofdsshvpn new file mode 100755 index 0000000..e95f8cc --- /dev/null +++ b/mysofdhost/run-sofdsshvpn @@ -0,0 +1,105 @@ +#!/usr/bin/perl -w + +sub log_msg($) { + my $text = shift; + print STDERR localtime() . ": ${text}\n"; +} + + +sub get_ip_and_age { + my @remote_hosts = qw{conde.cs.tu-berlin.de + 130.149.17.40 + basta.cs.tu-berlin.de + 130.149.17.1}; + my $remote_ipaddrfile = '/home/k/klischat/ipaddress.txt'; + + local $/=undef; + foreach my $host (@remote_hosts) { + # open(SSH, qq{ssh $host 'printf "ip: "; cat $remote_ipaddrfile; stat $remote_ipaddrfile' |}); + #open(SSH, qq{ssh $host 'printf ip:; cat $remote_ipaddrfile; stat $remote_ipaddrfile' |}); + open(SSH, qq{su - olaf -c "ssh -o PasswordAuthentication=no -l klischat $host 'printf ip:; cat $remote_ipaddrfile; stat $remote_ipaddrfile'" |}); + + my $ssh = ; + close SSH; + + my ($ip, $age) = $ssh =~ m!ip:(.*?)\n.*?Modify:.*?\((.*?)\)!si; + if ($ip) { + my ($days,$hrs,$mins,$secs) = $age=~/(.*?)\.(.*?):(.*?):(.*)/; + $age = $secs+$mins*60+$hrs*3600+$days*3600*24; + return ($ip,$age); + } + } + die "unparseable ip/age"; +} + + + +{ + my $running = 0; + + sub setup_tunnel($) { + return if $running; + + my $remoteip = shift; + log_msg "setting up tunnel to $remoteip..."; + + system("/usr/local/sbin/run-ppp-over-ssh $remoteip -l 192.168.17.2 -r 192.168.17.1 start") and + die "couldn't exec run-ppp-over-ssh $remoteip: $!"; + system("ssh $remoteip /usr/local/sbin/myhomehost/sofdsshvpn-routes"); + + log_msg "PPP connection established, setting up routes..."; + system < 650) { + log_msg "last remote IP change $age secs ago; assuming remote side is down"; + teardown_tunnel($ip); + $ip = ""; + } + elsif ($oldip ne $ip) { + log_msg "remote IP change detected: $oldip -> $ip"; + teardown_tunnel($oldip); + log_msg "waiting 120 sec for remote side to kill its VPN interface"; + sleep 120; + if ($interrupted) { + log_msg "interrupted."; + exit(0); + } + setup_tunnel($ip); + } + + sleep 610; + if ($interrupted) { + log_msg "interrupted."; + teardown_tunnel($oldip); + exit(0); + } + $oldip = $ip; + ($ip,$age) = get_ip_and_age(); +} diff --git a/mysofdhost/run-sofdsshvpn-continuously b/mysofdhost/run-sofdsshvpn-continuously new file mode 100755 index 0000000..07c56a0 --- /dev/null +++ b/mysofdhost/run-sofdsshvpn-continuously @@ -0,0 +1,15 @@ +#!/bin/sh +# vorher (als root): +# eval `ssh-agent -s` +# ssh-add ~/.ssh/id_dsa + +while true; do + if [ -f /var/run/ppp0.pid ]; then + echo "ppp0 still up (PID `cat /var/run/ppp0.pid`). Killing it." + kill `cat /var/run/ppp0.pid`; + fi + echo "starting run-sofdsshvpn..." + /usr/local/sbin/mysofdhost/run-sofdsshvpn; + echo "run-sofdsshvpn has terminated unexpectedly. Sleeping 620 sec..." + sleep 620; +done 2>&1 | tee -a /var/log/run-sofdsshvpn.log diff --git a/mysofdhost/ssh-forward-mldonkey b/mysofdhost/ssh-forward-mldonkey new file mode 100755 index 0000000..6447cda --- /dev/null +++ b/mysofdhost/ssh-forward-mldonkey @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +tick=`showhomeip` + +ssh -2 -N -L 4000:localhost:4000 $tick & # telnet +ssh -2 -N -L 4080:localhost:4080 $tick & # web +ssh -2 -N -L 4001:localhost:4001 $tick & # gui +ssh -2 -N -L 1213:localhost:1213 $tick & # GiFT (?) diff --git a/palm-fetchheise b/palm-fetchheise new file mode 100755 index 0000000..18aa5c7 --- /dev/null +++ b/palm-fetchheise @@ -0,0 +1,4 @@ +#!/bin/sh + +plucker-build -M2 --noimages -f Heisenews http://www.heise.de/newsticker/pda/data/paket2.html && +coldsync -mr ~/.plucker/Heisenews.pdb diff --git a/perl-e-perline b/perl-e-perline new file mode 100755 index 0000000..23817bd --- /dev/null +++ b/perl-e-perline @@ -0,0 +1,3 @@ +#!/bin/sh + +perl -ne "$1" diff --git a/perl-e-perline-inplace b/perl-e-perline-inplace new file mode 100755 index 0000000..6b05655 --- /dev/null +++ b/perl-e-perline-inplace @@ -0,0 +1,5 @@ +#!/bin/sh + +expr="$1"; shift + +perl -pi -e "$expr" "$@" diff --git a/pidof b/pidof new file mode 100755 index 0000000..8b82691 --- /dev/null +++ b/pidof @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w +# +# author Olaf Klischat + +use strict; + +sub usage() { + + print STDERR < + +print pid of process +EOF + +} + + +if ($#ARGV == -1) { + usage(); exit -1; +} + +use Proc::ProcessTable; +my @ptbl = @{(new Proc::ProcessTable)->table}; + + +my $name = $ARGV[0]; +for my $p (@ptbl) { + if ($p->fname eq $name) { + print $p->pid . "\n"; + exit 0; + } +} + +exit -1; diff --git a/ppp-over-ssh/debug1/logs.txt b/ppp-over-ssh/debug1/logs.txt new file mode 100644 index 0000000..477ec9d --- /dev/null +++ b/ppp-over-ssh/debug1/logs.txt @@ -0,0 +1,49 @@ +tick +---- + +Mar 19 14:10:43 tick pppd[21324]: No response to 3 echo-requests +Mar 19 14:10:43 tick pppd[21324]: Serial link appears to be disconnected. +Mar 19 14:10:44 tick pppd[21324]: Modem hangup +Mar 19 14:10:44 tick pppd[21324]: Connection terminated. +Mar 19 14:10:44 tick pppd[21324]: Connect time 304.5 minutes. +Mar 19 14:10:44 tick pppd[21324]: Sent 201587092 bytes, received 265725702 bytes. +Mar 19 14:10:44 tick pppd[21324]: Exit. +Mar 19 14:10:49 tick pppd[23418]: pppd 2.4.2 started by root, uid 0 +Mar 19 14:10:49 tick pppd[23418]: Using interface ppp0 +Mar 19 14:10:49 tick pppd[23418]: Connect: ppp0 <--> /dev/ttyp0 +Mar 19 14:10:50 tick pppd[23418]: CHAP authentication succeeded +Mar 19 14:10:50 tick pppd[23418]: local IP address 213.23.148.240 +Mar 19 14:10:50 tick pppd[23418]: remote IP address 145.253.4.144 +Mar 19 14:10:50 tick pppd[23418]: primary DNS address 195.50.140.252 +Mar 19 14:10:50 tick pppd[23418]: secondary DNS address 195.50.140.250 + + + +Sat 19 Mar 2005 02:11:30 PM CET: DSL IP change detected: 82.82.88.26 -> 213.23.148.240. Killing VPN +Sat 19 Mar 2005 02:11:31 PM CET: waiting 800 sec. for remote side to re-establish the VPN... +Sat 19 Mar 2005 02:24:51 PM CET: assuming VPN has been re-established. Setting up routes... +/root/bin/routes.sh: no VPN interface running + + + +swangoose (Uhrzeit um +48s angepasst -- siehe time-difference.txt) +------------------------------------------------------------------- + +Sat Mar 19 14:25:36 2005: remote IP change detected: 82.82.88.26 -> 213.23.148.240 +Sat Mar 19 14:25:36 2005: tearing down tunnel to 82.82.88.26... +Stopping vpn to 82.82.88.26: +disconnected. +Sat Mar 19 14:25:36 2005: DONE tearing down tunnel to 82.82.88.26. +Sat Mar 19 14:25:36 2005: waiting 120 sec for remote side to kill its VPN interface +Killed by signal 15. +Sat Mar 19 14:27:36 2005: setting up tunnel to 213.23.148.240... +Starting vpn to 213.23.148.240: +Using interface ppp0 +Connect: ppp0 <--> /dev/pts/3 +Deflate (15) compression enabled +local IP address 192.168.3.2 +remote IP address 192.168.3.1 +connected. +Sat Mar 19 14:27:38 2005: PPP connection established, setting up routes... +SIOCDELRT: No such process +Sat Mar 19 14:27:38 2005: DONE setting up tunnel to 213.23.148.240. diff --git a/ppp-over-ssh/debug1/problem.txt b/ppp-over-ssh/debug1/problem.txt new file mode 100644 index 0000000..8b8a227 --- /dev/null +++ b/ppp-over-ssh/debug1/problem.txt @@ -0,0 +1,2 @@ +VPN wurde korrekt neu aufgebaut, aber Routen auf tick wurden nicht neu +gesetzt. diff --git a/ppp-over-ssh/debug1/time-difference.txt b/ppp-over-ssh/debug1/time-difference.txt new file mode 100644 index 0000000..e2ee77a --- /dev/null +++ b/ppp-over-ssh/debug1/time-difference.txt @@ -0,0 +1,5 @@ +[root@tick ~]# date +Sat Mar 19 16:44:43 CET 2005 + +swangoose:~# date +Sat Mar 19 16:43:55 CET 2005 diff --git a/ppp-over-ssh/misc.txt b/ppp-over-ssh/misc.txt new file mode 100644 index 0000000..55c10ac --- /dev/null +++ b/ppp-over-ssh/misc.txt @@ -0,0 +1,61 @@ +Def.: t_newIP: Zeitpunkt des Erhalts der neuen IP + + (t0...t1) zeitintervall von t0 bis t1 + + int + t (mit "int" - Z.Intervall, "t"-Zeit): Zeitintervall + (Start(int)+t...Stop(int)+t) + +auf tick: + +(Ziel: Nach Erhalt neuer IP muss Verbindung gekillt werden, bevor +swangoose versucht, das VPN neu aufzubauen) + + +while true; do + + falls neue IP: + kill-vpn + sleep 1400 + routen zum ISST neu aufbauen + end + + sleep 60 + +done + +& + +while true; do + + publish-ip + + sleep 600 + +done + + + +=> vpn gekillt (t_newIP...t_newIP+60s) + Laufzeit(kill-vpn) + + Neuaufbau der Routen (t_newIP+1400s...t_newIP+1460s) + Laufzeit(kill-vpn) + + + +auf swangoose: + + +while true; do + + get_ip # die oben gepublishte + + wenn neu: + sleep 120 # kill-vpn auf tick abwarten + vpn neu aufbauen + end + + sleep 610 + +done + + +=> vpn neu aufgebaut (t_newIP+120s...t_newIP+1330s) + Laufzeit(vpn neu aufbauen) diff --git a/print-hierarchical-website b/print-hierarchical-website new file mode 100755 index 0000000..8d14d4d --- /dev/null +++ b/print-hierarchical-website @@ -0,0 +1,27 @@ +#!/bin/sh +# print web-based multi-page documents having a single index/contents page +# linking all existing sub-pages via relative links +# +# usage: print-hierarchical-website +# +# printing will be done using lpr [-P$PRINTER] in PostScript +# +# prerequisites: Perl, wget, html2ps +# +# TODO: funktion "printWebsite $site", darin Test-Modus kapseln +# (schwierig wg. xargs unten => evtl. alles in Perl schreiben) + +indexpage="$1" + +[ -n "$indexpage" ] || { echo "usage: $0 " >&1; exit 1; } + +base="`echo $indexpage | grepc '^(.*)/'`" + +LPR="lpr" +[ -n "$PRINTER" ] && { LPR="$LPR -P$PRINTER"; } + +html2ps $indexpage | $LPR + +wget -O- "$indexpage" | \ + perl -ne 'for (m!href="(.*?)[#"]!g) { print $_, "\n" unless($found{$_}); $found{$_}=1; }' | \ + xargs -i /bin/sh -c "html2ps $base/{} | $LPR" diff --git a/psfindbywd b/psfindbywd new file mode 100755 index 0000000..751939f --- /dev/null +++ b/psfindbywd @@ -0,0 +1,3 @@ +#!/bin/sh + +ls -l /proc/*/cwd | grep "$1" | grepre '/proc/(.*?)/' | xargs -i sh -c 'echo -n "{} "; cat /proc/{}/cmdline; echo' diff --git a/pslibs.pl b/pslibs.pl new file mode 100755 index 0000000..3883268 --- /dev/null +++ b/pslibs.pl @@ -0,0 +1,88 @@ +#!/usr/bin/perl -w +# +# author Olaf Klischat + +use strict; + +sub usage() { + + print STDERR < + +print libraries/devices process currently uses + +If "-n" is supplied, denotes the process name instead of the pid +If "-f" is supplied, process all child processes of the specified process +as well. +EOF + +} + + +use Getopt::Std; + +my %opts; +getopts('fn', \%opts); + +if ($#ARGV == -1) { + usage(); exit -1; +} + +my @ptbl; + +sub initptbl { + if (!@ptbl) { + use Proc::ProcessTable; + @ptbl = @{(new Proc::ProcessTable)->table}; + } +} + +sub pidof($) { + initptbl(); + my $name = shift; + for my $p (@ptbl) { + if ($p->fname =~ $name) { + return $p->pid; + } + } + return 0; +} + + +sub getchildren($) { + initptbl(); + my $pid = shift; + my @directChildren = grep {$_->ppid == $pid} @ptbl; + return ($pid, map { getchildren($_->pid) } @directChildren); +} + +my $name = $ARGV[0]; +my $ppid; + +if ($opts{'n'}) { + $ppid = pidof($name) || die "no such process: $name"; +} else { + $ppid = $name; +} + +my @pids = ($ppid); + +if ($opts{'f'}) { + @pids = getchildren($ppid); +} + +my %libs = (); # map => 1 (libname as key for avoiding duplicates) + +for my $pid (@pids) { + open(MAPS,") { + if (m!\s(/.*?)\s!) { + $libs{$1} = 1; + } + } + close MAPS; +} + +foreach my $lib (sort keys %libs) { + print $lib . "\n"; +} diff --git a/quotelines b/quotelines new file mode 100755 index 0000000..a5754d3 --- /dev/null +++ b/quotelines @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use Getopt::Std; + +my %opts; +getopts('n', \%opts); + +my $sep = $opts{n}?' ':"\n"; + +while (<>) { + chomp; + s/([\s"'()|&])/\\$1/g; + print "$_$sep"; +} diff --git a/rfcidx.pl b/rfcidx.pl new file mode 100755 index 0000000..593b053 --- /dev/null +++ b/rfcidx.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +use Getopt::Std; + +my %opts; + +getopts('s',\%opts); + +my @fileNames = $opts{'s'}? sort @ARGV : @ARGV; + +FILE: for my $fn (@fileNames) { + open(F,"<$fn") or { print STDERR "couldn't read $f: $!"; next FILE; }; + + # TODO: sybolic names QU: how to do it best (no strings and such)? + my $state = 1; + while(1) { + my $line = or { print STDERR "parse error in $f"; close F; next FILE; }; + SW: { + if ($state == 1) { + if ($line !~ /^\s*$/) { $state = 2; last SW; } + last SW; + } + if ($state == 2) { + if ($line =~ /^\s*$/) { $state = 3; last SW; } + last SW; + } + if ($state == 3) { + if ($line =~ /^\s*(\S+)\s*$/) { printf "%-12s %s\n", "${fn}:", $1; close F; next FILE; } + last SW; + } + } + } +} diff --git a/rminst b/rminst new file mode 100755 index 0000000..5ded7ce --- /dev/null +++ b/rminst @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w +##### see TODO below before use! + +# In: +# list of files on stdin + +# Out: +# listed files have been removed +# EOF + +use strict; + +# remove a "dirempty" directory (i.e. one +# that is either empty or contains only +# "dirempty" directories) +# +# return 0 if directory wasn't dirempty, 1 else. +# In the former case, some dirempty subdirs of +# the given dir may still have been removed +sub rmdiremptydir($); +sub rmdiremptydir($) { + my $dir = shift; + return 0 unless -d $dir; + my $D; + opendir($D,$dir); + while (my $ent = readdir($D)) { + next if ($ent eq '.' or $ent eq '..'); + my $subdir = "$dir/$ent"; + return 0 unless -d $subdir; + return 0 unless rmdiremptydir($subdir); + } + rmdir $dir; + 1; +} + + + +my @filenames = ; + +for my $filename (@filenames) { + chomp $filename; + unlink $filename if -f $filename; +} + +# TODO: this will also delete "dirempty" directories +# that were sub-directories of directories given +# on stdin, but weren't themselves given on stdin +for my $filename (@filenames) { + rmdiremptydir $filename if -d $filename; +} diff --git a/rmnonbookmarks b/rmnonbookmarks new file mode 100644 index 0000000..b132d0f --- /dev/null +++ b/rmnonbookmarks @@ -0,0 +1,20 @@ +#!/bin/sh + +# pre: logged in as wwwoffled, `pwd`==/var/spool/wwwoffle/http, +# Galeon bookarks in /tmp/bookmarks.xbel, /tmp/bookmarks.ctd.xbel +# +# post: directories containing wwwoffle caches for all domains *not* +# present in any bookmarked URLs removed + +echo "TODO: *read* comments, comment out exit statement, use program as documented" +exit 1; + +export PATH=/home/olaf/bin:$PATH + +bmdomains="`cat /tmp/bookmarks.xbel /tmp/bookmarks.ctd.xbel | grepre 'href="http://(.*?)[/"]' | sort | uniq`" + +#echo $bmdomains + +for f in *; do + if ! echo $bmdomains | grep -q "$f"; then rm -rf "$f"; fi +done diff --git a/rspeedway b/rspeedway new file mode 100755 index 0000000..7c74f0f --- /dev/null +++ b/rspeedway @@ -0,0 +1,3 @@ +#!/bin/sh + +exec x64 -joydev2 0 -joydev1 1 /home/olaf/c64/rspeedway.vsf diff --git a/ruby-e-perline b/ruby-e-perline new file mode 100755 index 0000000..8bf6111 --- /dev/null +++ b/ruby-e-perline @@ -0,0 +1,3 @@ +#!/bin/sh + +ruby -ne "$1" diff --git a/run-if-not-running.sh b/run-if-not-running.sh new file mode 100755 index 0000000..ec6dcfe --- /dev/null +++ b/run-if-not-running.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +PRG=$1 +shift + +CMDLINE="$@" + +if ps -u $UID -eo args | egrep -q "^$PRG"; then + exit 0; +fi + +exec $CMDLINE diff --git a/run-ppp-over-ssh b/run-ppp-over-ssh new file mode 100755 index 0000000..fbc6c76 --- /dev/null +++ b/run-ppp-over-ssh @@ -0,0 +1,101 @@ +#!/bin/sh + +# usage: $0 remoteip + +# this thing only works from swangoose to tick for now... + +# run-ppp-over-ssh +# +# This script initiates a ppp-ssh vpn connection. +# see the VPN PPP-SSH HOWTO on http://www.linuxdoc.org for more information. +# +# revision history: +# 1.6 11-Nov-1996 miquels@cistron.nl +# 1.7 20-Dec-1999 bart@jukie.net +# 2.0 16-May-2001 bronson@trestle.com + + + +# The host name or IP address of the SSH server that we are +# sending the connection request to: +SERVER_HOSTNAME="$1"; shift + +# The username on the VPN server that will run the tunnel. +# For security reasons, this should NOT be root. (Any user +# that can use PPP can intitiate the connection on the client) +SERVER_USERNAME=root + +# The VPN network interface on the server should use this address: +SERVER_IFIPADDR=192.168.3.1 + +# ...and on the client, this address: +CLIENT_IFIPADDR=192.168.3.2 + +while getopts 'l:r:' OPTNAME; do +case "$OPTNAME" in + "l") + CLIENT_IFIPADDR="$OPTARG" ;; + "r") + SERVER_IFIPADDR="$OPTARG" ;; +esac +done + +shift $(($OPTIND - 1)) + +# This tells ssh to use unprivileged high ports, even though it's +# running as root. This way, you don't have to punch custom holes +# through your firewall. +LOCAL_SSH_OPTS="-2 -P" + + +# +# The rest of this file should not need to be changed. +# + + + +PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11/: + +# +# required commands... +# + +PPPD=/usr/sbin/pppd +SSH=/usr/bin/ssh + +if ! test -f $PPPD ; then echo "can't find $PPPD"; exit 3; fi +if ! test -f $SSH ; then echo "can't find $SSH"; exit 4; fi + + +case "$1" in + start) + echo "Starting vpn to $SERVER_HOSTNAME: " + ${PPPD} updetach noauth passive lcp-echo-failure 10 pty "${SSH} ${LOCAL_SSH_OPTS} ${SERVER_HOSTNAME} -l${SERVER_USERNAME} -o Batchmode=yes ${PPPD} nodetach notty noauth lcp-echo-failure 10" ipparam vpn ${CLIENT_IFIPADDR}:${SERVER_IFIPADDR} || exit 1 + echo "connected." + ;; + + stop) + echo "Stopping vpn to $SERVER_HOSTNAME: " + PID=`ps ax | grep "${SSH} ${LOCAL_SSH_OPTS} ${SERVER_HOSTNAME} -l${SERVER_USERNAME} -o" | grep -v ' passive ' | grep -v 'grep ' | awk '{print $1}'` + if [ "${PID}" != "" ]; then + kill $PID + echo "disconnected." + else + echo "Failed to find PID for the connection" + fi + ;; + + config) + echo "SERVER_HOSTNAME=$SERVER_HOSTNAME" + echo "SERVER_USERNAME=$SERVER_USERNAME" + echo "SERVER_IFIPADDR=$SERVER_IFIPADDR" + echo "CLIENT_IFIPADDR=$CLIENT_IFIPADDR" + ;; + + *) + echo "Usage: run-ppp-over-ssh [-l ] [-r ] {start|stop|config}" + exit 1 + ;; +esac + +exit 0 diff --git a/scp-myissthost b/scp-myissthost new file mode 100755 index 0000000..250978a --- /dev/null +++ b/scp-myissthost @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ssh myissthost "$@" diff --git a/sendmails b/sendmails new file mode 100755 index 0000000..6ea4a4a --- /dev/null +++ b/sendmails @@ -0,0 +1,3 @@ +#!/bin/sh + +ssh tick su - mailout sendmails diff --git a/sensible-browser b/sensible-browser new file mode 100755 index 0000000..6b08328 --- /dev/null +++ b/sensible-browser @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# This program is copyright 2002 by Joey Hess , +# and is licensed under the terms of the GNU GPL, version 2 or higher. +# +# Olaf Klischat special casing for Opera +my $url=shift; +if (exists $ENV{BROWSER}) { + foreach (split ':' , $ENV{BROWSER}) { + if (! /%s/) { + $_.=" %s"; + } + # substitute %s with url, and %% to %. + s/%([%s])/$1 eq '%' ? '%' : $url/eg; + $ret=system split ' ', $_; + if ($ret >> 8 == 0) { + exit(0); + } + # on failure, continue to next in list + } + + print STDERR "None of the browsers in \$BROWSER worked!\n"; + exit 1; +} + + +{ + my @ptbl; + + sub initptbl { + if (!@ptbl) { + use Proc::ProcessTable; + @ptbl = @{(new Proc::ProcessTable)->table}; + } + } + + sub is_running($) { + initptbl(); + my $name = shift; + grep {$_->fname eq $name && $_->uid==$<} @ptbl; + } + +} + + +if (exists $ENV{DISPLAY}) { + if (is_running("opera")) { + if ($url) { + exec "opera", "--remote", "openURL($url, new-window)"; + exit 1; + } else { + exec "opera"; + exit 1; + } + } + elsif (-e '/usr/bin/x-www-browser') { + exec '/usr/bin/x-www-browser', $url; + exit 1; + } + elsif (-e '/usr/bin/x-terminal-emulator' && -e '/usr/bin/www-browser') { + exec "x-terminal-emulator", "-e", "/usr/bin/www-browser", $url; + exit 1; + } +} +elsif (-e '/usr/bin/www-browser') { + exec '/usr/bin/www-browser', $url; + exit 1; +} + +print STDERR "Couldn't find a suitable web browser!\n"; +print STDERR "Set the BROWSER environment variable to your desired browser.\n"; +exit 1; diff --git a/settimefromntp b/settimefromntp new file mode 100755 index 0000000..22c04ad --- /dev/null +++ b/settimefromntp @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w + +my @known_timeservers = qw/ + #gips.nich.de + times.zrz.tu-berlin.de + slug.ctv.es + time.kfki.hu + ntp.lth.se + ntp1.arnes.si + ntp2.arnes.si + ntp1.uk.uu.net + /; + + +for my $server (@known_timeservers) { + print "trying $server...\n"; + + my $child = fork(); + die "couldn't fork(): $!" unless defined($child); + + if ($child==0) { + my $cmd = "/usr/bin/rdate -s $server && /sbin/hwclock --systohc"; + exec $cmd + or die "unable to exec(): $cmd: $!\n"; + } + + eval { + local $SIG{ALRM} = sub { die "timed_out" }; + alarm 8; + waitpid($child,0); + alarm 0; + die "exited: $?"; + }; + + if ($@ =~ /timed_out/) { + kill 'SIGTERM', $child; + print "timed out.\n"; + next; + } + + if ($@ =~ /exited: ([^\s]*)/ and $1 != 0) { + print "child exit status $1\n"; + next; + } + + exit 0; +} + +print "gosh, no server worked...\n"; +exit 1; diff --git a/show-encrypted b/show-encrypted new file mode 100755 index 0000000..f517671 --- /dev/null +++ b/show-encrypted @@ -0,0 +1,10 @@ +#!/bin/sh + +encrfile="$1" +if [ -z "$encrfile" ]; then + echo "usage: `basename $0` "; + exit 1; +fi + +echo "decrypting..." >&2 && +gpg --decrypt "$encrfile" diff --git a/show-spurious-listeners b/show-spurious-listeners new file mode 100755 index 0000000..2223970 --- /dev/null +++ b/show-spurious-listeners @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w + +open(NETSTAT, "netstat -tulpen |") or do { print STDERR "couldn't run netstat -tulpen: $!\n" ; exit 2; }; +#open(NETSTAT, ") { + my ($prot,$lip,$lpt,$rip,$rpt,$state,$user,$inode,$pid,$pgname) = + m!^(.*?)\s+.*?\s+.*?\s+(.*?):([^:]*?)\s+(.*?):([^:]*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)/(.*)! or next; + $pgname =~ s/\s*$//; + + next if grep {$_ == $lpt} @safe_local_ports + or grep {$_ eq $pgname} @safe_progs + or grep {$_ eq $lip} @safe_local_ips; + + print; + $exitcode=0; +} +close(NETSTAT); + +exit $exitcode; diff --git a/showargs b/showargs new file mode 100755 index 0000000..e0dcc2a --- /dev/null +++ b/showargs @@ -0,0 +1,4 @@ +#!/usr/bin/perl -w + +print "${\(@ARGV+0)} arguments:\n"; +foreach (@ARGV) { print "'$_' "; }; print "\n"; diff --git a/showargs.c b/showargs.c new file mode 100644 index 0000000..77d0df2 --- /dev/null +++ b/showargs.c @@ -0,0 +1,10 @@ +#include + +int main (int argc, char** argv) +{ + int i; + printf ("showargs parameters:\n"); + for (i=0; i]\n"; + print " pipe stdin to stdout, sleeping (default 4) milliseconds between lines.\n"; + exit; +} + +#$delay = ( $opt_t || 40 ) / 1000; # sehr cool, aber versagt, wenn $opt == 0 ... + +$delay = ( defined($opt_t)?$opt_t:40 ) / 1000; + +use IO::Handle; + +STDOUT->autoflush(1); + +while () { + select(undef, undef, undef, $delay); # lt. Doku die einzige einfache(?) Moeglichkeit, kurze Zeitspannen zu sleepen + print $_; +} diff --git a/spurious-listeners-watchdog b/spurious-listeners-watchdog new file mode 100755 index 0000000..5d17f72 --- /dev/null +++ b/spurious-listeners-watchdog @@ -0,0 +1,15 @@ +#!/bin/sh + +tmpfile=`mktemp` + +while true; do + echo 'processes with potentially dangerous internet connections:' >$tmpfile + /usr/local/bin/show-spurious-listeners >>$tmpfile + + case $? in + 0) wall <$tmpfile;; + 2) exit 1;; + esac + + sleep 120 +done diff --git a/sqlddl2dia b/sqlddl2dia new file mode 100755 index 0000000..397c449 --- /dev/null +++ b/sqlddl2dia @@ -0,0 +1,227 @@ +#!/usr/bin/perl -w +# TODO: SQL-DDL-Grammatik -> Syntaxbaum -> (+Templates->) XML. Irgendwann... + +print < + + + + + + + + #A4# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOS + +my ($currTable); + +while (<>) { + + + if (/^ *CREATE TABLE .*?(\w+) *\(/) { + $currTable = $1; + + print STDERR ">>>>>>>>Tabelle erkannt: $currTable\n"; + + print < + + + + + + + + + + + + + + + + + #$currTable# + + + ## + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOS + + next; + } + + + print STDERR ">>>>>>>>suche Attr...\n"; + #id VARCHAR(100) NOT NULL, + if (/^\s*(\w+) +([\w\d()]+).*?,/ + and defined($currTable) + and !/(?:FOREIGN|PRIMARY) KEY/) { + #if (/^\s*(\w+) +(\w+);/ and defined($currTable)) { + my ($attrName,$attrType) = ($1,$2); + print STDERR ">>>>>>>>Attr. erkannt: ($attrName,$attrType)\n"; + print < + + #$attrName# + + + #$attrType# + + + ## + + + ## + + + + + + + + + + + +EOS + + next; + } + + + if (/^ *\).*?;/) { + print < + + + + + + +EOS + + $currTable = undef; + } + +} + + + + +print < + +EOS diff --git a/ssh-forward-allisst b/ssh-forward-allisst new file mode 100755 index 0000000..8ae84e3 --- /dev/null +++ b/ssh-forward-allisst @@ -0,0 +1,12 @@ +#!/bin/sh + +# TODO: race condition: ssh-forward-isstssh->(ssh-forward-myissthostssh|ssh-forward-isstcvs)... + +ssh-forward-isstssh & +pid=$! +sleep 20; +ssh-forward-myissthostssh & +ssh-forward-isstcvs & +ssh-forward-isstica & + +wait $pid diff --git a/ssh-forward-allisst-continuously b/ssh-forward-allisst-continuously new file mode 100755 index 0000000..47a3ab7 --- /dev/null +++ b/ssh-forward-allisst-continuously @@ -0,0 +1,6 @@ +#!/bin/sh + +while true; do + ssh-forward-allisst; + sleep 60; +done diff --git a/ssh-forward-isstcvs b/ssh-forward-isstcvs new file mode 100755 index 0000000..611f825 --- /dev/null +++ b/ssh-forward-isstcvs @@ -0,0 +1,4 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +ssh -nN -L 5142:panda.isst.fhg.de:2401 isstunixhost sleep 86400 diff --git a/ssh-forward-isstica b/ssh-forward-isstica new file mode 100755 index 0000000..162ff58 --- /dev/null +++ b/ssh-forward-isstica @@ -0,0 +1,4 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +ssh -nN -L 1494:redstart.isst.fhg.de:1494 isstunixhost sleep 86400 diff --git a/ssh-forward-isstssh b/ssh-forward-isstssh new file mode 100755 index 0000000..fcb4dc8 --- /dev/null +++ b/ssh-forward-isstssh @@ -0,0 +1,3 @@ +#!/bin/sh + +ssh -nN -L 2222:deer.isst.fhg.de:22 butterfly.cs.tu-berlin.de sleep 86400 diff --git a/ssh-forward-isstwww b/ssh-forward-isstwww new file mode 100755 index 0000000..421b69b --- /dev/null +++ b/ssh-forward-isstwww @@ -0,0 +1,4 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +ssh -N -L 5144:www.isst.fhg.de:80 isstunixhost diff --git a/ssh-forward-myissthostssh b/ssh-forward-myissthostssh new file mode 100755 index 0000000..e4c3d17 --- /dev/null +++ b/ssh-forward-myissthostssh @@ -0,0 +1,5 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +ssh -nN -L 5143:swangoose.isst.fhg.de:22 isstunixhost sleep 86400 +#ssh -n -l oklischa -i ~/.ssh/identity.pphr -L 5143:swangoose.isst.fhg.de:22 -p 2222 localhost diff --git a/ssh-forwarded-isstssh b/ssh-forwarded-isstssh new file mode 100755 index 0000000..bf12b98 --- /dev/null +++ b/ssh-forwarded-isstssh @@ -0,0 +1,5 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +shift; # ignore hostname +ssh isstunixhost "$@" diff --git a/ssh-forwarded-myissthost b/ssh-forwarded-myissthost new file mode 100755 index 0000000..63670d0 --- /dev/null +++ b/ssh-forwarded-myissthost @@ -0,0 +1,5 @@ +#!/bin/sh +# run ssh-forward-isstssh first! + +shift; # ignore hostname +ssh-myissthost "$@" diff --git a/ssh-isstunixhost b/ssh-isstunixhost new file mode 100755 index 0000000..c2cd9d4 --- /dev/null +++ b/ssh-isstunixhost @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ssh isstunixhost "$@" diff --git a/ssh-myhomehost b/ssh-myhomehost new file mode 100644 index 0000000..9011c08 --- /dev/null +++ b/ssh-myhomehost @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ssh `showhomeip` "$@" diff --git a/ssh-myissthost b/ssh-myissthost new file mode 100755 index 0000000..250978a --- /dev/null +++ b/ssh-myissthost @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ssh myissthost "$@" diff --git a/stopwatch b/stopwatch new file mode 100755 index 0000000..1192f15 Binary files /dev/null and b/stopwatch differ diff --git a/stopwatch.c b/stopwatch.c new file mode 100644 index 0000000..124a0b8 --- /dev/null +++ b/stopwatch.c @@ -0,0 +1,24 @@ +#include +#include + +int main() { + struct timeval tv1,tv2; + fprintf(stderr,"press enter...\n"); + getchar(); + + if (0 != gettimeofday (&tv1,NULL)) { + perror("err..."); + exit(-1); + } + + fprintf(stderr,"press enter...\n"); + getchar(); + + if (0 != gettimeofday (&tv2,NULL)) { + perror("err..."); + exit(-1); + } + + printf("%.4f\n", (double)tv2.tv_sec+(double)tv2.tv_usec/1e6 + -(double)tv1.tv_sec-(double)tv1.tv_usec/1e6); +} diff --git a/strace-all b/strace-all new file mode 100755 index 0000000..f857303 --- /dev/null +++ b/strace-all @@ -0,0 +1,19 @@ +#!/bin/sh + +while getopts u: name; do + if [ "$name"="u" ]; then + user=$OPTARG + fi +done + +shift $[ $OPTIND - 1 ] +proc=$1 + +if [ -z "$proc" ]; then + echo "usage: strace-all [-u user] processname" >&2 + exit 1 +fi + +# echo user: $user process: $proc + +ps axfu | grep "$proc" | grep "$user" | grep -v grep | awk '{print $2}' | xargs -i /bin/sh -c 'xterm -T {} -e strace -f -p {} &' diff --git a/sumsizes b/sumsizes new file mode 100755 index 0000000..62640b5 --- /dev/null +++ b/sumsizes @@ -0,0 +1,3 @@ +#!/bin/sh + +xargs -d '\n' du | cut -f1 | sumup diff --git a/sumup b/sumup new file mode 100755 index 0000000..8aff589 --- /dev/null +++ b/sumup @@ -0,0 +1,12 @@ +#!/bin/sh + +sum=0 + +for size in `xargs`; +do + sum=$[ $sum + $size ] +done + +echo $sum + + diff --git a/svnshowunkn b/svnshowunkn new file mode 100755 index 0000000..e389ac0 --- /dev/null +++ b/svnshowunkn @@ -0,0 +1,3 @@ +#!/bin/sh + +find . -type f | xargs svn status 2>&1 | grepre "svn: warning: '(.*?)' is not a working copy" diff --git a/syncmp3s b/syncmp3s new file mode 100755 index 0000000..badf847 --- /dev/null +++ b/syncmp3s @@ -0,0 +1,15 @@ +#!/bin/sh + +# TODO: sync removals? + +targetdir="$1" +if [ -z "$targetdir" ]; then + echo "usage: $0 " + exit 1 +fi + +find . -type f -name '*mp3' | +while read f; do + echo "copying: $f" + cp -n --parents "$f" "$targetdir/"; +done diff --git a/teststdoutspeed.c b/teststdoutspeed.c new file mode 100644 index 0000000..7e1ed5f --- /dev/null +++ b/teststdoutspeed.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +static int line_num; +static struct timeval start, stop; + +static void sighandler(int); + +static char *alloc_lines(unsigned line_length, unsigned count) { + int i; + char *result = malloc(count*(line_length+2)); + int rnd = open("/dev/urandom", O_RDONLY); + for (i=0; i1) { + if (1 != sscanf(argv[1], "%u", &measurement_interval)) { + fputs("argument parse error\n", stderr); + exit(-1); + } + } + fprintf(stderr,"measurement_interval: %u secs\n", measurement_interval); + + if (SIG_ERR == signal(SIGALRM, sighandler)) { + perror("signal"); + exit(-1); + } + + lines = alloc_lines(line_length, count); + + if (0 != gettimeofday (&start,NULL)) { + perror("gettimeofday"); + exit(-1); + } + alarm(measurement_interval); + + for (line_num=0; ; ++line_num) { + fputs(lines + (line_num % count)*(line_length+2), stdout); + //puts("Hello World foo bar baz quick brown fox"); + } +} + + +static void sighandler(int signum) { + int i_val = line_num; + double time; + gettimeofday (&stop,NULL); + time = (double)stop.tv_sec+(double)stop.tv_usec/1e6 - (double)start.tv_sec-(double)start.tv_usec/1e6; + fprintf(stderr,"\n\n==END== lines printed: %i, time: %.4f secs, %.2f lines/sec\n", + i_val, time, (double)i_val/time); + exit(0); +} diff --git a/thermal-snapshot b/thermal-snapshot new file mode 100755 index 0000000..0623332 --- /dev/null +++ b/thermal-snapshot @@ -0,0 +1,4 @@ +#!/bin/sh + +date +'TIME: %x %X (%s)' +sensors diff --git a/thermallogd b/thermallogd new file mode 100755 index 0000000..c388eeb --- /dev/null +++ b/thermallogd @@ -0,0 +1,8 @@ +#!/bin/sh + +exec >>/var/log/thermal.log 2>&1 + +while true; do + /usr/local/bin/thermal-snapshot; + sleep 60; +done diff --git a/timedrun.sh b/timedrun.sh new file mode 100755 index 0000000..327310a --- /dev/null +++ b/timedrun.sh @@ -0,0 +1,10 @@ +#! /bin/bash + +seconds=$1 +shift + +"$@" & + +sleep $seconds + +kill -INT $? diff --git a/timelogger.pl b/timelogger.pl new file mode 100755 index 0000000..6ffbe6e --- /dev/null +++ b/timelogger.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl -w + +use POSIX qw(strftime); + + +while(1) { + print time() . "\n"; + sleep(1); +} diff --git a/tvbrowser b/tvbrowser new file mode 100755 index 0000000..3d86772 --- /dev/null +++ b/tvbrowser @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +export LANG=de_DE +cd /usr/local/tvbrowser +exec java -jar tvbrowser.jar diff --git a/umltxt2dia b/umltxt2dia new file mode 100755 index 0000000..45400ce --- /dev/null +++ b/umltxt2dia @@ -0,0 +1,214 @@ +#!/usr/bin/perl -w +# TODO: Java-Grammatik -> Syntaxbaum -> (+Templates->) XML. Irgendwann... + +print < + + + + + + + + #A4# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOS + +my ($currClass); + +while (<>) { + if (/(?:class|interface) +(\w+).+?\{/) { + $currClass = $1; + + print < + + + + + + + + + + + + + + + + + #$currClass# + + + ## + + + ## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOS + + next; + } + + if (/^\s*(\w+) +(\w+);/) { + my ($attrType,$attrName) = ($1,$2); + print < + + #$attrName# + + + #$attrType# + + + ## + + + ## + + + + + + + + + + + +EOS + + next; + } + + + if (/^\s*\}\s*$/) { + print < + + + + + + +EOS + } + +} + + + + +print < + +EOS diff --git a/umountdata b/umountdata new file mode 100755 index 0000000..3b65f10 --- /dev/null +++ b/umountdata @@ -0,0 +1,3 @@ +#!/bin/sh + +for i in `seq 1 15`; do umount /mnt/data$i; done diff --git a/unique-lines b/unique-lines new file mode 100755 index 0000000..feb6ed2 --- /dev/null +++ b/unique-lines @@ -0,0 +1,12 @@ +#!/usr/bin/perl +# remove duplicate lines from stdin. Like sort | uniq, but +# is more time- and space-efficient (no sorting is performed). +# (time: O(n) instead of O(nlogn), +# space: O(# of unique lines) vs. O(# of all lines)) + +while() { + unless ($seen{$_}) { + print; + $seen{$_}=1; + } +} diff --git a/unpacksrcrpm.sh b/unpacksrcrpm.sh new file mode 100755 index 0000000..0aa707a --- /dev/null +++ b/unpacksrcrpm.sh @@ -0,0 +1,20 @@ +#! /bin/sh + +rpmdir=/tmp/rpmdir + +tmpdir=/tmp/unpacksrcrpm.$$ +mkdir -p $tmpdir + +(rpm2cpio $1 && touch $tmpdir/rpm2cpio.$$) | (cd $tmpdir && cpio -id && touch $tmpdir/cpio.$$) + +( [ ! -f $tmpdir/rpm2cpio.$$ ] || [ ! -f $tmpdir/cpio.$$ ] ) && { rm -rf $tmpdir; exit 1; } + +rm -f $tmpdir/rpm2cpio.$$ $tmpdir/cpio.$$ + +cd $tmpdir + +cp -i `find . -type f -name '*.spec'` $rpmdir/SPECS/ +cp -i `find . -type f ! -name '*.spec'` $rpmdir/SOURCES/ + +cd .. +rm -rf $tmpdir diff --git a/unzip2d b/unzip2d new file mode 100755 index 0000000..2272c2d --- /dev/null +++ b/unzip2d @@ -0,0 +1,6 @@ +#!/bin/sh + +for f in "$@"; do + mkdir "$f.d" && + (cd "$f.d" && unzip "../`basename $f`";) +done diff --git a/update_cookiestxts b/update_cookiestxts new file mode 100755 index 0000000..1a44024 --- /dev/null +++ b/update_cookiestxts @@ -0,0 +1,23 @@ +#!/usr/bin/ruby -w + +require 'rubygems' +require 'find' +require 'dbi' + +["#{ENV['HOME']}/.mozilla/", "#{ENV['HOME']}/.firefox/", "#{ENV['HOME']}/.songbird2/"].each do |dirname| + next unless FileTest.exists?(dirname) + Find.find(dirname) do |fn| + if File.file?(fn) and "cookies.sqlite"==File.basename(fn) + # puts "#{fn} => #{File.dirname(fn)}/cookies.txt" + outfn = "#{File.dirname(fn)}/cookies.txt" + if !(FileTest.exists? outfn) or (File.mtime(fn) > File.mtime(outfn)) + con = DBI.connect("dbi:SQLite3:#{fn}") + File.open(outfn,"w") do |outfile| + con.select_all("SELECT host, path, isSecure, expiry, name, value FROM moz_cookies").each do |(host,path,isSecure,expiry,name,value)| + outfile.puts "#{host}\tTRUE\t#{path}\t#{isSecure=='0' ? 'TRUE' : 'FALSE'}\t#{expiry}\t#{name}\t#{value}" + end + end + end + end + end +end diff --git a/vcr-chilitv b/vcr-chilitv new file mode 100755 index 0000000..40e99a1 --- /dev/null +++ b/vcr-chilitv @@ -0,0 +1,29 @@ +#!/bin/sh + +time='61129'; +length=4000; +station=kika; +prefix=chilitv; + +echo "time=$time"; +echo "length=$length"; +echo "station=$station"; +echo "prefix=$prefix"; + + + +while true; do + while [ "`date +%u%H%M`" != "$time" ]; do + sleep 2; + done + + xscreensaver-keepaway & + scsvpid=$!; + + (v4lctl setstation "$station"; sleep 2; videnc.sh "$prefix-`date +%d%m%y`.avi") & + + sleep $length && killall -TERM mencoder + kill -TERM $scsvpid; + + sleep 60; +done diff --git a/vcr-daily b/vcr-daily new file mode 100755 index 0000000..9d66c66 --- /dev/null +++ b/vcr-daily @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ $# != 4 ]; then + echo "usage: $0 " >&1 + exit 1; +fi + +HM="$1"; +length="$2"; +station="$3"; +prefix="$4"; + +echo "HM=$HM"; +echo "length=$length"; +echo "station=$station"; +echo "prefix=$prefix"; + + + +while true; do + while [ "`date +%H%M`" != $HM ]; do + sleep 2; + done + + xscreensaver-keepaway & + scsvpid=$!; + + (v4lctl setstation "$station"; sleep 2; videnc.sh "$prefix-`date +%d%m%y`.avi") & + + sleep $length && killall -TERM mencoder + kill -TERM $scsvpid; + + sleep 60; +done diff --git a/videnc b/videnc new file mode 100755 index 0000000..4f82ccb --- /dev/null +++ b/videnc @@ -0,0 +1,301 @@ +#!/usr/bin/perl -w +# $Id: videnc,v 1.5 2008/01/10 05:44:45 klischat Exp $ +# Copyright (c) 2003 Olaf Klischat. All rights reserved. +# This program is free software; you can redistribute it and/or +# modify it under the same terms as Perl itself. + + +use strict; +use Getopt::Long; +use Date::Manip; +use Pod::Usage; + +#use FileHandle; +#autoflush STDOUT 1; + +sub date2str($) { + UnixDate($_[0],'%C'); +} + +sub delta2str($) { + Delta_Format($_[0],0,'%hhh %mvmin %svsec'); +} + +my ($start,$stop,$length,$size,$vbr,$abr,$res,$channel,$test); + +$abr=128; +$res="pal"; +exit(1) unless GetOptions ("start=s" => \$start, + "length=s" => \$length, + "stop=s" => \$stop, + "size=s" => \$size, + "res=s" => \$res, + "vbr=f" => \$vbr, + "channel=s" => \$channel, + "test" => \$test, + ); + +pod2usage(-msg => "" , + -exitval => 1 , + -verbose => 2) + unless(@ARGV); + + +die "--size only permitted in conjunction with --stop or --length" + if (defined($size) and not defined($stop) and not defined($length)); + +die "--stop and --length are mutually exclusive" + if (defined($stop) and defined($length)); + +die "--size and --vbr are mutually exclusive" + if (defined($size) and defined($vbr)); + +my $outfile = shift @ARGV; +print "output file: $outfile\n"; + +my $now = ParseDate('now'); +$start = defined($start)? ParseDate($start) : $now; +unless ($start) { + die "couldn't parse start time $start"; +} + +print "start time: " . date2str($start) . "\n"; + +die "start time lies in the past" + if (1==Date_Cmp($now,$start)); + +if (defined($stop)) { + die "couldn't parse stop time" + unless ($stop=ParseDate($stop)); +} +elsif (defined($length)) { + die "couldn't parse length" + unless ($length=ParseDateDelta($length)); + $stop = DateCalc($start,$length); +} + +$vbr = 1800 unless defined($vbr); + +if (defined($stop)) { + print "stop time: " . date2str($stop) . "\n"; + + die "stop time must be greater than start time" + if (1==Date_Cmp($start,$stop)); + + $length = DateCalc($start,$stop); + print "length: " . delta2str($length) . "\n"; + + + if (defined($size)) { + $size = lc $size; + $size =~ /^(\d+)([km]?)$/ or die 'invalid size specification, must be "[k|m]"'; + $size = $1*($2 eq 'k'? 2**10:2**20) if ($2); + $vbr = $size * 8.0 / Delta_Format($length, 0, '%sh') / 1000 - $abr; + } + + $vbr = int($vbr); + + $size = ($vbr + $abr) * 1000.0 / 8 * Delta_Format($length, 0, '%sh'); + + print "projected file size: $size bytes\n"; +} + +print "video bitrate: $vbr kbit/s\n"; +print "audio bitrate: $abr kbit/s\n"; +print "overall bitrate: " . ($vbr+$abr) . " kbit/s\n"; + +die "vbr must be > 0. Choose larger size if necessary." + if $vbr<=0; + +die "vbr is insanely high" + if $vbr>20000; + +my %resAliases = (pal => '768x576', + 'pal/2' => '384x288', + '1/2pal' => '384x288', + '2/3pal' => '512x384'); +$res = $resAliases{$res} if defined($resAliases{$res}); +my ($resX,$resY) = $res =~ /(\d+)x(\d+)/ or die "couldn't parse resolution from \"$res\""; +print "resolution: ${resX}x${resY}\n"; + +if (defined($channel)) { + open(XAWTVRC,"<$ENV{HOME}/.xawtv") or die "couldn't open $ENV{HOME}/.xawtv for verifying channel name"; + grep /^\[$channel\]$/, or die "channel $channel not found in $ENV{HOME}/.xawtv\n"; + close XAWTVRC; + print "channel: $channel\n"; +} + + +sub waitfortime($); +sub start_encoder; +sub stop_encoder; + + +unless ($test) { + waitfortime($start); + start_encoder; + + if ($stop) { + waitfortime($stop); + stop_encoder; + } + else { sleep; } +} + + + +sub waitfortime($) { + my ($time) = @_; + sleep 10 while (-1 == Date_Cmp(ParseDate('now'),$time)); +} + + + +my ($encoder_pid, $scrsv_blocker_pid); + +sub start_encoder { + if ($channel) { + system qw/v4lctl setstation/, $channel; + system("sleep 2"); + } + system("audioreset"); + + $scrsv_blocker_pid = fork(); + die "couldn't fork() screensaver blocker: $!" unless defined($scrsv_blocker_pid); + if ($scrsv_blocker_pid==0) { + while(1) { + system "xscreensaver-command -deactivate >/dev/null 2>&1"; + sleep 60; + } + } + + $encoder_pid = fork(); + die "couldn't fork() encoder process: $!" unless defined($encoder_pid); + + if ($encoder_pid==0) { + my @cmd= (qw{mencoder + tv:// -tv}, "driver=v4l2:width=$resX:height=$resY:adevice=/dev/dsp0", + qw{-ovc lavc -lavcopts}, "vcodec=mpeg4:vbitrate=$vbr", + qw{-oac mp3lame -lameopts}, "cbr:br=$abr:vol=1", + '-vf', 'pp=tn/lb,crop=720:544:24:16', '-o', $outfile); + print "executing: @cmd\n"; + exec @cmd or die "couldn't exec mencoder: $!"; + } + + # test if mencoder exits early + eval { + local $SIG{ALRM} = sub { die "alarm clock restart" }; + alarm 3; + waitpid($encoder_pid,0); + alarm 0; + }; + + if ($@ !~ /alarm clock restart/) { + kill 'SIGTERM', $scrsv_blocker_pid; + die "mencoder exited unexpectedly."; + } +} + + +sub stop_encoder { + kill 'SIGTERM', $encoder_pid; + kill 'SIGTERM', $scrsv_blocker_pid; + waitpid($encoder_pid,0); + waitpid($scrsv_blocker_pid,0); +} + + +#audioreset; + +#mencoder\ +# -tv on:driver=v4l:width=768:height=576:adevice=/dev/dsp0 -ovc lavc\ +# -lavcopts vcodec=mpeg4:vbitrate=1800\ +# -oac mp3lame -lameopts cbr:br=128:vol=1 -vop pp=tn/lb,crop=720:544:24:16\ +# -o "$1" + + +# moeglichkeiten: +# +# Audio: +# -lameopts ...:vol=[0..10] -- audio "input gain" für lame. +# Default: ? +# -tv ....:volume=[0..65535] -- Audiolautstaerke des v4l-Devices (TV-Karte). +# Default: 65535 +# extern: "igain"-Einstellung der Soundkarte + + +__END__ + +=head1 NAME + +videnc - encode divx from TV card + +=head1 SYNOPSIS + +videnc [options] outfile.avi + +=head1 DESCRIPTION + +records current programme from TV card, encodes it into outfile.avi. + +=head1 AUTHOR + +Olaf Klischat + +=head1 OPTIONS + +All options may be specified in the form -- , +--=, - , or -=. +Option names may be shortened as long as they remain unambiguous. + +=over 8 + +=item B<--start

\s*(.*?)\s*
@si) { + print STDERR "error: $file: \"$1\"\n"; + return; + } + +# my ($args) = ($body =~ m@/player2.swf(\?[^/"]*?video_id=$id\&[^"]+)"@s); + my ($args) = ($body =~ m@swfArgs = {(.*?)}@s); + + if (!$args && + $body =~ m@may contain content that is (inappropriate)@) { + print STDERR "error: $file: \"$1\"\n"; + return; + } + +# print STDERR "####\n$body\n####\n\n" unless ($args); + + error ("unable to find args in $url") unless ($args); + + # hl:'en',video_id:'CjGi-1FHq8Y',l:'207',etc + # becomes: + # hl=en&video_id=CjGi-1FHq8Y&l=207& etc + + # "hl": "en", "plid": "AAR..." + # becomes: + # hl=en&plid=AAR... + + $args =~ s/[\'\"]?, *[\'\"]?/&/gs; + $args =~ s/[\'\"]?: *[\'\"]?/=/gs; + $args =~ s/[\'\"] *$//s; + $args =~ s/^[\'\"] *//s; + + error ("unparsable args: $args") if ($args =~ m/[\s\'\"]/); + + $url = 'http://www.youtube.com/get_video?' . $args; + + print STDERR "$progname: downloading \"$file\"\n" if ($verbose); + my @cmd = ("wget", "-O", $file, $url); + push @cmd, "-q" if ($verbose <= 2); + safe_system (@cmd); +} + + +sub error($) { + my ($err) = @_; + print STDERR "$progname: $err\n"; + exit 1; +} + +sub usage() { + print STDERR "usage: $progname [--verbose] youtube-urls...\n"; + exit 1; +} + +sub main() { + my @urls = (); + while ($#ARGV >= 0) { + $_ = shift @ARGV; + if ($_ eq "--verbose") { $verbose++; } + elsif (m/^-v+$/) { $verbose += length($_)-1; } + elsif (m/^-./) { usage; } + elsif (! m@^http://www\.youtube\.com/@s ) { + print STDERR "$progname: not a www.youtube.com url: $_\n"; + usage; } + else { push @urls, $_; } + } + usage unless ($#urls >= 0); + foreach (@urls) { + download_url ($_); + } +} + +main(); +exit 0; diff --git a/zipdir.sh b/zipdir.sh new file mode 100755 index 0000000..9405ea7 --- /dev/null +++ b/zipdir.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +dir=$1; + +(gtar c $dir/ && touch /tmp/tar.$$ ) | (bzip2 >$dir.tar.bz2 && touch /tmp/bzip2.$$ ) +[ -f /tmp/tar.$$ ] && [ -f /tmp/bzip2.$$ ] && { rm -rf $dir/; true; } || rm -f $dir.tar.bz2 + +rm -f /tmp/tar.$$ /tmp/bzip2.$$