commit ff78f5b821f6f8890fea51c1df093cd785c6b77a Author: Gabriel Ebner Date: Sun Mar 16 22:02:24 2008 +0100 Initial import; *sigh* now w/o paswords. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d72b3af --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +SUBDIRS = conf gentoo + +.PHONY: all install clean + +all install clean: + @for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done diff --git a/conf/Makefile b/conf/Makefile new file mode 100644 index 0000000..de1d480 --- /dev/null +++ b/conf/Makefile @@ -0,0 +1,32 @@ +FILES = ratpoisonrc vimrc Xresources zshrc $(wildcard zfuncs/*) emacs.el \ + bashrc bash_completion + +ifeq "$(USER)" "gebner" +FILES += muttrc signature.ml gnus.el +XFILES = xsession + +ifeq "$(shell hostname)" "www" +FILES += procmailrc +endif +endif + +.PHONY: all install clean check + +all: $(FILES) $(XFILES) + +install: $(FILES) $(XFILES) + mkdir -p ~/.zfuncs + for i in $(FILES); do install -m0644 $$i ~/.$$i; done + for i in $(XFILES); do install -m0755 $$i ~/.$$i; done + +clean: + rm -f procmailrc muttrc + +check: + for i in $(FILES) $(XFILES); do diff ~/.$$i $$i; done + +procmailrc muttrc: maildirs.m4 +muttrc: gpg.rc + +%: %.m4 + m4 $< >$@ diff --git a/conf/Xresources b/conf/Xresources new file mode 100644 index 0000000..25d4594 --- /dev/null +++ b/conf/Xresources @@ -0,0 +1 @@ +vncviewer*grabKeyboard: true diff --git a/conf/bash_completion b/conf/bash_completion new file mode 100644 index 0000000..2df5dac --- /dev/null +++ b/conf/bash_completion @@ -0,0 +1,4 @@ +# Copyright (C) 2004 Gabriel Ebner + +test -f $MYPREFIX/etc/darcs/bash_completion.d/darcs \ +&& . $MYPREFIX/etc/darcs/bash_completion.d/darcs diff --git a/conf/bashrc b/conf/bashrc new file mode 100644 index 0000000..50ede9b --- /dev/null +++ b/conf/bashrc @@ -0,0 +1,34 @@ +# Copyright (C) 2004 Gabriel Ebner + +. /etc/profile + +MYPREFIX=$HOME/build/myprefix +export USER=`whoami` +export PATH=$MYPREFIX/bin:$PATH +export LD_LIBRARY_PATH=$MYPREFIX/lib64:$MYPREFIX/lib:$LD_LIBRARY_PATH +export MANPATH=$MYPREFIX/man:$MANPATH +export PKG_CONFIG_PATH=$MYPREFIX/lib/pkgconfig:$PKG_CONFIG_PATH +export PYTHONPATH=$MYPREFIX/lib/python2.4/site-packages:$PYTHONPATH +export R_LIBS=$MYPREFIX/lib/R +export RUBYLIB=$MYPREFIX/lib/ruby/site_ruby/1.8/ + +if [[ $- != *i* ]]; then + # Shell is non-interactive. Be done now + return +fi + +HISTCONTROL=erasedups +HISTFILESIZE=10000 +HISTSIZE=10000 + +PS1='\u@\h:\w\$ ' + +alias ls='ls --color=auto' +alias qemu='qemu -cirrusvga -user-net' +export EMAIL='Gabriel Ebner ' +test -x /usr/bin/lesspipe && eval `lesspipe` + +# Bash completion +for i in /etc/profile.d/bash-completion /etc/bash_completion; do + test -f $i && . $i && break +done diff --git a/conf/emacs.el b/conf/emacs.el new file mode 100644 index 0000000..afa2d08 --- /dev/null +++ b/conf/emacs.el @@ -0,0 +1,54 @@ +(global-font-lock-mode 1) +(show-paren-mode) +;(server-start) + +(let ((site-gentoo-el "/usr/share/emacs/site-lisp/site-gentoo.el")) + (if (file-exists-p site-gentoo-el) + (load-file site-gentoo-el))) + +(setq inferior-lisp-program "/usr/bin/sbcl") +(if (fboundp 'slime-setup) (slime-setup)) + +(setq user-full-name "Gabriel Ebner" + user-mail-address "ge@gabrielebner.at" + + mail-host-address + (concat + (let (o) + (setq o (shell-command-to-string + "hostname")) + (substring o 0 (- (length o) 1))) + ".gabrielebner.at")) + +(autoload 'run-haskell "inf-haskell" + "Start an inferior haskell buffer." t) +(setq haskell-program-name "ghci") + +(setq py-indent-offset 2) + +(setq browse-url-browser-function #'browse-url-firefox) + +(defun perltidy () + "Run perltidy on current buffer." + (interactive) + + (mark-whole-buffer) + (shell-command-on-region + (region-beginning) + (region-end) + "perltidy -q" + 0 0 nil)) + +(defun ebuild-mode () + "Mode for ebuilds and eclasses." + (interactive) + + (shell-script-mode) + (sh-set-shell "bash") + (make-local-variable 'tab-width) + (setq tab-width 4)) + +(setq auto-mode-alist + (cons '("\\.ebuild\\'" . ebuild-mode) + (cons '("\\.eclass\\'" . ebuild-mode) + auto-mode-alist))) diff --git a/conf/gnus.el b/conf/gnus.el new file mode 100644 index 0000000..93e9103 --- /dev/null +++ b/conf/gnus.el @@ -0,0 +1,21 @@ +(eval-when-compile (require 'gnus)) +(require 'spam) + +(setq gnus-select-method '(nntp "news.gmane.org") + gnus-message-archive-group "nnmaildir:outbox" + + gnus-secondary-select-methods + '((nntp "nntp.dragonflybsd.org") + (nntp "nntp.perl.org") + (nntp "news.chello.at") + (nntp "news.gnus.org") + (nnmaildir "" (directory "~/Mail"))) + + gnus-spam-process-newsgroups '(("^gmane\." ((spam spam-use-gmane)))) + + pgg-default-user-id + (concat user-full-name + " <" user-mail-address ">") + + spam-use-bogofilter t + spam-use-bogofilter-headers t) diff --git a/conf/gpg.rc b/conf/gpg.rc new file mode 100644 index 0000000..67fd705 --- /dev/null +++ b/conf/gpg.rc @@ -0,0 +1,85 @@ +# -*-muttrc-*- +# +# Command formats for gpg. +# +# This version uses gpg-2comp from +# http://muppet.faveve.uni-stuttgart.de/~gero/gpg-2comp.tar.gz +# +# $Id: gpg.rc,v 3.4 2005/01/27 18:27:36 roessler Exp $ +# +# %p The empty string when no passphrase is needed, +# the string "PGPPASSFD=0" if one is needed. +# +# This is mostly used in conditional % sequences. +# +# %f Most PGP commands operate on a single file or a file +# containing a message. %f expands to this file's name. +# +# %s When verifying signatures, there is another temporary file +# containing the detached signature. %s expands to this +# file's name. +# +# %a In "signing" contexts, this expands to the value of the +# configuration variable $pgp_sign_as. You probably need to +# use this within a conditional % sequence. +# +# %r In many contexts, mutt passes key IDs to pgp. %r expands to +# a list of key IDs. + +# Note that we explicitly set the comment armor header since GnuPG, when used +# in some localiaztion environments, generates 8bit data in that header, thereby +# breaking PGP/MIME. + +# decode application/pgp +set pgp_decode_command="/usr/bin/gpg --charset utf-8 --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f" + +# verify a pgp/mime signature +set pgp_verify_command="/usr/bin/gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f" + +# decrypt a pgp/mime attachment +set pgp_decrypt_command="/usr/bin/gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f" + +# create a pgp/mime signed attachment +# set pgp_sign_command="/usr/bin/gpg-2comp --comment '' --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f" +set pgp_sign_command="/usr/bin/gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --detach-sign --textmode %?a?-u %a? %f" + +# create a application/pgp signed (old-style) message +# set pgp_clearsign_command="/usr/bin/gpg-2comp --comment '' --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f" +set pgp_clearsign_command="/usr/bin/gpg --charset utf-8 --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --textmode --clearsign %?a?-u %a? %f" + +# create a pgp/mime encrypted attachment +# set pgp_encrypt_only_command="pgpewrapng gpg-2comp -v --batch --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f" +set pgp_encrypt_only_command="pgpewrapng /usr/bin/gpg --charset utf-8 --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f" + +# create a pgp/mime encrypted and signed attachment +# set pgp_encrypt_sign_command="pgpewrapng gpg-2comp --passphrase-fd 0 -v --batch --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f" +set pgp_encrypt_sign_command="pgpewrapng /usr/bin/gpg --charset utf-8 %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f" + +# import a key into the public key ring +set pgp_import_command="/usr/bin/gpg --no-verbose --import %f" + +# export a key from the public key ring +set pgp_export_command="/usr/bin/gpg --no-verbose --export --armor %r" + +# verify a key +set pgp_verify_key_command="/usr/bin/gpg --verbose --batch --fingerprint --check-sigs %r" + +# read in the public key ring +set pgp_list_pubring_command="/usr/bin/gpg --no-verbose --batch --quiet --with-colons --list-keys %r" + +# read in the secret key ring +set pgp_list_secring_command="/usr/bin/gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r" + +# fetch keys +# set pgp_getkeys_command="pkspxycwrap %r" + +# pattern for good signature - may need to be adapted to locale! + +# set pgp_good_sign="^gpg: Good signature from" + +# OK, here's a version which uses gnupg's message catalog: +# set pgp_good_sign="`gettext -d gnupg -s 'Good signature from "' | tr -d '"'`" + +# This version uses --status-fd messages +set pgp_good_sign="^\\[GNUPG:\\] GOODSIG" + diff --git a/conf/maildirs.m4 b/conf/maildirs.m4 new file mode 100644 index 0000000..332344b --- /dev/null +++ b/conf/maildirs.m4 @@ -0,0 +1,126 @@ +dnl or(either, otherwise) +define(`or', `ifelse(`$1', `', `$2', `$1')') + +dnl q(text) +define(`q', `patsubst(`$1', `[.]', `\\\&')') + +dnl join(delim, elems*) +define(`join', `ifelse( + `$#', `0', `', + `$#', `1', `', + `$#', `2', `$2', + ``$2$1'join(`$1', shift(shift($@)))')') + +dnl md*(mbox, rule, addr) +define(`md', `indir(`md_'md_target, $@)') + +dnl muttrc +define(`md_muttrc_mboxes', `mailboxes +$1') +define(`md_muttrc_subscr', `ifelse(`$3', `', `', `subscribe $3')') + +dnl procmailrc +define(`md_procmailrc', ` +:0 +* ^$2 +deliver(`$1') + +') + +dnl ml(addr, mbox, id, fix, rule) +define(`ml', `md( + or(`$2', `substr(`$1', 0, index(`$1', `@'))'), + ml_rule(or(`$3', `ifelse( + `$4', `ecartis', `substr(`$1', 0, index(`$1', `@'))', + `translit(`$1', `@', `.')')'), `$1', `$4', `$5'), + `$1')') + +dnl ml_rule(id, addr, fix, rule) +define(`ml_rule', `ifelse( + `$3', `to', `TO_`'q($2)', + `$3', `ezmlm', `Mailing-List:.* q(substr(`$2', 0, + index(`$2', `@'))-help`'substr(`$2', index(`$2', `@')));', + `$3', `ecartis', `X-list: q($1)$', + `$4', `', `List-Id:.*[ <]q($1)', + `$4')') + +dnl Mailing Lists +ml(`swpat@ffii.org', `ffii-swpat') +ml(`at-parl@ffii.org', `ffii-at-parl') +ml(`swpat@mond.at', `mond-swpat') +ml(`soekris-tech@lists.soekris.com') +ml(`www-math@w3.org') +ml(`geo-discuss@lists.okfn.org') +ml(`geowanking@lists.burri.to') +ml(`info-gplv3@gplv3.fsf.org', `gplv3',, `to') +ml(`(european-gi-policy|egip)@jrc.it', `egip',, `to') +ml(`cryopid-devel@lists.berlios.de') +ml(`lojban-beginners@lojban.org',,, `ecartis') +ml(`lojban-list@lojban.org',,, `ecartis') +ml(`talk-de@openstreetmap.org') +ml(`talk-fr@openstreetmap.org') +ml(`josm-dev@openstreetmap.org') +ml(`legal-talk@openstreetmap.org') +ml(`tahoe-dev@allmydata.org') + +dnl Bugzillas +define(`bz', `md(`bugs-$1', `$2')') +bz(`debian', `From.*') +bz(`gcc', `Reply-To: gcc-bugzilla@gcc.gnu.org') +bz(`gentoo', `From: bugzilla-daemon@gentoo.org') +bz(`kde', `X-Bugzilla-URL: http://bugs.kde.org/') +bz(`remotesensing', `From: bugzilla-daemon@bugzilla.remotesensing.org') +bz(`sablevm', `From: bugs-owner@sablevm.org') +bz(`berlios', `From: noreply@berlios.de') +bz(`gnome', `From: bugzilla-daemon@bugzilla.gnome.org') + +dnl Misc +md(`osm', `Subject:.*\[OpenStreetMap\] GPX Import success') +md(`sourceforge', `From:.*noreply@sourceforge\.net') + +dnl GMane +md(`gmane', `From:.*auth.gmane\.org') + +dnl Service providers +md(`ums', `From:.*ums@a1\.net') +md(`nit', `From:.*kundensupport@nit\.at') + +dnl Newsletters +md(`ffii', `From:.*ffii.org|TO_.*ffii.org') +md(`diepresse', `From:.*newsletter@diepresse.com') + +md(`werbung', `From:.*('join(`|', + `newsletter', + `newslist', + `newsteam', + `mailing', + `palmsource', + `palmgear', + `palmone', + `ebook.nl', + `webmaster@sony\.at', + `return@mandriva\.com', + `mailelk@.*swr3\.de', + `shockwave\.com', + `RealNetworks', + `email@softwarewelt\.de', + `noreply@widget-service\.de', + `tomtomnews@tomtommailer\.com', + `promotion5@amazon\.de', + `mailings@gmx-gmbh\.de', + `linuxland\.de', + `macromedia', + `promotion', + `', + `office@wenigzell\.at', + `', + `', + `@news\.niedermeyer\.at>', + `softwarewelt')`)') + +dnl Personal mailboxes + +define(`mymbox', `md(`$1', `TO_'q(`$2'))') + +mymbox(`INBOX', `ge@gabrielebner.at') +mymbox(`webmaster', `webmaster@gabrielebner.at') +mymbox(`a1net', `dieschnecke@a1.net') diff --git a/conf/muttrc.m4 b/conf/muttrc.m4 new file mode 100644 index 0000000..2d7554d --- /dev/null +++ b/conf/muttrc.m4 @@ -0,0 +1,94 @@ +# vim:ft=muttrc: +my_hdr From: Gabriel Ebner + +set folder=imaps://gebner@gabrielebner.at/ + +mailboxes /var/mail/gebner +outbox +postponed +maybe-spam + +define(`md_target', `muttrc_mboxes') +include(`maildirs.m4') dnl ' + +set mbox=+INBOX +set move +set postponed=+postponed +set postpone +set record=+outbox +set copy + +define(`md_target', `muttrc_subscr') +include(`maildirs.m4') dnl ' + +# Various options +set pipe_decode=no +set charset=utf8 +set header_cache=~/.mutt/hcache + +set editor='vim "+se ft=mail"' +set signature=~/.signature.ml +set crypt_autoencrypt=no +set crypt_autosign=no + +set sidebar_visible +set sidebar_width=25 +set pager_index_lines=7 + +# GnuPG + +set pgp_sign_as=0xFC3509A0 +set pgp_timeout=3600 + +include(`gpg.rc') dnl '` + +# News +set news_cache_dir="~/.mutt/newsspool" +set newsrc="~/.mutt/newsrc-%s" + +set sort=threads +set sort_aux=date-sent +set folder_format="%2C %N %-40.40f %d" + +# Header formatting +ignore * +unignore from date subject bcc cc to # standard headers +unignore x-crm114-status # crm114 + +hdr_order from to cc bcc date subject x-crm114-status + +color header brightcyan default ^(From|Date|Subject): + +# Colors +color normal white black +color attachment brightyellow black +color hdrdefault cyan black +color indicator black cyan +color markers brightred black +color quoted green black +color signature cyan black +color status brightgreen blue +color tilde blue black +color tree red black +color header brightgreen black ^From: +color header brightcyan black ^To: +color header brightcyan black ^Reply-To: +color header brightcyan black ^Cc: +color header brightblue black ^Subject: +color body brightred black [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+ +color body brightblue black (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+ + +# Key bindings: +# F2 news.gmane.org +# F3 news.chello.at + +macro generic "set news_server=news.gmane.org" +macro generic "set news_server=news.chello.at" + +# F9 requeue +# F10 queue as non-spam +# F11 queue as spam +# F12 process queues (out of order atm) + +macro generic "=queue-requeuey" +macro generic "=queue-unspamy" +macro generic "=queue-spamy" + +source ~/.mutt/aliases diff --git a/conf/procmailrc.m4 b/conf/procmailrc.m4 new file mode 100644 index 0000000..97b17c7 --- /dev/null +++ b/conf/procmailrc.m4 @@ -0,0 +1,30 @@ +# vim:ft=m4: +MAILDIR=$HOME/Mail +#VERBOSE=on +SPOOL=INBOX + +define(`deliver', `$1/') + +# crm114 + +:0 f +| grep -v ^X-CRM114-Status: + +:0 fw: .msgid.lock +| ~/build/myprefix/bin/runcrm114 mailreaver.crm + +:0 +* ^X-CRM114-Status: SPAM +deliver(`spam') + +:0 +* ^X-CRM114-Status: UNSURE +deliver(`maybe-spam') + +# Mailing lists + +define(`md_target', `procmailrc') +include(`maildirs.m4') + +:0 +deliver(`$SPOOL') diff --git a/conf/ratpoisonrc b/conf/ratpoisonrc new file mode 100644 index 0000000..875ac6f --- /dev/null +++ b/conf/ratpoisonrc @@ -0,0 +1,2 @@ +addhook switchwin banish +bind e exec emacs diff --git a/conf/runcrm114 b/conf/runcrm114 new file mode 100755 index 0000000..dc878a8 --- /dev/null +++ b/conf/runcrm114 @@ -0,0 +1,11 @@ +#!/bin/sh +CRM114DIR=/home/gebner/.crm114 + +lockfile $CRM114DIR/lock + +crm -u $CRM114DIR $@ +ret=$? + +rm -f $CRM114DIR/lock + +exit $ret diff --git a/conf/vimrc b/conf/vimrc new file mode 100644 index 0000000..24ae34e --- /dev/null +++ b/conf/vimrc @@ -0,0 +1,10 @@ +set tw=78 ts=8 sts=2 sw=2 sm ai si +"set gfn=Monospace\ 8 " use Monospace at 8pt +set ml mls=5 " scan 5 lines for modelines +syn on " enable syntax highlighting +set hls " highlight search +set bg=dark " dark background + +au BufNewFile,BufRead *.vala setf cs +au BufNewFile,BufRead *.java set ts=4 sts=4 sw=4 +au BufNewFile,BufRead *.cc set path=.,/usr/include,/usr/include/qt4/Qt, diff --git a/conf/xsession b/conf/xsession new file mode 100644 index 0000000..6b9d426 --- /dev/null +++ b/conf/xsession @@ -0,0 +1,44 @@ +#!/bin/bash + +if [ "`basename "$SHELL"`" != zsh -o -n "$BASH" ] && which zsh 2>/dev/null; then + exec zsh ~/.xsession +fi + +XSESSION=xfce4 + +case $XSESSION in + ratpoison) + xsetroot -solid black -cursor_name left_ptr + unclutter -idle 1 & + exec ratpoison + ;; + + xmonad) + exec xmonad + ;; + + ion3) + exec ion3 + ;; + + gnome) + exec gnome-session + ;; + + kde) + exec startkde + ;; + + xfce4) + if test -x /etc/xdg/xfce4/xinitrc; then + exec /etc/xdg/xfce4/xinitrc + else + exec startxfce4 + fi + ;; + + *) + msg="I've got no clue on what to do! Call master Gabriel!" + xmessage "$msg" || echo "$msg" + exit 1 +esac diff --git a/conf/zfuncs/prompt_gebner_setup b/conf/zfuncs/prompt_gebner_setup new file mode 100644 index 0000000..f4b23b9 --- /dev/null +++ b/conf/zfuncs/prompt_gebner_setup @@ -0,0 +1,32 @@ +#!/bin/zsh + +local host_color user_color user_sym user_prompt host_prompt + +case "$HOST" in +schnecke1) host_color=blue ;; +schnecke2) host_color=green ;; +achatina) host_color=red ;; +*) host_color=yellow ;; +esac + +case "$USER" in +gebner) + user_color=green + user_sym=\$ + ;; +root) + user_color=red + user_sym=\# + ;; +*) + user_color=yellow + user_sym=\% +esac + +user_prompt="%{$fg[$user_color]%}$USER%{$reset_color%}" +host_prompt="%{$fg[$host_color]%}$HOST%{$reset_color%}" + +PS1="$user_prompt@$host_prompt %~ [%?] $user_sym " +PS2="%_ ... " +PS3="? " +PS4="%N:%i: " diff --git a/conf/zshrc b/conf/zshrc new file mode 100644 index 0000000..9f4c0e7 --- /dev/null +++ b/conf/zshrc @@ -0,0 +1,69 @@ +# Copyright (C) 2004 Gabriel Ebner +# vim:fdm=marker: + +. /etc/profile +export USER=$USERNAME +fpath=(~/.zfuncs $fpath) + +# $MYPREFIX {{{1 + +add_myprefix_to() { + if [[ `eval echo \$\{\+$1\}` == 1 ]]; then + export $1=$MYPREFIX/$2:`eval echo \$\{$1\}` + else + export $1=$MYPREFIX/$2 + fi +} + +MYPREFIX=~/build/myprefix +add_myprefix_to PATH bin +add_myprefix_to LD_LIBRARY_PATH lib +add_myprefix_to LD_LIBRARY_PATH lib64 +add_myprefix_to MANPATH man +add_myprefix_to PKG_CONFIG_PATH lib/pkgconfig +add_myprefix_to PYTHONPATH lib/python2.4/site-packages +add_myprefix_to PYTHONPATH lib/python/site-packages +add_myprefix_to PYTHONPATH lib/python +add_myprefix_to PERL5LIB lib/perl/`perl -e 'printf"%vd\n",$^V'` +add_myprefix_to PERL5LIB share/perl/`perl -e 'printf"%vd\n",$^V'` +add_myprefix_to R_LIBS lib/R:/usr/lib/R/site-library + +# ZLE {{{1 +bindkey '\e[3~' delete-char +bindkey "\e[1~" beginning-of-line +bindkey "\e[4~" end-of-line +setopt printeightbit + +# Prompt {{{1 +autoload -U promptinit +promptinit +prompt gebner + +# Window Title {{{1 +chpwd() { [[ -t 1 ]] && print -Pn '\e]2;%n@%m:%~\a' }; chpwd + +# Customisation of Programs {{{1 +alias ls='ls --color=auto' +export EMAIL='Gabriel Ebner ' +test -x /usr/bin/lesspipe && eval `/usr/bin/lesspipe` +test -x /usr/bin/vim && export EDITOR=/usr/bin/vim + +export MPD_HOST=127.0.0.1 MPD_PORT=6600 + +# History {{{1 +setopt APPEND_HISTORY SHARE_HISTORY EXTENDED_HISTORY INC_APPEND_HISTORY \ + HIST_IGNORE_ALL_DUPS HIST_FIND_NO_DUPS +HISTSIZE=100000 +SAVEHIST=100000 +HISTFILE=~/.zhist + +# Completion {{{1 + +# The following lines were added by compinstall +zstyle ':completion:*' completer _complete +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle :compinstall filename '/home/gebner/.zshrc' + +autoload -U compinit +compinit +# End of lines added by compinstall diff --git a/gentoo/02locale b/gentoo/02locale new file mode 100644 index 0000000..12420e1 --- /dev/null +++ b/gentoo/02locale @@ -0,0 +1 @@ +LANG=de_AT.utf8 diff --git a/gentoo/Makefile b/gentoo/Makefile new file mode 100644 index 0000000..ebbf186 --- /dev/null +++ b/gentoo/Makefile @@ -0,0 +1,25 @@ +.PHONY: all install clean + +all install clean: + +PORTDIR = $(wildcard /usr/portage) + +ifeq "$(USER)" "root" +ifneq "$(PORTDIR)" "" + +BIN = machine-update tla-mirror-all +SBIN = laptop-mode m4conf-update make-kernel regen-virtuals +MISC = grub.conf.m4 local.conf.m4 02locale + +DIRS = /usr/local/bin /boot/grub /etc/fonts /etc/env.d + +install: + mkdir -p $(DIRS) + install -m755 -o0 -g0 $(BIN) $(SBIN) /usr/local/bin + install -m664 -o0 -g0 grub.conf.m4 /boot/grub + install -m664 -o0 -g0 local.conf.m4 /etc/fonts + install -m664 -o0 -g0 02locale /etc/env.d + m4conf-update + +endif +endif diff --git a/gentoo/grub.conf.m4 b/gentoo/grub.conf.m4 new file mode 100644 index 0000000..ac19252 --- /dev/null +++ b/gentoo/grub.conf.m4 @@ -0,0 +1,26 @@ +default 0 +timeout 2 + +define(`host', `esyscmd(`hostname | xargs echo -n')') + +define(`main_part_grub', `(hd0,0)') +define(`kargs', `ifelse( + host, `schnecke2', `video=radeonfb:vesa:0x11B root=/dev/hda1', + host, `achatina', `video=radeonfb:vesa:0x11B udev dolvm2 root=/dev/ram0 init=/linuxrc real_root=/dev/datavg/gentoo', + host, `schnecke1', `video=matroxfb:vesa:0x11B root=/dev/hda1' +)') + +define(`kernel_file', `/boot/kernel-$1') + +define(`linux', ` +title Gentoo Linux $1 +root main_part_grub +kernel kernel_file(`$1') kargs +ifelse(host, `achatina', `initrd /boot/initramfs-genkernel-x86_64-$1') +') + +define(`m_linux', `linux($1) +ifelse(`$#', `1', `', `m_linux(shift($@))')') + +m_linux(esyscmd(`ls -t /boot/kernel-* | cut -c 14- | xargs echo -n \ + | tr " " ,')) diff --git a/gentoo/laptop-mode b/gentoo/laptop-mode new file mode 100644 index 0000000..686d193 --- /dev/null +++ b/gentoo/laptop-mode @@ -0,0 +1,126 @@ +#!/bin/sh + +# start or stop laptop_mode, best run by a power management daemon when +# ac gets connected/disconnected from a laptop +# +# install as /sbin/laptop_mode +# +# Contributors to this script: Kiko Piris +# Bart Samwel +# Dax Kelson +# Original Linux 2.4 version by: Jens Axboe + +parse_mount_opts () { + echo "$*" | \ + sed 's/commit=[0-9]*//g' | \ + sed 's/,,*/,/g' | \ + sed 's/^,//' | \ + sed 's/,$//' | \ + cat - +} + +KLEVEL="$(uname -r | cut -c1-3)" +case "$KLEVEL" in + "2.4") + true + ;; + "2.6") + true + ;; + *) + echo "Unhandled kernel level: $KLEVEL ('uname -r' = '$(uname -r)')" + exit 1 + ;; +esac + +# Shall we remount journaled fs. with appropiate commit interval? (1=yes) +DO_REMOUNTS=1 + +# age time, in seconds. should be put into a sysconfig file +MAX_AGE=600 + +# Allowed dirty ratio, in pct. should be put into a sysconfig file as well. +DIRTY_RATIO=40 + +# kernel default dirty buffer age +DEF_AGE=30 +DEF_UPDATE=5 +DEF_DIRTY_BACKGROUND_RATIO=10 +DEF_DIRTY_RATIO=40 + + +if [ ! -e /proc/sys/vm/laptop_mode ]; then + echo "Kernel is not patched with laptop_mode patch." + exit 1 +fi + +if [ ! -w /proc/sys/vm/laptop_mode ]; then + echo "You do not have enough privileges to enable laptop_mode." + exit 1 +fi + +case "$1" in + start) + AGE=$((100*$MAX_AGE)) + echo -n "Starting laptop_mode" + case "$KLEVEL" in + "2.4") + echo "1" > /proc/sys/vm/laptop_mode + echo "30 500 0 0 $AGE $AGE 60 20 0" > /proc/sys/vm/bdflush + ;; + "2.6") + echo "1" > /proc/sys/vm/laptop_mode + echo "$AGE" > /proc/sys/vm/dirty_writeback_centisecs + echo "$AGE" > /proc/sys/vm/dirty_expire_centisecs + echo "$DIRTY_RATIO" > /proc/sys/vm/dirty_ratio + echo "$DIRTY_RATIO" > /proc/sys/vm/dirty_background_ratio + ;; + esac + if [ $DO_REMOUNTS -eq 1 ]; then + cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do + PARSEDOPTS="$(parse_mount_opts "$OPTS")" + case "$FST" in + "ext3") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS,commit=$MAX_AGE ;; + "reiserfs") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS,commit=$MAX_AGE ;; + "xfs") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS,commit=$MAX_AGE ;; + esac + done + fi + echo "." + ;; + stop) + U_AGE=$((100*$DEF_UPDATE)) + B_AGE=$((100*$DEF_AGE)) + echo -n "Stopping laptop_mode" + case "$KLEVEL" in + "2.4") + echo "0" > /proc/sys/vm/laptop_mode + echo "30 500 0 0 $U_AGE $B_AGE 60 20 0" > /proc/sys/vm/bdflush + ;; + "2.6") + echo "0" > /proc/sys/vm/laptop_mode + echo "$U_AGE" > /proc/sys/vm/dirty_writeback_centisecs + echo "$B_AGE" > /proc/sys/vm/dirty_expire_centisecs + echo "$DEF_DIRTY_RATIO" > /proc/sys/vm/dirty_ratio + echo "$DEF_DIRTY_BACKGROUND_RATIO" > /proc/sys/vm/dirty_background_ratio + ;; + esac + if [ $DO_REMOUNTS -eq 1 ]; then + cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do + PARSEDOPTS="$(parse_mount_opts "$OPTS")" + case "$FST" in + "ext3") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS ;; + "reiserfs") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS ;; + "xfs") mount $DEV -t $FST $MP -o remount,$PARSEDOPTS ;; + esac + done + fi + echo "." + ;; + *) + echo "$0 {start|stop}" + ;; + +esac + +exit 0 diff --git a/gentoo/local.conf.m4 b/gentoo/local.conf.m4 new file mode 100644 index 0000000..750085a --- /dev/null +++ b/gentoo/local.conf.m4 @@ -0,0 +1,34 @@ + + + + + + /usr/share/fonts/corefonts + + ifelse(esyscmd(`hostname | xargs echo -n'), `schnecke2', + ` + + rgb + ') + + define(`font_repl', ` + + $1 + + + $2 + + ') + + dnl Replace bit-mapped fonts with AA fonts + font_repl(`Helvetica', `Arial') + font_repl(`Times', `Times New Roman') + font_repl(`Courier', `Courier New') + + dnl Now replace M$ fonts with Bitstream ones... + font_repl(`Arial', `Bitstream Vera Sans') + font_repl(`Times New Roman', `Bitstream Vera Serif') + font_repl(`Courier New', `Bitstream Vera Mono Sans') + font_repl(`Verdana', `Bitstream Vera Sans') + font_repl(`Andale Sans UI', `Bitstream Vera Sans') + diff --git a/gentoo/m4conf-update b/gentoo/m4conf-update new file mode 100644 index 0000000..b8b111e --- /dev/null +++ b/gentoo/m4conf-update @@ -0,0 +1,9 @@ +#!/bin/sh +. /etc/init.d/functions.sh + +einfo "Regenerating M4 config files" +for i in /etc/fonts/local.conf /boot/grub/grub.conf; do + ebegin " $i" + m4 "$i.m4" >"$i" + eend $? +done diff --git a/gentoo/machine-update b/gentoo/machine-update new file mode 100644 index 0000000..563a3b8 --- /dev/null +++ b/gentoo/machine-update @@ -0,0 +1,1114 @@ +#!/usr/bin/perl -w +# For Emacs: -*- mode:cperl; mode:folding; -*- +# +# Get a machine's critical features, And mail/http them to the Linux Counter +# +# (c) 1999 - Harald Tveit Alvestrand, the Linux Counter Project +# 2003 - PetaMem Group (www.petamem.com) +# License: GNU Copyleft - see bottom of file. +# Changelog: see even more bottom of the file +# +# As a matter of courtesy, if you change this file on your own, +# make sure it does NOT mail to the counter! +# +use strict; +use POSIX; + +our $VERSION = '0.20'; +our $CVS_VERSION = '$Revision: 1.25 $ $Date: 2003/12/28 23:59:48 $ $Author: hta $'; +our $IsInTestHarness; +use vars qw(%values %oldvalues $errordata $debugdata); # data that is sent +use vars qw($progname %option); +use vars qw(%is_sys_account %is_user %is_account); + +# Some variables are for internal use, and never prompted for in +# the loop of askquestions +our %dontask = ('uniqueid' => 1, # Internal use + 'manual' => 1, + 'method' => 1, + 'owner' => 1, # These 2 are always prompted for + 'key' => 1, + 'uptime' => 1, # We think we know how to get these + ); + +# stuff that controls defaults for passwdscan & accounts subroutines +my ($UID_MIN, $UID_MAX, $got_defs) = (100, 65533, ''); + +# Make sure nothing happens, so that the script's routines +# can be debugged from another file +return 1 if($IsInTestHarness); + +&preparation; +&options; + +&readfile; +&checkconfig; + +if ($option{ask}) { + &askquestions; +} else { + ©manuals; +} + +&writefile; +&sendfile; + +# {{{ preparation + +# +sub preparation { + die "No HOME environment variable\n" if (!$ENV{HOME}); + die "No home diretory\n" if ! -d $ENV{HOME}; + my $infodir = "$ENV{HOME}/.linuxcounter"; + if (! -d $infodir) { + mkdir($infodir, 0766) || die "Unable to make $infodir\n"; + } + # Keep track of where I am; need it to install crontab entry + # progname is a global. + $progname = $0; + if ($progname !~ /^\//) { + my $progdir = `pwd`; + chop $progdir; + $progname = "$progdir/$progname"; + $progname =~ s!/./!/!; + } + chdir($infodir) || die "Unable to change to $infodir\n"; + my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname(); + if (! -f $nodename) { + print STDERR "Machine-update $VERSION. Use $0 -l to display license.\n"; + print STDERR "Creating the infofile for your computer.\n"; + # Create the infodir + open(INFO, ">$nodename"); + print INFO "uniqueid: ", randomnumber(), "\n"; + close INFO; + } + + srand time % $$; # do some seed "randomization" +} + +# }}} +# {{{ options + +# +sub options { + my $opt; + + while (defined($ARGV[0]) && $ARGV[0] =~ /^-/) { + $opt = shift @ARGV; + $opt =~ /c/ && &installcrontab; + $opt =~ /d/ && $option{DEBUG}++ && print STDERR "Debug is $option{DEBUG}\n"; + $opt =~ /h/ && &help; + $opt =~ /i/ && ($option{ask} = 1); + $opt =~ /l/ && &license; + $opt =~ /m/ && ($option{mail} = 1); + $opt =~ /t/ && ($option{mail} = 0); + $opt =~ /u/ && &uninstallcrontab; + $opt =~ /v/ && die "\n\t Linux Counter machine-update version $VERSION\n" + . "\tCVS version $CVS_VERSION\n"; + $opt =~ /x/ && ($option{info} = 1); + } +} + +# }}} + +# {{{ askquestions + +# +sub askquestions { + return if ! -t STDIN || ! -t STDOUT; + $| = 1; + print "Here you can specify some info that the script can't know for itself\n"; + $values{owner} = askone("Your Linux Counter reg#, if any", $values{owner}); + $values{key} = askone("Your machine's counter reg#, if any", $values{key}); + print "Here is what the program has found:\n"; + for my $key (keys(%values)) { + if (!$dontask{$key}) { + printf "%-10s%1s: %s\n", $key, $dontask{$key}?"*":" ", $values{$key}; + } + } + my $domore = &askone('Do you want to override some of the found values?', 'no'); + if ($domore =~ /^Y/i) { + my $manual; + for my $key (keys(%values)) { + next if $dontask{$key}; + my $value = &askone($key, $oldvalues{$key}, $values{$key}); + if ($values{$key} eq $value) { # go to automatic + &Debug("auto value: $key\n"); + } else { + &Debug("still manual value: $key\n"); + $manual .= " $key"; + } + $values{$key} = $value; + } + $values{manual} = $manual; + } else { + delete $values{manual}; + } +} + +# }}} +# {{{ askone +# +sub askone { + my $prompt = shift; + my $default = shift; + my $probed = shift; + + print $prompt; + if (!defined($default) && defined($probed)) { + $default = $probed; + } + if (defined($default)) { + print " [$default]"; + } + if (defined($probed) && $probed ne $default) { + print "(program found $probed)"; + } + print ':'; + + my $ans = ; + + chop $ans; + &Debug("Answer was $ans\n"); + $ans = $default if (!length($ans)); + + return $ans; +} +# }}} + +# {{{ copymanuals +# +sub copymanuals { + my %keeps = map {$_ => 1} split(' ', $values{manual}); + + &Debug('Keeping '.join(' ', keys(%keeps))."\n"); + for my $key (keys(%keeps)) { + $values{$key} = $oldvalues{$key}; + } +} +# }}} + +# {{{ readfile + +# +sub readfile { + my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname(); + open(INFO, $nodename) || die "Did not find infofile $nodename\n"; + while () { + chop; + s/#.*//; + if (/^(\S+): *(.+)/) { + &Debug("Read $1: $2\n"); + $values{$1} = $2; + } else { + print STDERR "Unparsed info line: $_ - discarded\n"; + } + } + close INFO; + %oldvalues = %values; +} + +# }}} +# {{{ writefile + +# +sub writefile { + my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname(); + + open(INFO, ">$nodename.new"); + for my $val (sort keys(%values)) { + &Debug("Saving $val: $values{$val}\n"); + print INFO "$val: $values{$val}\n"; + } + close INFO; + rename("$nodename.new", $nodename) || die "Rename failed\n"; +} + +# }}} +# {{{ sendfile + +# +sub sendfile { + if ($option{mail}) { + open(MAIL, "|/usr/lib/sendmail machine-registration\@counter.li.org") + || die "Unable to open sendmail\n"; + } else { + warn "--------------------------------------------------------\n"; + warn "This is what will be sent to the Linux Counter if you\n"; + warn "run the program with the -m switch. Now, NOTHING IS SENT\n"; + warn "--------------------------------------------------------\n"; + open(MAIL, ">&STDOUT"); + } + # note that $ENV{USER} isn't (always) set in a cron job... + my $user = (getpwuid($<))[0]; + $user = "unknown-id-$<" if !$user; + print MAIL < 0; + } + print MAIL "//END\n"; + # Attach possible other info + if ($errordata) { + print MAIL "----- Problem info gathered during probing -----\n"; + print MAIL $errordata; + } + $option{info} && do { + print MAIL "----- Debug data for the script maintainer's aid -----\n"; + print MAIL $debugdata; + }; + close MAIL; +} + +# }}} + +# {{{ randomnumber +# +sub randomnumber { + return int(rand(1_000_000_000)); +} +# }}} + +# {{{ checkconfig + +# +sub checkconfig { + my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname(); + + warn "This is not Linux, but $sysname!\n" if($sysname ne 'Linux'); + $values{method} = "machine-update version $VERSION"; + $values{os} = $sysname; + $values{kernel} = $release; + $values{cpu_uname} = $machine; + $values{name} = $nodename; # First order guess + + # Credit for some of the code below goes to + # Denis Havlik: + # Blame is, of course, all mine - HTA - + # Note - there are numerous problems with df, including: + # - early versions don't support the -l option + # - at least some include SAMBA filesystems in the -l option + open (TMP,"df -l -x shm |"); # exclude shmfs, its 50% of RAM (mostly) + my $HD = 0; + while () { + my @line = split(/\s+/); + ($line[0] =~ /\/dev/) && ($HD += $line[1]); + } + &Debug("$HD kbytes of disk found\n"); + $HD /= 1024; + $values{disk} = sprintf("%d", $HD); + $values{accounts} = &accounts; + $values{users} = &active_users; + + my $uptime = &xbin('uptime'); + if($uptime) { + $uptime = `$uptime`; + # get the uptime string here (could be more elegant, but so it is + # robust against various localizations) + if ($uptime =~ /^\s+[^\s]+\s+[^\s]+\s+([^,]+), /) { + $values{uptime} = $1; + } else { + &ErrorInfo("Can't parse uptime output: $uptime\n"); + } + if ($option{info}) { + &DebugInfo("***** Uptime output *****\n$uptime"); + } + } + # Not sure this is a Right Thing...so not saving it for the moment + # This section based on a patch from Mark-Jason Dominus + # try to guess mailer based on content of /usr/lib/sendmail link + if (-l '/usr/lib/sendmail') { + my $realsendmail = readlink('/usr/lib/sendmail'); + if ($realsendmail eq '../sbin/sendmail') { + $realsendmail = '/usr/sbin/sendmail'; + if (-l $realsendmail) { + $realsendmail = readlink($realsendmail); + } + } + if ($realsendmail =~ m{^/var/qmail}) { + $values{mailer} = "qmail"; + } else { + &DebugInfo("Found sendmail as a link to $realsendmail\n"); + } + } + # Link method did not work. Try to guess based on presence of + # config files. (this is more susceptible to the old-junk problem) + if (!$values{mailer}) { + if ( -d '/var/qmail') { + $values{mailer} = 'qmail'; + } elsif ( -f '/etc/sendmail.cf') { + $values{mailer} = 'sendmail'; + } elsif ( -d '/etc/postfix') { + $values{mailer} = 'postfix'; + } + } + + # forget about /proc/kcore: It's not reliable above 960MB. It also doesn't show + # real memory, because some may be eaten by graphics + # forget also about the "free" command: We don't want to be dependant on that + $values{memory} = int(&getval_from_file('/proc/meminfo',1,1) / (1024*1024)); + # But actually: Shouldn't we return the total of virtual memory here? Seems to + # be relevant to me - RJ - + + &cpuinfo; +} + +# }}} + +# {{{ cpuinfo + +# +sub cpuinfo { + my $cpufile = '/proc/cpuinfo'; # Linux: Place to get info on CPU + my %interesting = (# 2.0 and 2.2 kernels + 'bogomips' => '+bogomips', + 'processor' => '1+processors', + 'vendor_id' => 'cpu_vendor', + # 2.0 kernels + 'cpu' => 'cpu_only', + 'model' => 'cpu_model', + 'model name' => 'cpu_model_name', + # 2.2 kernels + 'cpu MHz' => 'cpu_mhz', + 'cpu family' => 'cpu_family', + # from an Alpha processor + 'cycle frequency [Hz]' => 'cpu_hz', + 'BogoMIPS' => '+bogomips', + 'cpu model' => 'cpu_model', + 'system type' => 'cpu_system_type', + 'cpus detected' => 'processors', + # from a PowerMAC + 'machine' => 'cpu_machine', + 'clock' => 'cpu_clock', + 'motherboard' => 'cpu_motherboard', + # from an UltraSparc + 'BogoMips' => '+bogomips', + 'ncpus active' => 'processors', + ); + + # Zero out the accumulative values + $values{bogomips} = 0; + $values{processors} = 0; + if (open (TMP,"<$cpufile")) { + &DebugInfo("**** Contents of $cpufile ****\n"); + while () { + &DebugInfo($_); # Save /proc/cpuinfo to debugdata if -d + chop; + # A bizarre selection of names are "interesting". + # Make a data-driven pick routine + if (/^(\S+[^:]+\S)\s+: /) { + my $name = $1; + my $value = $'; + if ($interesting{$name}) { + if ($interesting{$name} =~ /^\+/) { + $values{$'} += $value; + } elsif ($interesting{$name} =~ /^1\+/) { + $values{$'}++; + } else { + $values{$interesting{$name}} = $value; + } + } + } + } + } else { + &ErrorInfo("Could not open $cpufile\n"); + } +} + +# }}} + +# {{{ accounts + +# +sub accounts { + my $s; + my $niss; + my $ypcatbin; # will hold path to the ypcat binary (if any) + + open (TMP," /dev/null|" + || ($errordata .= "ypcat failed: $!\n"); + $niss = &passwdscan; + $s += $niss; + close TMP; + &Debug("Status of ypcat: $?\n"); + &DebugErr("Found $niss accounts in ypcat passwd\n"); + } + + &DebugErr('Sysaccounts: ', join(' ', keys(%is_sys_account)), "\n"); + &DebugErr("Found $s accounts total\n"); + + return $s; +} + +# }}} +# {{{ passwdscan + +# +sub passwdscan { + # Code for reading login.defs courtesy of Vassilii Khachaturov + # + local (*DEFS); + # Try importing UID_MIN and UID_MAX from /etc/login.defs, if possible + # else just assume the above defaults for min and max non-system UID + if (!$got_defs && open (DEFS, '/etc/login.defs')) { + while () { + if (/^\s*(UID_(?:MIN|MAX))\s+(\d+)/) { + # elegant, but not compatible with "strict refs": + #${ $1 } = $2; + if ($1 eq "UID_MIN") { + $UID_MIN = $2; + } else { + $UID_MAX = $2; + } + &Debug("DEFS match: $1 = $2\n"); + } + } + close (DEFS); + $got_defs = 1; + } + &Debug("UID_MIN = $UID_MIN, UID_MAX = $UID_MAX\n"); + # I suppose this is as good as it gets - + # Usually user accounts have UID > 100 and + # "system accounts" have UID < 100, but there is no guarantee + # that + # this will hold for pseudo-users like "postgress" etc. + # Also nobody is usually 99 on linux, but -1 on "standard" unices. + # RedHat places the dividing line at 500. Others use 400... + my @line; + my $s = 0; + + while () { + @line = split ':'; + if ($line[2] >= $UID_MIN && $line[2] <= $UID_MAX + && !($line[0] eq 'nobody')) { + $s++; + $is_account{$line[0]} = 1; + } else { + $is_sys_account{$line[0]} = 1; + } + } + + return $s; +} + +# }}} +# {{{ active_users + +# +# This is kind of alpha, but please test it. +# It calculates the number of "active" users based on the "wtmp" entries +# unfortunately at least Mandrake 8 and 9 ship with non-world-read wtmp +# and non-set-uid last, so this does not work any more... +# +# RJ: Actually I think the best thing to do is to bury this code and be silent about it. +# +sub active_users { + my $userslisted; + + for (qw(reboot wtmp runlevel)) { # This sysaccounts shouldn't be counted. Who else? + $is_sys_account{$_} = 1; + } + open( TMP, "/usr/bin/last 2>&1|"); + while () { + chop; + if (m!/var/log/wtmp: Permission denied!) { # RJ: ***Boom*** on every non-EN system + &ErrorInfo("/usr/bin/last failed because /var/log/wtmp isn't readable\n"); + last; + } + last if(!$_); # RJ: quick hack to safe bad code from harm + my @tmp = split; + my $name = $tmp[0]; + if ($is_sys_account{$name}) { + # do nothing + } elsif (defined $is_account{$name}) { + $is_user{$name} = 1; + } elsif (/^\s*$/) { # blank line - do nothing + } elsif ($#tmp == 9) { # OK line, but unknown user + $option{DEBUG} && do { + if (!$userslisted) { + print STDERR 'Know users are: ', + join(' ', keys(%is_account)), "\n"; + $userslisted = 1; + } + print STDERR "Unknown user: $name\n"; + } + } else { + &DebugErr("Strange line: $_\n"); + } + } + close TMP; + my $i = 0; + for (sort keys %is_user) { + $option{DEBUG} && printf "Active user %3d: %s\n", ++$i, $_; + } + &Debug("$i active users found.\n"); + + return $i; +} + +# }}} + +# {{{ installcrontab + +# +sub installcrontab { + my $hour = int(rand(24)); + my $min = int(rand(60)); + my $day = int(rand(7)); # Weekday. This version runs once a week. + my $cron; + + warn "Installing start of script into your crontab\n"; + if (open(CRON, "crontab -l |")) { + &Debug("Checking crontab for machine-update\n"); + &Debug("Want to install as $progname\n"); + while () { + if (/^#/ && $. <= 3) { # initial comment + &Debug("Skipping comment: $_"); + next; + } + if (/machine-update/) { + if (/ $progname -m/) { + die "Crontab entry already installed: $_\n"; + } else { + die "Another entry with machine-update: $_\n"; + } + } + $cron .= $_; + } + close CRON; + &Debug("Result from crontab -l: ", $? / 256, "\n"); + if ($? == 0) { + &Debug("Crontab successfully read\n"); + } elsif ($? == 256) { + warn "You don't seem to have a crontab. I will create one.\n"; + } else { + die "Failed to read your crontab. Please report this as a bug: $?\n"; + } + } else { + &Debug("Result from crontab open(): $?\n"); + die "Unable to execute crontab command. Please check your system\n"; + } + open(CRON, "|crontab -"); + print CRON $cron; + print CRON "$min $hour * * $day $progname -m\n"; + close CRON; + &Debug("Result from crontab: $?\n"); + if ($?) { + die(<) { + if (/^#/ && $. <= 3) { # initial comment + &Debug("Skipping comment: $_"); + next; + } + if (/machine-update/) { + if (/ $progname -m/) { + print STDERR "Crontab entry found and removed\n"; + $found = 1; + next; # skip stuff at end.... + } else { + die "Another entry with machine-update: $_\nUninstall manually?\n"; + } + } + $cron .= $_; + } + close CRON; + &Debug("Result from crontab -l: $?\n"); + if ($?) { + die "Failed to read your crontab. You may not have one?\n"; + } + if ($found) { + open(CRON, "|crontab -"); + print CRON $cron; + close CRON; + &Debug("Result from crontab: $?\n"); + if ($?) { + die(<; # read whole file to array + close FH; + + @cols = split /\s+/, $file[$row]; # get the right row + + return $cols[$col]; # return the right column +} + +# }}} + +# {{{ Debug print debug information if flag is set + +# +sub Debug { + $option{DEBUG} && print @_; +} + +# }}} +# {{{ DebugErr print debug on STDERR if flag is set + +# +sub DebugErr { + $option{DEBUG} && print STDERR @_; +} + +# }}} +# {{{ ErrorInfo +sub ErrorInfo { + $errordata .= join('', @_); +} +# }}} +# {{{ DebugInfo + +sub DebugInfo { + $option{info} && ($debugdata .= join('', @_)); +} + +# }}} + +# {{{ help print help & exit + +# +sub help { + my $host = `uname -n`; + + print <960MB capable +# - slightly better randomness +# +#vim:ts=8:sw=4:sts=4 + diff --git a/gentoo/make-kernel b/gentoo/make-kernel new file mode 100644 index 0000000..99f8ac2 --- /dev/null +++ b/gentoo/make-kernel @@ -0,0 +1,31 @@ +#!/bin/sh +. /etc/init.d/functions.sh + +if [ -z "$1" ]; then + KV=`ketchup -m 2>/dev/null` + + if [ -z "$KV" ]; then + KV=`readlink $PWD` + KV=`basename "$KV"` + test -z "$KV" && KV=`basename $PWD` + KV=${KV:6} + if [ -z "$KV" ]; then + eerror "Could not resolve kernel version" + exit 1 + fi + fi +else + KV=$1 +fi + +einfo "I am now going to build kernel $KV" +einfo "Press C-c to stop or RET to continue..." +read + +set -ex + +make -j4 +make modules_install +cp arch/*/boot/bzImage /boot/kernel-$KV +cp .config /boot/config-$KV +m4conf-update diff --git a/gentoo/regen-virtuals b/gentoo/regen-virtuals new file mode 100644 index 0000000..782f91c --- /dev/null +++ b/gentoo/regen-virtuals @@ -0,0 +1,2 @@ +#!/bin/sh +find /var/db/pkg/ -name PROVIDE | perl -ne 'chomp;($p)=m#^/var/db/pkg/(.*?/.*?)-(\d+.*)/PROVIDE$#; {local$/=undef;open$f,$_;$c=<$f>;close$f}$c=~s/^\s*//;$c=~s/\s*$//;@c=split/\s+/,$c;($v{$_}.=" $p")for@c; END{while(($k,$v)=each%v){print"$k$v\n"}}' >/var/cache/edb/virtuals diff --git a/gentoo/tla-mirror-all b/gentoo/tla-mirror-all new file mode 100644 index 0000000..0741718 --- /dev/null +++ b/gentoo/tla-mirror-all @@ -0,0 +1,2 @@ +#!/bin/sh +tla archives | grep MIRROR | sed s/-MIRROR// | xargs -n1 tla archive-mirror