align
dpkg_not_running
-pong
reread_partition_table
vmware-detect
+grml-runtty
-PROGS = pong vmware-detect align dpkg_not_running reread_partition_table grml-runtty
+PROGS = vmware-detect dpkg_not_running reread_partition_table grml-runtty
#ifndef CFLAGS
CFLAGS = -O2 -Wall -s
all: $(PROGS)
-pong: pong.c
-
vmware-detect: vmware-detect.c
diet $(CC) $(CFLAGS) -o $@ $^
dpkg_not_running: dpkg_not_running.c
diet $(CC) $(CFLAGS) -o $@ $^
-align: align.c
- $(CC) -Wall -o align align.c
-
reread_partition_table: reread_partition_table.c
diet $(CC) $(CFLAGS) -o $@ $^
+++ /dev/null
-/*
- * By Patrick Reynolds <reynolds@cs.duke.edu>
- * Too trivial to copyright. It's in the public domain!
- *
- * To build:
- * gcc align.c -o align
- *
- * To run:
- * ./align
- *
- * Note that optimizing compilers will almost certainly reorder the data
- * segment, throwing off the values you get for structure alignments.
- * Annoyingly, some compilers don't let you disable optimizations.
- * GCC by default (with optimizations off) doesn't reorder data segments.
- * So use GCC.
- */
-
-#include <stdio.h>
-
-typedef struct { char a; } s_char;
-typedef struct { short a; } s_short;
-typedef struct { int a; } s_int;
-typedef struct { long a; } s_long;
-typedef struct { long long a; } s_long_long;
-typedef struct { float a; } s_float;
-typedef struct { double a; } s_double;
-typedef struct { int *a; } s_intp;
-
-int main() {
- int i = 0x01020304;
- char *ch = (char*)&i;
- char c1; char ch0; char c2;
- double d1; char ch1; double d2;
- float f1; char ch2; float f2;
- short s1; char ch3; short s2;
- int i1; char ch4; int i2;
- long long ll1; char ch5; long long ll2;
- int *p1; char ch6; int *p2;
- long l1; char ch7; long l2;
- s_char sc1; char ch8; s_char sc2;
- s_short ss1; char ch9; s_short ss2;
- s_int si1; char ch10; s_int si2;
- s_long sl1; char ch11; s_long sl2;
- s_long_long sll1;char ch12;s_long_long sll2;
- s_float sf1; char ch13; s_float sf2;
- s_double sd1; char ch14; s_double sd2;
- s_intp sp1; char ch15; s_intp sp2;
-
- if (ch[0] == 0x01)
- printf("Big endian (%d %d %d %d)\n", ch[0], ch[1], ch[2], ch[3]);
- else if (ch[0] == 0x04)
- printf("Little endian (%d %d %d %d)\n", ch[0], ch[1], ch[2], ch[3]);
- else
- printf("Unknown endian (%d %d %d %d)\n", ch[0], ch[1], ch[2], ch[3]);
-
- printf("sizes:\n");
- printf(" char: %d\n", sizeof(char));
- printf(" short: %d\n", sizeof(short));
- printf(" int: %d\n", sizeof(int));
- printf(" long: %d\n", sizeof(long));
- printf(" long long: %d\n", sizeof(long long));
- printf(" float: %d\n", sizeof(float));
- printf(" double: %d\n", sizeof(double));
- printf(" int*: %d\n", sizeof(int*));
- printf("alignments:\n");
- printf(" char: %d (%p %p %p)\n",
- (char*)&c1 - (char*)&c2 - sizeof(char), &c1, &ch0, &c2);
- printf(" short: %d (%p %p %p)\n",
- (char*)&s1 - (char*)&s2 - sizeof(short), &s1, &ch3, &s2);
- printf(" int: %d (%p %p %p)\n",
- (char*)&i1 - (char*)&i2 - sizeof(int), &i1, &ch4, &i2);
- printf(" long: %d (%p %p %p)\n",
- (char*)&l1 - (char*)&l2 - sizeof(long), &l1, &ch7, &l2);
- printf(" long long: %d (%p %p %p)\n",
- (char*)&ll1 - (char*)&ll2 - sizeof(long long), &ll1, &ch5, &ll2);
- printf(" float: %d (%p %p %p)\n",
- (char*)&f1 - (char*)&f2 - sizeof(float), &f1, &ch2, &f2);
- printf(" double: %d (%p %p %p)\n",
- (char*)&d1 - (char*)&d2 - sizeof(double), &d1, &ch1, &d2);
- printf(" int*: %d (%p %p %p)\n",
- (char*)&p1 - (char*)&p2 - sizeof(int*), &p1, &ch6, &p2);
- printf("structure alignments:\n");
- printf(" char struct: %d (%p %p %p)\n",
- (char*)&sc1 - (char*)&sc2 - sizeof(s_char), &sc1, &ch8, &sc2);
- printf(" short struct: %d (%p %p %p)\n",
- (char*)&ss1 - (char*)&ss2 - sizeof(s_short), &ss1, &ch9, &ss2);
- printf(" int struct: %d (%p %p %p)\n",
- (char*)&si1 - (char*)&si2 - sizeof(s_int), &si1, &ch10,&si2);
- printf(" long struct: %d (%p %p %p)\n",
- (char*)&sl1 - (char*)&sl2 - sizeof(s_long), &sl1, &ch11,&sl2);
- printf(" llong struct: %d (%p %p %p)\n",
- (char*)&sll1 - (char*)&sll2 - sizeof(s_long_long),&sll1,&ch12,&sll2);
- printf(" float struct: %d (%p %p %p)\n",
- (char*)&sf1 - (char*)&sf2 - sizeof(s_float), &sf1, &ch13,&sf2);
- printf("double struct: %d (%p %p %p)\n",
- (char*)&sd1 - (char*)&sd2 - sizeof(s_double), &sd1, &ch14,&sd2);
- printf(" int* struct: %d (%p %p %p)\n",
- (char*)&sp1 - (char*)&sp2 - sizeof(s_intp), &sp1, &ch15,&sp2);
-
- return 0;
-}
+++ /dev/null
-/*
- * By Patrick Reynolds <reynolds@cs.duke.edu>
- * Distributed under GPL.
- *
- * Build instructions
- * gcc pong.c -o pong
- *
- * Usage:
- * pong 1.2.3.0 # as root!
- */
-
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netinet/ip_icmp.h>
-#include <sys/socket.h>
-
-#define PONG_DEAD 0
-#define PONG_BROKEN 1
-#define PONG_OKAY 2
-
-#undef I_CARE_ABOUT_BAD_RETURN_PACKETS
-
-int id, sock;
-int datalen = 0;
-int nhosts = 256;
-int vec[256];
-int foo_set = 0;
-struct sockaddr_in dest;
-
-void pong();
-void catch();
-int in_cksum(u_short *addr, int len);
-void print();
-void foo(int i) { foo_set = 1; }
-
-int main(int argc, char **argv) {
- id = getpid();
- if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
- perror("pong: socket");
- return -1;
- }
- if (argc != 2) {
- fprintf(stderr, "Usage:\n %s aaa.bbb.ccc.0\n\n", argv[0]);
- return -1;
- }
- bzero(&dest, sizeof(dest));
- dest.sin_family = AF_INET;
- inet_aton(argv[1], &dest.sin_addr);
- pong();
- catch();
- print();
- return 0;
-}
-
-void pong() {
- unsigned char buf[sizeof(struct icmphdr)];
- struct icmphdr *p = (struct icmphdr *)buf;
- int ret, i;
-
- fprintf(stderr, "Sending packets");
-
- p->type = ICMP_ECHO;
- p->code = 0;
- p->checksum = 0;
- p->un.echo.sequence = 0;
- p->un.echo.id = id;
-
- p->checksum = in_cksum((u_short *)p, datalen + 8);
-
- dest.sin_addr.s_addr &= 0xffffff;
- for (i=1; i<=254; i++) {
- fputc('.', stderr);
- fflush(stderr);
- dest.sin_addr.s_addr &= 0xffffff;
- dest.sin_addr.s_addr |= (i<<24);
- ret = sendto(sock, (char *)buf, 8 + datalen, 0,
- (struct sockaddr *)&dest, sizeof(struct sockaddr_in));
- if (ret != 8 + datalen) {
- if (ret < 0)
- perror("pong: sendto");
- printf("pong: wrote %d chars, ret=%d\n", 8+datalen, ret);
- }
- }
- fputc('\n', stderr);
-}
-
-void catch() {
- int ret;
- char incoming[128];
- fprintf(stderr, "Gathering responses");
- bzero(vec, nhosts*sizeof(int));
- alarm(5);
- signal(SIGALRM, foo);
- signal(SIGINT, foo);
- while (!foo_set) {
- struct sockaddr_in from;
- fd_set rfds;
- struct timeval tv = { 1, 0 };
- socklen_t fromlen = sizeof(from);
- FD_ZERO(&rfds);
- FD_SET(sock, &rfds);
- if (select(sock+1, &rfds, NULL, NULL, &tv) <= 0) continue;
- ret = recvfrom(sock, (char *)incoming, 128, 0, (struct sockaddr *)&from,
- &fromlen);
-#ifdef I_CARE_ABOUT_BAD_RETURN_PACKETS
- if (ret != datalen + 16 && (ret >= 0 || errno != EINTR)) {
- if (ret < 0)
- perror("pong: recvfrom");
- else
- vec[from.sin_addr.s_addr >> 24] = PONG_BROKEN;
- printf("pong: read %d chars, ret=%d, host=%d\n", 16+datalen, ret,
- from.sin_addr.s_addr>>24);
- }
- else
-#endif
- {
- fputc('.', stderr);
- fflush(stderr);
- vec[from.sin_addr.s_addr >> 24] = PONG_OKAY;
- }
- }
- fputc('\n', stderr);
-}
-
-int in_cksum(u_short *addr, int len) {
- register int nleft = len;
- register u_short *w = addr;
- register int sum = 0;
- u_short answer = 0;
-
- while (nleft > 1) {
- sum += *w++;
- nleft -= 2;
- }
- if (nleft == 1) {
- *(u_char *)(&answer) = *(u_char *)w ;
- sum += answer;
- }
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- answer = ~sum;
- return(answer);
-}
-
-void print() {
- int i, count = 0;
- for (i=0; i<=255; i++)
- if (vec[i]) {
- unsigned int ip = ntohl(dest.sin_addr.s_addr);
- count++;
- printf("%d.%d.%d.%d: %s\n", ip>>24, (ip>>16)&0xff, (ip>>8)&0xff, i,
- vec[i]==PONG_OKAY ? "found" : "broken");
- }
- printf("\nTotal hosts: %d\n", count);
-}
Package: grml-scripts
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, less, dialog, perl, zsh, dash, links | w3m | links2, screen, grml-network, grml-etc-core, libterm-readkey-perl, lockfile-progs, grml-scripts-core
-Suggests: ruby, python, grml-x, ipcalc, hwinfo, antiword, grml-etc, grml-rebuildfstab, grml-files, grml-hwinfo, flite, wmii, mutt, slrn, grml-docs, grml-autoconfig, dirvish, sudo, idesk, python-dbus, notification-daemon, grml-quickconfig, lzop, alsa-utils
+Depends: ${shlibs:Depends}, ${misc:Depends}, less, dialog, perl, zsh, dash, links | w3m | links2, screen, grml-network, grml-etc-core, lockfile-progs, grml-scripts-core
+Suggests: python, grml-x, ipcalc, hwinfo, grml-etc, grml-rebuildfstab, grml-files, mutt, slrn, grml-docs, grml-autoconfig, dirvish, sudo, idesk, python-dbus, notification-daemon, grml-quickconfig, lzop, alsa-utils
Breaks: grml-autoconfig (<< 0.9.19)
Description: Scripts for the Grml system for an easier life
Some scripts which should make life easier.
.
This package contains a lot of scripts and is only really suited for
full Grml systems. It provides, amongst others: grml-mutt, grml-slrn,
- iimage, make_chroot_jail.sh, sepdate.pl, sepdate.rb, sepdate.sh*,
- wwwis.
+ iimage, make_chroot_jail.
If you're on a plain Debian system, it's recommended to install
grml-scripts-core instead.
.
-grml-scripts: script-with-language-extension usr/bin/bincompare.pl
-grml-scripts: script-with-language-extension usr/bin/hgrep.sh
-grml-scripts: script-with-language-extension usr/bin/irclog2html-2.1.pl
grml-scripts: script-with-language-extension usr/bin/notifyd.py
-grml-scripts: script-with-language-extension usr/bin/sepdate.pl
-grml-scripts: script-with-language-extension usr/bin/sepdate.rb
-grml-scripts: script-with-language-extension usr/bin/sepdate.sh
-grml-scripts: script-with-language-extension usr/bin/unbleach.pl
-grml-scripts: script-with-language-extension usr/sbin/ndiswrapper.sh
-grml-scripts: script-with-language-extension usr/sbin/prepare_ramdisk.sh
-grml-scripts: script-with-language-extension usr/sbin/prepare_tmpfs.sh
-grml-scripts: script-with-language-extension usr/sbin/suspenduser_gui.sh
-grml-scripts: script-with-language-extension usr/sbin/suspenduser.sh
grml-scripts: statically-linked-binary usr/bin/vmware-detect
grml-scripts: statically-linked-binary usr/sbin/dpkg_not_running
grml-scripts: statically-linked-binary usr/sbin/reread_partition_table
cp -a usr_bin/* debian/grml-scripts/usr/bin/
cp -a usr_sbin/* debian/grml-scripts/usr/sbin/
cp -a usr_share/* debian/grml-scripts/usr/share/grml-scripts/
- cp makefile.postfix debian/grml-scripts/etc/postfix/Makefile
- install -m 755 compile/align debian/grml-scripts/usr/bin/align
- install -m 755 compile/pong debian/grml-scripts/usr/sbin/pong
install -m 755 compile/vmware-detect debian/grml-scripts/usr/bin/vmware-detect
install -m 755 compile/dpkg_not_running debian/grml-scripts/usr/sbin/dpkg_not_running
install -m 755 compile/reread_partition_table debian/grml-scripts/usr/sbin/reread_partition_table
- install -m 755 compile/grml-runtty debian/grml-scripts/sbin/grml-runtty
+ install -m 755 compile/grml-runtty debian/grml-scripts/sbin/grml-runtty
# Build architecture-independent files here.
binary-indep: build install
dh_installman $(wildcard doc/*.gz)
dh_installman manpages/grml-scripts.1 \
manpages/reread_partition_table.8 manpages/random-hostname.1 \
- manpages/grml-setkeyboard.8 manpages/grml-setlang.8 manpages/getsf.1 \
+ manpages/grml-setkeyboard.8 manpages/grml-setlang.8 \
manpages/grml-iptstate.8 manpages/qma.1 manpages/grml-swapon.8 \
- manpages/grml2ram.8 manpages/dirvish-setup.8 \
- manpages/iso-term.1 manpages/alignmargins.8 manpages/get_3ware.1 \
+ manpages/grml2ram.8 manpages/dirvish-setup.8 manpages/iso-term.1 \
manpages/grml-init-multitail.1 manpages/grml-setservices.8
-# cp --no-dereference man/*.1.gz debian/grml-scripts/usr/share/man/man1/
dh_link /usr/bin/soundtest /usr/bin/grml-soundtest
dh_link /usr/sbin/blacklist /usr/sbin/unblacklist \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/align.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/apt-check-sigs.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/attach-screen.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/bincompare.pl.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/blacklist.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/bt-hid.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/caps-ctrl.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/cicqhist.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/code2html.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/dir2html.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/dpkg_not_running.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/dpkg-rebuild.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/exifinfo.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/fex.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/findchanged.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/find-hidden-word-text.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/find-text.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/findwaste.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/firevim.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/get_tw_cli.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grepc.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grepedit.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grml-config.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grml-runtty.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grml-slrn.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grml-start.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/grml-tpm.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/hgrep.sh.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/iimage.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/irclog2html-2.1.pl.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/lodgeit.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/logview.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/mailhops.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/make_chroot_jail.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/mkdosswapfile.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/myip.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/ndiswrapper.sh.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/noeject.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/noprompt.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/osd_server.py.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/notifyd.py.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/pong.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/prepare_ramdisk.sh.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/prepare_tmpfs.sh.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/PrintAnalyzer.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/say.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/search.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/sepdate.pl.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/sepdate.rb.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/sepdate.sh.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/soundtest.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/suspenduser.sh.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/suspenduser_gui.sh.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/twebgal.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/unblacklist.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/unbleach.pl.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/urlgrep.awk.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/usbtree.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/vmware-detect.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/wm-ng.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/wwwis.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/xsay.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/XF86AudioLowerVolume.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/XF86AudioMute.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/XF86AudioRaiseVolume.1.gz
#a2x -f manpage $^ 2>&1 |grep -v '^Note: ' >&2
#gzip -f --best $(patsubst %.txt,%, $^)
asciidoc -d manpage -b docbook $^
- xsltproc /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl $(patsubst %.txt,%.xml, $^)
+ xsltproc --novalid --nonet /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl $(patsubst %.txt,%.xml, $^)
# try to get rid of ".sp" sequences, see http://bts.grml.org/grml/issue567
sed -i 's/\.sp//' $(patsubst %.txt,%, $^)
gzip -f --best $(patsubst %.txt,%, $^)
+++ /dev/null
-swspeak-setup(8)
-================
-Michael Prokop <mika@grml.org>
-
-NAME
-----
-swspeak-setup - script for activating software speak(up) features
-
-SYNOPSIS
---------
-
-*swspeak-setup* [-a] [-e|-s] [-f] [-h]
-
-DESCRIPTION
------------
-
-*swspeak-setup* is a wrapper arround setting up the speakup kernel module
-and its according userspace software (espeakup by default if available, otherwise
-falling back to speechd-up). The script is used inside the swspeak zsh function
-of grml's zshrc.
-
-OPTIONS
--------
-
-*-h*::
-Show summary of options.
-
-*-e*::
-Use espeakup (default, if available).
-
-*-s*::
-Use speechd-up (fallback, if available).
-
-*-a*::
-Do not execute aumix for setting mixer levels.
-
-*-f*::
-Disable flite sound output.
-
-EXAMPLES
---------
-
-*swspeak-setup* '-a'::
-
- Set up speakup kernel modules and start espeakup (if available) without executing aumix for setting mixer levels.
-
-AUTHOR
-------
-swspeak-setup and this manpage were written by Michael Prokop <mika@grml.org>.
+++ /dev/null
-# Makefile for postfix
-
-TARGETS = postmap alias reload
-
-restart:
- /etc/init.d/postfix restart
-
-reload:
- /etc/init.d/postfix reload
-
-postmap:
-# postmap recipient_checks
-# postmap regexp_table
-# postmap sender_canonical
- postmap virtual
-
-alias:
- newaliases
-
-all: Makefile $(TARGETS)
+++ /dev/null
-.TH alignmargins 8
-.SH "NAME"
-alignmargins \- adjust the margins and the position of the printed contents on the paper
-.SH SYNOPSIS
-.B alignmargins [/path/to/align.ps]
-.SH DESCRIPTION
-This manual page documents briefly the
-.B alignmargins
-command.
-.SH OPTIONS
-alignmargins does not support any options.
-.SH PURPOSE OF alignmargins
-With this program you can adjust the margins and the position of the
-printed contents on the paper. This way you get well-centered printouts and
-you can make use of the whole imageable area of your printer, The driver
-settings are overridden when this adjustment is used.
-
-This is especially important when your printer is used with a driver for
-another printer to which yours is compatible (for example many laser
-printers are compatible to the HP LaserJet printers). Your printer prints
-with this driver, but the non-printable margins are usually different or the
-contents is even not centered. With this program you can fix these problems
-.SH AUTHOR
-alignmargins was written by Till Kamppeter.
-.PP
-This manual page was written by Michael Prokop
-<mika@grml.org> for the grml project (but may be used by others).
+++ /dev/null
-.TH get_3ware 1
-.SH "NAME"
-get_3ware \- get 3ware RAID controller software
-.SH SYNOPSIS
-.B get_3ware
-.SH DESCRIPTION
-This manual page documents briefly the
-.B get_3ware
-command. 3ware is a simple shellscript which provides URLs
-for downloading the tw_cli and 3DM2 tools of 3ware.com.
-.SH OPTIONS
-get_3ware does not support any options.
-.SH AUTHOR
-get_3ware was written by Michael Prokop <mika@grml.org>.
-.PP
-This manual page was written by Michael Prokop
-<mika@grml.org> for the grml project (but may be used by others).
+++ /dev/null
-.TH getsf 1
-.SH "NAME"
-getsf \- download project from sourceforge.net
-.SH SYNOPSIS
-.B getsf <projectame-version.archive>
-.SH DESCRIPTION
-This manual page documents briefly the
-.B getsf
-command.
-.SH OPTIONS
-The first option is taken as the project's name which is downloaded via wget.
-You can specify the mirror which should be used via environment variable MIRROR.
-The default mirror is mesh (DE/germany).
-.SH USAGE EXAMPLES
-.TP
-.B getsf htop-0.6.3.tar.gz
-Download htop version 0.6.3 from default mirror (mesh).
-.TP
-.B getsf http://prdownloads.sourceforge.net/htop/htop-0.6.3.tar.gz
-Download htop version 0.6.3 from default mirror (mesh).
-.TP
-.B MIRROR=puzzle getsf http://prdownloads.sourceforge.net/htop/htop-0.6.3.tar.gz
-Download htop version 0.6.3 from mirror puzzle.
-.SH AUTHOR
-getsf was written by Michael Prokop <mika@grml.org>.
-.PP
-This manual page was written by Michael Prokop
-<mika@grml.org> for the grml project (but may be used by others).
.SS align
find out a platform's endianness, alignment rules, and type
sizes. Moderately useful for porting stuff.
-.SS attach-screen
-attach to a running screen-session
-.SS bincompare.pl
-binary file similarity checking (using entropy)
.SS caps-ctrl
Switch keyboard settings of key known as "Caps-Lock" between
using Caps-Lock either as control- or shift-key. Notice:
running caps-ctrl on console requires root-permissions,
running it in X window system works as normal user.
-.SS cicqhist
-create a human-readable version of centericq history
-.SS code2html
-convert code to html
-.SS dir2html
-create HTML-listing for a directory
-.SS exifinfo
-print EXIF information of an image file
-.SS fex
-extract archives via smart frontend
-.SS find-hidden-word-text
-find hidden text in MS Word documents
-.SS find-text
-search for text pattern in text file only
-.SS findwaste
-find good directories for archiving based on the average age
-of files (access time) in the directory and the directory size
-.SS firevim
-open a file from firefox with vim
.SS grepc
grep for pattern and cut it
.SS grml-bind
configuration script for newsreader slrn
.SS grml-start
start browser with information page on Grml
-.SS hgrep.sh
-highlight grep output
.SS iimage
create statical webgallery
-.SS irclog2html-2.1.pl
-create html output of irc log files
.SS lodgeit
Paste command line client. Pastes files or stdin to http://paste.pocoo.org.
.SS logview
Symlink to notifyd.py
.SS notifyd.py
Listen for incoming messages on a specific port and print them via specific handlers (per default via libnotify).
-.SS say
-wrapper for festival to use the text to speech system
-.SS search
-perl script by Jeffrey Friedl - a combo of find and grep
-.SS sepdate.pl sepdate.rb sepdate.sh
-"endless september"
.SS soundtest
-Test sound on your Grml system via playing a ogg-file.
-Provide the files you want to play as arguments,
-adjust player which should be used for playing the files
-via environment variable PLAYER. Calling the script without
-any arguments will play the default file via ogg123.
-.SS sysdump
-dump /sys to a textformat
-.SS twebgal
-create a tiny webgallery using CSS-features
-.SS unbleach.pl
-replace all the unsighted unprintable characters
-bleached out of your source, useful for really
-dirty perl programs
-.SS urlgrep.awk
-print http|ftp|rstp|mms:// text entries in text.
-.SS usbtree
-Reads /proc/bus/usb/devices and selectively lists and/or interprets it.
-.SS wwwis
-read in an HTML file and insert 'HEIGHT=### WIDTH=###' directives into the inlined images used in the file
+Legacy wrapper for speaker-test.
.SS XF86AudioLowerVolume
Lower audio volume.
.SS XF86AudioMute
Mute and - if run again - restore audio settings.
.SS XF86AudioRaiseVolume
Raise audio volume.
-.SS xsay
-output X clipboard text via flite (soundsystem)
.SH "ADMIN SCRIPTS"
.SS blacklist
Blacklist module via module-init-tools (/etc/modprobe.d/grml).
-.SS bt-hid
-Connect human input device via bluetooth to local system.
.SS dpkg_not_running
Check whether Debian's package management (dpkg) is running.
Returns 0 if it is not running and 1 if it is already running.
-.SS dpkg-rebuild
-rebuild your Debian dpkg/apt status file if it got
-corrupted by a system crash.
.SS grml-config
Central configuration interface to configure the Grml system.
.SS grml-config-root
frontend will be used, when given a parameter the provided
parameter will be used as hostname and script is executed in
non-interactive mode.
-.SS grml-tpm
-Set up a system for use with TPM technology.
-.SS grml-vpnc-tugraz
-Connect to TU Graz network via vpnc.
-.SS mkdosswapfile
-Create GRML swapfile on an existing DOS partition.
-.SS ndiswrapper.sh
-NdisWrapper configuration script.
.SS noeject
Wrapper script to avoid ejecting and prompting for CD removal when
rebooting/halting system. Use it via 'noeject <cmd>', e.g. 'noeject reboot'
Wrapper script to avoid prompting for CD removal when rebooting/halting
system. Use it via 'noprompt <cmd>', e.g. 'noprompt reboot' to reboot system
without prompting.
-.SS pong
-Ping a class-C subnet in parallel without using a broadcast
-address. Useful for seeing which IPs are in use.
-.SS prepare_ramdisk.sh
-Set up a ramdisk.
-.SS prepare_tmpfs.sh
-Set up a tmpfs.
-.SS PrintAnalyzer
-Generate some stats from cups page_log file.
-.SS suspenduser.sh
-Suspend a user account for the indefinite future.
.SS unblacklist
Remove blacklisted module from /etc/modprobe.d/grml.
+++ /dev/null
-#!/bin/sh
-# Filename: attach-screen
-# Purpose: multi-attach to GNU screen session, creating a new one if necessary
-# Authors: (c) Phil Gregory <phil_g@pobox.com>, (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: Taken from http://aperiodic.net/phil/configs/bin/attach-screen
-################################################################################
-
-# -U option basically means "terminal does not have UTF-8 support"
-if [ x$1 = "x-U" ]; then
- unset LC_CTYPE
-fi
-
-# Bring in my ssh-agent, so screen will have it available in all windows.
-if [ -x /usr/bin/keychain ] ; then
- keychain --nocolor --quiet ~/.ssh/id_rsa
- . ~/.keychain/`hostname`-sh
-fi
-
-# Not a standard environment variable, but I need it for host-dependent
-# decisions in .screenrc.
-export HOST=`hostname`
-
-# multi-attach to main session, creating it if necessary. exec to save a
-# process.
-[ -r /etc/grml/screenrc ] && SCREENRC='-c /etc/grml/screenrc'
-exec screen -S main -xRR $SCREENRC
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl
-# Filename: bincompare.pl
-# Purpose: Binary File Similarity Checking
-# Authors: (C) Copyright 2004 Diomidis Spinellis
-# Bug-Reports: see http://grml.org/bugs/
-# License: See notes by author (Diomidis Spinellis).
-################################################################################
-# See http://www.dmst.aueb.gr/dds/blog/20040319/index.html
-#
-# Original notes:
-#
-# (C) Copyright 2004 Diomidis Spinellis
-#
-# Permission to use, copy, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-# Return the entropy of the file passed as the argument
-sub
-entropy
-{
- my($file) = @_;
- my($i, $l);
-
- # File length
- $l = `wc -c $file`;
- # File information (approximation)
- $i = `bzip2 -c $file | wc -c`;
- print STDERR "$0: warning file size exceeds bzip2 block size\n" if ($l > 900 * 1024);
- return ($i / $l);
-}
-
-
-# Return the entropy of the two files passed as arguments
-sub
-entropy2
-{
- my($file1, $file2) = @_;
- my($oldrs) = ($/);
- my($tmp) = ("/tmp/entropy.$$");
-
- undef($/);
- open(IN, $file1) || die "read from $file1: $!\n";
- binmode(IN);
- open(OUT, ">$tmp") || die "write to $tmp: $!\n";
- print OUT <IN>;
- open(IN, $file2) || die "read from $file2: $!\n";
- binmode(IN);
- print OUT <IN>;
- close(IN);
- close(OUT);
- my($e) = (entropy($tmp));
- unlink($tmp);
- return ($e);
-}
-
-$#ARGV == 1 || die "Usage $0: file1 file2\n";
-
-printf("%.3g - Entropy of $ARGV[0]\n", $e0 = entropy($ARGV[0]));
-printf("%.3g - Entropy of $ARGV[1]\n", $e1 = entropy($ARGV[1]));
-printf("%.3g - Combined predicted entropy\n", ($e0 + $e1) / 2);
-printf("%.3g - Combined actual entropy\n", entropy2($ARGV[0], $ARGV[1]));
+++ /dev/null
-#!/usr/bin/perl -w
-
-# Julius Plenz <jp@cvmx.de>
-# http://www.plenz.com/
-#
-# $Id: cicqhist,v 0.4 2004/07/20 18:33:36 plenz Exp $
-#
-# This script has just been written because of a simple purpose:
-# To learn Perl. Or at least to make first few steps with perl.
-# It just aims to be like http://centericq.de/misc/cicq-history.sh -
-# and maybe it's even a bit more powerful... ;-)
-#
-# Released under the GNU GPL.
-
-use strict;
-use Getopt::Std;
-
-my %options = ();
-getopts ('d:hisv', \%options);
-
-$\ = "\n";
-$0 =~ s/^.*\///;
-
-my ($VER, $DATE);
-$VER = '$Revision: 0.4 $';
-$VER =~ s/^.*: ([0-9\.,]+)\s*\$$/$1/;
-$DATE = '$Date: 2004/07/20 18:33:36 $';
-$DATE =~ s/^.*: ([0-9\/]{10})[0-9: ]*\$$/$1/;
-$DATE =~ s/\//-/g;
-
-if ($options{"v"}) {
- print $0, ' ', $VER, ' ', $DATE;
- exit;
-}
-
-if (!$ARGV[0] ||
- $options{"h"} ||
- $ARGV[0] eq "") {
-
- # print help
- print $0, ' ', $VER, ' ', $DATE;
- print 'by Julius Plenz <jp@cvmx.de>';
- print 'http://www.plenz.com/';
- print '(just to learn Perl :-)';
- print '';
- print 'Usage: ' . $0 . ' [-d <dir>] [-h] [-i] [-s] <number>';
- print '-d ... Use ... as cicq-directory (default: ~/.centericq)';
- print '-h Display this message';
- print '-i Display initials rather than full nicknames';
- print '-s Display shortened date (yymmdd hh:mm)';
- print '-v Display program version';
- exit;
-}
-
-
-# Change this, if you want!
-my $mynick = $ENV{"USER"};
-# my $mynick = "Goofy";
-
-
-# The main directory
-my $cicqdir;
-if ($options{"d"}) {
- $cicqdir = $options{"d"};
-} else {
- $cicqdir = $ENV{"HOME"} . '/.centericq';
-}
-
-# Three basic settings
-my $number = $ARGV[0];
-my $infofile = "$cicqdir/$number/info";
-my $histfile = "$cicqdir/$number/history";
-
-# Getting the nickname
-open (INFO, $infofile) || die ("Couldn't open file $infofile");
-my @lines = <INFO>;
-
-my $i = $#lines;
-$i++;
-
-my $nickname;
-foreach (@lines) {
- $i--;
- if ($i == 6) {
- chomp;
- $nickname = $_;
- }
-}
-
-close (INFO);
-
-
-# Opening History
-print "--- Displaying conversation with $nickname ---\n";
-
-open (HIST, $histfile) || die ("Couldn't open file $histfile");
-
-my $linenumber = 0;
-my $nick = '';
-my $displaytime;
-
-while (<HIST>) {
- chomp;
- my $line = $_;
-
- if ($line eq "\f") {
- $linenumber = 0;
- next;
- }
-
- if ($linenumber < 4) {
- if ($line =~ /^IN$/) {
- $nick = sprintf ('%-13s', $nickname);
- }
-
- if ($line =~ /^OUT$/) {
- $nick = sprintf ('%-13s', $mynick);
- }
-
- if (/^[0-9]+$/) {
- my $tstamp = $_;
- chomp ($tstamp);
-
- if ($tstamp < 3) {
- next;
- }
-
- my ($sec, $min, $hour, $mday, $mon, $year) =
- localtime ($tstamp);
-
- if ($options{"s"}) {
- $year += 1900;
- $displaytime = sprintf ('%02d%02d%02d %02d:%02d ',
- substr ($year, 2, 2), $mon, $mday, $hour, $min);
- } else {
- $displaytime =
- sprintf ('[%02d.%02d.%02d, %02d:%02d:%02d] ',
- $mday, $mon, (1900+$year), $hour, $min, $sec);
- }
- }
-
- $linenumber++;
- if ($linenumber == 4) {
-
- $\ = "";
-
- if ($options{"i"}) {
- print $displaytime . substr ($nick, 0, 1) . ': ';
- } else {
- print $displaytime . $nick . ': ';
- }
-
- $\ = "\n";
- }
-
- } else {
- print $line;
- }
-
-}
-
-close (HIST);
-
-if ($options{"i"}) {
- print '';
- print '';
- print ' 'x8 . $number .' = '. substr ($nickname, 0, 1) .
- ' = ' . $nickname;
- print ' 'x8 . substr ($mynick, 0, 1) . ' = ' . $mynick;
-}
-
-print "\n--- End of conversation with $nickname ---";
-
-# EOF vim: set et sm nu ft=perl
+++ /dev/null
-#!/usr/bin/perl -p
-#
-# code2html - convert code to html for posting to slashdot
-#
-# tchrist@perl.com
-# Sunday, December 19th, 1999
-
-BEGIN { print "<TT>\n" } # and the spirit of awk...
-
-# first kill all the tabs
-1 while s{ \t + }
- { " " x (length($&)*8 - length($`)%8) }ex;
-
-# then the four standard naughty bits
-s/&/&/g; # must remember to do this one first!
-s/</</g; # this is the most important one
-s/>/>/g; # don't close too early
-s/"/"/g; # only in embedded tags, i guess
-
-# make lines break where they should
-s/^\s*$/<P>/ || s/$/<BR>/;
-
-# make sure spaces aren't squishticated so we
-# can do indentation and properly align comments
-s/ / /g;
-
-END { print "</TT>\n" } # ...shall be with us always
+++ /dev/null
-#!/bin/sh
-
-# Karsten Kruse - www.tecneeq.de
-#
-# dir2html - create HTML-listung for a directory
-#
-# Copyright (c) 2001 - 2004, Karsten Kruse tecneeq(at)tecneeq(dot)de
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# 3. Neither the name of the author nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# any last words before we die?
-die(){
- echo ERROR: $1
- exit 1
-}
-
-# print some help
-usage(){
-cat <<EOF
-
- Usage:
- `basename $0` [Options]
-
- Options:
- -h => print this help
- -o out.html => output to file => default: $my_output
- -t title => title => default: $my_title
- -s file.css => path to a css => default: $my_style
- -e exclude => exclude this from listing => default: $my_exclude
- -k keywords => keywords for metatag => default: $my_keywords
- -d diricon => icon for directorys => default: $my_diricon
- -f fileicon => icon for files => default: $my_fileicon
- -p path => directory to HTMLifiy => default: $my_dir
-
-EOF
-}
-
-# hardwired defaults
-my_output="stdout"
-my_title="Filelisting"
-my_style="unset"
-my_exclude="index.html"
-my_keywords="Files, Stuff"
-my_diricon="/icons/folder.gif"
-my_fileicon="/icons/"
-my_dir=$(pwd)
-
-#parse commandline
-while getopts ho:t:s:e:k:i:d:f:p: opt ; do
- case "$opt" in
- h) usage ; exit ;;
- o) my_output="$OPTARG" ;;
- t) my_title="$OPTARG" ;;
- s) my_style="$OPTARG" ;;
- e) my_exclude="$OPTARG" ;;
- k) my_keywords="$OPTARG" ;;
- d) my_diricon="$OPTARG" ;;
- f) my_fileicon="$OPTARG" ;;
- p) my_dir="$OPTARG" ;;
- \?) usage >&2 ; exit 1 ;;
- esac
-done
-shift `expr $OPTIND - 1`
-
-do_work(){
-
- cd $my_dir || die "Could not change directory to $my_dir"
-
- cat <<EOF
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <title>$my_title</title>
- <meta name="description" content="$my_title">
- <meta name="keywords" content="$my_keywords">
- <meta name="generator" content="dir2html from www.tecneeq.de">
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
-EOF
-
- if [ ! $my_style = unset ] ; then
- echo " <link rel=\"stylesheet\" href=\"'$my_style'\" type=\"text/css\">"
- fi
-
- cat <<EOF
- $style
- </head>
- <body>
- <h1 align="center">$my_title</h1>
- <table summary="Verzeichnislisting" align="center" border="1" cellpadding="6" cellspacing="0">
- <tr bgcolor="grey">
- <td> </td>
- <td>Name</td>
- <td>Grösse</td>
- <td>Mimetype</td>
- </tr>
-EOF
-
-for i in `find -type d -maxdepth 1 -printf "%f\n" | sort | sed 's/ /+++A_BLANK+++/g'` ; do
- doit=true
- for e in $(echo "$my_exclude .") ; do
- if [ "$i" = "$e" ] ; then
- doit=false
- break
- fi
- done
- if [ $doit = true ] ; then
- rname="$(echo $i | sed 's/+++A_BLANK+++/ /g')"
- echo " <tr>"
- echo " <td><img src=\"$my_diricon\" alt=\"Verzeichnis\"></td>"
- echo " <td><a href=\"$rname\">$rname/</a></td>"
- echo " <td> </td>"
- echo " <td>Verzeichnis</td>"
- echo " </tr>"
- fi
-done
-
-for i in `find ! -type d -maxdepth 1 -printf "%f\n" | sort | sed 's/ /+++A_BLANK+++/g'` ; do
- doit=true
- for e in $(echo "$my_exclude") ; do
- if [ "$e" = "$i" ] ; then
- doit=false
- break
- fi
- done
- if [ $doit = true ] ; then
- rname="$(echo $i | sed 's/+++A_BLANK+++/ /g')"
- echo " <tr>"
- echo " <td><img src=\"$my_fileicon\" alt=\"File \"></td>"
- echo " <td><a href=\"$rname\">$rname</a></td>"
- echo " <td>$([ -h "$rname" ] || du -h "$rname" | awk '{print $1}') </td>"
- echo " <td>$(file -biL "$rname" | awk '{print $1}' | sed 's/;//g') </td>"
- echo " </tr>"
- fi
-done
-
- cat <<EOF
- </table>
- <p align="center"><small>Created with <a href="http://www.tecneeq.de/">dir2html</a>.</small></p>
- </body>
-</html>
-
-EOF
-}
-
-if [ $my_output = "stdout" ] ; then
- do_work
-else
- echo Writing to $my_output
- do_work > $my_output
-fi
-
-# eof
+++ /dev/null
-#!/bin/sh
-##########################################################################
-# Title : exifinfo - print EXIF information of an image file
-# Author : Heiner Steven <heiner.steven@odn.de>
-# Date : 2004-01-09
-# Category : Graphics
-# Requires : identify
-# SCCS-Id. : @(#) exifinfo 1.3 04/10/13
-##########################################################################
-# Description
-#
-# Caveats
-# o EXIF tags that would result in invalid shell variable names
-# should be rewritten, e.g. by replacing invalid characters with a
-# '_' character
-# o Individual tag names (e.g. "ImageWidth") should be allowed
-#
-# Bibiliography
-# o exif.org: "Specifications"
-# http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
-# o TsuruZoh Tachibanaya: "Description of Exif file format",
-# http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
-#
-# Output example (identify 5.5.4)
-# EXIF_Make='EASTMAN KODAK COMPANY'
-# EXIF_Model='KODAK DX4530 ZOOM DIGITAL CAMERA'
-# EXIF_Orientation='1'
-# EXIF_XResolution='230/1'
-# EXIF_YResolution='230/1'
-# EXIF_ResolutionUnit='2'
-# EXIF_YCbCrPositioning='1'
-# EXIF_ExifOffset='506'
-# EXIF_ExposureTime='1/30'
-# EXIF_FNumber='28/10'
-# EXIF_ExposureProgram='2'
-# EXIF_ExifVersion='0220'
-# EXIF_DateTimeOriginal='2003:01:03 08:41:52'
-# EXIF_DateTimeDigitized='2003:01:03 08:41:52'
-# EXIF_ComponentsConfiguration='...'
-# EXIF_ShutterSpeedValue='50/10'
-# EXIF_ApertureValue='3/1'
-# EXIF_ExposureBiasValue='0/1000'
-# EXIF_MaxApertureValue='30/10'
-# EXIF_MeteringMode='5'
-# EXIF_LightSource='0'
-# EXIF_Flash='25'
-# EXIF_FocalLength='80/10'
-# EXIF_MakerNote='KDK0002IDX4530 ..'
-# EXIF_FlashPixVersion='0100'
-# EXIF_ColorSpace='1'
-# EXIF_ExifImageWidth='2580'
-# EXIF_ExifImageLength='1932'
-# EXIF_InteroperabilityOffset='2320'
-# EXIF_unknown='R98'
-# EXIF_unknown='0100'
-# EXIF_ExposureIndex='140/1'
-# EXIF_SensingMethod='2'
-# EXIF_FileSource='.'
-# EXIF_SceneType='.'
-# EXIF_unknown='0'
-# EXIF_unknown='0'
-# EXIF_unknown='0'
-# EXIF_unknown='0/100'
-# EXIF_unknown='38'
-# EXIF_unknown='0'
-# EXIF_unknown='1'
-# EXIF_unknown='0'
-# EXIF_unknown='0'
-# EXIF_unknown='0'
-# EXIF_unknown='0'
-##########################################################################
-
-PN=`basename "$0"` # Program name
-VER='1.3'
-
-usage () {
- echo >&2 "$PN - print EXIF information of an image file, $VER
-usage: $PN [-p prefix] image [image ...]
- -p: variable prefix (default is \"EXIF_\")
-
-Prints the EXIF information from the image files. The output is printed
-as "var=value" pairs in a way suitable as input to the shell, e.g.
-
- eval \`$PN image.jpg\`
-
-can be used to set variables e.g. \"EXIF_ExifVersion\". Note that EXIF
-tags with names that would be invalid shell variable names are silently
-ignored."
- exit 1
-}
-
-msg () {
- for MsgLine
- do echo "$PN: $MsgLine" >&2
- done
-}
-
-fatal () { msg "$@"; exit 1; }
-
-Prefix=
-while getopts :hp: opt
-do
- case "$opt" in
- p) Prefix=$OPTARG;;
- h) usage;;
- ?) usage;;
- esac
-done
-shift `expr $OPTIND - 1`
-
-[ $# -lt 1 ] && usage
-
-prefix=${Prefix:-EXIF_}
-info='*'
-
-for file
-do
- # Explanation of the "sed" expressions:
- # o remove all lines not containing a "="
- # o remove "exif:" prefix from identify
- # o remove all lines containing tag names that would form invalid
- # shell variable names
- # o quote all apostrophy characters ' as '\''
- # o add an apostrophy at the front and the end of the value
- # string
- # o write the variable name prefix in front of each variable
-
- identify -format "%[EXIF:$info]" "$file" |
- sed \
- -e '/^[^=]*$/d' \
- -e 's/^exif://' \
- -e '/[^A-Za-z0-9_=][^=]*=/d' \
- -e "s/'/'\\\\''/g" \
- -e "s/=/='/" \
- -e "s/\$/'/" \
- -e "s/^/$prefix/"
-done
+++ /dev/null
-#!/bin/zsh
-# Filename: fex
-# Purpose: extract archives via smart frontend
-# Authors: grml-team ( grml.org), (c) Matthias Kopfermann, (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-zmodload zsh/files
-autoload -U colors && colors
-emulate zsh
-
-FILENAME=$0
-ARGV=$1
-alarmcol=$fg_bold[red]
-defcol=$fg[default]$bg[default]
-col1=$fg_bold[green]
-col2=$fg_bold[magenta]
-col3=$fg_bold[cyan]
-col4=$fg[cyan]
-
-usage() { print "Usage: $FILENAME file_to_extract" && exit ; }
- (( $ARGC != 1 )) && usage
- [[ $ARGV == "-h" || $ARGV == "--help" ]] && usage
- file=$1
- FILEPRG=$( which file )
- [[ $( tar --version 3>&1 ) != *(GNU|star)* ]] && echo "sorry, GNU tar or star is needed" && exit
- test -z $FILEPRG && echo $0 needs a program named file to detect the filetype && exit
-
-qprompt="
- Really decompress $alarmcol${file}$defcol? Press y or Y for YES
- or any other key for NO $defcol
-"
-
-nothing_to_do="
- ${col1}Okay, I will not uncompress the file $col2${file}$defcol as requested.
-"
-decision="read -q '?$qprompt'"
-
-local -A filetype; filetype=(\
- bz2cpio "cpio archive *bzip2*"
- cpiogz "cpio archive *gzip*"
- tarbz2 "*tar archive*bzip2*"
- targz "*tar archive*gzip*"
- tarz "*POSIX tar archive \(compress\'d data 16 bits\)*"
- bz2 "*\(bzip2 compressed data*"
- tar "*tar*"
- gz "*gzip*"
- 7zip "*7-zip archive data*"
- arj "ARJ archive data*"
- zip "*Zip archive data*"
- Z "*compress'd data 16 bits*"
- deb "Debian binary package*"
- uu "*uuencoded*xxencoded*"
- lzo "lzop compressed data - *"
- cpio "cpio archive"
- rar "RAR archive data*"
- cab "CAB file"
- #rpm "$file: *RPM*"
-)
-
-tarlist='/usr/bin/env tar -tvf' ; tarextract='/usr/bin/env tar -C $whereto -xvf'
-tarbz2list='/usr/bin/env tar -tvjf' ; tarbz2extract='/usr/bin/env tar -C ${whereto:-$PWD} -xvjf'
-targzlist='/usr/bin/env tar -tvzf' ; targzextract='/usr/bin/env tar -C $whereto -xvzf'
-gzlist='/usr/bin/env gzip -lv' ; gzextract='/usr/bin/env gzip -dc'
-tarzlist='/usr/bin/env tar -tvZf' ; tarzextract='/usr/bin/env tar -C $whereto -xvZf'
-tarcompresslist='/usr/bin/env tar -tvZf' ; tarcompressextract='/usr/bin/env tar -$ whereto -xvZf'
-#cpiobz2list='bzip2 -cd $file | cpio -ivt'; cpiobz2extract='bzip2 -cd $CWD/$file | cpio -idv'
-#cpiogzlist='gzip -cd $file | cpio -tv'
-#cpiogzextract='gzip -cd $file | cpio -ivd'
-cpiogz='/usr/bin/env star tzvf' ; cpiogzextract='/usr/bin/env star xzvf'
-_7ziplist='/usr/bin/env 7zr l' ; _7zipextract='/usr/bin/env 7zr e -o$whereto'
-arjlist='/usr/bin/env arj l' ; arjextract='/usr/bin/env arj e -e $CWD/$file'
-compresslist='/usr/bin/env uncompress -l' ; compressextract='/usr/bin/env uncompress -cv'
-lhalist='/usr/bin/env lha -l' ; lhaextract='/usr/bin/env lha -xw=$whereto'
-deblist='/usr/bin/env dpkg-deb -c' ; debextract='/usr/bin/env dpkg -X'
-lzolist='/usr/bin/env lzop -l' ; lzoextract='/usr/bin/env lzop -dN -p$whereto'
-cpiolist='/usr/bin/env cpio -t' ; cpioextract='/usr/bin/env cpio -idv'
-rarlist='/usr/bin/env unrar lb' ; rarextract='/usr/bin/env unrar e'
-cablist='/usr/bin/env cabextract -l' ; cabextract='/usr/bin/env cabextract -d $whereto'
-#rpmlist='/usr/bin/env rpm2cpio #rpmextract=
-ziplist='/usr/bin/env unzip -l' ; zipextract='/usr/bin/env unzip -d $whereto'
-
-
-# ------------------------------------------------- functions
-put_there() {
- vared -p "
- ${col2}Where should I extract to?
- ${col4}( Non existing directories will be created,
- completion works as do usual editing commands )$defcol
- " whereto && test -d $whereto \
- || builtin mkdir -p $whereto
-}
-# -------------------------------------------end of functions
-
-(( ${+PAGER} )) || local PAGER=less
-
-
- if [[ -f $file ]]
- then
- filetest=$( $FILEPRG -bz $file )
- echo "This is a $col2$filetest$defcol"
- sleep 1
- whereto=$PWD
- case "$filetest" in
- ( ${~filetype[bz2cpio]} )
- $=cpiobz2list |& $PAGER && eval $decision \
- && put_there \
- && CWD=$PWD \
- && ( cd $whereto && print "${col1}extracting to $whereto$defcol" && ${(e)=cpiobz2extract} ) \
- || print $nothing_to_do ;;
- ( ${~filetype[cpiogz]} )
- ${(e)=cpiogzlist} | $PAGER && eval $decision \
- && put_there \
- && CWD=$PWD \
- && ( cd $whereto && print "${col1}extracting to $whereto$defcol" && ${(e)=cpiogzextract} ) \
- || print $nothing_to_do ;;
- ( ${~filetype[tarbz2]} )
- $=tarbz2list $file \
- |
- $PAGER && eval $decision && put_there \
- && ${(e)=tarbz2extract} $file \
- || print $nothing_to_do ;;
- ( ${~filetype[targz]} )
- $=targzlist $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=targzextract} $file \
- || print $nothing_to_do ;;
- ( ${~filetype[tarz]} )
- $=tarzlist $file | $PAGER && eval $decision \
- && put_there \
- && print "${col3}extracting to $whereto:$defcol" \
- && ${(e)=tarzextract} $file \
- || print $nothing_to_do ;;
- ( ${~filetype[bz2]} )
- bzip2 -tv $file | $PAGER && eval $decision \
- && put_there \
- && bzip2 -dc $file > $whereto/${file:t:r} \
- && print "extracting to $whereto/${file:t:r}" || print $nothing_to_do ;;
- ( ${~filetype[gz]} )
- $=gziplist $file | $PAGER && eval $decision \
- && put_there \
- && dest="$whereto/${file:t:r}" \
- && gzip -dc $file > $dest && print "extracting to $dest" || print $nothing_to_do ;;
- ( ${~filetype[tar]} )
- $=tarlist $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=tarextract} $file || print $nothing_to_do ;; #ok
- ( ${~filetype[7zip]} )
- $=_7ziplist $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=_7zipextract} $file || print $nothing_to_do ;; # -o cannot stand a space, attention! #ok
- ( ${~filetype[arj]} )
- $=arjlist $file | $PAGER && eval $decision \
- && put_there \
- && CWD=$PWD \
- && ( cd $whereto && arj e -e $CWD/$file ) || print $nothing_to_do ;;
- ( ${~filetype[zip]} )
- ${=ziplist} $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=zipextract} $file || print $nothing_to_do ;; #ok
- ( ${~filetype[Z]} )
- $=compresslist $file | $PAGER && eval $decision \
- && put_there \
- && dest="$whereto/${file:t:r}" \
- && ${(e)=compressextract} $file > $dest && print "extracting to $dest" || print $nothing_to_do ;; #ok
- ( ${~filetype[lha]} )
- $=lhalist $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=lhaextract} $file || print $nothing_to_do ;; #ok
- ( ${~filetype[rar]} )
- $=rarlist $file | $PAGER && eval $decision \
- && put_there \
- && CWD=$PWD \
- && (cd $whereto && ${(e)=rarextract} $CWD/$file ) || print $nothing_to_do ;; #ok
- ( ${~filetype[lzo]} )
- $=lzolist $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=lzoextract} $file || print $nothing_to_do ;; #ok
- ( ${~filetype[cpio]} )
- $=cpiolist < $file | $PAGER && eval $decision \
- && put_there \
- && CWD=$PWD \
- && ( cd $whereto && ${(e)=cpioextract} < $CWD/$file ) || print $nothing_to_do ;; #ok
- ( ${~filetype[deb]} )
- ${(e)=deblist} $file | $PAGER && eval $decision \
- && put_there \
- && ${(e)=debextract} $file $whereto || print $nothing_to_do ;; #ok
- ( ${~filetype[uu]} )
- put_there \
- && CWD=$PWD \
- && ( cd $whereto && uudecode $CWD/$file ) || print $nothing_to_do ;;
- ( ${~filetype[cab]} )
- $=cablist $file | $PAGER && eval $decision \
- put_there \
- && ${(e)=cabextract} $file || print $nothing_to_do ;;
- #( ${~filetype[rpm]} )
- # temp=$( dd if=/dev/urandom bs=1 count=30 2>/dev/null | uuencode - | tr -d '[[:punct:]]' | sed '2!d' )
- # temp=${(C)${${${(f)"$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | uuencode - 2>/dev/null)"}[2]}//[[:punct:]]}}
- # (cd $temp && rpm2cpio $file && CPIO=*.cpio && cpio -ivt < $CPIO )\
- # put_there \
- #
- # && ( cd $whereto && cpio -ivd < $temp/$file ) || print $nothing_to_do
- # rm -r $temp ;;
- ( * )
- echo "${alarmcol}Error. Not the expected arguments or other problem!$defcol"
- echo "Usage: $0 file" ; exit 1 ;;
- esac
- else
- echo "'$file' is not a valid file"
- fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl -w
-=head1 NAME
-
-find-hidden-word-text - find hidden text in MS Word documents
-
-=head1 SYNOPSIS
-
-find-hidden-word-text word.doc > hidden.txt
-
-=head1 DESCRIPTION
-
-This is a command-line UNIX tool to ease the task of discovering hidden text
-in MS Word documents.
-
-More specifically, it is an implementation of Method 2 from Simon Byers'
-paper, _Scalable Exploitation of, and Responses to Information Leakage
-Through Hidden Data in Published Documents_, at
-<URL:http://www.user-agent.org/word_docs.pdf>.
-
-This goes a little further in that it removes some common 'noise' strings,
-like 'Word.Document.8', 'Title', 'PAGE', 'Microsoft Word Document' and
-the like. It will also remove any strings that do not contain at least
-1 whitespace character.
-
-=head1 PREREQUISITES
-
-This tool requires antiword be installed.
-
-=head1 AUTHOR
-
-Justin Mason, C<jm dash wordtext at jmason dot org>
-
-=head1 VERSION
-
-1.0 Aug 15 2003 jm
-
-=cut
-
-my $print_names = 0;
-if (scalar @ARGV > 1) { $print_names = 1; }
-
-foreach my $file (@ARGV) {
- if ($print_names) {
- print "\n$file\n\n";
- }
-
- open (IN, "antiword -t $file |") or die "cannot run antiword";
- my $aw = join ('', <IN>);
- close IN or die "cannot run antiword -t $file";
-
- open (IN, "strings $file |") or die "cannot run strings";
- my $str = join ('', <IN>);
- close IN;
-
- # normalize the antiword version
- $aw =~ s/\s+/ /gs;
-
- # get each string from strings, and see if we can find it in the "visible"
- # text from antiword
- my %count = ();
- foreach (split (/\n/, $str)) {
- s/\s+/ /g; s/^ //gs; s/ $//gs;
- next if ($aw =~ /\Q$_\E/);
-
- # killfile.
- # skip almost-entirely non-alpha 4-byte snippets
- #next if /^(?:\W\w\W\W|\W\W\w\W|\w\W{3,3}|\W{4,4}|\W{3,3}\w)$/;
-
- next if (!/ /); # no spaces!
-
- # skip 4-to-6-byte snippets with 1 nonalpha and no spaces
- #next if (/^\S{4,6}$/ && /\W/);
-
- # common word droppings
- next if /^\s*PAGE\s*$/;
- #next if /^Word.Document.\d$/;
- next if /^Microsoft Word 9.0$/;
- next if /^Microsoft Word Document$/;
- #next if /^Normal$/;
- #next if /^Title$/;
- #next if /^MSWordDoc$/;
- next if /^Click to edit Master text styles$/;
- next if /^Click to edit Master title style$/;
- next if /^Embedded OLE Servers$/;
-
- $count{$_}++;
- }
-
-# output the strings and their counts
- foreach (sort keys %count) {
- my $cnt = $count{$_};
- print "$cnt|$_\n";
- }
-}
+++ /dev/null
-#!/usr/bin/perl -s
-# Written By Shamir Biton , 27/08/2001
-# This script can search for text pattern in text file only
-
-use Cwd; # to use internal perl libreary
-sub ScanDirectory
-{
- my ($workdir) = shift;
- my ($startdir) = &cwd; # $startdir will get the current directory value
-
- # This part of code take the list of names from $workdir and place it in @names array
-
- chdir($workdir) or die "Unable to enter dir $workdir:$!\n";
- opendir(DIR,".") or die "Unable to open dir $workdir:$!\n";
- my @names = readdir(DIR) or die "Unable to read dir $workdir:$!\n";
- closedir(DIR);
-
- #
- foreach my $name (@names)
- {
- next if ($name eq ".");
- next if ($name eq "..");
- next if ($name eq "lost+found");
-
- if (-d $name)
- {
- &ScanDirectory($name);
- next;
- }
-
- if (-T $name) # only if it is text file
- {
- # print ("Checking $name..\n");
- $NofTimes = 0;
- open(FILENAME,$name);
-
- while(<FILENAME>)
- {
-
- if (/$wordTOfind/i) # key word to search
- {
- $NofTimes +=1;
- }
- }
-
- close(FILENAME);
- if ($NofTimes > 0)
- {
- print ("Found in $workdir/$name [$NofTimes Times]\n");
- }
-
- }
- }
-
- chdir($startdir) or die "Unable to change dir $startdir:$!\n";
-}
-
-my ($defaultdir) = &cwd;
-printf("Enter root path: [$defaultdir] ");
-$userdir = <STDIN>;
-chomp $userdir;
-
-if (! $userdir eq "")
-{
- while (! -d $userdir)
- {
- printf("Wrong Directory name, Please Enter Valid path name:");
- $userdir = <STDIN>;
- chomp $userdir;
- }
-}
-printf("Enter Text To seach: ");
-$wordTOfind = <STDIN>;
-chomp $wordTOfind;
-
-if ($userdir eq "")
- {
- &ScanDirectory(".")
- }
-else
- {
- print $userdir ;
- &ScanDirectory($userdir);
-
- }
-
+++ /dev/null
-#!/bin/sh
-# Filename: findchanged
-# Purpose: find changes in (real) files of dir1 ... dir2
-# Authors: grml-team (grml.org), (c) Klaus Knopper, (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
- if [ -d "$1" ]; then
- for i in `( cd "$1"; find . -type f 2>/dev/null | sed 's,^\./,,g' | grep -v ' ' )`; do
- cmp -s "$1/$i" "$2/$i" || echo "$1/$i"
- done
- elif [ -e "$1" ]; then
- cmp -s "$1" "$2" || echo "$1"
- fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl -w
-
-# This script finds good directories for archiving based on the
-# average age of files (access time) in the directory and the
-# directory size.
-
-# Directories whose size (in megabytes) is less than this value will
-# not be displayed
-my $size_minimum = 5;
-
-# Directories whose average file age (in days) is less than this value
-# will not be displayed
-my $average_age_minimum = 30;
-
-use strict;
-
-die "Usage: $0 [directory1, directory2, ...]\n" unless @ARGV;
-
-use File::Find;
-
-# ---------------------------------------------------------------------------
-
-# Global so that the callback can see them
-my $total_files;
-my $total_size;
-my $total_age;
-
-sub compute_age_callback
-{
- my $file_location = $File::Find::name;
- my $filename = $_;
-
- # Return if it's the '.' or '..' files;
- return if $filename eq '.' || $filename eq '..';
- # Return if it's a directory
- return if -d $filename;
- # Ignore links
- return if -l $filename;
-
- my @stats = stat $filename or die "Couldn't stat $filename: $!";
- my $access_time = $stats[8];
- my $size = $stats[7];
-
- my $current_time = time;
-
-# print "# $file_location\n# Current: $current_time, Access time: $access_time\n";
- my $age = $current_time - $access_time;
- $total_age += $age;
- $total_files++;
-
- $total_size += $size;
-}
-
-sub compute_directory_stats
-{
- my $starting_directory = shift;
-
- $total_age = 0;
- $total_size = 0;
- $total_files = 0;
-
- find(\&compute_age_callback, $starting_directory);
-
- return (0,0) if $total_files == 0;
-
- return ($total_age / $total_files / 60 / 60 / 24,
- $total_size / 1024 / 1024);
-}
-
-# ---------------------------------------------------------------------------
-
-@ARGV = ('.') unless @ARGV;
-
-my @directory_stats;
-
-foreach my $directory (@ARGV)
-{
- next unless -d $directory;
-
- my ($average_age, $size) = compute_directory_stats($directory);
- push @directory_stats, [$directory, $average_age, $size];
-}
-
-@directory_stats = sort { $b->[2] <=> $a->[2] } @directory_stats;
-
-@directory_stats = grep { $_->[2] > $size_minimum } @directory_stats;
-@directory_stats = grep { $_->[1] > $average_age_minimum } @directory_stats;
-
-foreach my $directory_stat (@directory_stats)
-{
- print "$directory_stat->[0]:\n";
- my $size_string = sprintf 'Size: %6.2f megabytes', $directory_stat->[2];
- my $age_string = sprintf 'Average age: %6.2f days', $directory_stat->[1];
- printf ' %-38s%s', $size_string, $age_string;
- printf "\n";
-}
+++ /dev/null
-#!/bin/sh
-# Filename: firevim
-# Purpose: small wrapper to open any file from firefox with vim
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-xterm -e "vim $*"
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: get_3ware
-# Purpose: get 3ware RAID controller command line interface tool (tw_cli)
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>, Wolfram Schlich <wschlich@gentoo.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-# Notice: this file is based on:
-# Copyright 1999-2006 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/www/www.gentoo.org/raw_cvs/gentoo-x86/sys-block/tw_cli/tw_cli-9.3.0.2.ebuild,v 1.1 2006/01/12 23:36:17 wschlich Exp $
-################################################################################
-
-if [ -r /etc/grml/lsb-functions ] ; then
- . /etc/grml/lsb-functions
-else
- alias einfo="echo"
-fi
-
-PN="tw_cli"
-PV="9.4.1"
-MV="9.4.0.1"
-
-case `uname -m` in
- x86_64)
- ARCH="x86_64"
- ;;
- i?86)
- ARCH="x86"
- ;;
- *)
- echo "Unsupported architecture, must be x86 or amd64 - sorry."
- exit 1
- ;;
-esac
-
-MY_P="${PN}-linux-${ARCH}-${PV}"
-URL_BASE="http://www.3ware.com/download/Escalade7000Series/${PV}"
-CMDLINETOOL="${URL_BASE}/${PN}-linux-${ARCH}-${PV}.tgz"
-MANAGEMENTTOOL="http://www.3ware.com/download/Escalade7000Series/${MV}/3DM2-Linux-${MV}.tgz"
-AGREE1="http://www.3ware.com/support/windows_agree.asp?path=/download/Escalade7000Series/${PV}/${MY_P}.tgz"
-AGREE2="http://www.3ware.com/support/windows_agree.asp?path=/download/Escalade7000SSeries/${MV}/3DM2-Linux-${MV}.tgz"
-RELEASENOTES1="http://www.3ware.com/download/Escalade9650SE-Series/${PV}/${PV}_Release_Notes_Web.pdf"
-RELEASENOTES2="http://www.3ware.com/download/Escalade9650SE-Series/${MV}/${MV}_Release_Notes_Web.pdf"
-
-info() {
- einfo "get_3ware - get 3ware RAID controller command line interface tool (tw_cli)"
- einfo "==========================================================================="
- einfo ""
-}
-
-supportedcards() {
- einfo "This binary supports all current cards, including, but not limited to:"
- einfo ""
- einfo "PATA: 7210, 7410, 7450, 7810, 7850, 7000-2, 7500-4, 7500-8,"
- einfo " 7500-12, 7006-2, 7506-4, 7506-4LP, 7506-8, 7506-12"
- einfo ""
- einfo "SATA: 8500-4, 8500-8, 8500-12, 8006-2, 8506-4, 8506-12,"
- einfo " 8506-8MI, 8506-12MI, 9500S-4LP, 9500S-8, 9500S-12,"
- einfo " 9500S-8MI, 9500S-12MI"
- einfo " 9500S-8MI, 9500S-12MI"
- einfo ""
-}
-
-pkg_nofetch() {
- einfo "Please agree to the license at URL"
- einfo ""
- einfo "\t${AGREE1}"
- einfo "\t${AGREE2}"
- einfo ""
- einfo "And then use the following URLs to download the tarballs:"
- einfo ""
- einfo "\t${CMDLINETOOL}"
- einfo "\t${MANAGEMENTTOOL}"
- einfo ""
- einfo "Release notes available at:"
- einfo ""
- einfo "\t${RELEASENOTES1}"
- einfo "\t${RELEASENOTES2}"
- einfo ""
-}
-
-info
-pkg_nofetch
-supportedcards
-# unp ${MY_P}.tgz
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: getsf
-# Purpose: download project from sourceforge.net
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if ! which wget >/dev/null 2>&1 ; then
- echo "wget is not available. Exiting." 1>&2
- exit 1
-fi
-
-if [ -z "$1" ] ; then
- echo "$0 - download project from sourceforge.net" 1>&2
- echo 1>&2
- echo "Usage: $0 <projectname-version.archive>" 1>&2
-
- echo 1>&2 "
-Usage examples:
-
- $0 htop-0.6.3.tar.gz
- $0 http://prdownloads.sourceforge.net/htop/htop-0.6.3.tar.gz
- MIRROR=puzzle $0 http://prdownloads.sourceforge.net/htop/htop-0.6.3.tar.gz
-
-Available mirrors:
-
- superb-east (US), jaist (JP), ovh (FR), optusnet (AU), kent (UK), mesh (DE),
- superb-west (US), easynews (US), surfnet (NL), ufpr (BR), heanet (IE),
- nchc (TW), umn (US), belnet (BE), puzzle (CH), switch (CH)
-
-Send bug reports to Michael Prokop <mika@grml.org>"
- exit 1
-fi
-
-[ -n "$MIRROR" ] || MIRROR=mesh # set default mirror if not already set
-
-case "$PROG" in
- *http://*)
- PROG=${PROG##*/}
- BASENAME=${PROG%%-*}
- BASENAME=${BASENAME%%_*}
- BASENAME=$(echo $BASENAME| tr 'A-Z' 'a-z')
- wget http://$MIRROR.dl.sourceforge.net/sourceforge/$BASENAME/$PROG
- ;;
- *)
- PROG="$1"
- BASENAME=${PROG%%-*}
- BASENAME=${BASENAME%%_*}
- BASENAME=$(echo $BASENAME| tr 'A-Z' 'a-z')
- wget http://$MIRROR.dl.sourceforge.net/sourceforge/$BASENAME/$PROG
- ;;
-esac
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/zsh
-# Filename: hgrep.sh
-# Purpose: highlight grep
-# Authors: Oliver Kiddle (<URL:http://www.zsh.org/mla/workers/2001/msg00390.html>)
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if (( ! $# )); then
- echo "Usage: $0:t [-e pattern...] [file...]" >&2
- return 1
-fi
-
-local -a regex
-local htext=`echotc so` ntext=`echotc se`
-
-while [[ "$1" = -e ]]; do
- regex=( $regex "$2" )
- shift 2
-done
-
-if (( ! $#regex )); then
- regex=( "$1" )
- shift
-fi
-
-regex=( "-e
-s/${^regex[@]}/$htext&$ntext/g" )
-sed ${(Ff)regex[@]} "$@"
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl
-
-# irclog2html.pl Version 2.1 - 27th July, 2001
-# Copyright (C) 2000, Jeffrey W. Waugh
-
-# Author:
-# Jeff Waugh <jdub@perkypants.org>
-
-# Contributors:
-# Rick Welykochy <rick@praxis.com.au>
-# Alexander Else <aelse@uu.net>
-
-# Released under the terms of the GNU GPL
-# http://www.gnu.org/copyleft/gpl.html
-
-# Usage: irclog2html filename
-
-# irclog2html will write out a colourised irc log, appending a .html
-# extension to the output file.
-
-
-####################################################################################
-# Perl Configuration
-
-use strict;
-#$^W = 1; #RW# turn on warnings
-
-my $VERSION = "2.1";
-my $RELEASE = "27th July, 2001";
-
-
-# Colouring stuff
-my $a = 0.95; # tune these for the starting and ending concentrations of R,G,B
-my $b = 0.5;
-my $rgb = [ [$a,$b,$b], [$b,$a,$b], [$b,$b,$a], [$a,$a,$b], [$a,$b,$a], [$b,$a,$a] ];
-
-my $rgbmax = 125; # tune these two for the outmost ranges of colour depth
-my $rgbmin = 240;
-
-
-####################################################################################
-# Preferences
-
-# Comment out the "table" assignment to use the plain version
-
-my %prefs_colours = (
- "part" => "#000099",
- "join" => "#009900",
- "server" => "#009900",
- "nickchange" => "#009900",
- "action" => "#CC00CC",
-);
-
-my %prefs_colour_nick = (
- "jdub" => "#993333",
- "cantanker" => "#006600",
- "chuckd" => "#339999",
-);
-
-my %prefs_styles = (
- "simplett" => "Text style with little use of colour",
- "tt" => "Text style using colours for each nick",
- "simpletable" => "Table style, without heavy use of colour",
- "table" => "Default style, using a table with bold colours",
-);
-
-my $STYLE = "table";
-
-
-####################################################################################
-# Utility Functions & Variables
-
-sub output_nicktext {
- my ($nick, $text, $htmlcolour) = @_;
-
- if ($STYLE eq "table") {
- print OUTPUT "<tr><th bgcolor=\"$htmlcolour\"><font color=\"#ffffff\"><tt>$nick</tt></font></th>";
- print OUTPUT "<td width=\"100%\" bgcolor=\"#eeeeee\"><tt><font color=\"$htmlcolour\">$text<\/font></tt></td></tr>\n";
- } elsif ($STYLE eq "simpletable") {
- print OUTPUT "<tr bgcolor=\"#eeeeee\"><th><font color=\"$htmlcolour\"><tt>$nick</tt></font></th>";
- print OUTPUT "<td width=\"100%\"><tt>$text</tt></td></tr>\n";
- } elsif ($STYLE eq "simplett") {
- print OUTPUT "<\;$nick>\; $text<br>\n";
- } else {
- print OUTPUT "<font color=\"$htmlcolour\"><\;$nick>\;<\/font> <font color=\"#000000\">$text<\/font><br>\n";
- }
-}
-
-sub output_servermsg {
- my ($line) = @_;
-
- if ($STYLE =~ /table/) {
- print OUTPUT "<tr><td colspan=2><tt>$line</tt></td></tr>\n";
- } else {
- print OUTPUT "$line<br>\n";
- }
-}
-
-sub html_rgb
-{
- my ($i,$ncolours) = @_;
- $ncolours = 1 if $ncolours == 0;
-
- my $n = $i % @$rgb;
- my $m = $rgbmin + ($rgbmax - $rgbmin) * ($ncolours - $i) / $ncolours;
-
- my $r = $rgb->[$n][0] * $m;
- my $g = $rgb->[$n][1] * $m;
- my $b = $rgb->[$n][2] * $m;
- sprintf("#%02x%02x%02x",$r,$g,$b);
-}
-
-my $msg_usage = "Usage: irclog2html.pl [OPTION]... [FILE]
-Colourises and converts IRC logs to HTML format for easy web reading.
-
- -s, --style=[STYLE] format log according to specific style. style formats
- described using irclog2html [-s|--style]
-
- --colour-<attribute>=[COLOUR] format output colour scheme. attributes
- described using irclog2html [--colour]
-
-Report bugs to Jeff Waugh <jdub\@perkypants.org>.
-";
-
-my $msg_styles = "The following styles are available for use with irclog2html.pl:
-
- simplett
- Text style with little use of colour
-
- tt
- Text style using colours for each nick
-
- simpletable
- Table style, without heavy use of colour
-
- table
- Default style, using a table with bold colours
-";
-
-my $msg_colours = "The following attributes may be customized using the --colour
-parameter:
-
- join, part, action, server, nickchange
-";
-
-
-################################################################################
-# Main
-
-sub main {
-
- my $inputfile;
-
- my $nick;
- my $time;
- my $line;
- my $text;
-
- my $htmlcolour;
- my $nickcount = 0;
- my $NICKMAX = 30;
-
- my %colours = %prefs_colours;
- my %colour_nick = %prefs_colour_nick;
- my %styles = %prefs_styles;
-
-
- # Quit if there is no filename specified on the command line #
- if ($#ARGV == -1) {
- die "Required parameter missing\n\n$msg_usage";
- }
-
-
- # Loop through parameters, bringing filenames into $files #
- my $count = 0;
-
- while ($ARGV[$count]) {
-
- if ($ARGV[$count] =~ /-s|--style.*/) {
- $STYLE = $ARGV[$count];
-
- if ($STYLE =~ /--style=.*/) {
- $STYLE =~ s/--style=(.*)/$1/;
-
- } else {
- $count++;
- $STYLE = $ARGV[$count];
- }
-
- if ($STYLE eq "") {
- print $msg_styles;
- return 0;
-
- } elsif (!defined($styles{$STYLE})) {
- die "irclog2html.pl: invalid style: `$STYLE'\n\n$msg_styles";
- }
-
- } elsif ($ARGV[$count] =~ /--colou?r.*/) {
- my $colour_pref = $ARGV[$count];
- my $colour = $colour_pref;
-
- if ($colour_pref =~ /--colou?r$/) {
- print $msg_colours;
- return 0;
-
- } else {
- $colour_pref =~ s/--colou?r-(.*)?=.*/$1/;
- $colour =~ s/--colou?r-.*?=(.*)/$1/;
-
- $colours{$colour_pref} = $colour;
- }
-
- } else {
- $inputfile = $ARGV[$count];
- }
- $count++;
- }
-
- # Open input and output files #
- if (!$inputfile) {
- # no file to open, print appropriate usage information
- die "\n$msg_usage";
-
- } elsif (!open(INPUT, $inputfile)) {
- # not a vaild file to open, spew error and usage information
- die "irclog2html.pl: cannot open $inputfile for reading\n\n$msg_usage";
- }
- if (!open(OUTPUT, ">$inputfile.html")) {
- # can't open file for output, spew error
- die "irclog2html.pl: cannot open $inputfile.html for writing\n";
- }
-
-
- # Begin output #
- print OUTPUT qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <title>$inputfile</title>
- <meta name="generator" content="irclog2html.pl $VERSION by Jeff Waugh">
- <meta name="version" content="$VERSION - $RELEASE">
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-</head>
-<body text="#000000" bgcolor="#ffffff"><tt>
-};
-
- if ($STYLE =~ /table/) {
- print OUTPUT "<table cellspacing=3 cellpadding=2 border=0>\n";
- }
-
- while ($line = <INPUT>) {
-
- chomp $line;
-
- if ($line ne "") {
-
- # Replace ampersands, pointies, control characters #
- $line =~ s/&/&\;/g;
- $line =~ s/</<\;/g;
- $line =~ s/>/>\;/g;
- $line =~ s/[\x00-\x1f]+//g;
-
- # Replace possible URLs with links #
- $line =~ s/((http|https|ftp|gopher|news):\/\/\S*)/<a href="$1">$1<\/a>/g;
-
- # Rip out the time #
- if ($line =~ /^\[?\d\d:\d\d(:\d\d)?\]? .*$/) {
- $time = $line;
- $time =~ s/^\[?(\d\d:\d\d(:\d\d)?)\]? .*$/$1/;
- $line =~ s/^\[?\d\d:\d\d(:\d\d)?\]? (.*)$/$2/;
- print $time;
- }
-
- # Colourise the comments
- if ($line =~ /^<\;.*?>\;\s.*/) {
-
- # Split $nick and $line
- $nick = $line;
- $nick =~ s/^<\;(.*?)>\;\s.*$/$1/;
-
- # $nick =~ tr/[A-Z]/[a-z]/;
- # <======= move this into another function when getting nick colour
-
- $text = $line;
- $text =~ s/^<\;.*?>\;\s(.*)$/$1/;
- $text =~ s/ / \; \;/g;
-
- $htmlcolour = $colour_nick{$nick};
- if (!defined($htmlcolour)) {
- # new nick
- $nickcount++;
-
- # if we've exceeded our estimate of the number of nicks, double it
- $NICKMAX *= 2 if $nickcount >= $NICKMAX;
-
- $htmlcolour = $colour_nick{$nick} = html_rgb($nickcount, $NICKMAX);
- }
- output_nicktext($nick, $text, $htmlcolour);
-
- } else {
- # Colourise the /me's #
- if ($line =~ /^\* .*$/) {
- $line =~ s/^(\*.*)$/<font color=\"$colours{"action"}\">$1<\/font>/;
- }
-
- # Colourise joined/left messages #
- elsif ($line =~ /^(\*\*\*|-->) .*joined/) {
- $line =~ s/(^(\*\*\*|-->) .*)/<font color=\"$colours{"join"}\">$1<\/font>/;
- }
- elsif ($line =~ /^(\*\*\*|<--) .*left|quit/) {
- $line =~ s/(^(\*\*\*|<--) .*)/<font color=\"$colours{"part"}\">$1<\/font>/;
- }
-
- # Process changed nick results, and remember colours accordingly #
- elsif ($line =~ /^(\*\*\*|---) (.*?) are|is now known as (.*)/) {
- my $nick_old;
- my $nick_new;
-
- $nick_old = $line;
- $nick_old =~ s/^(\*\*\*|---) (.*?) (are|is) now known as .*/$1/;
-
- $nick_new = $line;
- $nick_new =~ s/^(\*\*\*|---) .*? (are|is) now known as (.*)/$2/;
-
- $colour_nick{$nick_new} = $colour_nick{$nick_old};
- $colour_nick{$nick_old} = undef;
-
- $line =~ s/^((\*\*\*|---) .*)/<font color=\"$colours{"nickchange"}\">$1<\/font>/
- }
- # server messages
- elsif ($line =~ /^(\*\*\*|---) /) {
- $line =~ s/^((\*\*\*|---) .*)$/<font color=\"$colours{"server"}\">$1<\/font>/;
- }
-
- output_servermsg($line);
- }
- }
- }
-
- if ($STYLE =~ /table/) {
- print OUTPUT "</table>\n";
- }
-
- print OUTPUT qq{
-<br>Generated by irclog2html.pl $VERSION by <a href="mailto:jdub\@NOSPAMperkypants.org">Jeff Waugh</a>
- - find it at <a href="http://freshmeat.net/projects/irclog2html.pl/">freshmeat.net</a>!
-</tt></body></html>};
-
- close INPUT;
- close OUTPUT;
-
- return 0;
-}
-
-exit main;
+++ /dev/null
-#!/bin/sh
-# Filename: say
-# Purpose: output text via flite or festival (general multi-lingual speech synthesis system)
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if [ $# -eq 0 ] ; then
- echo "Usage: $0 <text_to_say>"
- exit 1
-fi
-
-if [ -x /usr/bin/flite ] ; then
- flite -o play -t "$*"
-elif [ -x /usr/bin/festival ] ; then
- echo $* | festival --tts
-fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl -w
-'di
-.ig 00
-';
-
-##############################################################################
-##
-## search
-##
-## Jeffrey Friedl (jfriedl@omron.co.jp), Dec 1994.
-## Copyright 19.... ah hell, just take it.
-## Ported to Win95 by Dan Schmidt (dfan@alum.mit.edu)
-##
-## BLURB:
-## A combo of find and grep -- more or less do a 'grep' on a whole
-## directory tree. Fast, with lots of options. Much more powerful than
-## the simple "find ... | xargs grep ....". Has a full man page.
-## Powerfully customizable. Emacs interface included.
-##
-## This file is big, but mostly comments and man page.
-##
-## See man page for usage info.
-## Return value: 2=error, 1=nothing found, 0=something found.
-##
-
-$version = "960908.11";
-## "960908.11"
-## Added -depth=0, 'cause I needed it.
-##
-## "960506.10"
-## Added -F/-R, and made it a bit more smart about $ and @ in arguments.
-##
-## "960426.9"
-## Sigh -- fixed a perl4 backward-compatabilty problem.
-## "960330.8"
-## Made $&-clean!
-## "960325.7"
-## Added the "filter" directive to the startup file so I could have
-## search automatically look inside compressed files.
-##
-## Implementation: slightly changed semantics with how EVALs are
-## removed from the inlined program.
-## "960227.6"
-## From Lionel Cons a few bug fixes and cool emacs interface:
-##
-## ``Also, I integrated search in Emacs so that I can use "M-x search"
-## and then "C-x `" to browse through the occurences (like grep).
-## Here is the code that I use:
-##
-## (defun search (dir what) "Run search with all grep goodies."
-## (interactive "DSearch under: \nsSearch for: ")
-## (setq default-directory
-## (if (string-match "/$" dir) dir (concat dir "/")))
-## (compile-internal (concat "search -n " what)
-## "No more search hits" "grep" nil grep-regexp-alist))
-## "951019.5"
-## Add color stuff (-bold, -red, etc...)
-## Fix up nroff stuff to work with groff
-## "950918.4 1/2";
-## Changed all 'sysread' to 'read' because Linux perl's don't seem
-## to like sysread()
-## "941227.4"
-## Added -n, -u
-## "941222.3"
-## Added -nice (due to Lionel Cons <Lionel.Cons@cern.ch>)
-## Removed any leading "./" from name.
-## Added default flags for ~/.search, including TTY, -nice, -list, etc.
-## Program name now has path removed when printed in diagnostics.
-## Added simple tilde-expansion to -dir arg.
-## Added -dskip, etc. Fixed -iregex bug.
-## Changed -dir to be additive, adding -ddir.
-## Now screen out devices, pipes, and sockets.
-## More tidying and lots of expanding of the man page
-## "941217.2";
-## initial release.
-
-$stripped=0;
-
-&init;
-$rc_file = join('/', $ENV{'HOME'}, ".search");
-
-&check_args;
-
-## Make sure we've got a regex.
-## Don't need one if -find or -showrc was specified.
-$!=2, die "expecting regex arguments.\n"
- if $FIND_ONLY == 0 && $showrc == 0 && @ARGV == 0;
-
-&prepare_to_search($rc_file);
-
-&import_program if !defined &dodir; ## BIG key to speed.
-
-## do search while there are directories to be done.
-&dodir(shift(@todo)) while @todo;
-
-&clear_message if $VERBOSE && $STDERR_IS_TTY;
-exit($retval);
-###############################################################################
-
-sub init
-{
- ## initialize variables that might be reset by command-line args
- $DOREP=0; ## set true by -dorep (redo multi-hardlink files)
- $DO_SORT=0; ## set by -sort (sort files in a dir before checking)
- $FIND_ONLY=0; ## set by -find (don't search files)
- $LIST_ONLY=0; ## set true by -l (list filenames only)
- $NEWER=0; ## set by -newer, "-mtime -###"
- $NICE=0; ## set by -nice (print human-readable output)
- $NOLINKS=0; ## set true by -nolinks (don't follow symlinks)
- $OLDER=0; ## set by -older, "-mtime ###"
- $PREPEND_FILENAME=1; ## set false by -h (don't prefix lines with filename)
- $REPORT_LINENUM=0; ## set true by -n (show line numbers)
- $VERBOSE=0; ## set to a value by -v, -vv, etc. (verbose messages)
- $WHY=0; ## set true by -why, -vvv+ (report why skipped)
- $XDEV=0; ## set true by -xdev (stay on one filesystem)
- $all=0; ## set true by -all (don't skip many kinds of files)
- $iflag = ''; ## set to 'i' by -i (ignore case);
- $norc=0; ## set by -norc (don't load rc file)
- $showrc=0; ## set by -showrc (show what happens with rc file)
- $underlineOK=0; ## set true by -u (watch for underline stuff)
- $words=0; ## set true by -w (match whole-words only)
- $MARK=''; ## set by -bold (-red, etc.). Does ANSI markup.
- $literal=0; ## set by -F -- "regex" args taken as literal strings
- $retval=1; ## will set to 0 if we find anything.
- $DESCEND_SUBDIRECTORIES=1;## set to false by -depth=0
-
- $WINDOWS=0; ## under windows?
- $USE_INODES=1; ## are inodes valid?
-
- ## various elements of stat() that we might access
- $STAT_DEV = 1;
- $STAT_INODE = 2;
- $STAT_MTIME = 9;
-
- $VV_PRINT_COUNT = 50; ## with -vv, print every VV_PRINT_COUNT files, or...
- $VV_SIZE = 1024*1024; ## ...every VV_SIZE bytes searched
- $vv_print = $vv_size = 0; ## running totals.
-
- ## set default options, in case the rc file wants them
- $opt{'TTY'}= 1 if -t STDOUT;
-
- ## want to know this for debugging message stuff
- $STDERR_IS_TTY = -t STDERR ? 1 : 0;
- $STDERR_SCREWS_STDOUT = ($STDERR_IS_TTY && -t STDOUT) ? 1 : 0;
-
- $0 =~ s,.*/,,; ## clean up $0 for any diagnostics we'll be printing.
-}
-
-##
-## Check arguments.
-##
-sub check_args
-{
- while (@ARGV && $ARGV[0] =~ m/^-/)
- {
- $arg = shift(@ARGV);
-
- if ($arg eq '-version' || ($VERBOSE && $arg eq '-help')) {
- print qq/Jeffrey\'s file search, version "$version".\n/;
- exit(0) unless $arg eq '-help';
- }
- if ($arg eq '-help') {
- print <<INLINE_LITERAL_TEXT;
-usage: $0 [options] [-e] [PerlRegex ....]
-OPTIONS TELLING *WHERE* TO SEARCH:
- -dir DIR start search at the named directory (default is current dir).
- -xdev stay on starting file system.
- -sort sort the files in each directory before processing.
- -nolinks don\'t follow symbolic links.
- -depth=0 don\'t descend into subdirectories
-OPTIONS TELLING WHICH FILES TO EVEN CONSIDER:
- -mtime # consider files modified > # days ago (-# for < # days old)
- -newer FILE consider files modified more recently than FILE (also -older)
- -name GLOB consider files whose name matches pattern (also -regex).
- -skip GLOB opposite of -name: identifies files to not consider.
- -path GLOB like -name, but for files whose whole path is described.
- -dpath/-dregex/-dskip versions for selecting or pruning directories.
- -all don\'t skip any files marked to be skipped by the startup file.
- -x<SPECIAL> (see manual, and/or try -showrc).
- -why report why a file isn\'t checked (also implied by -vvvv).
-OPTIONS TELLING WHAT TO DO WITH FILES THAT WILL BE CONSIDERED:
- -f | -find just list files (PerlRegex ignored). Default is to grep them.
- -ff | -ffind Does a faster -find (implies -find -all -dorep)
-OPTIONS CONTROLLING HOW THE SEARCH IS DONE (AND WHAT IS PRINTED):
- -F | -lit "regex" args taken as literal strings (like fgrep)
- -R | -regex undoes -F -- regex ares really are perl regexes
- -l | -list only list files with matches, not the lines themselves.
- -nice | -nnice print more "human readable" output.
- -bold | -red mark found items (various colors supported)
- -n prefix each output line with its line number in the file.
- -h don\'t prefix output lines with file name.
- -u also look "inside" manpage-style underlined text
- -i do case-insensitive searching.
- -w match words only (as defined by perl\'s \\b).
-OTHER OPTIONS:
- -v, -vv, -vvv various levels of message verbosity.
- -e end of options (in case a regex looks like an option).
- -showrc show what the rc file sets, then exit.
- -norc don\'t load the rc file.
- -dorep check files with multiple hard links multiple times.
- -win necessary if running under Windows 95.
-INLINE_LITERAL_TEXT
- print "Use -v -help for more verbose help.\n" unless $VERBOSE;
- print "This script file is also a man page.\n" unless $stripped;
- print <<INLINE_LITERAL_TEXT if $VERBOSE;
-
-If -f (or -find) given, PerlRegex is optional and ignored.
-Otherwise, will search for files with lines matching any of the given regexes.
-
-Combining things like -name and -mtime implies boolean AND.
-However, duplicating things (such as -name '*.c' -name '*.txt') implies OR.
-
--mtime may be given floating point (i.e. 1.5 is a day and a half).
--iskip/-idskip/-ipath/... etc are case-insensitive versions.
-
-If any letter in -newer/-older is upper case, "or equal" is
-inserted into the test.
-
-You can always find the latest version on the World Wide Web in
- http://www.wg.omron.co.jp/~jfriedl/perl/
-INLINE_LITERAL_TEXT
- exit(0);
- }
- $DOREP=1, next if $arg eq '-dorep'; ## do repeats
- $DO_SORT=1, next if $arg eq '-sort'; ## sort files
- $NOLINKS=1, next if $arg eq '-nolinks'; ## no sym. links
- $PREPEND_FILENAME=0, next if $arg eq '-h'; ## no filename prefix
- $REPORT_LINENUM=1, next if $arg eq '-n'; ## show line numbers
- $WHY=1, next if $arg eq '-why'; ## tell why skipped
- $XDEV=1, next if $arg eq '-xdev'; ## don't leave F.S.
- $all=1,$opt{'-all'}=1,next if $arg eq '-all'; ## don't skip *.Z, etc
- $iflag='i', next if $arg eq '-i'; ## ignore case
- $iflag='', next if $arg eq '-noi'; ## don't ignore case
- $norc=1, next if $arg eq '-norc'; ## don't load rc file
- $showrc=1, next if $arg eq '-showrc'; ## show rc file
- $underlineOK=1, next if $arg eq '-u'; ## look throuh underln.
- $words=1, next if $arg eq '-w'; ## match "words" only
- $literal=1, next if $arg eq '-F'; ## args are literal
- $literal=1, next if $arg eq '-lit'; ## args are literal
- $literal=0, next if $arg eq '-R'; ## args are regexes
- $literal=0, next if $arg eq '-regex'; ## args are regexes
- &strip if $arg eq '-strip'; ## dump this program
- last if $arg eq '-e';
-
- $mark = '\e[7m', next if $arg eq '-bold'; ## embold found items]
- $mark = '\e[30m', next if $arg eq '-black'; ## embold found items]
- $mark = '\e[31m', next if $arg eq '-red'; ## embold found items]
- $mark = '\e[32m', next if $arg eq '-green'; ## embold found items]
- $mark = '\e[33m', next if $arg eq '-yellow'; ## embold found items]
- $mark = '\e[34m', next if $arg eq '-blue'; ## embold found items]
- $mark = '\e[36m', next if $arg eq '-cyan'; ## embold found items]
- $mark = '\e[37m', next if $arg eq '-white'; ## embold found items]
-
- $FIND_ONLY=1, next if $arg =~/^-f(ind)?$/;## do "find" only
-
- $FIND_ONLY=1, $DOREP=1, $all=1,
- next if $arg =~/^-ff(ind)?$/;## fast -find
- $LIST_ONLY=1,$opt{'-list'}=1,
- next if $arg =~/^-l(ist)?$/;## only list files
-
- $WINDOWS=1, $USE_INODES=0, $DOREP=1,
- next if $arg eq '-win'; ## running under Windows
-
-
- if ($arg =~ m/^-depth=(\d+)$/) {
- die qq/$0: only -depth of 0 currently supported\n/ if $1 != 0;
- $DESCEND_SUBDIRECTORIES=0;
- next;
- }
-
- if ($arg =~ m/^-(v+)$/) { ## verbosity
- $VERBOSE =length($1);
- foreach $len (1..$VERBOSE) { $opt{'-'.('v' x $len)}=1 }
- next;
- }
- if ($arg =~ m/^-(n+)ice$/) { ## "nice" output
- $NICE =length($1);
- foreach $len (1..$NICE) { $opt{'-'.('n' x $len).'ice'}=1 }
- next;
- }
-
- if ($arg =~ m/^-(i?)(d?)skip$/) {
- local($i) = $1 eq 'i';
- local($d) = $2 eq 'd';
- $! = 2, die qq/$0: expecting glob arg to -$arg\n/ unless @ARGV;
- foreach (split(/\s+/, shift @ARGV)) {
- if ($d) {
- $idskip{$_}=1 if $i;
- $dskip{$_}=1;
- } else {
- $iskip{$_}=1 if $i;
- $skip{$_}=1;
- }
- }
- next;
- }
-
-
- if ($arg =~ m/^-(i?)(d?)(regex|path|name)$/) {
- local($i) = $1 eq 'i';
- $! = 2, die qq/$0: expecting arg to -$arg\n/ unless @ARGV;
- foreach (split(/\s+/, shift @ARGV)) {
- $iname{join(',', $arg, $_)}=1 if $i;
- $name{join(',', $arg, $_)}=1;
- }
- next;
- }
-
- if ($arg =~ m/^-d?dir$/) {
- $opt{'-dir'}=1;
- $! = 2, die qq/$0: expecting filename arg to -$arg\n/ unless @ARGV;
- $start = shift(@ARGV);
- $start =~ s#^~(/+|$)#$ENV{'HOME'}$1# if defined $ENV{'HOME'};
- $! = 2, die qq/$0: can\'t find ${arg}\'s "$start"\n/ unless -e $start;
- $! = 2, die qq/$0: ${arg}\'s "$start" not a directory.\n/ unless -d _;
- undef(@todo), $opt{'-ddir'}=1 if $arg eq '-ddir';
- push(@todo, $start);
- next;
- }
-
- if ($arg =~ m/^-(new|old)er$/i) {
- $! = 2, die "$0: expecting filename arg to -$arg\n" unless @ARGV;
- local($file, $time) = shift(@ARGV);
- $! = 2, die qq/$0: can\'t stat -${arg}\'s "$file"./
- unless $time = (stat($file))[$STAT_MTIME];
- local($upper) = $arg =~ tr/A-Z//;
- if ($arg =~ m/new/i) {
- $time++ unless $upper;
- $NEWER = $time if $NEWER < $time;
- } else {
- $time-- unless $upper;
- $OLDER = $time if $OLDER == 0 || $OLDER > $time;
- }
- next;
- }
-
- if ($arg =~ m/-mtime/) {
- $! = 2, die "$0: expecting numerical arg to -$arg\n" unless @ARGV;
- local($days) = shift(@ARGV);
- $! = 2, die qq/$0: inappropriate arg ($days) to $arg\n/ if $days==0;
- $days *= 3600 * 24;
- if ($days < 0) {
- local($time) = $^T + $days;
- $NEWER = $time if $NEWER < $time;
- } else {
- local($time) = $^T - $days;
- $OLDER = $time if $OLDER == 0 || $OLDER > $time;
- }
- next;
- }
-
- ## special user options
- if ($arg =~ m/^-x(.+)/) {
- foreach (split(/[\s,]+/, $1)) { $user_opt{$_} = $opt{$_}= 1; }
- next;
- }
-
- $! = 2, die "$0: unknown arg [$arg]\n";
- }
- $DOMARK = defined($mark) ? 1 : 0;
-}
-
-##
-## Given a filename glob, return a regex.
-## If the glob has no globbing chars (no * ? or [..]), then
-## prepend an effective '*' to it.
-##
-sub glob_to_regex
-{
- local($glob) = @_;
- local(@parts) = $glob =~ m/\\.|[*?]|\[]?[^]]*]|[^[\\*?]+/g;
- local($trueglob)=0;
- foreach (@parts) {
- if ($_ eq '*' || $_ eq '?') {
- $_ = ".$_";
- $trueglob=1; ## * and ? are a real glob
- } elsif (substr($_, 0, 1) eq '[') {
- $trueglob=1; ## [..] is a real glob
- } else {
- s/^\\//; ## remove any leading backslash;
- s/(\W)/\\$1/g; ## now quote anything dangerous;
- }
- }
- unshift(@parts, '.*') unless $trueglob;
- join('', '^', @parts, q/$/);
-}
-
-sub prepare_to_search
-{
- local($rc_file) = @_;
-
- $HEADER_BYTES=0; ## Might be set nonzero in &read_rc;
- $last_message_length = 0; ## For &message and &clear_message.
-
- &read_rc($rc_file, $showrc) unless $norc;
- exit(0) if $showrc;
-
- $NEXT_DIR_ENTRY = $DO_SORT ? 'shift @files' : 'readdir(DIR)';
- $WHY = 1 if $VERBOSE > 3; ## Arg -vvvv or above implies -why.
- @todo = ('.') if @todo == 0; ## Where we'll start looking
-
- ## see if any user options were specified that weren't accounted for
- foreach $opt (keys %user_opt) {
- next if defined $seen_opt{$opt};
- warn "warning: -x$opt never considered.\n";
- }
-
- die "$0: multiple time constraints exclude all possible files.\n"
- if ($NEWER && $OLDER) && ($NEWER > $OLDER);
-
- ##
- ## Process any -skip/-iskip args that had been given
- ##
- local(@skip_test);
- foreach $glob (keys %skip) {
- $i = defined($iskip{$glob}) ? 'i': '';
- push(@skip_test, '$name =~ m/'. &glob_to_regex($glob). "/$i");
- }
- if (@skip_test) {
- $SKIP_TEST = join('||',@skip_test);
- $DO_SKIP_TEST = 1;
- } else {
- $DO_SKIP_TEST = $SKIP_TEST = 0;
- }
-
- ##
- ## Process any -dskip/-idskip args that had been given
- ##
- local(@dskip_test);
- foreach $glob (keys %dskip) {
- $i = defined($idskip{$glob}) ? 'i': '';
- push(@dskip_test, '$name =~ m/'. &glob_to_regex($glob). "/$i");
- }
- if (@dskip_test) {
- $DSKIP_TEST = join('||',@dskip_test);
- $DO_DSKIP_TEST = 1;
- } else {
- $DO_DSKIP_TEST = $DSKIP_TEST = 0;
- }
-
-
- ##
- ## Process any -name, -path, -regex, etc. args that had been given.
- ##
- undef @name_test;
- undef @dname_test;
- foreach $key (keys %name) {
- local($type, $pat) = split(/,/, $key, 2);
- local($i) = defined($iname{$key}) ? 'i' : '';
- if ($type =~ /regex/) {
- $pat =~ s/!/\\!/g;
- $test = "\$name =~ m!^$pat\$!$i";
- } else {
- local($var) = $type eq 'name' ? '$name' : '$file';
- $test = "$var =~ m/". &glob_to_regex($pat). "/$i";
- }
- if ($type =~ m/^-i?d/) {
- push(@dname_test, $test);
- } else {
- push(@name_test, $test);
- }
- }
- if (@name_test) {
- $GLOB_TESTS = join('||', @name_test);
-
- $DO_GLOB_TESTS = 1;
- } else {
- $GLOB_TESTS = $DO_GLOB_TESTS = 0;
- }
- if (@dname_test) {
- $DGLOB_TESTS = join('||', @dname_test);
- $DO_DGLOB_TESTS = 1;
- } else {
- $DGLOB_TESTS = $DO_DGLOB_TESTS = 0;
- }
-
- ##
- ## Process any 'magic' things from the startup file.
- ##
- if (@magic_tests && $HEADER_BYTES) {
- ## the $magic' one is for when &dodir is not inlined
- $tests = join('||',@magic_tests);
- $MAGIC_TESTS = "{ package magic; \$val = ($tests) }";
- $DO_MAGIC_TESTS = 1;
- } else {
- $MAGIC_TESTS = 1;
- $DO_MAGIC_TESTS = 0;
- }
-
- ##
- ## Prepare regular expressions.
- ##
- {
- local(@regex_tests);
- local(@mark_commands);
-
- if ($LIST_ONLY) {
- $mflag = '';
- ## need to have $* set, but perl5 just won't shut up about it.
- if ($] >= 5) {
- $mflag = 'm';
- } else {
- eval ' $* = 1 ';
- }
- }
-
- ##
- ## Until I figure out a better way to deal with it,
- ## We have to worry about a regex like [^xyz] when doing $LIST_ONLY.
- ## Such a regex *will* match \n, and if I'm pulling in multiple
- ## lines, it can allow lines to match that would otherwise not match.
- ##
- ## Therefore, if there is a '[^' in a regex, we can NOT take a chance
- ## and use the fast listonly.
- ##
- $CAN_USE_FAST_LISTONLY = $LIST_ONLY;
-
- local(@extra, $orig);
- local($underline_glue) = ($] >= 5) ? '(:?_\cH)?' : '(_\cH)?';
- while (@ARGV) {
- $regex = shift(@ARGV);
-
- if ($literal) {
- $orig = $regex if $literal;
- $regex =~ s/(\W)/\\$1/g; ## quote everything
- } else {
- ## try to be smart about a $ in the regex. If it looks
- ## like an end-of-line metacharacter, we'll leave it.
- ## Otherwise, escape it so that it has no variable
- ## substutition
- $regex =~ s/(.?)\$([^)|])/
- $1 eq '\\' ? $& : "$1\\\$$2"/eg; ## quote some $
- if ($] >= 5) {
- $regex =~ s/\@/\\@/g; ## quote @
- }
- }
- if ($DOMARK) {
- local($tmp) = $regex;
- $tmp =~ s,/,\/,g;
- $tmp = join($tmp, '\b(', ')\b') if $words;
- push(@mark_commands, "s/($tmp)/$mark\$1\e[m/g$iflag");
- }
-
- ##
- ## If watching for underlined things too, add another regex.
- ##
- if ($underlineOK) {
- if ($regex =~ m/[?*+{}()\\.|^\$[]/) {
- warn "$0: warning, can't underline-safe ``$regex''.\n";
- } else {
- $regex = join($underline_glue, split(//, $regex));
- }
- }
-
- ## If nothing special in the regex, just use index...
- ## is quite a bit faster.
- if (($iflag eq '') && ($words == 0) &&
- ($literal || $regex !~ m/[?*+{}()\\.|^\$[]/))
- {
- $regex = $orig if $literal;
- push(@regex_tests, "(index(\$_, q\001$regex\001)>=0)");
-
- } else {
- #$regex =~ s!([\$\@\/]\w)!\\$1!g;
- if ($words) {
- if ($regex =~ m/\|/) {
- ## could be dangerous -- see if we can wrap in parens.
- if ($regex =~ m/\\\d/) {
- warn "warning: -w and a | in a regex is dangerous.\n"
- } else {
- $regex = join($regex, '(', ')');
- }
- }
- $regex = join($regex, '\b', '\b');
- }
- $CAN_USE_FAST_LISTONLY = 0 if substr($regex, "[^") >= 0;
- push(@regex_tests, "m'$regex'$iflag$mflag");
- }
-
- ## If we're done, but still have @extra to do, get set for that.
- if (@ARGV == 0 && @extra) {
- @ARGV = @extra; ## now deal with the extra stuff.
- $underlineOK = 0; ## but no more of this.
- undef @extra; ## or this.
- }
- }
- if (@regex_tests) {
- $REGEX_TEST = join('||', @regex_tests);
- ## print STDERR $REGEX_TEST, "\n"; exit;
- } else {
- ## must be doing -find -- just give something syntactically correct.
- $REGEX_TEST = 1;
- }
-
- if ($DOMARK) {
- $MARK = join(';', @mark_commands);
- }
- }
-
- ##
- ## Make sure we can read the first item(s).
- ##
- foreach $start (@todo) {
- $! = 2, die qq/$0: can\'t stat "$start"\n/
- unless ($dev,$inode) = (stat($start))[$STAT_DEV,$STAT_INODE];
-
- if (defined $dir_done{"$dev,$inode"}) {
- ## ignore the repeat.
- warn(qq/ignoring "$start" (same as "$dir_done{"$dev,$inode"}").\n/)
- if $VERBOSE;
- next;
- }
-
- ## if -xdev was given, remember the device.
- $xdev{$dev} = 1 if $XDEV;
-
- ## Note that we won't want to do it again
- $dir_done{"$dev,$inode"} = $start;
- }
-}
-
-
-##
-## See the comment above the __END__ above the 'sub dodir' below.
-##
-sub import_program
-{
- sub bad {
- print STDERR "$0: internal error (@_)\n";
- exit 2;
- }
-
- ## Read from data, up to next __END__. This will be &dodir.
- local($/) = "\n__END__";
- $prog = <DATA>;
- close(DATA);
-
- ## Inline uppercase $-variables by their current values, removing
- ## any preceeding eval if applicable
- if ($] >= 5) {
- eval '
- $prog =~ s/(?:\beval\s*)?\$([A-Z][A-Z0-9_]{2,}\b)/
- &bad($1) if !defined ${$main::{$1}}; ${$main::{$1}};/eg;
- ';
- } else {
- $prog =~ s/(\beval\s*)?\$([A-Z][A-Z0-9_]{2,}\b)/local(*VAR) = $_main{$2};
- &bad($2) if !defined $VAR; $VAR;/eg;
- }
-
- eval $prog; ## now do it. This will define &dodir;
- $!=2, die "$0 internal error: $@\n" if $@;
-}
-
-###########################################################################
-
-##
-## Read the .search file:
-## Blank lines and lines that are only #-comments ignored.
-## Newlines may be escaped to create long lines
-## Other lines are directives.
-##
-## A directive may begin with an optional tag in the form <...>
-## Things inside the <...> are evaluated as with:
-## <(this || that) && must>
-## will be true if
-## -xmust -xthis or -xmust -xthat
-## were specified on the command line (order doesn't matter, though)
-## A directive is not done if there is a tag and it's false.
-## Any characters but whitespace and &|()>,! may appear after an -x
-## (although "-xdev" is special). -xmust,this is the same as -xmust -xthis.
-## Something like -x~ would make <~> true, and <!~> false.
-##
-## Directives are in the form:
-## filter: EXPR : "command"
-## option: STRING
-## magic : NUMBYTES : EXPR
-##
-## With option:
-## The STRING is parsed like a Bourne shell command line, and the
-## options are used as if given on the command line.
-## No comments are allowed on 'option' lines.
-## Examples:
-## # skip objects and libraries
-## option: -skip '.o .a'
-## # skip emacs *~ and *# files, unless -x~ given:
-## <!~> option: -skip '~ #'
-##
-## With magic:
-## EXPR can be pretty much any perl (comments allowed!).
-## If it evaluates to true for any particular file, it is skipped.
-## The only info you'll have about a file is the variable $H, which
-## will have at least the first NUMBYTES of the file (less if the file
-## is shorter than that, of course, and maybe more). You'll also have
-## any variables you set in previous 'magic' lines.
-## Examples:
-## magic: 6 : ($x6 = substr($H, 0, 6)) eq 'GIF87a'
-## magic: 6 : $x6 eq 'GIF89a'
-##
-## magic: 6 : (($x6 = substr($H, 0, 6)) eq 'GIF87a' ## old gif \
-## || $x6 eq 'GIF89a' ## new gif
-## (the above two sets are the same)
-## ## Check the first 32 bytes for "binarish" looking bytes.
-## ## Don't blindly dump on any high-bit set, as non-ASCII text
-## ## often has them set. \x80 and \xff seem to be special, though.
-## ## Require two in a row to not get things like perl's $^T.
-## ## This is known to get *.Z, *.gz, pkzip, *.elc and about any
-## ## executable you'll find.
-## magic: 32 : $H =~ m/[\x00-\x06\x10-\x1a\x1c-\x1f\x80\xff]{2}/
-##
-sub read_rc
-{
- local($file, $show) = @_;
- local($line_num, $ln, $tag) = 0;
- local($use_default, @default) = 0;
-
- { package magic; $\17 = 0; } ## turn off warnings for when we run EXPR's
-
- unless (open(RC, "$file")) {
- $use_default=1;
- $file = "<internal default startup file>";
- ## no RC file -- use this default.
- @default = split(/\n/,<<'--------INLINE_LITERAL_TEXT');
- magic: 32 : $H =~ m/[\x00-\x06\x10-\x1a\x1c-\x1f\x80\xff]{2}/
- filter: $N =~ m/\.(gz|Z)$/ : "zcat %"
- option: -skip '.a .COM .elc .EXE .o .pbm .xbm .dvi'
- option: -iskip '.tarz .zip .lzh .jpg .jpeg .gif .uu'
- <!~> option: -skip '~ #'
---------INLINE_LITERAL_TEXT
- }
-
- ##
- ## Make an eval error pretty.
- ##
- sub clean_eval_error {
- local($_) = @_;
- s/ in file \(eval\) at line \d+,//g; ## perl4-style error
- s/ at \(eval \d+\) line \d+,//g; ## perl5-style error
- s/\n[\x00-\xff]*//; ## remove all but first line
- "$_\n";
- }
-
- print "reading RC file: $file\n" if $show;
-
- while ($_ = ($use_default ? shift(@default) : <RC>)) {
- $ln = ++$line_num; ## note starting line num.
- $_ .= <RC>, $line_num++ while s/\\\n?$/\n/; ## allow continuations
- next if /^\s*(#.*)?$/; ## skip blank or comment-only lines.
- $do = '';
-
- ## look for an initial <...> tag.
- if (s/^\s*<([^>]*)>//) {
- ## This simple s// will make the tag ready to eval.
- ($tag = $msg = $1) =~
- s/([^\s&|(!)]+)/
- $seen_opt{$1}=1; ## note seen option
- "defined(\$opt{q>$1>})" ## (q>> is safe quoting here)
- /eg;
-
- ## see if the tag is true or not, abort this line if not.
- $dothis = (eval $tag);
- $!=2, die "$file $ln <$msg>: $_".&clean_eval_error($@) if $@;
-
- if ($show) {
- $msg =~ s/([^\s&|(!)]+)/-x$1/;
- $msg =~ s/\s*!\s*/ no /g;
- $msg =~ s/\s*&&\s*/ and /g;
- $msg =~ s/\s*\|\|\s*/ or /g;
- $msg =~ s/^\s+//; $msg =~ s/\s+$//;
- $do = $dothis ? "(doing because $msg)" :
- "(do if $msg)";
- } elsif (!$dothis) {
- next;
- }
- }
-
- if (m/^\s*filter\s*:(.*):\s*"(.*)\s*"\s*$/) {
- local($expr, $cmd) = ($1, $2);
- eval "local(\$^W) = 0; $expr; 1";
- die "$file $ln: ".&clean_eval_error($@) if $@;
- $filter_cmd{$expr} = $cmd;
- next;
- }
-
- if (m/^\s*option\s*:\s*(.*)/) {
- next if $all && !$show; ## -all turns off these checks;
- local($_) = $1;
- s/\n$//;
- local($orig) = $_;
- print " $do option: $_\n" if $show;
- local($0) = "$0 ($file)"; ## for any error message.
- local(@ARGV);
- local($this);
- ##
- ## Parse $_ as a Bourne shell line -- fill @ARGV
- ##
- while (length) {
- if (s/^\s+//) {
- push(@ARGV, $this) if defined $this;
- undef $this;
- next;
- }
- $this = '' if !defined $this;
- $this .= $1 while s/^\'([^\']*)\'// ||
- s/^\"([^\"]*)\"// ||
- s/^([^\'\"\s\\]+)//||
- s/^(\\[\D\d])//;
- die "$file $ln: error parsing $orig at $_\n" if m/^\S/;
- }
- push(@ARGV, $this) if defined $this;
- &check_args;
- die qq/$file $ln: unused arg "@ARGV".\n/ if @ARGV;
- next;
- }
-
- if (m/^\s*magic\s*:\s*(\d+)\s*:\s*(.*)/) {
- next if $all && !$show; ## -all turns off these checks;
- local($bytes, $check) = ($1, $2);
-
- if ($show) {
- $check =~ s/\n?$/\n/;
- print " $do contents: $check";
- }
- ## Check to make sure the thing at least compiles.
- eval "package magic; (\$H = '1'x \$main'bytes) && (\n$check\n)\n";
- $! = 2, die "$file $ln: ".&clean_eval_error($@) if $@;
-
- $HEADER_BYTES = $bytes if $bytes > $HEADER_BYTES;
- push(@magic_tests, "(\n$check\n)");
- next;
- }
- $! = 2, die "$file $ln: unknown command\n";
- }
- close(RC);
-}
-
-sub message
-{
- if (!$STDERR_IS_TTY) {
- print STDERR $_[0], "\n";
- } else {
- local($text) = @_;
- $thislength = length($text);
- if ($thislength >= $last_message_length) {
- print STDERR $text, "\r";
- } else {
- print STDERR $text, ' 'x ($last_message_length-$thislength),"\r";
- }
- $last_message_length = $thislength;
- }
-}
-
-sub clear_message
-{
- print STDERR ' ' x $last_message_length, "\r" if $last_message_length;
- $vv_print = $vv_size = $last_message_length = 0;
-}
-
-##
-## Output a copy of this program with comments, extra whitespace, and
-## the trailing man page removed. On an ultra slow machine, such a copy
-## might load faster (but I can't tell any difference on my machine).
-##
-sub strip {
- seek(DATA, 0, 0) || die "$0: can't reset internal pointer.\n";
- while(<DATA>) {
- print, next if /INLINE_LITERAL_TEXT/.../INLINE_LITERAL_TEXT/;
- ## must mention INLINE_LITERAL_TEXT on this line!
- s/\#\#.*|^\s+|\s+$//; ## remove cruft
- last if $_ eq '.00';
- next if ($_ eq '') || ($_ eq "'di'") || ($_ eq "'ig00'");
- s/\$stripped=0;/\$stripped=1;/;
- s/\s\s+/ /; ## squish multiple whitespaces down to one.
- print $_, "\n";
- }
- exit(0);
-}
-
-##
-## Just to shut up -w. Never executed.
-##
-sub dummy {
-
- 1 || &dummy || &dir_done || &bad || &message || $NEXT_DIR_ENTRY ||
- $VV_SIZE || $VV_PRINT_COUNT || $STDERR_SCREWS_STDOUT || @files ||
- @files || $magic'H || $magic'H || $magic'val || $magic'val ||
- $filter_cmd{1} || $xdev{''} || $MARK;
-
-}
-
-##
-## If the following __END__ is in place, what follows will be
-## inlined when the program first starts up. Any $ variable name
-## all in upper case, specifically, any string matching
-## \$([A-Z][A-Z0-9_]{2,}\b
-## will have the true value for that variable inlined. Also, any 'eval'
-## immediately preceeding one of the inlined variables is removed.
-##
-##
-## The idea is that when the whole thing is then eval'ed to define &dodir,
-## the perl optimizer will make all the decisions that are based upon
-## command-line options (such as $VERBOSE), since they'll be inlined as
-## constants
-##
-## Also, and here's the big win, the tests for matching the regex, and a
-## few others, are all inlined. Should be blinding speed here.
-##
-## See the read from <DATA> above for where all this takes place.
-## But all-in-all, you *want* the __END__ here. Comment it out only for
-## debugging....
-##
-
-__END__
-
-##
-## Given a directory, check all "appropriate" files in it.
-## Shove any subdirectories into the global @todo, so they'll be done
-## later.
-##
-## Be careful about adding any upper-case variables, as they are subject
-## to being inlined. See comments above the __END__ above.
-##
-sub dodir
-{
- local($dir) = @_;
- $dir =~ s,/+$,,; ## remove any trailing slash.
- unless (opendir(DIR, "$dir/.")) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- warn qq($0: can\'t opendir "$dir/".\n);
- return;
- }
-
- if ($VERBOSE) {
- &message($dir);
- $vv_print = $vv_size = 0;
- }
-
- @files = sort readdir(DIR) if $DO_SORT;
-
- while (defined($name = eval $NEXT_DIR_ENTRY))
- {
- next if $name eq '.' || $name eq '..'; ## never follow these.
-
- ## create full relative pathname.
- $file = $dir eq '.' ? $name : "$dir/$name";
-
- ## if link and skipping them, do so.
- if ($NOLINKS && -l $file) {
- warn qq/skip (symlink): $file\n/ if $WHY;
- next;
- }
-
- ## skip things unless files or directories
- unless (-f $file || -d _) {
- if ($WHY) {
- $why = (-S _ && "socket") ||
- (-p _ && "pipe") ||
- (-b _ && "block special")||
- (-c _ && "char special") || "somekinda special";
- warn qq/skip ($why): $file\n/;
- }
- next;
- }
-
- ## skip things we can't read
- unless (-r _) {
- if ($WHY) {
- $why = (-l $file) ? "follow" : "read";
- warn qq/skip (can\'t $why): $file\n/;
- }
- next;
- }
-
- ## skip things that are empty
- if (!$WINDOWS) { # -s fails for all dirs under Windows
- # or should we just put the -d test before this?
- unless (-s _) {
- warn qq/skip (empty): $file\n/ if $WHY;
- next;
- }
- }
-
- ## Note file device & inode. If -xdev, skip if appropriate.
- ($dev, $inode) = (stat(_))[$STAT_DEV, $STAT_INODE];
- if ($XDEV && defined $xdev{$dev}) {
- warn qq/skip (other device): $file\n/ if $WHY;
- next;
- }
- $id = "$dev,$inode" if $USE_INODES;
-
- ## special work for a directory
- if (-d _) {
- if ($DESCEND_SUBDIRECTORIES == 0) {
- warn qq/skip (-depth): $file\n/ if $WHY;
- next;
- }
-
- ## Do checks for directory file endings.
- if ($DO_DSKIP_TEST && (eval $DSKIP_TEST)) {
- warn qq/skip (-dskip): $file\n/ if $WHY;
- next;
- }
- ## do checks for -name/-regex/-path tests
- if ($DO_DGLOB_TESTS && !(eval $DGLOB_TESTS)) {
- warn qq/skip (dirname): $file\n/ if $WHY;
- next;
- }
-
- if ($USE_INODES)
- {
- ## _never_ redo a directory
- if (defined $dir_done{$id}) {
- warn qq/skip (did as "$dir_done{$id}"): $file\n/ if $WHY;
- next;
- }
- $dir_done{$id} = $file; ## mark it done.
- }
- unshift(@todo, $file); ## add to the list to do.
- next;
- }
- if ($WHY == 0 && $VERBOSE > 1) {
- if ($VERBOSE>2||$vv_print++>$VV_PRINT_COUNT||($vv_size+=-s _)>$VV_SIZE){
- &message($file);
- $vv_print = $vv_size = 0;
- }
- }
-
- ## do time-related tests
- if ($NEWER || $OLDER) {
- $_ = (stat(_))[$STAT_MTIME];
- if ($NEWER && $_ < $NEWER) {
- warn qq/skip (too old): $file\n/ if $WHY;
- next;
- }
- if ($OLDER && $_ > $OLDER) {
- warn qq/skip (too new): $file\n/ if $WHY;
- next;
- }
- }
-
- ## do checks for file endings
- if ($DO_SKIP_TEST && (eval $SKIP_TEST)) {
- warn qq/skip (-skip): $file\n/ if $WHY;
- next;
- }
-
- ## do checks for -name/-regex/-path tests
- if ($DO_GLOB_TESTS && !(eval $GLOB_TESTS)) {
- warn qq/skip (filename): $file\n/ if $WHY;
- next;
- }
-
-
- ## If we're not repeating files,
- ## skip this one if we've done it, or note we're doing it.
- unless ($DOREP) {
- if (defined $file_done{$id}) {
- warn qq/skip (did as "$file_done{$id}"): $file\n/ if $WHY;
- next;
- }
- $file_done{$id} = $file;
- }
-
- undef $filter;
- foreach $expr (keys %filter_cmd) {
- next unless eval "{ package filter; \$N = \$main'file; { $expr }}";
- $filter = $filter_cmd{$expr};
- $filter .= " $file" unless $filter =~ s/%/$file/g;
- last;
- }
-
- if ($DO_MAGIC_TESTS && !$filter) {
- if (!open(FILE_IN, $file)) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- warn qq/$0: can\'t open: $file\n/;
- next;
- }
- unless (read(FILE_IN, $magic'H, $HEADER_BYTES)) {#'
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- warn qq/$0: can\'t read from "$file"\n/;
- close(FILE_IN);
- next;
- }
-
- eval $MAGIC_TESTS;
- if ($magic'val) {#'
- close(FILE_IN);
- warn qq/skip (magic): $file\n/ if $WHY;
- next;
- }
- seek(FILE_IN, 0, 0); ## reset for later <FILE_IN>
- }
-
- if ($WHY != 0 && $VERBOSE > 1) {
- if ($VERBOSE>2||$vv_print++>$VV_PRINT_COUNT||($vv_size+=-s _)>$VV_SIZE){
- &message($file);
- $vv_print = $vv_size = 0;
- }
- }
-
-
- if ($FIND_ONLY) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- print $file, "\n";
- $retval=0; ## we've found something
- close(FILE_IN) if $DO_MAGIC_TESTS;
- next;
- } else {
- ## if we weren't doing magic tests, file won't be open yet...
- if ($filter) {
- if (!open(FILE_IN, "$filter|")) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- warn qq/$0: can\'t open filter: $filter\n/;
- next;
- }
- }elsif (!$DO_MAGIC_TESTS && !open(FILE_IN, $file)) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- warn qq/$0: can\'t open: $file\n/;
- next;
- }
- if ($LIST_ONLY && $CAN_USE_FAST_LISTONLY) {
- ##
- ## This is rather complex, but buys us a LOT when we're just
- ## listing files and not the individual internal lines.
- ##
- local($size) = 4096; ## block-size in which to do reads
- local($nl); ## will point to $_'s ending newline.
- local($read); ## will be how many bytes read.
- local($_) = ''; ## Starts out empty
- local($hold); ## (see below)
-
- while (($read = read(FILE_IN,$_,$size,length($_)))||length($_))
- {
- undef @parts;
- ## if read a full block, but no newline, need to read more.
- while ($read == $size && ($nl = rindex($_, "\n")) < 0) {
- push(@parts, $_); ## save that part
- $read = read(FILE_IN, $_, $size); ## keep trying
- }
-
- ##
- ## If we had to save parts, must now combine them together.
- ## adjusting $nl to reflect the now-larger $_. This should
- ## be a lot more efficient than using any kind of .= in the
- ## loop above.
- ##
- if (@parts) {
- local($lastlen) = length($_); #only need if $nl >= 0
- $_ = join('', @parts, $_);
- $nl = length($_) - ($lastlen - $nl) if $nl >= 0;
- }
-
- ##
- ## If we're at the end of the file, then we can use $_ as
- ## is. Otherwise, we need to remove the final partial-line
- ## and save it so that it'll be at the beginning of the
- ## next read (where the rest of the line will be layed in
- ## right after it). $hold will be what we should save
- ## until next time.
- ##
- if ($read != $size || $nl < 0) {
- $hold = '';
- } else {
- $hold = substr($_, $nl + 1);
- substr($_, $nl + 1) = '';
- }
-
- ##
- ## Now have a bunch of full lines in $_. Use it.
- ##
- if (eval $REGEX_TEST) {
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- print $file, "\n";
- $retval=0; ## we've found something
-
- last;
- }
-
- ## Prepare for next read....
- $_ = $hold;
- }
-
- } else { ## else not using faster block scanning.....
-
- $lines_printed = 0 if $NICE;
- while (<FILE_IN>) {
- study;
- next unless (eval $REGEX_TEST);
-
- ##
- ## We found a matching line.
- ##
- $retval=0;
- &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT;
- if ($LIST_ONLY) {
- print $file, "\n";
- last;
- } else {
- ## prepare to print line.
- if ($NICE && $lines_printed++ == 0) {
- print '-' x 70, "\n" if $NICE > 1;
- print $file, ":\n";
- }
-
- ##
- ## Print all the prelim stuff. This looks less efficient
- ## than it needs to be, but that's so that when the eval
- ## is compiled (and the tests are optimized away), the
- ## result will be less actual PRINTs than the more natural
- ## way of doing these tests....
- ##
- if ($NICE) {
- if ($REPORT_LINENUM) {
- print " line $.: ";
- } else {
- print " ";
- }
- } elsif ($REPORT_LINENUM && $PREPEND_FILENAME) {
- print "$file:$.: ";
- } elsif ($PREPEND_FILENAME) {
- print "$file: ";
- } elsif ($REPORT_LINENUM) {
- print "$.: ";
- }
- if ($DOMARK) { eval $MARK; }
- print $_;
- print "\n" unless m/\n$/;
- }
- }
- print "\n" if ($NICE > 1) && $lines_printed;
- }
- close(FILE_IN);
- }
- }
- closedir(DIR);
-}
-
-__END__
-.00
-
-'di
-.nr nl 0-1 \" fake up transition to first page again
-.nr % 0 \" start at page 1
-.\"__________________NORMAL_MAN_PAGE_BELOW_________________
-.ll +10n
-.TH search 1 "Dec 17, 1994"
-.SH SEARCH
-search \- search files (a'la grep) in a whole directory tree.
-.SH SYNOPSIS
-search [ grep-like and find-like options] [regex ....]
-.SH DESCRIPTION
-.I Search
-is more or less a combo of 'find' and 'grep' (although the regular
-expression flavor is that of the perl being used, which is closer to
-egrep's than grep's).
-
-.I Search
-does generally the same kind of thing that
-.nf
- find <blah blah> | xargs egrep <blah blah>
-.fi
-does, but is
-.I much
-more powerful and efficient (and intuitive, I think).
-
-This manual describes
-.I search
-as of version "960325.7".
-You can always find the latest version at
-.nf
- http://www.wg.omron.co.jp/~jfriedl/perl/index.html
-.fi
-
-.SH "QUICK EXAMPLE"
-Basic use is simple:
-.nf
- % search jeff
-.fi
-will search files in the current directory, and all sub directories, for
-files that have "jeff" in them. The lines will be listed with the
-containing file's name prepended.
-.PP
-If you list more than one regex, such as with
-.nf
- % search jeff Larry Randal+ 'Stoc?k' 'C.*son'
-.fi
-then a line containing any of the regexes will be listed.
-This makes it effectively the same as
-.nf
- % search 'jeff|Larry|Randal+|Stoc?k|C.*son'
-.fi
-However, listing them separately is much more efficient (and is easier
-to type).
-.PP
-Note that in the case of these examples, the
-.B \-w
-(list whole-words only) option would be useful.
-And if your terminal supports ANSI escape sequences, you can use
-.B \-bold
-to higlight the items found. Furthermore, if your display supports
-color as well, you can use
-.BR \-red ,
-.BR \-green ,
-.BR \-yellow ,
-etc. instead to have the searched items marked with the given color.
-.PP
-Normally, various kinds of files are automatically removed from consideration.
-If it has has a certain ending (such as ".tar", ".Z", ".o", .etc), or if
-the beginning of the file looks like a binary, it'll be excluded.
-You can control exactly how this works -- see below. One quick way to
-override this is to use the
-.B \-all
-option, which means to consider all the files that would normally be
-automatically excluded.
-Or, if you're curious, you can use
-.B \-why
-to have notes about what files are skipped (and why) printed to stderr.
-
-.SH "BASIC OVERVIEW"
-Normally, the search starts in the current directory, considering files in
-all subdirectories.
-
-You can use the
-.I ~/.search
-file to control ways to automatically exclude files.
-If you don't have this file, a default one will kick in, which automatically
-add
-.nf
- -skip .o .Z .gif
-.fi
-(among others) to exclude those kinds of files (which you probably want to
-skip when searching for text, as is normal).
-Files that look to be be binary will also be excluded.
-
-Files ending with "#" and "~" will also be excluded unless the
-.B -x~
-option is given.
-
-You can use
-.B -showrc
-to show what kinds of files will normally be skipped.
-See the section on the startup file
-for more info.
-
-You can use the
-.B -all
-option to indicate you want to consider all files that would otherwise be
-skipped by the startup file.
-
-Based upon various other flags (see "WHICH FILES TO CONSIDER" below),
-more files might be removed from consideration. For example
-.nf
- -mtime 3
-.fi
-will exclude files that aren't at least three days old (change the 3 to -3
-to exclude files that are more than three days old), while
-.nf
- -skip .*
-.fi
-would exclude any file beginning with a dot (of course, '.' and '..' are
-special and always excluded).
-
-If you'd like to see what files are being excluded, and why, you can get the
-list via the
-.B \-why
-option.
-
-If a file makes it past all the checks, it is then "considered".
-This usually means it is greped for the regular expressions you gave
-on the command line.
-
-If any of the regexes match a line, the line is printed.
-However, if
-.B -list
-is given, just the filename is printed. Or, if
-.B -nice
-is given, a somewhat more (human-)readable output is generated.
-
-If you're searching a huge tree and want to keep informed about how
-the search is progressing,
-.B -v
-will print (to stderr) the current directory being searched.
-Using
-.B -vv
-will also print the current file "every so often", which could be useful
-if a directory is huge. Using
-.B -vvv
-will print the update with every file.
-
-Below is the full listing of options.
-
-.SH "OPTIONS TELLING *WHERE* TO SEARCH"
-.TP
-.BI -dir " DIR"
-Start searching at the named directory instead of the current directory.
-If multiple
-.B -dir
-arguments are given, multiple trees will be searched.
-.TP
-.BI -ddir " DIR"
-Like
-.B -dir
-except it flushes any previous
-.B -dir
-directories (i.e. "-dir A -dir B -dir C" will search A, B, and C, while
-"-dir A -ddir B -dir C" will search only B and C. This might be of use
-in the startup file (see that section below).
-.TP
-.B -xdev
-Stay on the same filesystem as the starting directory/directories.
-.TP
-.B -sort
-Sort the items in a directory before processing them.
-Normally they are processed in whatever order they happen to be read from
-the directory.
-.TP
-.B -nolinks
-Don't follow symbolic links. Normally they're followed.
-.TP
-.B -depth=0
-Don't descend into subdirectories. Only a depth of 0 currently supported.
-.SH "OPTIONS CONTROLLING WHICH FILES TO CONSIDER AND EXCLUDE"
-.TP
-.BI -mtime " NUM"
-Only consider files that were last changed more than
-.I NUM
-days ago
-(less than
-.I NUM
-days if
-.I NUM
-has '-' prepended, i.e. "-mtime -2.5" means to consider files that
-have been changed in the last two and a half days).
-.TP
-.B -older FILE
-Only consider files that have not changed since
-.I FILE
-was last changed.
-If there is any upper case in the "-older", "or equal" is added to the sense
-of the test. Therefore, "search -older ./file regex" will never consider
-"./file", while "search -Older ./file regex" will.
-
-If a file is a symbolic link, the time used is that of the file and not the
-link.
-.TP
-.BI -newer " FILE"
-Opposite of
-.BR -older .
-.TP
-.BI -name " GLOB"
-Only consider files that match the shell filename pattern
-.IR GLOB .
-The check is only done on a file's name (use
-.B -path
-to check the whole path, and use
-.B -dname
-to check directory names).
-
-Multiple specifications can be given by separating them with spaces, a'la
-.nf
- -name '*.c *.h'
-.fi
-to consider C source and header files.
-If
-.I GLOB
-doesn't contain any special pattern characters, a '*' is prepended.
-This last example could have been given as
-.nf
- -name '.c .h'
-.fi
-It could also be given as
-.nf
- -name .c -name .h
-.fi
-or
-.nf
- -name '*.c' -name '*.h'
-.fi
-or
-.nf
- -name '*.[ch]'
-.fi
-(among others)
-but in this last case, you have to be sure to supply the leading '*'.
-.TP
-.BI -path " GLOB"
-Like
-.B -name
-except the entire path is checked against the pattern.
-.TP
-.B -regex " REGEX"
-Considers files whose names (not paths) match the given perl regex
-exactly.
-.TP
-.BI -iname " GLOB"
-Case-insensitive version of
-.BR -name .
-.TP
-.BI -ipath " GLOB"
-Case-insensitive version of
-.BR -path .
-.TP
-.BI -iregex " REGEX"
-Case-insensitive version of
-.BR -regex .
-
-.TP
-.BI -dpath " GLOB"
-Only search down directories whose path matches the given pattern (this
-doesn't apply to the initial directory given by
-.BI -dir ,
-of course).
-Something like
-.nf
- -dir /usr/man -dpath /usr/man/man*
-.fi
-would completely skip
-"/usr/man/cat1", "/usr/man/cat2", etc.
-.TP
-.BI -dskip " GLOB"
-Skips directories whose name (not path) matches the given pattern.
-Something like
-.nf
- -dir /usr/man -dskip cat*
-.fi
-would completely skip any directory in the tree whose name begins with "cat"
-(including "/usr/man/cat1", "/usr/man/cat2", etc.).
-.TP
-.BI -dregex " REGEX"
-Like
-.BI -dpath ,
-but the pattern is a full perl regex. Note that this quite different
-from
-.B -regex
-which considers only file names (not paths). This option considers
-full directory paths (not just names). It's much more useful this way.
-Sorry if it's confusing.
-.TP
-.BI -dpath " GLOB"
-This option exists, but is probably not very useful. It probably wants to
-be like the '-below' or something I mention in the "TODO" section.
-.TP
-.BI -idpath " GLOB"
-Case-insensitive version of
-.BR -dpath .
-.TP
-.BI -idskip " GLOB"
-Case-insensitive version of
-.BR -dskip .
-.TP
-.BI -idregex " REGEX"
-Case-insensitive version of
-.BR -dregex .
-.TP
-.B -all
-Ignore any 'magic' or 'option' lines in the startup file.
-The effect is that all files that would otherwise be automatically
-excluded are considered.
-.TP
-.BI -x SPECIAL
-Arguments starting with
-.B -x
-(except
-.BR -xdev ,
-explained elsewhere) do special interaction with the
-.I ~/.search
-startup file. Something like
-.nf
- -xflag1 -xflag2
-.fi
-will turn on "flag1" and "flag2" in the startup file (and is
-the same as "-xflag1,flag2"). You can use this to write your own
-rules for what kinds of files are to be considered.
-
-For example, the internal-default startup file contains the line
-.nf
- <!~> option: -skip '~ #'
-.fi
-This means that if the
-.B -x~
-flag is
-.I not
-seen, the option
-.nf
- -skip '~ #'
-.fi
-should be done.
-The effect is that emacs temp and backup files are not normally
-considered, but you can included them with the -x~ flag.
-
-You can write your own rules to customize
-.I search
-in powerful ways. See the STARTUP FILE section below.
-.TP
-.B -why
-Print a message (to stderr) when and why a file is not considered.
-
-.SH "OPTIONS TELLING WHAT TO DO WITH FILES THAT WILL BE CONSIDERED"
-.TP
-\fB-find\fP or \fB-b\fP
-This option changes the basic action of
-.IR search .
-
-Normally, if a file is considered, it is searched
-for the regular expressions as described earlier. However, if this option
-is given, the filename is printed and no searching takes place. This turns
-.I search
-into a 'find' of some sorts.
-
-In this case, no regular expressions are needed on the command line
-(any that are there are silently ignored).
-
-This is not intended to be a replacement for the 'find' program,
-but to aid
-you in understanding just what files are getting past the exclusion checks.
-If you really want to use it as a sort of replacement for the 'find' program,
-you might want to use
-.B -all
-so that it doesn't waste time checking to see if the file is binary, etc
-(unless you really want that, of course).
-
-If you use
-.BR -find ,
-none of the "GREP-LIKE OPTIONS" (below) matter.
-
-As a replacement for 'find',
-.I search
-is probably a bit slower (or in the case of GNU find, a lot slower --
-GNU find is
-.I unbelievably
-fast).
-However, "search -ffind"
-might be more useful than 'find' when options such as
-.B -skip
-are used (at least until 'find' gets such functionality).
-.TP
-\fB-ffind\fP or \fB-ff\fP
-A faster more 'find'-like find. Does
-.nf
- -find -all -dorep
-.fi
-.SH "GREP-LIKE OPTIONS"
-These options control how a searched file is accessed,
-and how things are printed.
-.TP
-\fB-F\fP or \fB-lit\fP
-Causes arguments to be taken as literal text rather than as perl regular
-expressions.
-.TP
-\fB-R\fP or \fB-regex\fP
-Undoes
-.BR -T .
-Regex arguments are indeed taken as perl regular expressions.
-.TP
-.B -i
-Ignore letter case when matching.
-.TP
-.B -noi
-Don't ignore letter case when matching (useful for overriding a
-.B -i
-in the startup file)
-.TP
-.B -w
-Consider only whole-word matches ("whole word" as defined by perl's "\\b"
-regex).
-.TP
-.B -u
-If the regex(es) is/are simple, try to modify them so that they'll work
-in manpage-like underlined text (i.e. like _^Ht_^Hh_^Hi_^Hs).
-This is very rudimentary at the moment.
-.TP
-\fB-list\fP or \fB-l\fP
-.B -list
-Don't print matching lines, but the names of files that contain matching
-lines. This will likely be *much* faster, as special optimizations are
-made -- particularly with large files.
-.TP
-.B -n
-Pepfix each line by its line number.
-.TP
-.B -nice
-Not a grep-like option, but similar to
-.BR -list ,
-so included here.
-.B -nice
-will have the output be a bit more human-readable, with matching lines printed
-slightly indented after the filename, a'la
-.nf
-
- % search foo
- somedir/somefile: line with foo in it
- somedir/somefile: some food for thought
- anotherdir/x: don't be a buffoon!
- %
-
-.fi
-will become
-.nf
-
- % search -nice foo
- somedir/somefile:
- line with foo in it
- some food for thought
- anotherdir/x:
- don't be a buffoon!
- %
-
-.fi
-This option due to Lionel Cons.
-.TP
-.B -nnice
-Be a bit nicer than
-.BR -nice .
-Prefix each file's output by a rule line, and follow with an extra blank line.
-.TP
-.B -h
-Don't prepend each output line with the name of the file
-(meaningless when
-.B -find
-or
-.B -l
-are given).
-
-.SH "OPTIONS WHICH INDICATE HOW TO DISPLAY"
-In addition to the
-.B \-nice
-and
-.B \-nnice
-from just above, you can use the following if your display supports
-ANSI escape sequences (most systems seem to).
-.TP
-.B \-bold
-Show the found items in reverse video.
-.TP
-.B \-red
-Show the found items in red.
-.TP
-.B \-green
-Show the found items in green.
-.TP
-.B \-yellow
-Show the found items in yellow.
-.TP
-.B \-blue
-Show the found items in blue.
-.TP
-.B \-cyan
-Show the found items in cyan.
-.TP
-.B \-white
-Show the found items in white.
-.TP
-.B \-black
-Show the found items in black.
-
-.SH "OTHER OPTIONS"
-.TP
-.B -help
-Print the usage information.
-.TP
-.B -version
-Print the version information and quit.
-.TP
-.B -v
-Set the level of message verbosity.
-.B -v
-will print a note whenever a new directory is entered.
-.B -vv
-will also print a note "every so often". This can be useful to see
-what's happening when searching huge directories.
-.B -vvv
-will print a new with every file.
-.B -vvvv
-is
--vvv
-plus
-.BR -why .
-.TP
-.B -e
-This ends the options, and can be useful if the regex begins with '-'.
-.TP
-.B -showrc
-Shows what is being considered in the startup file, then exits.
-.TP
-.B -dorep
-Normally, an identical file won't be checked twice (even with multiple
-hard or symbolic links). If you're just trying to do a fast
-.BR -find ,
-the bookkeeping to remember which files have been seen is not desirable,
-so you can eliminate the bookkeeping with this flag.
-
-.SH "STARTUP FILE"
-When
-.I search
-starts up, it processes the directives in
-.IR ~/.search .
-If no such file exists, a default
-internal version is used.
-
-The internal version looks like:
-.nf
-
- magic: 32 : $H =~ m/[\ex00-\ex06\ex10-\ex1a\ex1c-\ex1f\ex80\exff]{2}/
- filter: $N =~ m/\.(gz|Z)$/ : "zcat %"
- option: -skip '.a .COM .elc .EXE .o .pbm .xbm .dvi'
- option: -iskip '.tarz .zip .lzh .jpg .jpeg .gif .uu'
- <!~> option: -skip '~ #'
-
-.fi
-If you wish to create your own "~/.search",
-you might consider copying the above, and then working from there.
-
-There are three kinds of directives in a startup file: "filter", "magic"
-and "option".
-
-.RS 0n
-.TP
-OPTION
-Option lines will automatically do the command-line options given.
-For example, the line
-.nf
- option: -v
-.fi
-in you startup file will turn on -v every time, without needing to type it
-on the command line.
-
-The text on the line after the "option:" directive is processed
-like the Bourne shell, so make sure to pay attention to quoting.
-.nf
- option: -skip .exe .com
-.fi
-will give an error (".com" by itself isn't a valid option), while
-.nf
- option: -skip ".exe .com"
-.fi
-will properly include it as part of -skip's argument.
-
-.TP
-MAGIC
-Magic lines are used to determine if a file should be considered a binary
-or not (the term "magic" refers to checking a file's magic number). These
-are described in more detail below.
-
-.TP
-FILTER
-Filter lines are used to apply a command to a file to get the text to search.
-The format of a
-.B FILTER
-line is:
-.nf
- filter : EXPRESSION: "command...."
-.fi
-where
-.I EXPRESSION
-is a perl expression used to determine if the filter should be applied to a
-given file (the file's name will be in the variable $N, but remember that
-files excluded via
-.BR -skip ,
-etc., won't even be considered for a filter). If true, the
-.I COMMAND
-will be executed and its standard-output will be checked. ``\fB%\fP'' in the
-command string will be replace by the filename.
-
-The most common example would be to uncompress a file on the fly, i.e.
-.nf
- filter: $N =~ m/\.(gz|Z)$/ : "zcat %"
-.fi
-Note that had the ``\fBzcat\fP'' been ``\fBgunzip\fP'' instead, you'd
-uncompress your files in place instead of searching them, so take care when
-specifying a filter! If you're worried about mixing up GNU'z zcat with
-an old one, you might use seperate ones as with:
-.nf
- filter: $N =~ m/\.gz$/ : "/my/GNU/binaries/zcat %"
- filter: $N =~ m/\.Z$/ : "/the/non-GNU/binaries/zcat %"
-.fi
-
-Also note that when a filter is applied, the
-.B MAGIC
-section is ignored for the file (this can be considered a bug, so it might
-change in the future).
-
-.RE
-
-Blank lines and comments (lines beginning with '#') are allowed.
-
-If a line begins with <...>, then it's a check to see if the
-directive on the line should be done or not. The stuff inside the <...>
-can contain perl's && (and), || (or), ! (not), and parens for grouping,
-along with "flags" that might be indicated by the user with
-.BI -x flag
-options.
-
-For example, using "-xfoo" will cause "foo" to be true inside the <...>
-blocks. Therefore, a line beginning with "<foo>" would be done only when
-"-xfoo" had been specified, while a line beginning with "<!foo>" would be
-done only when "-xfoo" is not specified (of course, a line without any <...>
-is done in either case).
-
-A realistic example might be
-.nf
- <!v> -vv
-.fi
-This will cause -vv messages to be the default, but allow "-xv" to override.
-
-There are a few flags that are set automatically:
-.RS
-.TP
-.B TTY
-true if the output is to the screen (as opposed to being redirected to a file).
-You can force this (as with all the other automatic flags) with -xTTY.
-.TP
-.B -v
-True if -v was specified. If -vv was specified, both
-.B -v
-and
-.B -vv
-flags are true (and so on).
-.TP
-.B -nice
-True if -nice was specified. Same thing about -nnice as for -vv.
-.PP
-.TP
-.B -list
-true if -list (or -l) was given.
-.TP
-.B -dir
-true if -dir was given.
-.RE
-
-Using this info, you might change the last example to
-.nf
-
- <!v && !-v> option: -vv
-
-.fi
-The added "&& !-v" means "and if the '-v' option not given".
-This will allow you to use "-v" alone on the command line, and not
-have this directive add the more verbose "-vv" automatically.
-
-.RS 0
-Some other examples:
-.TP
-<!-dir && !here> option: -dir ~/
-Effectively make the default directory your home directory (instead of the
-current directory). Using -dir or -xhere will undo this.
-.TP
-<tex> option: -name .tex -dir ~/pub
-Create '-xtex' to search only "*.tex" files in your ~/pub directory tree.
-Actually, this could be made a bit better. If you combine '-xtex' and '-dir'
-on the command line, this directive will add ~/pub to the list, when you
-probably want to use the -dir directory only. You could do
-.nf
-
- <tex> option: -name .tex
- <tex && !-dir> option: -dir ~/pub
-.fi
-
-to will allow '-xtex' to work as before, but allow a command-line "-dir"
-to take precedence with respect to ~/pub.
-.TP
-<fluff> option: -nnice -sort -i -vvv
-Combine a few user-friendly options into one '-xfluff' option.
-.TP
-<man> option: -ddir /usr/man -v -w
-When the '-xman' option is given, search "/usr/man" for whole-words
-(of whatever regex or regexes are given on the command line), with -v.
-.RE
-
-The lines in the startup file are executed from top to bottom, so something
-like
-.nf
-
- <both> option: -xflag1 -xflag2
- <flag1> option: ...whatever...
- <flag2> option: ...whatever...
-
-.fi
-will allow '-xboth' to be the same as '-xflag1 -xflag2' (or '-xflag1,flag2'
-for that matter). However, if you put the "<both>" line below the others,
-they will not be true when encountered, so the result would be different
-(and probably undesired).
-
-The "magic" directives are used to determine if a file looks to be binary
-or not. The form of a magic line is
-.nf
- magic: \fISIZE\fP : \fIPERLCODE\fP
-.fi
-where
-.I SIZE
-is the number of bytes of the file you need to check, and
-.I PERLCODE
-is the code to do the check. Within
-.IR PERLCODE ,
-the variable $H will hold at least the first
-.I SIZE
-bytes of the file (unless the file is shorter than that, of course).
-It might hold more bytes. The perl should evaluate to true if the file
-should be considered a binary.
-
-An example might be
-.nf
- magic: 6 : substr($H, 0, 6) eq 'GIF87a'
-.fi
-to test for a GIF ("-iskip .gif" is better, but this might be useful
-if you have images in files without the ".gif" extension).
-
-Since the startup file is checked from top to bottom, you can be a bit
-efficient:
-.nf
- magic: 6 : ($x6 = substr($H, 0, 6)) eq 'GIF87a'
- magic: 6 : $x6 eq 'GIF89a'
-.fi
-You could also write the same thing as
-.nf
- magic: 6 : (($x6 = substr($H, 0, 6)) eq 'GIF87a') || ## an old gif, or.. \e
- $x6 eq 'GIF89a' ## .. a new one.
-.fi
-since newlines may be escaped.
-
-The default internal startup file includes
-.nf
- magic: 32 : $H =~ m/[\ex00-\ex06\ex10-\ex1a\ex1c-\ex1f\ex80\exff]{2}/
-.fi
-which checks for certain non-printable characters, and catches a large
-number of binary files, including most system's executables, linkable
-objects, compressed, tarred, and otherwise folded, spindled, and mutilated
-files.
-
-Another example might be
-.nf
- ## an archive library
- magic: 17 : substr($H, 0, 17) eq "!<arch>\en__.SYMDEF"
-.fi
-
-.SH "RETURN VALUE"
-.I Search
-returns zero if lines (or files, if appropriate) were found,
-or if no work was requested (such as with
-.BR -help ).
-Returns 1 if no lines (or files) were found.
-Returns 2 on error.
-
-.SH TODO
-Things I'd like to add some day:
-.nf
- + show surrounding lines (context).
- + highlight matched portions of lines.
- + add '-and', which can go between regexes to override
- the default logical or of the regexes.
- + add something like
- -below GLOB
- which will examine a tree and only consider files that
- lie in a directory deeper than one named by the pattern.
- + add 'warning' and 'error' directives.
- + add 'help' directive.
-.fi
-.SH BUGS
-If -xdev and multiple -dir arguments are given, any file in any of the
-target filesystems are allowed. It would be better to allow each filesystem
-for each separate tree.
-
-Multiple -dir args might also cause some confusing effects. Doing
-.nf
- -dir some/dir -dir other
-.fi
-will search "some/dir" completely, then search "other" completely. This
-is good. However, something like
-.nf
- -dir some/dir -dir some/dir/more/specific
-.fi
-will search "some/dir" completely *except for* "some/dir/more/specific",
-after which it will return and be searched. Not really a bug, but just sort
-of odd.
-
-File times (for -newer, etc.) of symbolic links are for the file, not the
-link. This could cause some misunderstandings.
-
-Probably more. Please let me know.
-.SH AUTHOR
-Jeffrey Friedl, Omron Corp (jfriedl@omron.co.jp)
-.br
-http://www.wg.omron.co.jp/cgi-bin/j-e/jfriedl.html
-
-.SH "LATEST SOURCE"
-See http://www.wg.omron.co.jp/~jfriedl/perl/index.html
+++ /dev/null
-#!/usr/bin/perl
-# sepdate utility
-# usage: sepdate [month date year]
-# where day month year are date of interest -- default is today
-
-# Adapted and updated from a version attributed to Rich Holmes
-
-use Time::Local;
-use POSIX qw(strftime);
-
-if ($#ARGV == 2) {
- $todmon = $ARGV[0]-1;
- $todday = $ARGV[1];
- $todyr = $ARGV[2];
- $todti = timelocal(0, 0, 0, $todday, $todmon, $todyr);
-} elsif ($#ARGV == -1) { $todti = time;
-} else { die;
-}
-
-$septime = timelocal(0, 0, 0, 31, 7, 93);
-
-$tdiff = $todti - $septime;
-$days = int ($tdiff / (60 * 60 * 24));
-
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-
-# this seems like overkill
-$tzstr = strftime("%Z", $sec, $min, $hour, $mday, $mon, $year);
-printf ("%3s Sep %2d %2.2d:%2.2d:%2.2d %3s 1993\n",
- (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday],
- $days,$hour,$min,$sec,$tzstr);
+++ /dev/null
-#!/usr/bin/env ruby
-require 'date'
-print Time.now.strftime("%a Sep #{Date.today-Date.new(1993,8,31)} %H:%M:%S %Z 1993\n")
+++ /dev/null
-#!/bin/sh
-# echo "Endless September"
-echo $(((`date +%s` - 746748000) / 86400)). September 1993
+++ /dev/null
-#!/bin/bash
-# Filename: twebgal
-# Purpose: create a tiny webgallery using CSS-features
-# Authors: Wolfgang Scheicher <worf@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-# Defaults
-DISPLAY_GEOMETRY=640x480
-THUMBNAIL_GEOMETRY=150x150
-PREVIEW_GEOMETRY=250x250
-THUMBNAIL_QUALITY=75
-
-PARENT_DIR="Ãœbergeordnetes Verzeichnis"
-
-PATH=$PATH:/usr/X11R6/bin:/usr/bin
-DATADIR=".tmp"
-LOG=".tmp/log"
-VERBOSE="/dev/null"
-OPTS=$*
-OLDIFS=$IFS
-IFS="
-"
-
-THUMBNAILS=("$DISPLAY_GEOMETRY" "$THUMBNAIL_GEOMETRY")
-FILE_EXTENSIONS=("jpg" "png" "gif")
-REQUIRED=("jpegtran" "convert" "identify" "find" "tr" "sed" "awk" "grep")
-
-##############################################################
-
-create_sample_config () {
-# sample config with some default values
-#
-if [ -f description ] ; then
- DST=/dev/stdout
- echo "description file allready exists!"
-else
- echo "creating example description file"
- DST="./description"
-fi
-echo -e "# Gallery Config File\n#
-# Title for this Directory
-TITLE=\"${PWD##*/}\"\n
-# Optional Comment
-COMMENT=\"\"\n
-# this parameters affect the dir list in the parent directory:
-# thumbnail to show
-THUMB=\"$(find_all_images | head -n 1 )\"\n
-# Index to sort dirs by.
-# You might want to use some date for chronological order
-INDEX=\"$(date +%F)\"\n" > $DST
-if [[ -z $STYLESHEET ]] ; then
-echo -e "# Stylesheet
-# This will be used for all subdirs as well
-STYLESHEET=\"stylesheet.css\"" >> $DST
-fi
-}
-
-##############################################################
-
-init_gallery () {
-# create datadir and check for required apps
-#
- mkdir -p ${DATADIR}
- echo -n "" > ${LOG}
- for app in "${REQUIRED[@]}" ; do
- if which $app 2>/dev/null >/dev/null ; then
- true
- else
- echo "ERROR: $app not found!"
- exit;
- fi
- done
- if [[ -f description ]] ; then source "description"; fi
- STYLESHEET=$( find_stylesheet )
-}
-
-parent_dir () {
-# adds a "../ if it is not a absolute path or a url"
-# otherwise returns the same string again
- if [[ "${1::1}" == "/" ]] ; then
- echo "$1"
- elif [[ "${1::7}" == "http://" ]] ; then
- echo "$1"
- elif [[ ! -z $1 ]] ; then
- echo "../${1}"
- fi
-}
-
-find_stylesheet () {
-# searches parent dirs recursively for a stylesheet
-# until it reaches the root dir
- if [[ -f description ]] ; then source "description"; fi
- if [[ -z $STYLESHEET ]] ; then
- if [[ ! "$PWD" == "/" ]] ; then
- cd ..
- parent_dir $( find_stylesheet )
- fi
- else
- echo $STYLESHEET
- fi
-}
-
-##############################################################
-
-find_all_images() {
-# returns a list of all (supported) Images in the current dir
-#
- for ext in "${FILE_EXTENSIONS[@]}" ; do
- find *.${ext} -maxdepth 0 2> /dev/null
- done
-}
-
-find_all_dirs() {
-# Searches all dirs and lists them,
-# sorted by the INDEX field in the description file
-#
- DIRS="$(find * -maxdepth 0 -type d)"
- for DIR in $DIRS ; do
- ( INDEX="_"
- if [[ -f ${DIR}/description ]] ; then source "${DIR}/description"; fi
- echo "${INDEX} ${DIR}" )
- done | sort | sed -e "s/^\S*\s//"
-}
-
-##############################################################
-
-prune() {
-# deletes old thumbnails and html files
-# temporarily creates a filelist
-#
- if [[ "$RECURSIVE" == "true" ]] ; then
- ALL_DIRS=( $(find_all_dirs) )
- for DIR in "${ALL_DIRS[@]}"; do
- ( IFS=$OLDIFS && cd "$DIR" && $0 $OPTS ; )
- done
- fi
- echo "-> ${PWD}"
- if [[ -d "${DATADIR}" ]] ; then
- find_all_images > "${DATADIR}/filelist"
- for GEOMETRY in "${THUMBNAILS[@]}"; do
- (
- [[ -d "${DATADIR}/${GEOMETRY}" ]] &&
- cd "${DATADIR}/${GEOMETRY}" &&
- find_all_images |
- awk 'NR==FNR {a[$0];next}
- !($0 in a)' ../filelist - |
- while read line ; do
- echo "rm ${DATADIR}/${GEOMETRY}/${line}"
- rm "${line}"
- done
- )
- done
- (
- cd "${DATADIR}/" &&
- find *.html -maxdepth 0 2> /dev/null |
- awk 'NR==FNR {a[$0];next}
- {sub(/\.html$/,"",$0)}
- !($0 in a)' filelist - |
- while read line ; do
- echo "rm ${DATADIR}/${line}.html"
- rm "${line}.html"
- done
- )
- rm "${DATADIR}/filelist"
- fi
-}
-
-##############################################################
-
-build_thumbnail() {
-# generates thumbnails
-# time of modification is set to that of the original and used
-# to check if existing thumbs need updating
-# orientation in the exif-header is used to rotate generated images
-#
- for GEOMETRY in "${THUMBNAILS[@]}"; do
- mkdir -p "$DATADIR/$GEOMETRY" || exit
- echo -ne "($GEOMETRY"
- DST="$DATADIR/$GEOMETRY/$FILE"
- SKIP=false
- if [[ -e $DST ]]; then
- if [[ $(stat -c "%Y" $FILE) == $(stat -c "%Y" $DST) ]]; then
- SKIP=true
- echo -n " skip"
- else
- echo -n " D"
- rm $DST
- fi
- else
- echo -n " "
- fi
-
- if [[ $SKIP == "false" ]]; then
- ORIENTATION=""
- ORIENTATION=$(identify -format "%[EXIF:Orientation]" "$FILE")
- if [[ "$ORIENTATION" == "6" ]]; then
- echo -n "TR"
- convert -quality $THUMBNAIL_QUALITY -rotate 90 -geometry "$GEOMETRY+0+0>" "$FILE" "$DST"
- elif [[ "$ORIENTATION" == "8" ]]; then
- echo -n "TL"
- convert -quality $THUMBNAIL_QUALITY -rotate 270 -geometry "$GEOMETRY+0+0>" "$FILE" "$DST"
- else
- echo -n "T "
- convert -quality $THUMBNAIL_QUALITY -geometry "$GEOMETRY+0+0>" "$FILE" "$DST"
- fi
- if [[ "${FILE##*.}" == "jpg" ]]; then
- echo -n "O"
- jpegtran -copy none -optimize -progressive "$DST" > "$DST.tmp"
- mv -f "$DST.tmp" "$DST"
- else
- echo -n " "
- fi
- touch -m --reference=$FILE $DST
- fi
- echo -n ") "
- done
-}
-
-build_html() {
-# generates the HTML
-
- echo -n "(html"
-
- THUMBGEOMETRY=$(identify -format "%wx%h" "$DATADIR/$THUMBNAIL_GEOMETRY/${FILE}")
- THUMBWIDTH=${THUMBGEOMETRY%x*}
- THUMBHEIGHT=${THUMBGEOMETRY#*x}
-
- THUMBT=$(((156 - $THUMBHEIGHT )/2 ))
- THUMBB=$(((157 - $THUMBHEIGHT )/2 ))
- THUMBL=$(((156 - $THUMBWIDTH )/2 ))
- THUMBR=$(((157 - $THUMBWIDTH )/2 ))
-
- TITLE=$FILE
- COMMENT=$(identify -format "%c" "${FILE}" | tr '\n' ' ')
- THUMBNAIL=$DATADIR/$THUMBNAIL_GEOMETRY/${FILE}
- THIS_HTML=$DATADIR/${FILE}.html
-
- html_header > ${THIS_HTML}
-
-echo "<div class=\"gallerynav\">
-${FILE}
-<a href=\"../index.html\">Index</a> <a href=\"${LAST}.html\"><<<</a> ${CURRENT}/${IMAGE_COUNT} <a href=\"${NEXT}.html\">>>></a>
-</div>
-
-<div class=\"cont\">
-<center>
-<a href=\"../${FILE}\"><img alt=\"${DISPLAY_GEOMETRY}/${FILE}\" src=\"${DISPLAY_GEOMETRY}/${FILE}\" /></a>
-</center><br />
-" >> $THIS_HTML
-
-identify -format "<table>
-<tr><td>Auflösung:</td><td>%wx%h</td></tr>
-<tr><td>Dateigröße:</td><td>%b</td></tr>
-<tr><td>Camera:</td><td>%[EXIF:Model]</td></tr>
-<tr><td>Datum/Zeit:</td><td>%[EXIF:DateTime]</td></tr>
-<tr><td>Kommentar:</td><td>%c</td></tr>
-</table>" ${FILE} >> $THIS_HTML
-
-echo "</div>" >> $THIS_HTML
-html_foot >> $THIS_HTML
-
-echo "<a href=\"$THIS_HTML\"><img alt=\"Thumbnail\" src=\"$THUMBNAIL\" style=\"width:${THUMBWIDTH}px; height:${THUMBHEIGHT}px; margin: ${THUMBT}px ${THUMBR}px ${THUMBB}px ${THUMBL}px;\" title=\"${COMMENT}\" /><br />$FILE</a>" >> index.html
-
-echo -en ")"
-}
-
-##############################################################
-
-start_index () {
-# generates the upper part of the index page
-# containing the list of subdirs
-# which are recursively processed from here too
-#
- TITLE="${TITLE=${PWD##*/}}"
- html_header > index.html
- echo "<div class=\"cont\">" >> index.html
- echo "<h1>${TITLE}</h1>" >> index.html
- echo "<ul>" >> index.html
- echo "<li class=\"back\"><b><a href=\"../index.html\">${PARENT_DIR}</a></b></li>" >> index.html
- ALL_DIRS=( $(find_all_dirs) )
- for DIR in "${ALL_DIRS[@]}"; do
- ( TITLE="${DIR}"; THUMB=""; INDEX=""; COMMENT=""
- if [[ -f ${DIR}/description ]] ; then source "${DIR}/description"; fi
- echo "<li class=\"dir\"><a class=\"tooltip\" href=\"${DIR}/index.html\"><b>${TITLE}</b>" >> index.html
-
- if [[ ! "${THUMB}${COMMENT}" == "" ]]; then
- if [[ "${COMMENT}" == "" ]]; then
- echo "<span><table><tr><td><img alt=\"Thumbnail\" src=\"${DIR}/${DATADIR}/thumb.${THUMB##*.}\" /></tr></table></span>" >> index.html
- elif [[ "${THUMB}" == "" ]]; then
- echo "<span><table><tr><td>${COMMENT}</td></tr></table></span>" >> index.html
- else
- echo "<span><table><tr><td><img alt=\"Thumbnail\" src=\"${DIR}/${DATADIR}/thumb.${THUMB##*.}\" /></td><td></td><td></td><td>${COMMENT}</td></tr></table></span>" >> index.html
- fi
- fi
- echo "</a></li>" >> index.html
- if [[ "$RECURSIVE" == "true" ]] ; then
- ( STYLESHEET="$(parent_dir ${STYLESHEET})"
- IFS=$OLDIFS && cd "$DIR" && $0 $OPTS ; )
- fi
- )
- done
-echo "
-</ul>
-${COMMENT}
-<div class=\"gallery\">
-<div class=\"spacer\"></div>
-" >> index.html
-}
-
-finish_index () {
-echo "
-<div class=\"spacer\"></div>
-</div>
-</div>
-" >> index.html
-html_foot >> index.html
-}
-
-##############################################################
-
-create_sample_stylesheet () {
-if [ -f stylesheet.css ] ; then
- echo "stylesheet.css allready exists!"
- exit 1
-fi
-cat << EOF > stylesheet.css
-a {text-decoration:none;}
-
-div.gallery img {border: 2px inset #aaa; margin:3px;}
-div.gallery a {color:#000; border: 2px outset #aaa; text-decoration:none; text-align:center; float:left; padding:3px; margin:4px; background-color:#ddd;}
-div.gallery a:hover {color:#333; border: 2px outset #ccc; background-color:#eee;}
-div.spacer {clear: both;}
-div.gallerynav {text-align: center; margin: 0px; padding:0em 0.3em 0em 0.3em;}
-
-a.tooltip, a.tooltip:link, a.tooltip:visited, a.tooltip:active { position: relative; }
-a.tooltip span {display: none}
-a:hover.tooltip span {display: block; position: absolute; top: 2.5em; left: 1.5em; z-index: 100; color: #000; padding: 3px; border:1px solid #000; background: #ffc; }
-EOF
-}
-
-##############################################################
-
-html_header () {
-echo "<html>
-<head>
-<title>${TITLE}</title>
-<link rel=\"stylesheet\" type=\"text/css\" href=\"${STYLESHEET}\" />
-</head>
-<body>
-"
-}
-
-html_foot () {
-echo "</body>
-</html>
-"
-}
-
-
-##############################################################
-
-build_gallery() {
-# generates the whole thing, puts everything together
-#
- ALL_IMAGES=( $(find_all_images) )
- IMAGE_COUNT=${#ALL_IMAGES[@]}
- start_index
- (
- STYLESHEET="$(parent_dir ${STYLESHEET})"
- echo "-> ${TITLE}"
- CURRENT="0"
- FILE="../index"
- for file in "${ALL_IMAGES[@]}" "../index" ; do
- NEXT="$file"
- if [[ "$FILE" != "../index" ]]; then
- echo -ne "$FILE\t"
- build_thumbnail
- build_html
- echo ""
- fi
- CURRENT="$(( ${CURRENT} + 1 ))"
- LAST="$FILE"
- FILE="$file"
- done
- if [[ ! -z "${THUMB}" ]] ; then
- echo -ne "preview thumbnail from ${THUMB}\t"
- THUMBNAILS=("$PREVIEW_GEOMETRY")
- FILE="${THUMB}"
- [ -e "${DATADIR}/thumb.${THUMB##*.}" ] && mv "${DATADIR}/thumb.${THUMB##*.}" "${DATADIR}/${PREVIEW_GEOMETRY}/${THUMB}"
- build_thumbnail &&
- mv "${DATADIR}/${PREVIEW_GEOMETRY}/${THUMB}" "${DATADIR}/thumb.${THUMB##*.}"
- echo
- fi
- ) | tee -a $LOG >> $VERBOSE
- finish_index
- echo " $IMAGE_COUNT Image(s) in ${TITLE}"
-}
-
-##############################################################
-
-init_gallery
-
-while getopts "vdsrp-:" OPT ; do
- case $OPT in
- v) VERBOSE=/dev/stdout
- ;;
- d) create_sample_config
- exit 0
- ;;
- s) create_sample_stylesheet
- exit 0
- ;;
- r) RECURSIVE="true"
- ;;
- p) prune
- exit 0
- ;;
- ?) # wrong argument
- echo -n "ERROR: Missing argument for option \"$OPTARG\". "
- exit 1
- ;;
- *) # wrong option
- echo -n "ERROR: Unknown option \"$OPTARG\". "
- exit 1
- ;;
- esac
-done
-shift $(($OPTIND -1))
-
-build_gallery 2>${DATADIR}/errors
-if [ -s ${DATADIR}/errors ]; then
- echo -e "\nWARNING: there were errors. see .tmp/errors"
-else
- rm .tmp/errors
-fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl
-# Filename: unbleach.pl
-# Purpose: for really dirty perl programs
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-# This script will replace all the unsighted unprintable characters bleached out of your source file by a:
-# use Acme::Bleach;
-# directive with elegant (perhaps) ASCII perl code.
-
-use strict;
-my $washing = pop or carp("Usage: unbleach.pl [file]\n");
-open white,"<$washing" or carp("Can't get $washing");
-local $/; $_=<white>;
-s/(.*)^\s*use\s+Acme::Bleach\s*;\n(?: \t){8}/$1/
-or carp("$washing is not bleached!");
-open line,">$washing" or carp("Can't dry $washing");
-print line out($_);
-sub out {s/\n//g;tr/ \t/01/;pack "b*",$_;}
-sub carp {print shift and exit}
-
-=head1 NAME
-
-unbleach.pl - For I<really> unclean programs
-
-=head1 SYNOPSIS
-
-unbleach.pl [file]
-
-=head1 DESCRIPTION
-
-This script will replace all the unsighted unprintable
-characters bleached out of your source file by a:
-
- use Acme::Bleach;
-
-directive with elegant (perhaps) ASCII perl code.
-
-It also removes the use bleach line when it rewrites
-the source code. The code continues to work exactly
-as it did before, but now looks like normal!
-
-=head1 DIAGNOSTICS
-
-=item C<Can't get '%s'>
-
-unbleach.pl could not read the source file.
-
-=item C<'%s' is not bleached!>
-
-unbleach.pl will only process files that have been
-previously bleached and have the expected format.
-
-=item C<Can't dry '%s'>
-
-unbleach.pl could not open the source file to modify it.
-
-=head1 SEE ALSO
-
-http://www.cpan.org/authors/id/DCONWAY/Acme-Bleach-1.12.tar.gz
-http://www.perlmonks.com
-
-=head1 AUTHOR
-
-not Damian Conway (as if you couldn't guess)
-
-=head1 COPYRIGHT
-
-Copyright (c) 2001, tachyon. All Rights Reserved.
-This script is free software. It may be used, redistributed
-and/or modified under the terms of the Perl Artistic License
-(see http://www.perl.com/perl/misc/Artistic.html)
+++ /dev/null
-#!/usr/bin/awk -f
-
-# /* 24.12.2004
-# urlgrep[.awk] v1 - print http|ftp|rstp|mms:// text entries in text
-# urlgrep [-v dup=[01]] [[+] regex] [! regex] [file|-] [files..]
-# no files specified = read from stdin
-# w/o files, read stdin
-
-# todo: doing hpfetch with v2 of this
-# todo: v2: multiple positive/negative regex support
-# todo: v2: recognition: http://blah.com/path) text
-
-# by xmb<xmb@skilled.ch> - localhack
-
-# 24.12.2004, 26.12.2004, 02.01.2005, 26.01.2005(rstp support)
-# 28.01.2005(grep like syntax and ! <notmatch>)
-# 09.02.2005(fixed args, others, renamed from httpgrep to urlgrep)
-# 12.02.2005(mms support), 28.02.2005(robustness update)
-# 07.03.2005(conf enhansements)
-# 24.03.2005(regex/gsub enh's, more cmd examples)
-# 01.05.2005(-- stop arg)
-# */
-
-# $ cp urlgrep.awk /usr/local/bin/urlgrep
-
-# $ urlgrep regex ! regex files
-# $ urlgrep '' file
-# $ urlgrep . file
-# $ curl -s www.blah.ch | urlgrep
-# $ wget -qO- www.microsoft.com | urlgrep [| xargs curl -sD-]
-# $ curl -s www.apple.com | urlgrep ! 200[25] +[^m]/$
-
-# $ curl -s http://e2e.serveftp.net/wee/ | urlgrep wmv$ | xargs -n1 mplayer
-# $
-
-## MMMM! example site aightgenossen.ch, play media files with max 3 mplayers@1p
-# $ wget xmb.ath.cx/threads.sh
-# $ . threads.sh ; threads_max=3
-# $ getwhile() { [[ ! $1 ]] && echo $last && return 1; last=$( curl -s $@ |
-# > urlgrep ) match=$( grep -E '(wm[av]|rm|mov|avi)$|^rtsp' ) && getwhile }
-# # v2 signal todo
-# curl -s aightgenossen.ch/index.php/m=multimedia
-# .. unfinished
-
-BEGIN {
- if (! dup && dup != "0") dup = 1 # filter duplicates, by default on
- if (! dup_domain && dup_domain != "0") dup_domain = 0 # filter duplicates
- # ^ by domain but show whole url matching first
- if (! show_dom_only && show_dom_only != "0") show_dom_only = 0 # show only
- # ^ the domain/host of the url
-
- # map env variables, accessable with URLGREP_ prefix
- # eg, NODUP is the env variable URLGREP_NODUP
- narg = split("\
- NODUP dup 0 \
- GREP grep . \
- NOGREP nogrep . \
- URL url . \
- DEBUG DEBUG .\
- DUP_DOMAIN dup_domain . \
- DOMAIN_ONLY domain_only .\
- ", Args)
-
- for (arg = 1; arg <= narg; arg++)
- if (ENVIRON[ Args[i] ]) {
- if (Args[i+2] == ".") CONF[ Args[i+1] ] = ENVIRON[ Args[i] ]
- else CONF[ Args[i+1] ] = Args[i+2]
-
- i += 2
- }
-
- # argument parsing, this uses quite some CPU, gah, fixed
- while (ARGV[++i]) {
- #if (i == 1 || ARGV[i] ~ /^\+/) grep = get_arg(i)
- #if (ARGV[i] ~ /^!/) nogrep = get_arg(i)
-
- if (ARGV[i] ~ /^!/) CONF["nogrep"] = get_arg(i)
- else CONF["grep"] = get_arg(i)
-
- if (skip) { skip = 0; delete ARGV[i]; delete ARGV[++i] }
- else delete ARGV[i]
-
- if (ARGV[i + 1] !~ /^[+!-]/) break # stop after having enough regexes
- }
-
- if (CONF["grep"]) grep = CONF["grep"]
- if (CONF["nogrep"]) nogrep = CONF["grep"]
- if (CONF["url"]) url = CONF["url"]
- if (CONF["DEBUG"]) DEBUG = CONF["DEBUG"]
-
- #if (ENVIRON["URLGREP_NODUP"]) dup = 0
- #if (ENVIRON["URLGREP_GREP"]) grep = ENVIRON["URLGREP_GREP"]
- #if (ENVIRON["URLGREP_NOGREP"]) nogrep = ENVIRON["URLGREP_NOGREP"]
- #if (ENVIRON["URLGREP_URL"]) url = ENVIRON["URLGREP_URL"]
- #if (ENVIRON["URLGREP_DEBUG"]) DEBUG = ENVIRON["URLGREP_DEBUG"]
- #if (ENVIRON["URLGREP_QUOT"]) quote = ENVIRON["URLGREP_QUOT"]
- #if (ENVIRON["URLGREP_DUP_DOMAIN]) dup_domain = ENVIRON["URLGREP_DUP_DOMAIN"]
-
- err = "/dev/stderr"
- r_h = "(https?|ftp|rtsp|mms)://" # head(er)
- #r_h = "[a-zA-Z]+://"
- #r_m = r_h " ?['\"]?[^ \t'\"<>]+"
- r_m = r_h " *['\"]?[^ \t'\"<>]+\\.[^ \t'\"<>]+" # match
-
- if (DEBUG) printf "url = %s, match '%s', dont match '%s'\n",
- (url) ? url : "none", grep, nogrep >err
-}
-
-#DEBUG > 2 # small slowdown
-
-$0 ~ r_h {
- if (DEBUG > 1) print "LINE:", $0
- #while ($0 ~ r_h "[^\"'\t<][ \t]*[^ \t]+\\.") { # original way uses r_h
- while ($0 ~ r_m) {
- s = substr($0, match($0, r_m), RLENGTH)
- total++
- if (dup && ! Seen[s]++)
- _p(s)
- else if (! dup)
- _p(s)
- else
- found_dup++
- sub(r_m, "")
- }
-}
-
-END {
- fflush()
- if (! count) exit 3
- printf "urlgrep: %d total", total >err
- if (found_dup)
- printf ", %d printed, %d duplicates", count, found_dup >err
- if (found_dup + count < total)
- printf ", %d not matched", total - (found_dup + count) >err
- printf "\n" >err
- fflush()
-}
-
-# get either current or next arg
-function get_arg(p ,tmp) {
- if (ARGV[p] ~ /^[+!-]/) {
- if (length(ARGV[p]) > 1) {
- tmp = substr(ARGV[p], 2)
- sub(/^ */, "", tmp)
- return tmp
- } else {
- skip = 1
- return ARGV[p + 1]
- }
- } else
- return ARGV[p]
-}
-
-# main match/nomatch check & print function
-function _p(s) {
- if ((grep && s !~ grep) || nogrep && s ~ nogrep) return 1
-
- gsub(/[ \t'"]*/, "", s) # :;, are newly added # ;,
- if (quote) print "'" s "'" # small slowdown
- else
- print s
- count++
-}
+++ /dev/null
-#!/usr/bin/perl
-#
-# Reads /proc/bus/usb/devices and selectively lists and/or
-# interprets it.
-#
-# Originally written by Randy Dunlap.
-#
-
-$DEVFILENAME = "/proc/bus/usb/devices";
-$PROGNAME = $0;
-
-if (! open (DEVNUM, "<$DEVFILENAME"))
-{
- print "$PROGNAME: cannot open '$DEVFILENAME'\n";
- exit 1;
-}
-
-$showconfig = "yes";
-
-while ($line = <DEVNUM>) # read a text line from DEVNUM
-{
- # skip all lines except those we recognize:
- if (($line !~ "^C:") # Configuration: one is active
- && ($line !~ "^D:") # Device:
- && ($line !~ "^I:") # Interface: protocol group
- && ($line !~ "^S:") # String: used with root hub
- && ($line !~ "^T:") # Topology: starts each device
- )
- {
- next; # to the next line
- }
-
- chomp $line; # remove line endings
-
- # First convert '=' signs to spaces.
- $line =~ tr/=/ /;
-
- # and convert all '(' and ')' to spaces.
- $line =~ tr/(/ /;
- $line =~ tr/)/ /;
-
- # split the line at spaces.
- @fields = split / +/, $line;
-
- # T: Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
- if ($line =~ "^T:")
- {
- # split yields: $bus, $level, $parent, $port, $count, $devnum, $speed, $maxchild.
-
- $bus = @fields [2];
- $level = @fields [4];
- $parent = @fields [6]; # parent devnum
- $port = @fields [8] + 1; # make $port 1-based
- $count = @fields [10];
- $devnum = @fields [12];
- $speed = @fields [14];
- $maxchild = @fields [16];
- $devclass = "?";
- $intclass = "?";
- $driver = "?";
- $ifnum = "?";
- $showclass = "?"; # derived from $devclass or $intclass
- $lastif = "?"; # show only first altsetting
- $HCtype = "?";
- $showconfig = "no";
- $nconfig = "0";
- next;
- } # end T: line
-
- # only show the _active_ configuration
- # C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
- elsif ( $line =~ "^C:" ) {
- if ( $line =~ "^C:\\*" ) {
- $showconfig = @fields[4];
- } else {
- $showconfig = "no";
- }
- next;
- }
-
- # D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
- elsif ($line =~ "^D:")
- { # for D: line
- $devclass = @fields [5];
- $nconfig = @fields [13];
- next;
- }
-
- # in case this is a root hub, look at the device strings.
- # - S: Manufacturer:Linux 2.6.5 ehci_hcd [all 2.6]
- # - S: Product=USB UHCI Root Hub [all 2.4, 2.2]
- # - S: Product=OPTi Inc 82C861 [2.6/PCI_NAMES]
- elsif ( $line =~ "^S:" )
- { # for S: line
- if ( $level == 00 && $line =~ "hcd" )
- {
- $HCtype = @fields [4];
- }
- elsif ( $level == 00 && $line =~ "HCI" && $HCtype eq "?")
- {
- $HCtype = @fields [3];
- }
- next;
- }
-
- # the rest of this code:
- # - only shows interface descriptors
- # - for the active configuration
- # - for the first (prefer: active!) altsetting
- elsif ( ! ( $line =~ "^I:" )
- || "$showconfig" eq "no") {
- next;
- }
-
-
- # I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=hid
- $intclass = @fields [9];
- $ifnum = @fields [2];
- $driver = @fields [15];
-
- if (($devclass eq ">ifc") || ($devclass eq "unk."))
- { # then use InterfaceClass, not DeviceClass
- $showclass = $intclass;
- }
- else
- { # use DeviceClass
- $showclass = $devclass;
- }
-
- if ($level == 0)
- {
- # substitute real driver name
- if ( $HCtype =~ "UHCI-alt" )
- {
- $HC = "uhci";
- }
- elsif ( $HCtype =~ "UHCI" )
- {
- $HC = "usb-uhci";
- }
- elsif ( $HCtype =~ "OHCI" )
- {
- $HC = "usb-ohci";
- }
- else
- {
- $HC = $HCtype;
- }
-
- print sprintf ("/: Bus $bus.Port $port: Dev $devnum, Class=root_hub, Driver=%s/%sp, %sM\n",
- $HC, $maxchild, $speed );
- }
- elsif ($lastif ne $ifnum)
- {
- $temp = $level;
- while ($temp >= 1)
- {
- print " ";
- $temp--;
- }
-
- if ($nconfig ne "1") {
- $temp = " Cfg $showconfig/$nconfig";
- } else {
- $temp = "";
- }
-
- print sprintf ("|__ Port $port: Dev $devnum$temp, If $ifnum, Class=$showclass, Driver=$driver%s, %sM\n",
- ($maxchild == 0) ? "" : ("/" . $maxchild . "p"),
- $speed);
- $lastif = $ifnum;
- }
-} # end while DEVNUM
-
-close (DEVNUM);
-
-# END.
+++ /dev/null
-#!/usr/bin/perl -w
-#
-# wwwis: adds HEIGHT= and WIDTH= to images referenced in specified HTML file.
-#
-# for documentation - changelog and latest version
-# see http://www.bloodyeck.com/wwwis/
-#
-# this program by (and copyright) Alex Knowles, Alex@bloodyEck.com
-# based on original code and idea by Andrew Tong, werdna@ugcs.caltech.edu
-#
-# You may distribute this code under the GNU public license
-#
-# THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND.
-#
-# RCS $Id: wwwis,v 2.43 2004/12/02 18:32:13 ark Exp $
-
-use strict;
-use File::Copy;
-use Socket;
-# if you do not have these system libraries make sure you comment them out
-# and have the options UsePerlCp, searchURLS, TryServer ALL SET TO NO
-
-if( ! $\ ){
- # this stops the error Use of uninitialized value at .../File/Copy.pm line 84
- # print "Out rec sep not defined?? someone help me with this\n";
- $\='';
-}
-
-# this array specifies what options are available what the default
-# value is and also what type it is, files are checked to see if they
-# exist and the only possible values for choice are given.
-# you should only need to change the third column
-my(@options)=
- ('searchURLS', 'bool', 'Yes',
- 'DocumentRoot', 'file', '/usr/local/etc/httpd/htdocs',
- 'UserDir', 'string', 'html',
- 'MakeBackup', 'bool', 'Yes',
- 'BackupExtension', 'string', '~',
- 'OverwriteBackup', 'choice', 'Yes', 3, 'Yes','No','Ask',
- 'ChangeIfThere', 'choice', 'Yes', 4, 'Yes','No','Ask','Clever',
- 'Skip1x1', 'bool', 'Yes',
- 'SkipThreshold', 'integer', '0', # 0 disables this option
- 'DoChmodChown', 'bool', 'No',
- 'UpcaseTags', 'choice', 'No', 4, 'Yes','No','Upper','Lower',
- 'UpcaseNewTags', 'bool', 'No',
- 'TryServer', 'bool', 'Yes',
- 'QuoteNums', 'choice', 'No', 4, 'Yes','No','Single','Double',
- 'Munge%', 'bool', 'Yes',
- 'NeedAlt', 'bool', 'Yes',
- 'SkipCGI', 'bool', 'Yes',
- 'UseNewGifsize', 'bool', 'No',
- 'UseHash', 'bool', 'Yes',
- 'Base', 'string', '',
- 'InFilter', 'string', '',
- 'OutFilter', 'string', '',
- 'Quiet', 'bool', 'No',
- 'Script', 'string', '',
- 'Proxy', 'string', '',
- 'SkipFilter', 'string', '',
- 'IgnoreLinks', 'bool', 'Yes',
- 'UsePerlCp', 'bool', 'Yes',
- );
-
-#####################################################################
-######### YOU SHOULD NOT HAVE TO CHANGE ANYTHING BELOW HERE #########
-#####################################################################
-
-
-my($Base, $SkipCGI, $InFilter, $MakeBackup, $SearchURLS, $OverwriteBackup,
- $Proxy, $UseHash, $OutFilter, $UpcaseTags, $UpcaseNewTags,
- $UseNewGifsize, $debug,
- $Script, $UserDir, $TryServer, $DoChmodChown,$ChangeIfThere, $IgnoreLinks,
- $NeedAlt,$MungePer, $QuoteNums, $DocumentRoot,$BackupExtension, $Quiet,
- $UsePerlCp, $Skip1x1, $SkipThreshold, $SkipFilter );
-
-my( %hashx, %hashy );
-
-# O.K. now we have defined the options go and get them and set the global vars
-my(@optionval)=&GetConfigFile(@options);
-&SetGlobals();
-
-$|=1; # make it so that I can fit lots of info on one line...
-
-############################################################################
-# Main routine. processes all files specified on command line, skipping
-# any file for which a .bak file exists.
-############################################################################
-while (@ARGV) {
- my($FILE)=shift;
- if( $FILE =~ /^-/ ){
- &proc_arg($FILE);
- next;
- }
-
- print "$FILE -- ";
-
- if( -s $FILE && -T $FILE ){
- if ( -e "$FILE$BackupExtension"){
- if( &isfalse($OverwriteBackup) ){
- print "Skipping -- found $FILE$BackupExtension\n";
- next;
- } elsif ( $OverwriteBackup =~ /ASK/i ){
- print "overwite $FILE$BackupExtension [Yn]\n";
- $_=<STDIN>;
- if( /n/i ){
- print " - Skipping\n";
- next;
- }
- }
- }
- if ( -l $FILE and &istrue($IgnoreLinks) ){
- print "Skipping -- this file is a symbolic link\n";
- next;
- }
- print "Processing...\n";
- &convert($FILE);
- } else {
- print "Skipping -- Doesn't look like a text file to me!\n";
- next;
- }
-}
-
-# SetGlobals:
-# This converts the optionval array into global variables
-# this is cos I don't know how to store pointers to variables in arrys (sorry)
-sub SetGlobals
-{
- my($i)=0;
-
- $SearchURLS = $optionval[$i++];
- $DocumentRoot = $optionval[$i++];
- $UserDir = $optionval[$i++];
- $MakeBackup = $optionval[$i++];
- $BackupExtension = $optionval[$i++];
- $OverwriteBackup = $optionval[$i++];
- $ChangeIfThere = $optionval[$i++];
- $Skip1x1 = $optionval[$i++];
- $SkipThreshold = $optionval[$i++];
- $DoChmodChown = $optionval[$i++];
- $UpcaseTags = $optionval[$i++];
- $UpcaseNewTags = $optionval[$i++];
- $TryServer = $optionval[$i++];
- $QuoteNums = $optionval[$i++];
- $MungePer = $optionval[$i++];
- $NeedAlt = $optionval[$i++];
- $SkipCGI = $optionval[$i++];
- $UseNewGifsize = $optionval[$i++];
- $UseHash = $optionval[$i++];
- $Base = $optionval[$i++];
- $InFilter = $optionval[$i++];
- $OutFilter = $optionval[$i++];
- $Quiet = $optionval[$i++];
- $Script = $optionval[$i++];
- $Proxy = $optionval[$i++];
- $SkipFilter = $optionval[$i++];
- $IgnoreLinks = $optionval[$i++];
- $UsePerlCp = $optionval[$i++];
-
- # do a quick check just to see we got everything
- $i--;
- if( $i!=$#optionval ){
- print "Internal Error: number of options is not equal to globals!\n";
- print "Please Email alex\@ed.ac.uk for help\n";
- exit;
- }
-}
-
-###########################################################################
-# Subroutine does all the actual HTML parsing --- grabs image URLs and tells
-# other routines to open the images and get their size
-###########################################################################
-sub convert {
- my($file) = @_;
- my($ox,$oy,$nx,$ny);
- my($changed,$type,$tag,$five,$user,$original,@original);
- my($widthtag,$heighttag);
- my($HTMLbase,$i);
- my(@PATH,$REL,$rel);
-
- my($ino, $mode, $uid, $gid, $ngid, $nuid );
-
- $changed=0; # did we change this file
- $original=""; # the string containing the whole file
-
- $widthtag=&istrue($UpcaseNewTags)?"WIDTH":"width";
- $heighttag=&istrue($UpcaseNewTags)?"HEIGHT":"height";
-
-
- if( !open(ORIGINAL, $InFilter =~ /\S+/ ? "$InFilter $file|" : "<$file") ){
- print "Couldn't open $file\n";
- return;
- }
- while (<ORIGINAL>) {
- $original .= $_;
- }
- close (ORIGINAL);
- @PATH = split(/[\\\/]/, $file); # \\ for NT (brian_helterline@om.cv.hp.com)
- pop(@PATH);
- $REL = join("/", @PATH);
-
- # print out the header to the columns
- printf(" %s %-34s %-9s %-9s\n",'Type','File',' Old',' New') if (isfalse($Quiet));
-
- @original=split(/</, $original);
- for ($i=0; $i <= $#original; $i++) {
- # make the tags upper case if that's is what the user wants
- if( &istrue( $UpcaseTags) && $original[$i] !~ /^!--/ ){
- $original[$i]=&changecase($original[$i]);
- }
-
- if ($original[$i] =~ /^BASE\s+HREF\s*=\s*(\"[^\"]+\"|\'[^\']+\'|\S+)/i){ #"
- # we found a BASE tag this is quite important to us!
- $HTMLbase=&strip_quotes($1);
- print " BASE $HTMLbase\n" if (isfalse($Quiet));
- } elsif ($original[$i] =~
- /^((IMG|FIGURE|INPUT)\s+([^\000]*\s+)?SRC\s*=\s*(\"[^\"]+\"|\'[^\']+\'|\S+)[^\000]*)>/i){ #"
- # we found an IMG or FIGURE tag! this is really important
-
- # initialise some of my flags
- if( !defined($1) || !defined($2) || !defined($4) ){
- print " Couldn't find tagtype or images source for tag number $i!\n";
- return;
- }
- $tag=$1; # The whole HTML tag (with attributes)
- $type=$2; # this is either IMG or FIGURE
- $five=$4; # we put the SRC in a variable called five for historic reasons
- $five=&strip_quotes($five);
- $ox=0; $oy=0; # old X & Y values (Was Width & Height)
- $nx=0; $ny=0; # the new values
-
- printf(" %3s %-34s ",substr($type,0,3),$five) if (isfalse($Quiet));
-
- if(&istrue($SkipCGI) &&
- $five =~ /(\.(cgi|pl)$|\/cgi-bin\/|\/cgi\/)/ ){
- print "\"$file\": Skipping CGI program\n" if (isfalse($Quiet));
- next;
- }
- if( $SkipFilter && $five =~/$SkipFilter/i ){
- print "\"$file\": SkipFilter matched\n" if (isfalse($Quiet));
- next;
- }
-
- if( $tag =~ /(width|height)\s*=\s*[\"\']?\d+%/i ){ #"
- # we found a % sign near width or height
- if( ! &istrue($MungePer) ){
- print "\"$file\": Found % Skipping\n";
- next;
- }
- } else {
- $ox=$2 if( $tag =~ /\s*width\s*=\s*(\"|\')?(\d+)\s*/i ); #"
- $oy=$2 if( $tag =~ /\s*height\s*=\s*(\"|\')?(\d+)\s*/i ); #"
- }
-
- printf("(%3d,%3d) ",$ox,$oy) if (isfalse($Quiet));
-
- if( $ox && $oy && &isfalse($ChangeIfThere) ){
- print "Already There\n";
- next;
- }
-
- if( defined($HTMLbase) && $HTMLbase =~ /\S+/ ){
- print "\nUsing HTMLbase to turn:$five\n" if $debug;
- $five=&ARKjoinURL($HTMLbase,$five);
- print "Into :$five\n" if $debug;
- }
-
- if ($five =~ /^http:\/\/.*/) {
- if (&istrue($SearchURLS)) {
- ($nx,$ny) = &URLsize($five);
- }
- } elsif ($five =~ /^\/\~.*/) {
- @PATH = split(/\//, $five);
- shift(@PATH); $user = shift(@PATH) ; $rel = join ("/", @PATH);
- $user =~ s/^\~//;
- $user=(getpwnam( $user ))[7];
- print "User dir is $user/$UserDir/$rel\n" if $debug;
- ($nx,$ny) = &imgsize("$user/$UserDir/$rel",$five);
- } elsif ($five =~ /^\/.*/) {
- ($nx,$ny) = &imgsize("$DocumentRoot$five",$five);
- } else {
- if ($REL eq '') {
- ($nx,$ny) = &imgsize("$five",$five);
- } else {
- ($nx,$ny) = &imgsize("$REL/$five",$five);
- }
- }
-
- if( $nx==0 && $ny==0 ){
- print "\"$file\": No Values : $!\n";
- next;
- }
-
- printf( "(%3d,%3d) ", $nx,$ny) if (isfalse($Quiet));
-
- if(&istrue($Skip1x1) &&
- $nx==1 && $ny==1){
- print "Skipping 1x1 image\n" if (isfalse($Quiet));
- next;
- }
-
- if (&istrue($SkipThreshold) && $nx<=$SkipThreshold &&
- $ny<=$SkipThreshold){
- print "Skipping $nx"."x$ny image (\$SkipThreshold=$SkipThreshold)\n" if
- (isfalse($Quiet));
- next;
- }
-
- if( $nx && $ny && &do_change($ox,$oy,$nx,$ny)){
- $changed=1; # mark the page as changed
- $original[$i]=&replce_attrib($original[$i],$heighttag,$ny);
- $original[$i]=&replce_attrib($original[$i],$widthtag,$nx);
- if( $ox==0 && $oy==0 ){
- print "Added tags " if (isfalse($Quiet));
- } else {
- print "Updated " if (isfalse($Quiet));
- }
- }
-
- print "Needs Alt" if(&istrue($NeedAlt) && $tag !~ /ALT\s*=\s*\S+/i );
-
- print "\n" if (isfalse($Quiet));
- }
- }
-
- if( !($changed)) {
- print " No need to write \"$file\": nothing changed\n";
- return;
- }
-
- if( ! &isfalse($MakeBackup) ){
- # maybe I should move the rest of this stuff into a separate function?
- if( &istrue($DoChmodChown) ){
- # find out about this file
- ($ino,$mode,$uid,$gid) = (stat($file))[1,2,4,5];
- if ($ino == 0 || !rename($file, "$file$BackupExtension")) {
- if( $ino == 0 ){
- print "Couldn't stat \"$file\" for permissions & ownership: $!\n";
- } else {
- print "couldn't rename \"$file\" for backup: $!\n";
- }
- return;
- }
- } else {
- if( &istrue( $UsePerlCp ) ){
- copy( $file, "$file$BackupExtension" );
- } else {
- # system( "cp $file $file$BackupExtension" );
- # we could have added the -p flag e.g. cp -p ....
- # use copy cos this keeps the permissions the same!
- system( "cp -p $file $file$BackupExtension" );
- }
- }
- }
-
- $file="output.html" if $debug;
-
- if(open(CONVERTED, $OutFilter =~ /\S+/ ? "|$OutFilter $file" : ">$file") ){
- print CONVERTED join("<", @original);
- close(CONVERTED);
-
- if( &istrue($DoChmodChown) ){
- # now change the ownership & permissions
- chmod $mode, $file || print "Warning: Couldn't chmod $file\n";
- # It seems that chown doesn't necessarily indicate any errors
- chown $uid, $gid, $file || print "Warning: Couldn't chown $file\n";
-
- ($nuid,$ngid) = (stat($file))[4,5];
- if ($nuid != $uid ||
- $ngid != $gid ){
- print "Warning: $file now has different group or owner\n";
- }
- }
- # if we defined a script to run the make it so....
- system("$Script $file") if( $Script =~ /\S+/ );
- } else {
- print "Either: could not backup or could not write to $file!\n";
- }
-}
-
-# replaces the $attrib's value to $val in $line
-# if $attrib is not present it is inserted at the start of the tag
-sub replce_attrib
-{
- my($line,$attrib,$val)=@_;
- my( $start, $oldval );
-
- # argument checking
- if(!defined($line ) ||
- !defined($attrib) ||
- !defined($val)){
- print "Error: dodgy arguments to replace_attrib!\n";
- return $line if(defined($line)); # have no effect if we can
- exit;
- }
-
- $attrib =~ tr/[A-Z]/[a-z]/ if($UpcaseTags=~/lower/i);
-
- if( !(&isfalse($QuoteNums)) ){
- if( $QuoteNums =~ /single/i ){
- $val = "\'" . $val . "\'";
- } else {
- $val = "\"" . $val . "\"";
- }
- }
-
- if( $line =~ /(\s+$attrib\s*=\s*)([\'\"]?\d+%?[\'\"]?)[^\000]*>/i ){ #"
- $start=$1;
- $oldval=$2;
- $line =~ s/$start$oldval/$start$val/;
- } else {
- $line =~ s/(\S+\s+)/$1$attrib=$val /;
- }
- return $line;
-}
-
-sub ask_for_change{
- my($ret)=1;
- print "Change [Yn]?";
- $_=<STDIN>;
- if( /n/i ){
- $ret=0;
- }
- return $ret;
-}
-
-sub do_change{
- my($oldwidth, $oldheight, $newwidth, $newheight) = @_;
- my($wrat);
- my($hrat);
-
- return 0 if (!defined($oldwidth) ||
- !defined($oldheight) ||
- !defined($newwidth) ||
- !defined($newheight) ||
- !($newwidth) ||
- !($newheight) ||
- ($oldwidth ==$newwidth &&
- $newheight==$oldheight));
-
- return 1 if(!($oldwidth) && !($oldheight) );
-
- if( &isfalse($ChangeIfThere) ){
- return 0;
- } elsif( $ChangeIfThere =~ /clever/i ){
- if( $oldwidth ){
- eval { $wrat= $newwidth / $oldwidth }; warn $@ if $@;
- if( $wrat < 1.0 ){
- eval {$wrat = 1/ $wrat }; warn $@ if $@;
- }
- } else {
- $wrat=1.5;
- }
- if( $oldheight ){
- eval { $hrat= $newheight / $oldheight }; warn $@ if $@;
- if( $hrat < 1.0 ){
- eval {$hrat = 1/ $hrat }; warn $@ if $@;
- }
- } else {
- $hrat=1.5;
- }
- if((int($wrat) == $wrat) &&
- (int($hrat) == $hrat) ){
- return 0;
- } else {
- return &ask_for_change();
- }
- } elsif($ChangeIfThere =~ /ask/i){
- return &ask_for_change();
- }
- return 1;
-}
-
-# looking at the filename really sucks I should be using the first 4 bytes
-# of the image. If I ever do it these are the numbers.... (from chris@w3.org)
-# PNG 89 50 4e 47
-# MNG 8a 4d 4e 47
-# GIF 47 49 46 38
-# JPG ff d8 ff e0
-# XBM 23 64 65 66
-sub imgsize {
- my($file)= shift @_;
- my($ref)=@_ ? shift @_ : "";
- my($x,$y)=(0,0);
-
- # first check the hash table (if we use one)
- # then try and open the file
- # then try the server if we know of one
- if(&istrue($UseHash) &&
- $hashx{$file} &&
- $hashy{$file} ){
- print "Hash " if $debug;
- $x=$hashx{$file};
- $y=$hashy{$file};
- } elsif( defined($file) && open(STRM, "<$file") ){
- binmode( STRM ); # for crappy MS OSes - Win/Dos/NT use is NOT SUPPORTED
- if ($file =~ /\.jpg$/i || $file =~ /\.jpeg$/i) {
- ($x,$y) = &jpegsize(\*STRM);
- } elsif($file =~ /\.gif$/i) {
- ($x,$y) = &gifsize(\*STRM);
- } elsif($file =~ /\.xbm$/i) {
- ($x,$y) = &xbmsize(\*STRM);
- } elsif($file =~ /\.[pm]ng$/i) {
- ($x,$y) = &pngsize(\*STRM);
- } else {
- print "$file is not gif, xbm, jpeg, png or mng (or has stupid name)";
- }
- close(STRM);
-
- if(&istrue($UseHash) && $x && $y){
- $hashx{$file}=$x;
- $hashy{$file}=$y;
- }
-
- } else {
- # we couldn't open the file maybe we want to try the server?
-
- if(&istrue($TryServer) &&
- defined($ref) &&
- $ref =~ /\S+/ &&
- $Base =~ /\S+/ ){
- $ref= &ARKjoinURL( $Base, $ref );
- print "Trying server for $ref\n" if $debug;
-
- ($x,$y)=&URLsize($ref);
- }
- }
-
- return ($x,$y);
-}
-
-###########################################################################
-# Subroutine gets the size of the specified GIF
-###########################################################################
-sub gifsize
-{
- my($GIF) = @_;
- if( &istrue($UseNewGifsize) ){
- return &NEWgifsize($GIF);
- } else {
- return &OLDgifsize($GIF);
- }
-}
-
-
-sub OLDgifsize {
- my($GIF) = @_;
- my($type,$a,$b,$c,$d,$s)=(0,0,0,0,0,0);
-
- if(defined( $GIF ) &&
- read($GIF, $type, 6) &&
- $type =~ /GIF8[7,9]a/ &&
- read($GIF, $s, 4) == 4 ){
- ($a,$b,$c,$d)=unpack("C"x4,$s);
- return ($b<<8|$a,$d<<8|$c);
- }
- return (0,0);
-}
-
-# part of NEWgifsize
-sub gif_blockskip {
- my ($GIF, $skip, $type) = @_;
- my ($s)=0;
- my ($dummy)='';
-
- read ($GIF, $dummy, $skip); # Skip header (if any)
- while (1) {
- if (eof ($GIF)) {
- warn "Invalid/Corrupted GIF (at EOF in GIF $type)\n";
- return "";
- }
- read($GIF, $s, 1); # Block size
- last if ord($s) == 0; # Block terminator
- read ($GIF, $dummy, ord($s)); # Skip data
- }
-}
-
-# this code by "Daniel V. Klein" <dvk@lonewolf.com>
-sub NEWgifsize {
- my($GIF) = @_;
- my($cmapsize, $a, $b, $c, $d, $e)=0;
- my($type,$s)=(0,0);
- my($x,$y)=(0,0);
- my($dummy)='';
-
- return($x,$y) if(!defined $GIF);
-
- read($GIF, $type, 6);
- if($type !~ /GIF8[7,9]a/ || read($GIF, $s, 7) != 7 ){
- warn "Invalid/Corrupted GIF (bad header)\n";
- return($x,$y);
- }
- ($e)=unpack("x4 C",$s);
- if ($e & 0x80) {
- $cmapsize = 3 * 2**(($e & 0x07) + 1);
- if (!read($GIF, $dummy, $cmapsize)) {
- warn "Invalid/Corrupted GIF (global color map too small?)\n";
- return($x,$y);
- }
- }
- FINDIMAGE:
- while (1) {
- if (eof ($GIF)) {
- warn "Invalid/Corrupted GIF (at EOF w/o Image Descriptors)\n";
- return($x,$y);
- }
- read($GIF, $s, 1);
- ($e) = unpack("C", $s);
- if ($e == 0x2c) { # Image Descriptor (GIF87a, GIF89a 20.c.i)
- if (read($GIF, $s, 8) != 8) {
- warn "Invalid/Corrupted GIF (missing image header?)\n";
- return($x,$y);
- }
- ($a,$b,$c,$d)=unpack("x4 C4",$s);
- $x=$b<<8|$a;
- $y=$d<<8|$c;
- return($x,$y);
- }
- if ($type eq "GIF89a") {
- if ($e == 0x21) { # Extension Introducer (GIF89a 23.c.i)
- read($GIF, $s, 1);
- ($e) = unpack("C", $s);
- if ($e == 0xF9) { # Graphic Control Extension (GIF89a 23.c.ii)
- read($GIF, $dummy, 6); # Skip it
- next FINDIMAGE; # Look again for Image Descriptor
- } elsif ($e == 0xFE) { # Comment Extension (GIF89a 24.c.ii)
- &gif_blockskip ($GIF, 0, "Comment");
- next FINDIMAGE; # Look again for Image Descriptor
- } elsif ($e == 0x01) { # Plain Text Label (GIF89a 25.c.ii)
- &gif_blockskip ($GIF, 12, "text data");
- next FINDIMAGE; # Look again for Image Descriptor
- } elsif ($e == 0xFF) { # Application Extension Label (GIF89a 26.c.ii)
- &gif_blockskip ($GIF, 11, "application data");
- next FINDIMAGE; # Look again for Image Descriptor
- } else {
- printf STDERR "Invalid/Corrupted GIF (Unknown extension %#x)\n", $e;
- return($x,$y);
- }
- }
- else {
- printf STDERR "Invalid/Corrupted GIF (Unknown code %#x)\n", $e;
- return($x,$y);
- }
- }
- else {
- warn "Invalid/Corrupted GIF (missing GIF87a Image Descriptor)\n";
- return($x,$y);
- }
- }
-}
-
-sub xbmsize {
- my($XBM) = @_;
- my($input)="";
-
- if( defined( $XBM ) ){
- $input .= <$XBM>;
- $input .= <$XBM>;
- $input .= <$XBM>;
- $_ = $input;
- if( /.define\s+\S+\s+(\d+)\s*\n.define\s+\S+\s+(\d+)\s*\n/i ){
- return ($1,$2);
- }
- }
- return (0,0);
-}
-
-# pngsize : gets the width & height (in pixels) of a png file
-# cor this program is on the cutting edge of technology! (pity it's blunt!)
-# GRR 970619: fixed bytesex assumption
-sub pngsize {
- my($PNG) = @_;
- my($head) = "";
-# my($x,$y);
- my($a, $b, $c, $d, $e, $f, $g, $h)=0;
-
- if(defined($PNG) &&
- read( $PNG, $head, 8 ) == 8 &&
- ( $head eq "\x8a\x4d\x4e\x47\x0d\x0a\x1a\x0a" ||
- $head eq "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" ) &&
- read($PNG, $head, 4) == 4 &&
- read($PNG, $head, 4) == 4 &&
- ($head eq "MHDR" ||
- $head eq "IHDR") &&
- read($PNG, $head, 8) == 8 ){
-# ($x,$y)=unpack("I"x2,$head); # doesn't work on little-endian machines
-# return ($x,$y);
- ($a,$b,$c,$d,$e,$f,$g,$h)=unpack("C"x8,$head);
- return ($a<<24|$b<<16|$c<<8|$d, $e<<24|$f<<16|$g<<8|$h);
- }
- return (0,0);
-}
-
-# jpegsize : gets the width and height (in pixels) of a jpeg file
-# Andrew Tong, werdna@ugcs.caltech.edu February 14, 1995
-# modified slightly by alex@ed.ac.uk
-sub jpegsize {
- my($JPEG) = @_;
- my($done)=0;
- my($c1,$c2,$ch,$s,$length, $dummy)=(0,0,0,0,0,0);
- my($a,$b,$c,$d);
-
- if(defined($JPEG) &&
- read($JPEG, $c1, 1) &&
- read($JPEG, $c2, 1) &&
- ord($c1) == 0xFF &&
- ord($c2) == 0xD8 ){
- while (ord($ch) != 0xDA && !$done) {
- # Find next marker (JPEG markers begin with 0xFF)
- # This can hang the program!!
- while (ord($ch) != 0xFF) { return(0,0) unless read($JPEG, $ch, 1); }
- # JPEG markers can be padded with unlimited 0xFF's
- while (ord($ch) == 0xFF) { return(0,0) unless read($JPEG, $ch, 1); }
- # Now, $ch contains the value of the marker.
- if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) {
- return(0,0) unless read ($JPEG, $dummy, 3);
- return(0,0) unless read($JPEG, $s, 4);
- ($a,$b,$c,$d)=unpack("C"x4,$s);
- return ($c<<8|$d, $a<<8|$b );
- } else {
- # We **MUST** skip variables, since FF's within variable names are
- # NOT valid JPEG markers
- return(0,0) unless read ($JPEG, $s, 2);
- ($c1, $c2) = unpack("C"x2,$s);
- $length = $c1<<8|$c2;
- last if (!defined($length) || $length < 2);
- read($JPEG, $dummy, $length-2);
- }
- }
- }
- return (0,0);
-}
-
-# this is untested contributed code From: Jan Paul Schmidt <jps@fundament.org>
-# if you have problems with the jpegsize above - try this one!
-sub jpegsize2
-{
- my($JPEG) = @_;
- my( $i, $w, $y, $h, $j, $b ) = (0,0,0,0,0,0);
-
- read $JPEG, $b, 4;
- $j = unpack "N", $b;
-
- if ($j == 0xffd8ffe0) {
- do {
- read $JPEG, $b, 2;
- seek $JPEG, unpack("n", $b) - 2, 1;
- read $JPEG, $b, 2;
- $j = unpack "n", $b;
- if ($j >= 0xffc0 and $j <= 0xffc3) {
- seek $JPEG, 3, 1;
-
- read $JPEG, $b, 2;
- $h = unpack "n", $b;
-
- read $JPEG, $b, 2;
- $w = unpack "n", $b;
- goto done; # last;
- }
- } while not eof($JPEG);
- done:
- }
- return ($w, $h );
-}
-
-###########################################################################
-# Subroutine grabs a gif from another server, and gets its size
-###########################################################################
-
-
-sub URLsize {
- my($five) = @_;
- my($dummy, $server, $url);
- my($c1, $c2, $c3, $c4)=(0,0,0,0);
-
- my( $x,$y) = (0,0);
-
- print "URLsize: $five\n" if $debug;
-
- # first check the hash table (if we're using one)
- if(&istrue($UseHash) &&
- $hashx{$five} &&
- $hashy{$five} ){
- print "Hash " if $debug;
-
- $x=$hashx{$five};
- $y=$hashy{$five};
- return($x,$y);
- }
-
- if( $Proxy =~ /\S+/ ){
- ($dummy, $dummy, $server, $url) = split(/\//, $Proxy, 4);
- $url=$five;
- } else {
- ($dummy, $dummy, $server, $url) = split(/\//, $five, 4);
- $url= '/' . $url;
- }
-
- my($them,$port) = split(/:/, $server);
- my( $iaddr, $paddr, $proto );
-
- $port = 80 unless $port;
- $them = 'localhost' unless $them;
-
- print "\nThey are $them on port $port\n" if $debug;# && $Proxy;
- print "url is $url\n" if $debug;
-
- $_=$url;
- if( /gif/i || /jpeg/i || /jpg/i || /xbm/i || /png/i ){
-
- $iaddr= inet_aton( $them );
- $paddr= sockaddr_in( $port, $iaddr );
- $proto=getprotobyname('tcp');
-
- # Make the socket filehandle.
-
- if(socket(STRM, PF_INET, SOCK_STREAM, $proto) &&
- connect(STRM,$paddr) ){
- # Set socket to be command buffered.
- select(STRM); $| = 1; select(STDOUT);
-
- print "Getting $url\n" if $debug;
-
- my $str=("GET $url HTTP/1.1\n".
- #"User-Agent: Mozilla/4.08 [en] (WWWIS)\n".
- #"Accept: */*\n".
- "Connection: close\n".
- "Host: $them\n\n");
-
- print "$str" if $debug;
-
- print STRM $str;
-
- # we're looking for \n\r\n\r
- while ((ord($c1) != 10) || (ord($c2) != 13) || (ord ($c3) != 10) ||
- (ord($c4) != 13)) {
- $c4 = $c3;
- $c3 = $c2;
- $c2 = $c1;
- read(STRM, $c1, 1);
- print "$c1" if $debug;
- }
- print "\n" if $debug;
-
- if ($url =~ /\.jpg$/i || $url =~ /\.jpeg$/i) {
- ($x,$y) = &jpegsize(\*STRM);
- } elsif($url =~ /\.gif$/i) {
- ($x,$y) = &gifsize(\*STRM);
- } elsif($url =~ /\.xbm$/i) {
- ($x,$y) = &xbmsize(\*STRM);
- } elsif($url =~ /\.png$/i) {
- ($x,$y) = &pngsize(\*STRM);
- } else {
- print "$url is not gif, jpeg, xbm or png (or has stupid name)";
- }
-
- close ( STRM );
- } else {
- # there was a problem
- print "ERROR: $!";
- }
- } else {
- print "$url is not gif, xbm or jpeg (or has stupid name)";
- }
- if(&istrue($UseHash) && $x && $y){
- $hashx{$five}=$x;
- $hashy{$five}=$y;
- }
- return ($x,$y);
-}
-
-sub istrue
-{
- my( $val)=@_;
- return (defined($val) && ($val =~ /^y(es)?/i || $val =~ /true/i ));
-}
-
-sub isfalse
-{
- my( $val)=@_;
- return (defined($val) && ($val =~ /^no?/i || $val =~ /false/i ));
-}
-
-sub strip_quotes{
- my($name)=@_;
-
- $_=$name; # now to gte rid of quotes if they were there
- if( /\"([^\"]*)\"/ ){ return $1; } #"
- elsif( /\'([^\']*)\'/ ){ return $1; }
- return $name;
-}
-
-# this doesn't cope with \-ed " which it should!!!
-# I also didn't cope with javascript stuff like onChange (whoops)
-# this is why it is unsupported.
-sub changecase{
- my($text)=@_;
- my( @line )=();
- my( $ostr, $str, $j )=("","",0);
-
- $text=~/^([^>]*)>/;
- return $text if( !defined($1));
- $ostr=$str=$1;
-
- @line=split(/\"/, $str); #"
-
- for( $j=0 ; $j <= $#line ; $j+=2 ){
- if( $UpcaseTags =~ /lower/i ){
- $line[$j] =~ tr/[A-Z]/[a-z]/;
- } else {
- $line[$j] =~ tr/[a-z]/[A-Z]/;
- }
- }
- if( $str =~ /\"$/ ){ #"
- $str=join( "\"", @line , "");
- } else {
- $str=join( "\"", @line );
- }
- $text=~ s/^$ostr/$str/;
-
- return $text;
-}
-
-# joins together two URLS to make one url
-# e.g. http://www/ + fish.html = http://www/fish.html
-# e.g. http://www/index.html + fish.html = http://www/fish.html
-# e.g. http://www/s/index.html + /fish.html = http://www/fish.html
-sub ARKjoinURL
-{
- my($base,$url)=@_;
-
- # if url has a double // in it then it is fine thank you!
- return $url if( $url =~ /\/\// );
-
- # strip down base url to make sure that it doesn't have a .html at the end
- $base=~s/[^\/]*$//;
-
- if( $url =~ /^\// ){
- # strip off leading directories
- $base =~ s/(\/\/[^\/]*)\/.*$/$1/;
- }
-
- return ($base . $url);
-}
-
-# File: wwwis-options.pl -*- Perl -*-
-# Created by: Alex Knowles (alex@ed.ac.uk) Sat Nov 2 16:41:12 1996
-# Last Modified: Time-stamp: <03 Nov 96 1549 Alex Knowles>
-# RCS $Id: wwwis,v 2.43 2004/12/02 18:32:13 ark Exp $
-############################################################################
-# There now follows some routines to get the configuration file
-############################################################################
-
-# NextOption:
-# give me the start of the next option (as options can take up a
-# different number of array elements)
-sub NextOption
-{
- my($i) = @_;
-
- $_=$options[$i+1];
- if( /string/i || /integer/i || /file/i || /bool/i ){
- $i+=3;
- } elsif( /choice/i ){
- $i+=4+$options[$i+3];
- }else {
- print "unknown option type! $_\n";
- exit 2;
- }
- return $i;
-}
-
-# ShowOptions: now I use -usage it's much better
-
-# CheckOption:
-# Check if $val (arg2) is valid for option which starts at options[$i (arg1)]
-# returns either 0 (failure) or 1 (success)
-sub CheckOption
-{
- my($i,$val) = @_;
- my($k);
-
- return 0 unless $i && $val;
-
- $_=$options[$i+1];
- if( /string/i ){
- # can't think of a check for this
- }elsif( /integer/i ){
- if( $val !~ /^\d+$/ ){
- print "$val is not an integer!\n";
- return 0;
- }
- } elsif( /file/i ){
- if( ! (-e ($val) ) ){
- print "can't find file $val for $options[$i]\n";
- return 0;
- }
- }elsif( /bool/i ){
- if( $val !~ /^(y(es)?|no?)$/i ){
- print "$val is neither Yes nor No\n";
- return 0;
- }
- }elsif( /choice/i ){
- for( $k=0 ; $k < $options[$i+3] ; $k++ ){
- if( $val =~ /^$options[$i+4+$k]$/i ){
- return 1;
- }
- }
- print "$val is not a valid value for $options[$i]\n";
- return 0;
- }else {
- print "unknown option type! $_\n";
- exit 2;
- }
- return 1;
-}
-
-# GetConfigFile:
-# Read user's configuration file, if such exists. If WWWIMAGESIZERC is
-# set in user's environment, then read the file referenced, otherwise
-# try for $HOME/.wwwimagesizerc
-sub GetConfigFile
-{
- my( @options )= @_;
- my( @optionval )=();
- # my(*CONFIG);
- my($filename)="";
- my(@files)=();
- my($i,$j,$line);
-
- #first go through options array and puyt the default values into optionval
- $i=0;
- $j=0;
- while( $i < $#options ){
- $optionval[$j]=$options[$i+2];
- $i=&NextOption($i);
- $j++;
- }
-
- push(@files,$ENV{'WWWISRC'}) if $ENV{'WWWISRC'};
- push(@files,$ENV{'WWWIMAGESIZERC'}) if $ENV{'WWWIMAGESIZERC'};
- push(@files,("$ENV{'HOME'}/.wwwisrc",
- "$ENV{'HOME'}/.wwwimagesizerc",)) if $ENV{'HOME'};
-
- foreach $i (@files){
- if( defined($i) && -f $i ){
- $filename=$i;
- last;
- }
- }
-
- if(defined($filename) &&
- -f $filename &&
- open(CONFIG,"< $filename") ){
- while (<CONFIG>){
- # skip lines with a hash on them
- s/#.*$//;
- next if /^\s*$/;
-
- $line=$_;
- if( $line =~ /^(\S+)(\s+|\s*:\s*)(.+)$/ ){
- if( !(&proc_option($1,$3)) ){
- print "Invalid .wwwisrc line: $line";
- }
- }
- }
- close CONFIG;
- } else {
- if( -f $filename ){
- print "Unable to read config file `$filename': $!\n";
- }
- }
- return @optionval;
-}
-
-sub proc_option
-{
- my($opt,$value)=@_;
- my($i,$j,$proced)=(0,0,0);
-
- return 0 unless $opt && $value;
-
- while( !$proced && $i < $#options ){
- if( $options[$i] =~ /$opt/i ){
- $proced=1;
- if( &CheckOption($i,$value) ){
- $optionval[$j]=$value;
- } else {
- printf("Invalid .wwwisrc value \"%s\" for option \"%s\"\n",
- $value,$options[$i]);
- }
- }
-
- $i=&NextOption($i); # move onto the next option
- $j++;
- }
- return $proced;
-}
-
-sub proc_arg
-{
- my($arg)= @_;
-
- return if !defined($arg);
-
- if( $arg =~ /^-+v(ersion)?$/i ){
- my($version)='$Revision: 2.43 $ ';
- my($progname)=$0;
- $progname =~ s/.*\///; # we only want the name
- $version =~ s/[^\d\.]//g; # we only care about numbers and full stops
- print "$progname: $version\n";
- } elsif( $arg =~ /^-+u(sage)?$/i ||
- $arg =~ /^-+h(elp)?$/i ){
- &usage();
- } elsif( $arg =~ /^-+d(ebug)$/i ){
- $debug=1;
- } elsif( $arg =~ /-+im(a)?g(e)?size/i ){
- my($x,$y)=&imgsize(shift @ARGV);
- print "WIDTH=$x HEIGHT=$y\n";
- } else {
- $arg=~s/^-+//;
- if( &proc_option( $arg, shift @ARGV)){
- &SetGlobals();
- } else {
- print "Unrecognized option $arg\n";
- &usage();
- exit;
- }
- }
-
-}
-
-sub get_values
-{
- my($i)=@_;
- return "" if !defined $i;
-
- if( $options[$i+1] =~ /file/i ){
- return ();
- } elsif($options[$i+1] =~ /string|integer/i ){
- return ();
- } elsif($options[$i+1] =~ /bool/i ){
- return ('Yes','No');
- } elsif($options[$i+1] =~ /choice/i ){
- my($start,$end)=(($i+4),($options[$i+3]));
- return (@options[$start .. $start+$end-1]);
- } else {
- print "Unrecognized option type\n";
- exit 0;
- }
-}
-
-sub usage
-{
- my($progname)=$0;
- $progname =~ s/.*\///; # we only want the name
- my($vals)="";
-
- print "$progname: [-version] [-usage] [-option optionval] file.html ... \n";
-
- my($fmt)=" %15s %6s %-10s %s\n";
-
- printf($fmt,"Option Name","Type","Default","Values");
- printf($fmt,"-----------","----","-------","------");
-
- my($i,$j)=(0,0);
-
- while( $i < $#options ){
- $vals=join(',', &get_values($i));
- printf($fmt,$options[$i],$options[$i+1],$optionval[$j],$vals);
-
- $i=&NextOption($i);
- $j++;
- }
-}
-
-1;
+++ /dev/null
-#!/bin/sh
-# Filename: xsay
-# Purpose: output X clipboard text via flite
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if [ -x /usr/bin/sselp ] ; then # package dwm-tools
- flite -o play -t "$(sselp)"
-elif [ -x /usr/bin/xclip ] ; then # package xclip
- flite -o play -t "$(xclip -o)"
-elif [ -x /usr/bin/wmiipsel ] ; then # old wmii package
- flite -o play -t "$(wmiipsel)"
-elif [ -x /usr/bin/wmiiplumb ] ; then # old wmii package
- flite -o play -t "$(wmiiplumb)"
-elif [ -x /usr/bin/wmiplumb ] ; then # deprecated wmi package
- flite -o play -t "$(wmiplumb)"
-else
- echo "error, no program for reading X selection found" | flite
-fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl -w
-#***************************************************************************
-# PrintAnalyzer
-# Generate some stats from cups page_log file
-# copyright : (C) 1999 - 2003 by Thies Moeller
-# email : moeller@tu-harburg.de
-#***************************************************************************
-
-#***************************************************************************
-#* *
-#* 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. *
-#* *
-#***************************************************************************
-use strict;
-use warnings;
-use POSIX qw(strftime);
-use Time::Local;
-use Getopt::Std;
-
-
-
-##############
-# edit place of your page_log file or give it as option "-f filename"
-##############
-my %opt;
-my $PAGE_LOG_FILE;
-
-getopt("f:q",\%opt);
-
-if (exists $opt{"f"}) { $PAGE_LOG_FILE = $opt{f};}
-else {$PAGE_LOG_FILE = "/var/log/cups/page_log";}
-
-##############
-# edit start and end of normal work time
-# activity outside this interval will be marked with an "!"
-# to disable set WorkStart to 0 and WorkEnd to 24
-##############
-my $WorkStart = 07;
-my $WorkEnd = 22;
-
-
-############################ nothing to modify below this line ##############
-
-my %userRequests = ();
-my %userPages = ();
-my %hourRequests = ();
-my %dateRequests = ();
-my %datePages = ();
-my %pageRequests = ();
-my %queueRequests = ();
-my %queuePages = ();
-my %pageHeu = ();
-my %copyRequests = ();
-my %logline = ();
-my %lastlogline = ();
-my %billingStats = ();
-my %queueUserStats = ();
-my $totalReq = 0;
-my $totalPages = 0;
-
-sub DateCompare
-{
- my $date1 = substr($a, 6, 2) * 1024; # Years
- my $date2 = substr($b, 6, 2) * 1024;
-
- $date1 += substr($a,3,2) * 64; # Months
- $date2 += substr($b,3,2) * 64;
-
- $date1 += substr($a, 0, 2); # Days
- $date2 += substr($b, 0, 2);
- return ($date1 <=> $date2);
-}
-
-
-sub tzdiff2sec
-{
-## this method is copied from LogReport Time.pm
-## Copyright (C) 2000-2002 Stichting LogReport Foundation LogReport@LogReport.org
-
- die "tzdiff2sec needs 1 arg\n"
- unless @_ == 1;
-
- # e.g. +0100 or -0900 ; +hh:mm, +hhmm, or +hh
- my ( $sign, $hour, $min ) = $_[0] =~ /^([+-])?(\d\d):?(\d\d)?$/
- or die "invalid tzdiff format: $_[0]. It must looks like +0100 or -01:00\n";
- $sign ||= "+";
- $hour ||= 0;
- $min ||= 0;
- my $sec = $hour * 60 * 60 + $min * 60;
- $sec *= -1 if $sign eq '-';
- return $sec;
-}
-
-sub getMonth
-{
- my $AllMonths= 'JanFebMarAprMayJunJulAugSepOctNovDec';
- my $month = shift(@_);
- return index($AllMonths, $month)/3;
-}
-
-
-
-sub DateTime2Epoch
-{
- my ($day,$month,$year,$hour,$min,$sec,$tz)=
- unpack'@1 A2 @4 A3 @8 A4 @13 A2 @16 A2 @19 A2 @22 A5', shift();
-
- my $epoch=timegm $sec ,
- $min ,
- $hour,
- $day,
- getMonth($month),
- $year;
- return $epoch - tzdiff2sec($tz);
-}
-
-sub PrintDayLog
-{
- my $dateReq;
-
-############# Output Form ################
-format DAYLOG_TOP =
-
-Daily Usage
-Date %Requests Pages
------------------------------------------
-.
-
-format DAYLOG =
-@<<<<<<<<<<<<< @>>>>>>> @>>>>>>>
-$dateReq,$dateRequests{$dateReq},$datePages{$dateReq}
-.
-############# Output Form ################
-
-
- $-=0;
- $~="DAYLOG";
- $^="DAYLOG_TOP";
- foreach $dateReq (sort DateCompare keys %dateRequests)
- {
- #printf("Monat %d\n",getMonth($dateReq));
- write;
- }
-}
-
-sub PrintUserLog
-{
- my $userReq;
- my $pageperjob;
-
-############# Output Form ################
-format USERLOG_TOP =
-PrinterAccounting
-Username Requests Pages Pages/Request
---------------------------------------------------------
-.
-
-format USERLOG =
-@<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>>>>
-$userReq, $userRequests{$userReq}, $userPages{$userReq}, $pageperjob
-.
-############# Output Form ################
-
- $-=0;
- $~="USERLOG";
- $^="USERLOG_TOP";
- foreach $userReq (sort { $userPages{$b} <=> $userPages{$a}} keys %userRequests)
- {
- $pageperjob = sprintf("%5d", POSIX::ceil($userPages{$userReq} / $userRequests{$userReq}));
- write ;
- }
-}
-
-sub PrintHourLog
-{
- my $hourReq;
- my $outOfWorkingTime;
-
-############# Output Form ################
-format HOURLOG_TOP =
-Hour Usage
-Hour Requests
----------------------
-.
-
-format HOURLOG =
-@<@<<<<< @>>>>>>>
-$outOfWorkingTime,$hourReq,$hourRequests{$hourReq}
-.
-############# Output Form ################
-
-
- $-=0;
- $~="HOURLOG";
- $^="HOURLOG_TOP";
-
- foreach $hourReq (sort {$a <=> $b} keys %hourRequests)
- {
- if($hourReq <$WorkStart || $hourReq > $WorkEnd)
- {
- if($hourRequests{$hourReq} == 0)
- {
- next;
- }
- else
- {
- $outOfWorkingTime = "!";
- }
- }
- else
- {
- $outOfWorkingTime = " ";
- }
- write;
- }
-
-}
-
-sub PrintRequestSize
-{
- my $pageReq;
- my %pageHeu;
- my $pageHeuK;
- my $pageperHeu;
-############# Output Form ################
-
-format REQUESTLOG_TOP =
-Heuristic
-JobSize %Requests
----------------------------
-.
-
-format REQUESTLOG =
-@||||||||||| @>>>>>>>>
-$pageHeuK,$pageperHeu
-.
-############# Output Form ################
-
- # sammeln der Daten
- foreach $pageReq (sort {$a <=> $b} keys %pageRequests)
- {
- if($pageReq >0 && $pageReq <=10)
- {$pageHeu{"1. 0-10"}+=$pageRequests{$pageReq}};
- if ($pageReq >10 && $pageReq <=20)
- {$pageHeu{ "2. 20-30"}+=$pageRequests{$pageReq}};
- if ($pageReq >20 && $pageReq <=30)
- {$pageHeu{ "3. 30-40"}+=$pageRequests{$pageReq}};
- if ($pageReq >40 && $pageReq <=50)
- {$pageHeu{ "4. 40-50"}+=$pageRequests{$pageReq}};
- if ($pageReq >50 && $pageReq <=100)
- {$pageHeu{ "5. 50-100"}+=$pageRequests{$pageReq}};
- if ($pageReq >100 && $pageReq <=200)
- {$pageHeu{ "6. 100-200"}+=$pageRequests{$pageReq}};
- if ($pageReq >200 )
- {$pageHeu{ "7. 200- "}+=$pageRequests{$pageReq}};
- }
- $-=0;
- $~="REQUESTLOG";
- $^="REQUESTLOG_TOP";
-
- foreach $pageHeuK (sort keys %pageHeu)
- {
- $pageperHeu = sprintf("%5.2f", 100*$pageHeu{$pageHeuK}/$totalReq);
- write;
- }
-}
-
-sub PrintCopySize
-{
- my $copyReq;
- my %copyHeu;
- my $copyHeuK;
- my $copyperheu;
-############# Output Form ################
-format COPY_TOP =
-Heuristic
-Copies %Requests
----------------------------
-.
-format COPYLOG =
-@||||||||||||| @>>>>>>>>
-$copyHeuK,$copyperheu
-.
-############# Output Form ################
-
-
- foreach $copyReq (sort {$a <=> $b} keys %copyRequests)
- {
- if($copyReq == 1 )
- {$copyHeu{" 1. single"}+=$copyRequests{$copyReq}};
- if($copyReq == 2)
- {$copyHeu{" 2. 2 "}+=$copyRequests{$copyReq}};
- if($copyReq == 3)
- {$copyHeu{" 3. 3 "}+=$copyRequests{$copyReq}};
- if($copyReq == 4)
- {$copyHeu{" 4. 4 "}+=$copyRequests{$copyReq}};
- if($copyReq >=5 && $copyReq <=10)
- {$copyHeu{" 5. 5-10 "}+=$copyRequests{$copyReq}};
- if ($copyReq >10 && $copyReq <=20)
- {$copyHeu{ " 6. 20-30 "}+=$copyRequests{$copyReq}};
- if ($copyReq >20 && $copyReq <=30)
- {$copyHeu{ " 7. 30-40 "}+=$copyRequests{$copyReq}};
- if ($copyReq >40 && $copyReq <=50)
- {$copyHeu{ " 8. 40-50 "}+=$copyRequests{$copyReq}};
- if ($copyReq >50 && $copyReq <=100)
- {$copyHeu{ " 9. 50-100 "}+=$copyRequests{$copyReq}};
- if ($copyReq >100 && $copyReq <=200)
- {$copyHeu{ "10. 100-200 "}+=$copyRequests{$copyReq}};
- if ($copyReq >200 )
- {$copyHeu{ "11. 200- "}+=$copyRequests{$copyReq}};
- }
- $-=0;
- $~="COPYLOG";
- $^="COPY_TOP";
- foreach $copyHeuK (sort keys %copyHeu)
- {
- $copyperheu = sprintf("%5.2f", 100*$copyHeu{$copyHeuK}/$totalReq);
- write;
- }
-}
-
-sub PrintQueueLog
-{
- my $queueReq;
- my $reqperqueue;
- my $pagepermin;
- my $pageperqueue ;
-############# Output Form ################
-format QUEUELOG_TOP =
-Queue Heuristic
-Queue %Requests %Pages Pages
---------------------------------------------------------------
-.
-
-format QUEUELOG =
-@>>>>>>>>>>>>>>>>>>>>> @>>>>>>> @>>>>>>> @>>>>>>>>
-$queueReq,$reqperqueue,$pageperqueue,$queuePages{$queueReq}
-.
-############# Output Form ################
-
-
- $-=0;
- $~="QUEUELOG";
- $^="QUEUELOG_TOP";
- foreach $queueReq (sort { $queuePages{$b} <=> $queuePages{$a} } keys %queuePages)
- {
- $reqperqueue = sprintf("%5.2f", 100*$queueRequests{$queueReq}/$totalReq);
- $pageperqueue = sprintf("%5.2f", 100*$queuePages{$queueReq}/$totalPages);
- write;
- }
-
-}
-
-sub PrintBillingLog
-{
- my $billing;
- my $pageperbilling ;
- my $billinguser;
-
-############# Output Form ################
-format BILLINGLOG_TOP =
-Billing Heuristic
-Billing Pages
---------------------------------------------------------------
-.
-
-format BILLINGLOG =
-@<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>
-$billing,$pageperbilling
-.
-
-format BILLINGUSERLOG =
-|- @>>>>>>>>>>>>>>>>>>>>> @>>>>>>>>
-$billinguser,$pageperbilling
-.
-############# Output Form ################
-
-
- $-=0;
- $~="BILLINGLOG";
- $^="BILLINGLOG_TOP";
- foreach $billing (sort keys %billingStats)
- {
- $pageperbilling = $billingStats{$billing}{"total_pages"};
- $~="BILLINGLOG";
- write;
- $~="BILLINGUSERLOG";
- foreach $billinguser ( sort {$billingStats{$billing}{"user"}{$b} <=> $billingStats{$billing}{"user"}{$a}} keys %{$billingStats{$billing}{"user"}})
- {
- $pageperbilling = $billingStats{$billing}{"user"}{$billinguser};
- write;
- }
- }
-
-}
-
-sub PrintQueueUserLog
-{
- my $queue;
- my $pageperqueue;
- my $queueuser;
-
-############# Output Form ################
-format QUEUEUSER_TOP =
-Queue-User
-Queue Pages
---------------------------------------------------------------
-.
-
-format QUEUENAME =
-@<<<<<<<<<<<<<<<<<<<<<<<<
-$queue
-.
-
-format QUEUEUSERLOG =
-|- @>>>>>>>>>>>>>>>>>>>>> @>>>>>>>>
-$queueuser,$pageperqueue
-.
-############# Output Form ################
-
-
- $-=0;
- $~="QUEUENAME";
- $^="QUEUEUSER_TOP";
- foreach $queue (sort keys %queueUserStats)
- {
- $~="QUEUENAME";
- write;
- $~="QUEUEUSERLOG";
- foreach $queueuser ( sort {$queueUserStats{$queue}{$b} <=> $queueUserStats{$queue}{$a}} keys %{$queueUserStats{$queue}})
- {
- $pageperqueue = $queueUserStats{$queue}{$queueuser};
- write;
- }
- }
-
-}
-
-sub HandleNewJob
-{
- my $realpages = $lastlogline{num_pages}*$lastlogline{copies};
- my $hourstring = POSIX::strftime "%H", localtime($lastlogline{time}) ;
- my $daystring = POSIX::strftime "%d/%m/%y", localtime($lastlogline{time}) ;
-
- $userRequests{$lastlogline{user}}++;
- $userPages{$lastlogline{user}}+=$realpages;
- $dateRequests{$daystring}++;
- $datePages{$daystring}+=$realpages;
- $pageRequests{$realpages}++;
- $queueRequests{$lastlogline{printer}}++;
- $queuePages{$lastlogline{printer}}+=$realpages;
- $hourRequests{$hourstring}++;
- $copyRequests{$lastlogline{copies}}++;
- $billingStats{$lastlogline{billing}}{"user"}{$lastlogline{user}} += $realpages;
- $billingStats{$lastlogline{billing}}{"printer"}{$lastlogline{printer}} += $realpages;
- $billingStats{$lastlogline{billing}}{"total_pages"} += $realpages;
- $queueUserStats{$lastlogline{printer}}{$lastlogline{user}} += $realpages;
-
- $totalReq++;
- $totalPages+=$realpages;
-}
-
-sub InitHourHistogram
-{
- my $i;
- for ($i = 0 ; $i <=24 ; $i++)
- {
- my $hourstring = sprintf("%02d", $i);
- $hourRequests{$hourstring}=0;
- }
-}
-
-# main
-open(PAGELOG,"$PAGE_LOG_FILE") || die "Can't open pagelog file $PAGE_LOG_FILE";
-
-
-#initialize the hourhistogram
-InitHourHistogram;
-
-while(<PAGELOG>)
-{
- my $time;
- my $pagenum;
- %logline = ();
- chomp();
- ($logline{printer},
- $logline{user},
- $logline{jobid},
- $time,
- $pagenum,
- $logline{copies},
- $logline{billing}) =
- ($_ =~ /^(.*)\s(.*)\s(\d+)\s(\[.*\])\s(\d+)\s(\d+)\s(.*)$/)
- or do {
- if(! exists $opt{"q"}) {print STDERR "Cannot convert $_ \n";}
- next;
- };
- # downcase username because of samba
- $logline{user}=~ tr/A-Z/a-z/;
- # handle empty user
- if ($logline{user} eq "") {
- $logline{user}="TestPages";
- }
- # handle empty billing code
- if ($logline{billing} eq "") {
- $logline{billing}="-none-";
- }
- my $endtime = DateTime2Epoch( $time );
-
- if ( ! defined $lastlogline{jobid} || $lastlogline{jobid} ne $logline{jobid} )
- {
- # new job;
- $logline{num_pages} = 1;
- $logline{time} = $endtime;
- if ( defined $lastlogline{jobid} ) {
- HandleNewJob;
- };
- } else {
- # same job; update info
- $logline{num_pages} = $lastlogline{num_pages} + 1;
- $logline{time} = $lastlogline{time};
- }
- %lastlogline= %logline;
-
-}
-close(PAGELOG);
-
-# handle last job
-if ( defined $lastlogline{jobid} ) {
- HandleNewJob;
- }
-
-
-
-PrintQueueLog;
-PrintQueueUserLog;
-PrintRequestSize;
-PrintCopySize;
-PrintBillingLog;
-PrintUserLog;
-PrintHourLog;
-PrintDayLog;
-
-__END__
-
-=head1 NAME
-
-PrintAnalyzer - create statistics from CUPS page_log file
-
-=head1 SYNOPSIS
-
- PrintAnalyzer [-f filename][-q]
-
-=head1 DESCRIPTION
-
-This Tool generates statistics from the CUPS page_log file.
-
-Features:
-
-=over 8
-
-=item Queue usage
-
-=item Pages per user per queue (Accounting)
-
-=item Jobsize histogram (all queues in one)
-
-=item Number of copies histogram (all queues in one)
-
-=item Jobs/Pages per hour (all queues in one)
-
-=item Jobs/Pages per day (all queues in one)
-
-=item Jobs/Pages per user (all queues in one)
-
-=item Pages per Billingcode (all queues in one)
-
-=item Pages per User per Billingcode (all queues in one)
-
-=back
-
-=head1 OPTIONS AND ARGUMENTS
-
-=over 8
-
-=item B<-f> filename
-
-Location of the page_log file
-
-=item B<-q>
-
-Quiet operation
-
-=back
-
-=head1 SEE ALSO
-
- http://www.cups.org
-
-=head1 AUTHOR
-
- Thies Moeller
-
-=cut
-
-
-
-
-
-
+++ /dev/null
-#! /usr/bin/perl
-# Filename: alignmargins
-# Purpose: adjust the margins and the position of the printed contents on the paper
-# Authors: (C) 2001 by Till Kamppeter
-# Bug-Reports: see http://grml.org/bugs/
-# License: Free software under the terms of the GNU General Public License (GPL)
-################################################################################
-# Downloaded from http://www.linuxprinting.org/download/printing/alignmargins
-
-$0 =~ m!^(.*)/[^/]+$!;
-my $programpath = $1;
-my $printcommand = '/usr/bin/lpr -P ';
-my $egrep = '/bin/egrep';
-my $cat = '/bin/cat';
-my $cut = '/usr/bin/cut';
-my $head = '/usr/bin/head';
-my $tail = '/usr/bin/tail';
-my $wc = '/usr/bin/wc';
-my $adjustmentpagename = 'align.ps';
-my $adjustmentpagepath = ($programpath ? "${programpath}:" : "") . '.:~:/usr/share/grml-scripts:/usr/share/alignmargins:/usr/local/share/alignmargins:/usr/share:/usr/local/share:/usr/share/printer-testpages:/usr/local/share/printer-testpages:/usr/share/ghostscript/*/lib:/usr/local/share/ghostscript/*/lib';
-my $ppddir = '/etc/cups/ppd';
-my $printerconffile = '/etc/cups/printers.conf';
-
-# Find "ælign.ps"
-
-my $adjustmentpage;
-for $path (split(":", $adjustmentpagepath)) {
- if (-r "$path/$adjustmentpagename") {
- $adjustmentpage = "$path/$adjustmentpagename";
- last;
- }
-}
-
-# Are we running as root?
-
-if (!(-w $printerconffile)) {die "\"alignmargins\" must be run logged in as \"root\"!";}
-
-# Check whether there are local printer queues
-
-open NUMBEROFQUEUES, "$cat $printerconffile | $egrep '<Printer|<DefaultPrinter' | $wc -l |" or die "Cannot read local printer configuration!";
-
-my $nqueues = <NUMBEROFQUEUES>;
-close NUMBEROFQUEUES;
-
-# Ask the user which printer he wants to align
-
-print "\n";
-print "CUPS printer margin and offset alignment\n";
-print "----------------------------------------\n";
-print "\n";
-print "(C) 2001 by Till Kamppeter\n";
-print "Free software under the terms of the GNU General Public License (GPL)\n";
-my $queue = "";
-
-do {
- print "\n";
- print "With this program you can adjust the margins and the position of the\n";
- print "printed contents on the paper. This way you get well-centered printouts and\n";
- print "you can make use of the whole imageable area of your printer, The driver\n";
- print "settings are overridden when this adjustment is used.\n";
- print "\n";
- print "This is especially important when your printer is used with a driver for\n";
- print "another printer to which yours is compatible (for example many laser\n";
- print "printers are compatible to the HP LaserJet printers). Your printer prints\n";
- print "with this driver, but the non-printable margins are usually different or the\n";
- print "contents is even not centered. With this program you can fix these problems\n";
- print "\n";
- print "The program can only be applied to local printer queues. The following\n";
- print "queues are available:\n";
- print "\n";
-
- system "$cat $printerconffile | $egrep '<Printer|<DefaultPrinter' | $cut -d ' ' -f 2 | $cut -d '>' -f 1 | $cat -n";
-
- print "\n";
- print "Please enter the number of the desired printer and make sure that it is\n";
- print "connected to your computer and turned on.\n";
- print "\n";
-
- print "Number: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*(\d+)\D*/ ) {
- my $number = $1;
- if (($number > 0) && ($number <= $nqueues)) {
- open QUEUE, "$cat $printerconffile | $egrep '<Printer|<DefaultPrinter' | $cut -d ' ' -f 2 | $cut -d '>' -f 1| $head -$number | $tail -1 |";
- if (!$?) {
- $queue = <QUEUE>;
- close QUEUE;
- }
- }
- } else {
- print "\nWrong input, try again!\n";
- }
-} until ($queue ne "");
-
-chomp $queue;
-
-print "\n";
-print "Printing margin/offset adjustment page ...\n";
-print "\n";
-
-# The "%!" which is needed in a file to be recognized as a PostScript file
-# is missing in the adjustment page, therefore it is preceeded to the file
-# here.
-if (system "(echo %!; $cat $adjustmentpage) | $printcommand$queue") {
-die "Could not print the adjustment page.";
-}
-
-print "Please read the instructions on the margin adjustment page and determine the\n";
-print "six numbers mentioned there. If you measure in cm and not in inches, devide\n";
-print "the measured quantities by 2.54 before you insert them into the equations\n";
-print "shown on the page. You do not need to create any file with PostScript\n";
-print "commands, this program will insert your settings into your printer's\n";
-print "configuration.\n";
-print "\n";
-print "If the adjustment page did not come out of your printer, this method cannot\n";
-print "be applied, press Ctrl + C to stop this program. This can especially happen\n";
-print "with very old PostScript printers.\n";
-print "\n";
-print "Note also that this adjustment does not necessarily work with every driver.\n";
-print "The concept is taken from GhostScript and the implementation of this program\n";
-print "is not much tested yet.\n";
-print "\n";
-
-print "Please enter your results now:\n";
-print "\n";
-
-my $ml = 9999999.;
-my $mb = 9999999.;
-my $mr = 9999999.;
-my $mt = 9999999.;
-my $x = 9999999.;
-my $y = 9999999.;
-
-do {
- print "ml: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $ml = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($ml != 9999999.);
-
-do {
- print "mb: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $mb = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($mb != 9999999.);
-
-do {
- print "mr: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $mr = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($mr != 9999999.);
-
-do {
- print "mt: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $mt = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($mt != 9999999.);
-
-do {
- print "x: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $x = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($x != 9999999.);
-
-do {
- print "y: ";
- my $input = <STDIN>;
-
- if ( $input =~ m/^\s*([+-]?[\d\.]+)\D*/ ) {
- my $number = $1;
- if (($number >= -100000) && ($number <= 100000)) {
- $y = $number * 1.;
- }
- } else {
- print "Wrong input, try again!\n";
- }
-} until ($y != 9999999.);
-
-my $ppdfilename = "$ppddir/$queue.ppd";
-print "\n";
-print "Saving your settings in $ppdfilename ...\n";
-print "\n";
-
-my @marginsoption = (
- "*OpenUI *Margins/Page Margins/Offsets: PickOne\n",
- "*DefaultMargins: Custom\n",
- "*Margins Default/Driver Default: \"\"\n",
- "*Margins Custom/Custom (set with 'alignmargins'): \"<</.HWMargins[$ml $mb $mr $mt] /Margins[$x $y]>>setpagedevice\"\n",
- "*CloseUI: *Margins\n"
-);
-
-# Read PPD file of the chosen printer
-
-if (!(-f $ppdfilename)) {die "No PPD file $ppdfilename!"};
-open PPDFILE, "$ppdfilename" or die "Can't open $ppdfilename!";
-my @ppdfile = <PPDFILE>;
-close PPDFILE;
-
-# Remove an old margin adjustment option
-
-($_ =~ m!^\s*\*OpenUI\s*\*Margins/.*:! and $_="") foreach @ppdfile;
-($_ =~ m!^\s*\*DefaultMargins:! and $_="") foreach @ppdfile;
-($_ =~ m!^\s*\*Margins\s*.*/.*:! and $_="") foreach @ppdfile;
-($_ =~ m!^\s*\*CloseUI:\s*\*Margins! and $_="") foreach @ppdfile;
-
-# Insert the new margin adjustment option
-
-splice(@ppdfile,-1,0,@marginsoption);
-
-# Write back PPD file
-
-open PPDFILE, ">$ppdfilename" or die "Can't open $ppdfilename";
-print PPDFILE @ppdfile;
-close PPDFILE;
-
-# Re-initialize CUPS (must be done after a "manual" change on the PPD file)
-
-system("killall -HUP cupsd");
-
-print "\n";
-print "Done.\n";
-print "\n";
-print "Now your printer \"$queue\" will use the new margin and offset settings by\n";
-print "default. You can turn them off by switching the option \"Page Margins/Offsets\"\n";
-print "to \"Driver Default\" in kprinter, GTKlp, or XPP.\n";
-print "\n";
-print "On the command line (\"lpr\", \"lp\", \"lpoptions\", ...) use the option\n";
-print "\"-o Margins=Default\" to turn off and \"-o Margins=Custom\" to turn on your\n";
-print "settings.\n";
-print "\n";
-
-exit 0;
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/bash
-
-# Copyright (c) 2001 Anthony Towns <ajt@debian.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-rm -rf /tmp/apt-release-check
-mkdir /tmp/apt-release-check || exit 1
-cd /tmp/apt-release-check
-
->OK
->MISSING
->NOCHECK
->BAD
-
-arch=`dpkg --print-installation-architecture`
-
-am_root () {
- [ `id -u` -eq 0 ]
-}
-
-get_md5sumsize () {
- cat "$1" | awk '/^MD5Sum:/,/^SHA1:/' |
- MYARG="$2" perl -ne '@f = split /\s+/; if ($f[3] eq $ENV{"MYARG"}) { print "$f[1] $f[2]\n"; exit(0); }'
-}
-
-checkit () {
- local FILE="$1"
- local LOOKUP="$2"
-
- Y="`get_md5sumsize Release "$LOOKUP"`"
- Y="`echo "$Y" | sed 's/^ *//;s/ */ /g'`"
-
- if [ ! -e "/var/lib/apt/lists/$FILE" ]; then
- if [ "$Y" = "" ]; then
- # No file, but not needed anyway
- echo "OK"
- return
- fi
- echo "$FILE" >>MISSING
- echo "MISSING $Y"
- return
- fi
- if [ "$Y" = "" ]; then
- echo "$FILE" >>NOCHECK
- echo "NOCHECK"
- return
- fi
- X="`md5sum < /var/lib/apt/lists/$FILE | cut -d\ -f1` `wc -c < /var/lib/apt/lists/$FILE`"
- X="`echo "$X" | sed 's/^ *//;s/ */ /g'`"
- if [ "$X" != "$Y" ]; then
- echo "$FILE" >>BAD
- echo "BAD"
- return
- fi
- echo "$FILE" >>OK
- echo "OK"
-}
-
-echo
-echo "Checking sources in /etc/apt/sources.list:"
-echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
-echo
-(echo "You should take care to ensure that the distributions you're downloading"
-echo "are the ones you think you are downloading, and that they are as up to"
-echo "date as you would expect (testing and unstable should be no more than"
-echo "two or three days out of date, stable-updates no more than a few weeks"
-echo "or a month)."
-) | fmt
-echo
-
-cat /etc/apt/sources.list |
- sed 's/^ *//' | grep '^[^#]' |
- while read ty url dist comps; do
- if [ "${url%%:*}" = "http" -o "${url%%:*}" = "ftp" ]; then
- baseurl="${url#*://}"
- else
- continue
- fi
-
- echo "Source: ${ty} ${url} ${dist} ${comps}"
-
- rm -f Release Release.gpg
- lynx -reload -dump "${url}/dists/${dist}/Release" >/dev/null 2>&1
- wget -q -O Release "${url}/dists/${dist}/Release"
-
- if ! grep -q '^' Release; then
- echo " * NO TOP-LEVEL Release FILE"
- >Release
- else
- origline=`sed -n 's/^Origin: *//p' Release | head -1`
- lablline=`sed -n 's/^Label: *//p' Release | head -1`
- suitline=`sed -n 's/^Suite: *//p' Release | head -1`
- codeline=`sed -n 's/^Codename: *//p' Release | head -1`
- dateline=`grep "^Date:" Release | head -1`
- dscrline=`grep "^Description:" Release | head -1`
- echo " o Origin: $origline/$lablline"
- echo " o Suite: $suitline/$codeline"
- echo " o $dateline"
- echo " o $dscrline"
-
- if [ "${dist%%/*}" != "$suitline" -a "${dist%%/*}" != "$codeline" ]; then
- echo " * WARNING: asked for $dist, got $suitline/$codeline"
- fi
-
- lynx -reload -dump "${url}/dists/${dist}/Release.gpg" >/dev/null 2>&1
- wget -q -O Release.gpg "${url}/dists/${dist}/Release.gpg"
-
- gpgv --status-fd 3 Release.gpg Release 3>&1 >/dev/null 2>&1 | sed -n "s/^\[GNUPG:\] //p" | (okay=0; err=""; while read gpgcode rest; do
- if [ "$gpgcode" = "GOODSIG" ]; then
- if [ "$err" != "" ]; then
- echo " * Signed by ${err# } key: ${rest#* }"
- else
- echo " o Signed by: ${rest#* }"
- okay=1
- fi
- err=""
- elif [ "$gpgcode" = "BADSIG" ]; then
- echo " * BAD SIGNATURE BY: ${rest#* }"
- err=""
- elif [ "$gpgcode" = "ERRSIG" ]; then
- echo " * COULDN'T CHECK SIGNATURE BY KEYID: ${rest%% *}"
- err=""
- elif [ "$gpgcode" = "SIGREVOKED" ]; then
- err="$err REVOKED"
- elif [ "$gpgcode" = "SIGEXPIRED" ]; then
- err="$err EXPIRED"
- fi
- done
- if [ "$okay" != 1 ]; then
- echo " * NO VALID SIGNATURE"
- >Release
- fi)
- fi
- okaycomps=""
- for comp in $comps; do
- if [ "$ty" = "deb" ]; then
- X=$(checkit "`echo "${baseurl}/dists/${dist}/${comp}/binary-${arch}/Release" | sed 's,//*,_,g'`" "${comp}/binary-${arch}/Release")
- Y=$(checkit "`echo "${baseurl}/dists/${dist}/${comp}/binary-${arch}/Packages" | sed 's,//*,_,g'`" "${comp}/binary-${arch}/Packages")
- if [ "$X $Y" = "OK OK" ]; then
- okaycomps="$okaycomps $comp"
- else
- echo " * PROBLEMS WITH $comp ($X, $Y)"
- fi
- elif [ "$ty" = "deb-src" ]; then
- X=$(checkit "`echo "${baseurl}/dists/${dist}/${comp}/source/Release" | sed 's,//*,_,g'`" "${comp}/source/Release")
- Y=$(checkit "`echo "${baseurl}/dists/${dist}/${comp}/source/Sources" | sed 's,//*,_,g'`" "${comp}/source/Sources")
- if [ "$X $Y" = "OK OK" ]; then
- okaycomps="$okaycomps $comp"
- else
- echo " * PROBLEMS WITH component $comp ($X, $Y)"
- fi
- fi
- done
- [ "$okaycomps" = "" ] || echo " o Okay:$okaycomps"
- echo
- done
-
-echo "Results"
-echo "~~~~~~~"
-echo
-
-allokay=true
-
-cd /tmp/apt-release-check
-diff <(cat BAD MISSING NOCHECK OK | sort) <(cd /var/lib/apt/lists && find . -type f -maxdepth 1 | sed 's,^\./,,g' | grep '_' | sort) | sed -n 's/^> //p' >UNVALIDATED
-
-cd /tmp/apt-release-check
-if grep -q ^ UNVALIDATED; then
- allokay=false
- (echo "The following files in /var/lib/apt/lists have not been validated."
- echo "This could turn out to be a harmless indication that this script"
- echo "is buggy or out of date, or it could let trojaned packages get onto"
- echo "your system."
- ) | fmt
- echo
- sed 's/^/ /' < UNVALIDATED
- echo
-fi
-
-if grep -q ^ BAD; then
- allokay=false
- (echo "The contents of the following files in /var/lib/apt/lists does not"
- echo "match what was expected. This may mean these sources are out of date,"
- echo "that the archive is having problems, or that someone is actively"
- echo "using your mirror to distribute trojans."
- if am_root; then
- echo "The files have been renamed to have the extension .FAILED and"
- echo "will be ignored by apt."
- cat BAD | while read a; do
- mv /var/lib/apt/lists/$a /var/lib/apt/lists/${a}.FAILED
- done
- fi) | fmt
- echo
- sed 's/^/ /' < BAD
- echo
-fi
-
-if grep -q ^ MISSING; then
- allokay=false
- (echo "The following files from /var/lib/apt/lists were missing. This"
- echo "may cause you to miss out on updates to some vulnerable packages."
- ) | fmt
- echo
- sed 's/^/ /' < MISSING
- echo
-fi
-
-if grep -q ^ NOCHECK; then
- allokay=false
- (echo "The contents of the following files in /var/lib/apt/lists could not"
- echo "be validated due to the lack of a signed Release file, or the lack"
- echo "of an appropriate entry in a signed Release file. This probably"
- echo "means that the maintainers of these sources are slack, but may mean"
- echo "these sources are being actively used to distribute trojans."
- if am_root; then
- echo "The files have been renamed to have the extension .FAILED and"
- echo "will be ignored by apt."
- cat NOCHECK | while read a; do
- mv /var/lib/apt/lists/$a /var/lib/apt/lists/${a}.FAILED
- done
- fi) | fmt
- echo
- sed 's/^/ /' < NOCHECK
- echo
-fi
-
-if $allokay; then
- echo 'Everything seems okay!'
- echo
-fi
-
-rm -rf /tmp/apt-release-check
+++ /dev/null
-#!/bin/sh
-# Filename: bt-hid
-# Purpose: connect human input device via bluetooth to local system
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-. /etc/grml/lsb-functions
-
-if [ "$(id -ru)" != "0" ] ; then
- eerror "Need root privileges. Please run $0 as user root." ; eend 1
- exit 1
-fi
-
-case "$1" in
- start)
- einfo "Starting bluetooth support."
- eindent
-
- if pgrep dbus-daemon 1>/dev/null; then
- einfo "dbus already running." ; eend 0
- else
- einfo "Starting dbus."
- /etc/init.d/dbus start 1>/dev/null ; eend $?
- fi
-
- if pgrep sdpd 1>/dev/null; then
- einfo "Main bluetooth daemons seem to be already running." ; eend 0
- else
- einfo "Starting main bluetooth support."
- /etc/init.d/bluetooth start 1>/dev/null ; eend $?
- fi
-
- if pgrep hcid 1>/dev/null; then
- einfo "hcid already running."
- else
- einfo "Starting hcid."
- HCIINFO=$(mktemp)
- if start-stop-daemon --start --exec /usr/sbin/hcid 1>$HCIINFO 2>&1 ; then
- rm -f $HCIINFO
- eend 0
- else
- eerror "hcid could not be started: `cat $HCIINFO`. Exiting."
- rm -f $HCIINFO
- eend 1
- exit 1
- fi
- fi
- einfo "Loading bluetooth modules:"
- for module in bluetooth ohci1394 hci_usb ; do
- eindent
- einfo "$module" ; modprobe $module ; eend $?
- eoutdent
- done
-
- einfo "Scanning for human input device(s). Press the 'connect' button on the device!"
- einfo "Scanning might take a while. Searching..."
- SUCCESS=$(mktemp)
- ERROR=$(mktemp)
- if hidd --search 1>${SUCCESS} 2>${ERROR} ; then
- if ! grep -q 'Connecting to device' $SUCCESS ; then
- eerror "Could not find any devices. Exiting." ; eend 1
- exit 1
- else
- ID=$(awk '/Connecting to device/ {print $4}' $SUCCESS)
- if [ -n "$ID" ] ; then
- einfo "Success: connected device ${ID}." ; eend 0
- logger -t "bluez-connect" "connected human input device ${ID}"
- else
- ewarn "Warning: searching for device succeded but no connection could be established."
- fi
- fi
- else
- eerror "Error: `cat $ERROR`" ; eend 1
- fi
- rm -f $SUCCESS $ERROR
- ;;
- stop)
- einfo "Stopping hcid."
- killall hcid ; eend $? # workaround because start-stop-daemon does not work :-/
- einfo "Disconnecting all human input devices."
- logger -t "bluez-connect" "disconnected all human input devices"
- hidd --killall ; eend $?
- ;;
- restart|force-reload)
- $0 stop
- sleep 1
- $0 start
- ;;
- status)
- local INFO="$(hidd --show)"
- einfo "$0 - checking status:"
- eindent
- if pgrep hcid 1>/dev/null ; then
- einfo "hcid running." ; eend 0
- else
- eerror "hcid not running." ; eend 1
- fi
- if [ -n "$INFO" ] ; then
- einfo "$INFO" ; eend 0
- else
- eerror "No devices connected." ; eend 1
- fi
- eoutdent
- ;;
- *)
- echo "Usage: $0 {start|stop|status|restart|force-reload}"
- exit 1
- ;;
-esac
-
-eoutdent
-
-exit 0
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/usr/bin/perl
-
-# Rebuild the Debian '/var/lib/dpkg/status' file from information in
-# '/var/lib/dpkg/available' and '/var/lib/dpkg/info/*.list'. This is
-# useful if your 'status' file got corrupted if the system crashed during
-# package maintenance, for example.
-#
-# Copyright 2002 by Patrick Reynolds <reynolds@cs.duke.edu>
-# Distributed under the terms of the GNU General Public License (GPL).
-#
-# Usage:
-# dpkg-rebuild
-# It takes no arguments and generates output in /tmp/status.
-# Move /tmp/status to /var/lib/dpkg if it looks acceptable.
-#
-# Limitations:
-# 1) Packages that are no longer available will not show up in the
-# rebuilt 'status' file. This means installed-but-obsolete packages
-# can't be managed after a rebuild.
-#
-# 2) The 'Conffiles:' keys in the 'status' file are not rebuilt.
-# Configuration files may not be completely removed when you purge
-# packages, and package upgrades may clobber existing configuration
-# files without asking.
-#
-# 3) The 'Essential:' keys in the 'status' file now appear after, not
-# before, the 'Status:' keys. I believe this is harmless.
-#
-# 4) Packages in the 'deinstall' state will appear to be in the 'purge'
-# state. Their configuration files will remain, but dpkg won't know
-# about them.
-#
-# 5) Packages in transitional or error states will be misreported.
-
-$available = "/var/lib/dpkg/available";
-$status = "/tmp/status";
-$info_dir = "/var/lib/dpkg/info";
-
-foreach (<$info_dir/*.list>) {
- s#.*/([^/]+)\.list$#$1#;
- $installed{$_} = 1;
-}
-
-$state = 0; # 0=between, 1=copying-installed, 2=copying-not-installed
-open(AVAILABLE, "<$available") || die "no $available";
-open(STATUS, ">$status") || die "no $status";
-while (<AVAILABLE>) {
- chomp;
- if ($state == 0) {
- if (/^Package: (\S+)$/) {
- print STATUS "$_\n";
- if ($installed{$1}) {
- $state = 1;
- print STATUS "Status: install ok installed\n";
- delete $installed{$1};
- }
- else {
- $state = 2;
- print STATUS "Status: purge ok not-installed\n";
- }
- }
- else {
- die "Expected 'Package:' at $.";
- }
- }
- elsif ($state == 1) {
- if ($_ eq "") {
- print STATUS "\n";
- $state = 0;
- }
- elsif (!/^Architecture: / && !/^Filename: / && !/^Size: / && !/^MD5sum: /) {
- print STATUS "$_\n";
- }
- }
- elsif ($state == 2) {
- if ($_ eq "") {
- print STATUS "\n";
- $state = 0;
- }
- elsif (/^Priority: / || /^Section: /) {
- print STATUS "$_\n";
- }
- }
- else {
- die "Invalid state $state";
- }
-}
-
-printf "Installed packages not found in $available:\n";
-foreach (sort keys %installed) {
- print " $_\n";
-}
"grml-setkeyboard" "Configure system wide keyboard settings" \
"grml-network" "Configure network settings/setup" \
"grml-terminalserver" "Configure and start terminalserver for booting via network" \
-"suspenduser" "Suspend a user account for indefinite time" \
"exit" "Exit this program")
retval=$?
if [ "$MENU" = "grml-terminalserver" ]; then
exec grml-terminalserver
fi
- if [ "$MENU" = "suspenduser" ]; then
- exec suspenduser_gui.sh
- fi
if [ "$MENU" = "exit" ]; then
exit
fi
+++ /dev/null
-#!/bin/zsh
-# Filename: grml-tpm
-# Purpose: set up a system for use with TPM technology
-# Authors: (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-. /etc/grml/lsb-functions
-
-if [ $(id -u) != 0 ] ; then
- eerror Error: become root before starting $0 >& 2 ; eend 1
- exit 100
-fi
-
-PN=$(basename "$0")
-TPM_MODULES=$(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)
-
-case "$1" in
- start)
- # tpm_emulator registers as /sys/class/misc/tpm while
- # real tpm modules should provide /sys/class/misc/tpm0
- if [ -d /sys/class/misc/tpm0 ] ; then
- ewarn "TPM kernel modules $TPM_MODULES seem to be loaded already." ; eend 0
- else
- if ! modinfo tpm_emulator &>/dev/null ; then
- eerror "Error: kernel module tpm_emulator not found." >& 2
- eerror "Check for an existing debian package or get it from http://tpm-emulator.berlios.de/" >& 2
- exit 1
- fi
-
- if grep -q tpm_emulator /proc/modules ; then
- ewarn "Kernel driver tpm_emulator already loaded." ; eend 0
- else
- einfo "Loading kernel driver tpm_emulator."
- modprobe tpm_emulator startup=clear ; eend $?
- fi
- fi
-
- if [ -x /usr/sbin/tcsd ] ; then
- if pidof tcsd &>/dev/null ; then
- ewarn "trousers daemon already running." ; eend 0
- else
- einfo "Starting trousers daemon."
- /usr/sbin/tcsd ; eend $?
- [ $? != 0 ] && exit 1
- fi
- else
- eerror "trousers daemon not available. Exiting." ; eend 1
- exit 1
- fi
-
- einfo "Startup of $PN finished." ; eend 0
- ;;
- stop)
- if pidof tcsd &>/dev/null ; then
- einfo "Stopping trousers daemon."
- kill `pidof tcsd` ; eend $?
- else
- ewarn "No running trousers daemon found. Nothing to be done." ; eend 0
- fi
-
- if grep -q tpm_emulator /proc/modules ; then
- einfo "Unloading kernel driver tpm_emulator."
- rmmod tpm_emulator ; eend $?
- elif grep -q tpm /proc/modules ; then
- einfo "Unloading TPM kernel drivers $(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)."
- while grep -q tpm /proc/modules ; do
- for module in $(cd /lib/modules/$(uname -r)/kernel/drivers/char/tpm/ ; ls *.ko) ; do
- rmmod ${module%%.ko} &>/dev/null
- done
- eend 0
- done
- else
- ewarn "No TPM kernel driver found. Nothing to be done." ; eend 0
- fi
- ;;
- status)
- if [ -r /sys/class/misc/tpm ] ; then
- einfo "Seems to be running with tpm_emulator." ; eend 0
- fi
-
- if [ -r /sys/class/misc/tpm0 ] ; then
- einfo "Seems to be running with real TPM hardware." ; eend 0
- fi
-
- if pidof tcsd &>/dev/null ; then
- einfo "trousers daemon running." ; eend 0
- if [ -x /usr/sbin/tpm_version ] ; then
- einfo "tpm-version: "
- tpm_version ; eend $?
- else
- eerror "tpm_version not found." ; eend 1
- fi
- else
- ewarn "trousers daemon not running." ; eend 0
- fi
-
- if [ -r /sys/class/misc/tpm0/device/pcrs ] ; then
- einfo "Dumping PCRS..."
- cat /sys/class/misc/tpm0/device/pcrs ; RC=$?
- einfo "... finished dumping of PCRS." ; eend $RC
- fi
- ;;
- restart)
- $0 stop ; sleep 1 ; $0 start
- ;;
- *)
- eerror "Usage: $PN [start|stop|restart|status]"
- ;;
-esac
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: mkdosswapfile
-# Purpose: create GRML swapfile on an existing DOS partition
-# Authors: (c) Klaus Knopper Mar 2001, (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-PATH="/bin:/sbin:/usr/bin:/usr/sbin"
-export PATH
-
-# XDIALOG_HIGH_DIALOG_COMPAT=1
-# export XDIALOG_HIGH_DIALOG_COMPAT
-
-[ "`id -u`" != "0" ] && exec sudo "$0" "$@"
-
-#TMP="/tmp/mkdosswapfile.tmp$$"
-TMP=$(mktemp)
-
-bailout(){
- rm -f "$TMP"
- exit 0
-}
-
-DIALOG="dialog"
-# [ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
-
-trap bailout 1 2 3 15
-
-# LANGUAGE etc.
-[ -r /etc/default/locale ] && . /etc/default/locale
-
-DOSPARTITIONS=""
-
-# Find all DOS partitions
-if [ -f /proc/partitions ]
-then
-partitions=""
-for p in $(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $4}}}' /proc/partitions); do
-case $p in
- hd?|sd?) partitions="$partitions /dev/$p"; ;;
- *) ;;
-esac
-done
-if [ -n "$partitions" ]
-then
-foundp="$(LANG=C LC_ALL=C fdisk -l $partitions 2>/dev/null)"
-for p in `echo "$foundp" | awk '/^\/dev\//{if(/FAT/){print $1}}'`
-do
-d="/mnt/${p##*/}"
-if mount -o ro -t vfat $p $d 2>/dev/null; then
-[ ! -f $d/grml.swp ] && DOSPARTITIONS="$DOSPARTITIONS $p"
-umount $d
-fi
-done
-fi
-fi
-
-if [ -n "$DOSPARTITIONS" ]; then
-echo -n "\ec"
-for p in $DOSPARTITIONS; do
-# Language-dependent Messages
-case "$LANGUAGE" in
-de|at|ch)
-MESSAGE1="Moechten Sie eine SWAP-Datei 'grml.swp' fuer GRML auf Ihrer bestehenden DOS-Partition $p anlegen? Eine solche SWAP-Datei ermoeglicht es Ihnen, trotz geringem Hauptspeicher Programmpakete wie KDE zu benutzen. Sie koennen diese Datei nach Beendigung Ihrer GRML-Session gefahrlos wieder loeschen."
-MESSAGE2="Bitte geben Sie an, wieviel MB Sie als SWAP verwenden wollen. Empfohlen: 60 - 128. Frei: "
-MESSAGE3="Erzeuge swapfile 'grml.swp' auf $p..."
-ERROR1="Leider ist nicht genug Platz auf dieser Partition ($p), es sollten mindestens 60 MB frei sein."
-SUCCESS="Das Einrichten des Swapfiles 'grml.swp' auf $p war erfolgreich."
-;;
-es)
-MESSAGE1="¿Quiere crear un fichero de memoria virtual (swap) 'grml.swp' en su partición DOS existente $p? Un fichero swap le permite utilizar grandes aplicaciones como KDE incluso si su ordenador tiene poca memoria. Puede borrar tranquilamente el fichero swap una vez haya finalizado su sesión con GRML."
-MESSAGE2="Por favor, especifique la cantidad de espacio en disco que quiere utilizar como SWAP. Recomendado: 60 - 128. Libre: "
-MESSAGE3="Creando archivo de memoria virtual 'grml.swp' en $p..."
-ERROR1="Lo siento, no hay suficiente espacio libre en $p. Son necesarios al menos 60 MB."
-SUCCESS="Archivo swap 'grml.swp' en $p creado satisfactoriamente."
-;;
-*)
-MESSAGE1="Do you want to create a swapfile 'grml.swp' on your existing DOS partition $p? A swapfile allows you to use huge application packages like KDE even if your computer is low on memory. You can safely delete the swapfile after finishing your GRML session."
-MESSAGE2="Please specify the amount of diskspace that you want to use as SWAP. Recommended: 60 - 128. Free: "
-MESSAGE3="Creating swapfile 'grml.swp' on $p..."
-ERROR1="Sorry, not enough free space on $p. At least 60 MB required."
-SUCCESS="Swapfile 'grml.swp' on $p successfully created."
-;;
-esac
-
-d="/mnt/${p##*/}"
-f="$d/grml.swp"
-if mount -o umask=000,rw -t vfat $p $d; then
-if $DIALOG --yesno "$MESSAGE1" 11 62; then
-AVAIL=$(df -m $d | awk '/^\/dev\//{print $4}')
-if [ "$AVAIL" -lt 60 ]; then
-$DIALOG --msgbox "$ERROR1" 10 45
-umount $d
-else
-rm -f "$TMP"
-$DIALOG --inputbox "$MESSAGE2 $AVAIL" 8 62 "60" 2>"$TMP" || { umount "$d" ; bailout; }
-IN="`cat $TMP`"
-[ "$IN" -ge 60 -a "$IN" -le "$AVAIL" ] 2>/dev/null || IN="60"
-echo "$MESSAGE3"
-dd if=/dev/zero of="$f" bs=1000k count="$IN" && \
-mkswap -v1 "$f" && swapon -v "$f" 2>/dev/null && \
-echo "$f swap swap defaults 0 0" >>/etc/fstab
-[ "$?" = "0" ] && { sleep 2 ; $DIALOG --msgbox "$SUCCESS" 10 45; } || umount "$d" 2>/dev/null
-mount -o remount,ro $d
-fi
-else
-umount "$d"
-fi
-fi
-done
-else
-case "$LANGUAGE" in
-de|at|ch)
-ERROR2="Leider sind auf Ihrem System keine geeigneten DOS-Partitionen zum Einrichten eines Swapfile vorhanden."
-;;
-es)
-ERROR2="Lo siento, no se han encontrado particiones disponibles de tipo DOS para el fichero swap de memoria virtual."
-;;
-*)
-ERROR2="Sorry, no DOS partitions available for swapfile."
-;;
-esac
-
-$DIALOG --msgbox "$ERROR2" 10 45
-fi
-
-bailout
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/bash
-# Filename: ndiswrapper.sh
-# Purpose: NdisWrapper configuration script
-# Authors: (c) Martin Oehler 2004, (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin"
-export PATH
-
-# Get root
-if [ $(id -u) != 0 ] ; then
- echo Error: become root before starting $0 >& 2
- exit 100
-fi
-unset SUDO_COMMAND
-
-# XDIALOG_HIGH_DIALOG_COMPAT=1
-# export XDIALOG_HIGH_DIALOG_COMPAT
-# XDIALOG_FORCE_AUTOSIZE=1
-# export XDIALOG_FORCE_AUTOSIZE
-
-TMP=$(mktemp)
-
-DIALOG="dialog"
-# [ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
-
-BACKTITLE="GRML NDISWRAPPER TOOL"
-
-# this error is displayed when something is wrong eith the
-# inf file
-inf_error() {
- $DIALOG --title "$BACKTITLE" --backtitle "ERROR" --msgbox "The selected file is no *.inf file or the *.inf file is invalid, exiting." 12 75;
-}
-
-
-# at first we show the usual disclaimer that the usage of this
-# script could simply destroy everything
-
-# dialog doesn't knows --center
-if [ "$DIALOG" = "dialog" ]; then
- $DIALOG --title "$BACKTITLE" --backtitle "DISCLAIMER" --msgbox "This is the configuration tool for the ndiswrapper utilities. \n
-Be aware that loading a windows driver file for your wlan \n
-card using this tool could freeze your system. \n
-\n
-You need matching driver.inf and driver.sys files residing on \n
-a mounted data medium. After the windows drivers have been \n
-successfully loaded via the ndiswrapper, you have to configure \n
-your wlan settings via iwconfig. Future releases of this script \n
-will include this. \n
-\n
-Please send your feedback to <oehler@knopper.net>" 16 75;
-else
- $DIALOG --center --title "$BACKTITLE" --backtitle "DISCLAIMER" --msgbox "This is the configuration tool for the ndiswrapper utilities. \n
-Be aware that loading a windows driver file for your \n
-wlan card using this tool could freeze your system. \n
-\n
-You need matching driver.inf and driver.sys files residing on \n
-a mounted data medium. After the windows drivers have been \n
-successfully loaded via the ndiswrapper, you have to configure \n
-your wlan settings via iwconfig. Future releases of this script \n
-will include this. \n
-\n
-Please send your feedback to \n
-<oehler@knopper.net>" 12 75;
-fi
-
-$DIALOG --title "$BACKTITLE" --backtitle "SELECT <DRIVER>.INF FILE" --fselect "/home/grml" 12 75 2>"$TMP"; read DRIVER_PATH <"$TMP"; rm -f "$TMP";
-
-test -x "/usr/sbin/ndiswrapper" || { echo "NdisWrapper not found, exiting." >&2; exit 1; }
-test -x "/sbin/modprobe" || { echo "modprobe not found, exiting." >&2; exit 1; }
-test -e $DRIVER_PATH || { echo "$DRIVER_PATH does not exist, exiting." >&2; exit 1; }
-case "$DRIVER_PATH" in
- *\.inf*) NUM=`grep -c "sys" "$DRIVER_PATH"`
- if [ "$NUM" -lt 1 ]; then
- inf_error; exit 1;
- fi;;
- *) inf_error; exit 1;
-esac
-
-# how much lines are in /proc/net/wireless
-LINES1=`cat /proc/net/wireless | wc -l`
-
-ndiswrapper -i $DRIVER_PATH
-modprobe ndiswrapper
-ndiswrapper -m
-
-# have we got a new device?
-LINES2=`cat /proc/net/wireless | wc -l`
-
-if [ "$LINES2" -gt "$LINES1" ]; then
- $DIALOG --title "$BACKTITLE" --backtitle "RESULT" --msgbox "The ndiswrapper module has been loaded. You may configure your wlan card with iwconfig now." 12 75 2>"$TMP"; [ "$?" != "0" ] && return 1; rm -f "$TMP";
-else
- $DIALOG --title "$BACKTITLE" --backtitle "RESULT" --msgbox "The ndiswrapper module has been loaded but there is no new device. Perhaps NdisWrapper is not working with your driver file." 12 75 2>"$TMP"; [ "$?" != "0" ] && return 1; rm -f "$TMP";
-fi
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/zsh
-# Filename: prepare_ramdisk.sh
-# Purpose: set up a ramdisk of a selected directory
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if [ $(id -u) != 0 ] ; then
- echo "Error: $0 requires root permissions. Exiting."
- exit 1
-fi
-
-setopt nonomatch
-
-usage(){
- echo "Usage: $0 <directory> <start|stop>"
-}
-
-if ! [ -n "$1" -a -n "$2" ] ; then
- usage
- exit 1
-fi
-
-DIRECTORY="$1"
-FILENAME=$(echo $DIRECTORY | sed 's#/#_#g')
-CACHE_FILE="/ramdisk_cache/$FILENAME"
-CACHE_FILE_SIZE=64
-
-prepare_start () {
- if ! mount | grep -q "tmpfs on /ramdisk_cache" ; then
- echo -n "Setting up ramdisk /ramdisk_cache: "
- [ -d /ramdisk_cache ] || mkdir /ramdisk_cache
- mount -t tmpfs tmpfs /ramdisk_cache && echo "done"
- fi
-
- if ! mount | grep -q "${DIRECTORY}.*loop" ; then
- if [ -d "$DIRECTORY" ] ; then
- if ! mount | grep -q "loop.*${DIRECTORY}" ; then
- mv $DIRECTORY/ $DIRECTORY.tmpfile && \
- mkdir $DIRECTORY
-
- echo -n "Setting up cachefile $CACHE_FILE for $DIRECTORY: "
- dd if=/dev/zero of=${CACHE_FILE} bs=1M count=${CACHE_FILE_SIZE} \
- seek=${CACHE_FILE_SIZE} &>/dev/null && \
- mkfs.ext2 -F ${CACHE_FILE} &>/dev/null && \
- mount -o loop ${CACHE_FILE} $DIRECTORY && \
- cp -a $DIRECTORY.tmpfile/* $DIRECTORY &>/dev/null
- cp -a $DIRECTORY.tmpfile/.* $DIRECTORY &>/dev/null
- echo "done" || echo "failed."
- else
- echo "Error: $DIRECTORY already mounted as loopback device. Exiting."
- fi
- else
- echo "Error: $DIRECTORY does not exist. Exiting."
- exit 1
- fi
- else
- echo "Error: $DIRECTORY already mounted loop back."
- fi
-}
-
-prepare_stop () {
- if mount | grep -q $DIRECTORY ; then
- echo -n "Unmounting cachefile ${CACHE_FILE}: "
- cp -a $DIRECTORY/* $DIRECTORY.tmpfile/ &>/dev/null
- cp -a $DIRECTORY/.* $DIRECTORY.tmpfile/ &>/dev/null
- if umount $DIRECTORY ; then
- rmdir $DIRECTORY
- mv $DIRECTORY.tmpfile/ $DIRECTORY
- echo done
- else
- echo "error [while unmounting ${DIRECTORY}]"
- fi
- else
- echo "Error: $DIRECTORY not mounted."
- fi
-}
-
-case "$2" in
- start)
- prepare_start || exit 1
- ;;
- stop)
- prepare_stop || exit 1
- ;;
- *)
- usage
- exit 1
-esac
-
-exit 0
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/zsh
-# Filename: prepare_tmpfs.sh
-# Purpose: set up a tmpfs of a selected directory
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-if [ $(id -u) != 0 ] ; then
- echo "Error: $0 requires root permissions. Exiting."
- exit 1
-fi
-
-setopt nonomatch
-
-usage(){
- echo "Usage: $0 <directory> <start|stop>"
-}
-
-if ! [ -n "$1" -a -n "$2" ] ; then
- usage
- exit 1
-fi
-
-DIRECTORY="$1"
-
-prepare_start () {
- if ! mount | grep -q "tmpfs on ${DIRECTORY}" ; then
- if [ -d $DIRECTORY ] ; then
- if ! [ -d $DIRECTORY.tmpfile ] ; then
- echo -n "Setting up tmpfs ${DIRECTORY}: "
- mv $DIRECTORY/ $DIRECTORY.tmpfile && \
- mkdir $DIRECTORY && \
- if mount $TMPFS -t tmpfs tmpfs $DIRECTORY ; then
- cp -a $DIRECTORY.tmpfile/* $DIRECTORY &>/dev/null
- cp -a $DIRECTORY.tmpfile/.* $DIRECTORY &>/dev/null
- echo done
- else
- echo failed
- fi
- else
- echo "Erorr: tmpdir $DIRECTORY.tmpfile exists already. Exiting."
- exit 1
- fi
- else
- echo "Error: $DIRECTORY does not exist. Exiting."
- exit 1
- fi
- else
- echo "Error: $DIRECTORY already mounted. Exiting."
- exit 1
- fi
-}
-
-prepare_stop () {
- if mount | grep -q $DIRECTORY ; then
- echo -n "Unmounting tmpfs ${DIRECTORY}: "
- umount ${DIRECTORY} && \
- rmdir $DIRECTORY && \
- mv $DIRECTORY.tmpfile $DIRECTORY && echo done || echo failed
- else
- echo "Error: ${DIRECTORY} not mounted."
- exit 1
- fi
-}
-
-case "$2" in
- start)
- prepare_start || exit 1
- ;;
- stop)
- prepare_stop || exit 1
- ;;
- *)
- usage
- exit 1
-esac
-
-exit 0
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: suspenduser.sh
-# Purpose: suspend a user account for the indefinite future
-# Authors: Dave Taylor / http://www.intuitive.com/wicked/showscript.cgi?045-suspenduser.sh
-# Bug-Reports: see http://grml.org/bugs/
-################################################################################
-
-homedir="/home" # home directory for users
-secs=10 # seconds before user is logged out
-
-if [ -z "$1" ] ; then
- echo "Usage: $0 account" >&2 ; exit 1
-elif [ "$(whoami)" != "root" ] ; then
- echo "Error. You must be 'root' to run this command." >&2; exit 1
-fi
-
-echo "Please change account $1 password to something new."
-passwd $1
-
-# Now, let's see if they're logged in, and if so, boot 'em
-
-if [ ! -z $(who | grep $1) ] ; then
-
- tty="$(who | grep $1 | tail -1 | awk '{print $2}')"
-
- cat << "EOF" > /dev/$tty
-
-*************************************************************
-URGENT NOTICE FROM THE ADMINISTRATOR:
-
-This account is being suspended at the request of management.
-You are going to be logged out in $secs seconds. Please immediately
-shut down any processes you have running and log out.
-
-If you have any questions, please contact your supervisor or
-John Doe, Director of Information Technology.
-*************************************************************
-EOF
-
- echo "(Warned $1, now sleeping $secs seconds)"
-
- sleep $secs
-
- killall -s HUP -u $1 # send hangup sig to their processes
- sleep 1 # give it a second...
- killall -s KILL -u $1 # and kill anything left
-
- echo "$(date): $1 was logged in. Just logged them out."
-fi
-
-# Finally, let's close off their home directory from prying eyes:
-
-chmod 000 $homedir/$1
-
-echo "Account $1 has been suspended."
-
-exit 0
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: suspenduser_gui.sh
-# Purpose: dialog interface for suspend user
-# Authors: grml-team (grml.org), (c) Nico Golde <nico@grml.org>, (c) Michael Prokop <mika@grml.org>
-# License: This file is licensed under the GPL v2.
-################################################################################
-
-PATH=${PATH:-'/usr/bin:/usr/sbin'}
-
-if [ "$(whoami)" != "root" ] ; then
- echo "Error. You must be 'root' to run this command." >&2
- exit 1
-fi
-
-dialog --stdout --title "Suspend User" --msgbox "Welcome to Suspend User
-
-This script allows you to suspend a user from your system for
-an indefinite time." 8 65
-
-GETUSER=$(dialog --stdout --title "Suspend User" --inputbox "User to suspend:" 0 40) || exit 0
-SUSPENDUSER=${GETUSER%/*}
-suspenduser.sh $SUSPENDUSER
-
-## END OF FILE #################################################################
+++ /dev/null
-#!/bin/sh
-# Filename: swspeak-setup
-# Purpose: script for activating software speak(up) features
-# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports: see http://grml.org/bugs/
-# License: This file is licensed under the GPL v2 or any later version.
-################################################################################
-# Note: the script is used via swspeak() function in grml's zshrc so
-# the prompt of zsh is set accordingly
-# TODO: support disabling swspeakup again?
-
-if [ -r /etc/grml/script-functions ] ; then
- . /etc/grml/script-functions
-else
- echo "Failed to source /etc/grml/script-functions - exiting.">&2
- exit 1
-fi
-
-if [ -r /etc/grml/lsb-functions ] ; then
- . /etc/grml/lsb-functions
-else
- echo "Failed to source /etc/grml/lsb-functions - exiting.">&2
- exit 1
-fi
-
-if [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
- cat << EOF
-swspeak - script for activating software speak features
-
-Usage: swspeak [-a] [-e|-s] [-f] [-h]
-
-Supported options:
-
- -e use espeakup (default, if available)
- -s use speechd-up (fallback, if available)
- -a do not execute aumix for setting mixer levels
- -f disable flite sound output
- -h display this help text
-EOF
- exit 0
-fi
-
-NOAUMIX=''
-[ "$1" = '-a' ] && NOAUMIX=1
-ESPEAK=''
-[ "$1" = '-e' ] && ESPEAK=1
-NOFLITE=''
-[ "$1" = '-f' ] && NOFLITE=1
-SPEECHD=''
-[ "$1" = '-s' ] && SPEECHD=1
-
-check4root || exit 1
-
-# execute flite only if it's present
-flitewrapper() {
- if [ -x /usr/bin/flite -a -z "$NOFLITE" ] ; then
- flite -o play -t "$*"
- fi
-}
-
-# execute aumix
-if [ -x /usr/bin/aumix -a -z "$NOAUMIX" ] ; then
- einfo "Setting mixer levels to 90"
- aumix -w 90 -v 90 -p 90 -m 90
- eend $?
-fi
-
-# check for software synthesizer support
-if ! [ -r /dev/softsynth ] ; then
- if [ ! -d /proc/speakup/ ] && ! grep -q speakup /proc/modules ; then
- ewarn "Kernel does not support software speakup - trying to load kernel module:" ; eend 0
- eindent
- einfo "Loading speakup_soft"
- if modprobe speakup_soft ; then
- eend 0
- else
- flitewrapper "Fatal error setting up software speakup"
- eend 1
- exit 1
- fi
- eoutdent
- fi
-fi
-
-# the kernel module takes some time until it can be accessed
-sleep 1
-
-# helper functions for espeakup and speechd-up
-espeak() {
-if [ -x /usr/bin/espeakup ] ; then
- espeakup
-else
- flitewrapper "espeakup not available, sorry."
- return 1
-fi
-}
-
-speechd() {
-if [ -x /usr/bin/speechd-up ] ; then
- /etc/init.d/speech-dispatcher start
- nice -n -20 speechd-up
-else
- flitewrapper "speechd-up not available, sorry."
- return 1
-fi
-}
-
-# finally execute the according program:
-if [ -n "$ESPEAK" ] ; then
- espeak && exit 0 || exit 1
-fi
-
-if [ -n "$SPEECHD" ] ; then
- speechd && exit 0 || exit 1
-fi
-
-if grep -q 'swspeak=espeak' /proc/cmdline ; then
- ( espeak && exit 0 ) || ( speechd && exit 0 ) || exit 1
-elif grep -q 'swspeak=speechd' /proc/cmdline ; then
- ( speechd && exit 0 ) || ( espeak && exit 0 ) || exit 1
-else
- ( espeak && exit 0 ) || ( speechd && exit 0 ) || exit 1
-fi
-
-## END OF FILE #################################################################
-# vim: ai tw=100 expandtab foldmethod=marker shiftwidth=3
+++ /dev/null
-%!PS-Adobe-3.0
-%%Pages: 1
-%%Title: Alignment testpage for Ghostscript
-%%Creator: Dieter Stueken (<EMAIL: PROTECTED>)
-%%BeginProlog
-% Source: http://www.geocrawler.com/archives/3/378/1997/1/50/2064509/
-
-/rectdraw % <x0> <y0> <x1> <y1> rectdraw -
- { exch 4 -1 roll exch 2 array astore {0 moveto 0 PH rlineto stroke} forall
- 2 array astore {0 exch moveto PW 0 rlineto stroke} forall
- } bind def
-
-/arrow % <ang> <x0> <y0> arrow
- { gsave translate rotate
- 0 0 moveto 20 60 lineto -20 60 lineto closepath stroke
- 0 0 moveto 0 80 lineto stroke
- grestore
- } bind def
-
-/triangle { % len ang x y
- gsave translate dup rotate exch
- 0 setlinewidth
- 0 0 moveto
- dup 0 lineto
- dup 0.98 mul dup 10 div lineto
- closepath
- gsave 0.65 setgray fill grestore stroke
- 100 10 moveto
- 100 100 2 index {
- gsave 0 -12 rmoveto 0 24 rlineto stroke grestore
- gsave 0 24 rmoveto 10 div 2 index neg rotate
- cvi =string cvs -6 -4 rmoveto show grestore
- 100 10 rmoveto
- } for
- 0 0 moveto
- 0 10 2 index {
- pop
- gsave 0 -6 rmoveto 0 12 rlineto stroke grestore
- 10 1 rmoveto
- } for
- pop pop
- grestore
-} bind def
-
-/round {dup 3 1 roll mul cvi exch div} def
-
-/Show { % print value or unfold array
- dup type /realtype eq {100 round} if
- dup type /nulltype eq
- { pop (-NULL-) show}
- {dup type /arraytype eq
- { ([ ) show {Show} forall ( ]) show}
- {=string cvs show ( ) show}
- ifelse }
- ifelse
-} bind def
-
-/Pval { % key val, move down 1 line
- gsave exch
- gsave Show (:) show grestore
- 150 0 rmoveto Show
- grestore
- 0 -12 rmoveto
-} bind def
-
-/showtext {
- /S 80 string def
- { currentfile S readline pop dup (%END) eq { pop exit } if
- gsave show grestore 0 -12 rmoveto
- } loop
-} bind def
-
-/.knownget { 2 copy known { get true } { pop pop false } ifelse } bind def
-
-%%EndProlog
-%%BeginSetup
-
-% you may try different settings here, but start with default settings first
-%<<
-% /.HWMargins [8.5 38.0 10.5 12.5]
-% /Margins [-35 -51]
-%>> setpagedevice
-%
-
-%%EndSetup
-%%Page: 1
-
-% printout all values
-
-/Helvetica findfont
-12 scalefont setfont
-120 756 moveto
-
-showtext
-Current settings:
-
-%END
-
-[/OutputDevice
- /Margins
- /.HWMargins
- /.MarginsHWResolution
- /HWResolution
- /PageOffset
- /PageSize
-] { currentpagedevice 1 index
- .knownget not {(-undefined-)} if Pval
-} forall
-
-showtext
-
-Graphics alignment:
-
-Let the distance in inches from the left edge of the page to the
-vertical line be H, and from the bottom edge to the horizontal line
-be V. You may define the alignment of your page to the paper by
-
- << /Margins [x y] >> setpagedevice
-with
-%END
-
-gsave
-/res currentpagedevice /.MarginsHWResolution .knownget not {600} if def
-( x = (1 - H) * ) show res 0 get =string cvs show
-(, y = (V - 1) * ) show res 1 get =string cvs show
-grestore 0 -12 rmoveto
-
-showtext
-
-If set correctly the drawn arrows should extend into the
-papers corners (not the clipping corners). After archieving
-that, you may continue with the clipping edges.
-
-The clipping edges may be set by
-
- << /.HWMargins [ml mb mr mt] >> setpagedevice
-
-where [ml mb mr mt] are the distances of the clipped edges of
-your graphics relative to the papers edges (left bottom right top)
-measured in 1/72 inches. The wedge shaped rules may be used to
-define these values very accurately as its intersections are in
-1/72 inches. Take the value at the cutoff point from the scale to
-the next clockwise edge.
-
-Start setting the margin values to all zero to see the natural hardware
-clipping of your printer. You should then define the margins just as big
-enough to keep the defined margins within your printers real hardware
-clipping. This is archieved if you can see the thin line drawn all around
-your defined margin. In addition the thin drawn arrows are just touching
-the margin and should be totally visible.
-
-When you put this settings into your inititializing file "gs_init.ps"
-you may want to apply this setting to a specific printer device only.
-Here is an example of a printer specific setup:
-
-<<
- /ljet4 << % make entries for some device
- /.HWMargins [16.0 13.2 13.0 11.1]
- /Margins [-132 -92]
- >>
- /ljet2p << % and for an other devices, too
- /.HWMargins [14.4 6.8 14.5 17.5]
- /Margins [-60 -23]
- >>
->> currentpagedevice /OutputDevice get
-.knownget {setpagedevice} if
-%END
-
-% get page size
-currentpagedevice /PageSize get aload pop
-/PH exch def
-/PW exch def
-
-1 setlinewidth
-PW 0 0 0 triangle
-PH 90 PW 0 triangle
-PW 180 PW PH triangle
-PH 270 0 PH triangle
-
-% get clipping values
-clippath pathbbox newpath
-
-% show clipping box
-gsave
-1 setlinewidth % 0.65 setgray
-4 copy rectdraw
-grestore
-
-/CT exch def
-/CR exch def
-/CB exch def
-/CL exch def
-
-% draw the alignment lines
-0 setlinewidth
-72 0 moveto 0 CT rlineto stroke
-0 72 moveto CR 0 rlineto stroke
-
-2 setlinewidth
-1 setlinejoin
-1 setlinecap
-
-0 200 moveto 71 0 rlineto -24 -12 rlineto 0 24 rlineto 24 -12 rlineto stroke
-34 206 moveto (H) show
-
-144 0 moveto 0 71 rlineto -12 -24 rlineto 24 0 rlineto -12 24 rlineto stroke
-150 34 moveto (V) show
-
-
-% draw arrows into to the papers corners
-1 setlinewidth
-45
-90 sub dup 0 0 arrow
-90 sub dup 0 PH arrow
-90 sub dup PW PH arrow
-90 sub dup PW 0 arrow
-pop %45
-
-% draw arrows touching the clipping edges
-0 setlinewidth
- 0 PW 2 div CB arrow
-180 PW 2 div CT arrow
--90 CL PH 2 div arrow
- 90 CR PH 2 div arrow
-
-showpage
-%%EOF
\ No newline at end of file
$script
fi
;;
- # turn on speakers for accessibility users:
- *\ swspeak*|*blind*|*brltty*|*speakup*)
- if [ $(which flite) ] ; then
- flite -o play -t "Finished booting"
- fi
- ;;
# do nothing if booting with bootoption noquick:
*\ noquick*)