summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@kremium>2011-12-01 20:59:27 +0100
committerroot <root@kremium>2011-12-01 20:59:27 +0100
commit2d733f93b82a1c11a014af1a3dd07d3540282356 (patch)
treeec23111722523ec03ec7d35e708735cf787c6f79
parentbfa204a580a503a216cedbedd36586fb00458181 (diff)
parent4be0c81eafe0f315b91eb13d5d9aa8886faef308 (diff)
Merge branch 'master' of http://github.com/krebscode/painload
-rw-r--r--cholerab/assets/structs.nojson43
-rw-r--r--cholerab/assets/usecases.txt4
-rw-r--r--infest/profiles/README5
-rwxr-xr-xinfest/profiles/makefu/bootstrap.sh44
-rw-r--r--infest/profiles/makefu/dircolors194
-rwxr-xr-xinfest/profiles/makefu/vim/vimrc105
l---------infest/profiles/makefu/vimrc1
-rw-r--r--infest/profiles/makefu/zshrc44
-rw-r--r--punani/README.md30
-rwxr-xr-xpunani/bin/punani318
-rwxr-xr-xpunani/bot/__init__.py99
-rw-r--r--punani/db/punani64
-rwxr-xr-xpunani/index.py96
-rwxr-xr-xpunani/tightnani/tightnani-web.py48
-rw-r--r--punani/tightnani/tightnani_db25
-rw-r--r--retiolum/Makefile1
-rwxr-xr-xretiolum/bin/hosts2
-rw-r--r--retiolum/hosts/Lassulus1
-rw-r--r--retiolum/hosts/Styx1
-rw-r--r--streams/stream.db1
-rwxr-xr-xutil/bin/sshkill33
21 files changed, 814 insertions, 345 deletions
diff --git a/cholerab/assets/structs.nojson b/cholerab/assets/structs.nojson
new file mode 100644
index 00000000..4c084862
--- /dev/null
+++ b/cholerab/assets/structs.nojson
@@ -0,0 +1,43 @@
+"name": // default: random (gensym)
+ "type": "grafikkarte"
+ "location": "kremium"
+ "amount": 23 // default: 1
+ "owner": "shack" // default: krebs
+
+"nebula":
+ "type": "location"
+ "owner": "tv"
+
+"tv":
+ "type": "owner"
+
+"grafikkarte":
+ "type": "type"
+
+"amount":
+ "type": "natural"
+
+"root-server":
+ "type": "irgend ein owner ist root"
+
+"shared":
+ "type": "alle owner sind root"
+
+"oxberg":
+ "type": "root-server"
+ "location": "de"
+ "ipv4-address": "84.23.80.172"
+ "isp": "euserv"
+ "ram": "512MiB"
+
+"ram":
+ "must-match": /[0-9]+[MGk]iB/
+
+"kremium":
+ "location": "nebula"
+ "type": "root-server"
+ "shared": true
+
+"euserv":
+ "type": "ISP"
+
diff --git a/cholerab/assets/usecases.txt b/cholerab/assets/usecases.txt
index 0c6a2b3a..a3e2a4fa 100644
--- a/cholerab/assets/usecases.txt
+++ b/cholerab/assets/usecases.txt
@@ -29,8 +29,8 @@
Welt der Dinge und der Daten muessen wieder synchron sein.
# use case #9: asset anzahl erniedrigen; assets mergen
- Eine von hundert Batterien soll von platz X entnommen werden
- und in ein asset integriert werden.
+ Eines von hundert 4-Port-USB-Hubs soll von platz X entnommen werden
+ und an ein asset gestoepselt werden.
# use case #A: asset entfernen
Urkrebs wir vom Besitzer ausserhalb von krebs benoetigt und dem Bestand
diff --git a/infest/profiles/README b/infest/profiles/README
index cab5fd93..79dde1a4 100644
--- a/infest/profiles/README
+++ b/infest/profiles/README
@@ -1,9 +1,8 @@
Install different profiles for a user on the system
UseCase:
-./load-profile bob
- [if necessary, check out the bob submodule]
+./deploy-profile bob
[write dotfiles of profile bob for logged-in users ~]
-./load-profile system
+./deploy-profile system
[write krebs additions to /etc and /root]
diff --git a/infest/profiles/makefu/bootstrap.sh b/infest/profiles/makefu/bootstrap.sh
new file mode 100755
index 00000000..67122d0d
--- /dev/null
+++ b/infest/profiles/makefu/bootstrap.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+set -euf
+cd $(readlink -f $(dirname $0))
+echo "* Using punani to install git vim and zsh"
+../../../punani/bin/punani install git vim zsh
+
+# Backing up false positives
+if [ -e $HOME/.vim ] ; then
+ echo "* Backing up old vim folder"
+ mv -v $HOME/.vim $HOME/.vim.`date +%Y%M%d`
+fi
+
+# write dotfiles
+for dotfile in $(ls .);do
+ [ "x./${dotfile}" = "x$0" ] && continue
+ cp -fr --remove-destination $dotfile $HOME/.$dotfile
+done
+
+#install all the vim stuff with the help of vundle
+cd $HOME/.vim
+mkdir bundle
+mkdir backup
+echo "* Fetching vim-vundle"
+git clone https://github.com/gmarik/vundle.git bundle/vundle > /dev/null && echo "Vim Vundle deployed"
+echo "* Installing Vundle Bundles"
+vim "+:BundleInstall" "+:qall"
+cd -
+
+
+if which zsh &>/dev/null ; then
+ if [ "x$SHELL" != "x`which zsh`" ] ;then
+ echo "* setting zsh as new shell,please enter your user password"
+ chsh -s `which zsh`
+ else
+ echo "* zsh already set as default shell"
+ fi
+ if [ ! -d ~/.oh-my-zsh ] ; then
+ git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh > /dev/null && echo "oh-my-zsh deployed"
+ else
+ echo "* oh-my-zsh already installed"
+ fi
+else
+ echo "* cannot find zsh :("
+fi
diff --git a/infest/profiles/makefu/dircolors b/infest/profiles/makefu/dircolors
new file mode 100644
index 00000000..1de435ac
--- /dev/null
+++ b/infest/profiles/makefu/dircolors
@@ -0,0 +1,194 @@
+# Configuration file for dircolors, a utility to help you set the
+# LS_COLORS environment variable used by GNU ls with the --color option.
+# Copyright (C) 1996, 1999-2010 Free Software Foundation, Inc.
+# Copying and distribution of this file, with or without modification,
+# are permitted provided the copyright notice and this notice are preserved.
+# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
+# slackware version of dircolors) are recognized but ignored.
+# Below, there should be one TERM entry for each termtype that is colorizable
+TERM Eterm
+TERM ansi
+TERM color-xterm
+TERM con132x25
+TERM con132x30
+TERM con132x43
+TERM con132x60
+TERM con80x25
+TERM con80x28
+TERM con80x30
+TERM con80x43
+TERM con80x50
+TERM con80x60
+TERM cons25
+TERM console
+TERM cygwin
+TERM dtterm
+TERM eterm-color
+TERM gnome
+TERM gnome-256color
+TERM jfbterm
+TERM konsole
+TERM kterm
+TERM linux
+TERM linux-c
+TERM mach-color
+TERM mlterm
+TERM putty
+TERM rxvt
+TERM rxvt-256color
+TERM rxvt-cygwin
+TERM rxvt-cygwin-native
+TERM rxvt-unicode
+TERM rxvt-unicode256
+TERM screen
+TERM screen-256color
+TERM screen-256color-bce
+TERM screen-bce
+TERM screen-w
+TERM screen.linux
+TERM vt100
+TERM xterm
+TERM xterm-16color
+TERM xterm-256color
+TERM xterm-88color
+TERM xterm-color
+TERM xterm-debian
+# Below are the color init strings for the basic file types. A color init
+# string consists of one or more of the following numeric codes:
+# Attribute codes:
+# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+# Text color codes:
+# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+# Background color codes:
+# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+#NORMAL 00 # no color code at all
+#FILE 00 # regular file: use no color at all
+RESET 0 # reset to "normal" color
+DIR 01;36 # directory
+LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
+ # numerical value, the color is as for the file pointed to.)
+MULTIHARDLINK 00 # regular file with more than one link
+FIFO 40;33 # pipe
+SOCK 01;35 # socket
+DOOR 01;35 # door
+BLK 40;33;01 # block device driver
+CHR 40;33;01 # character device driver
+ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file
+SETUID 37;41 # file that is setuid (u+s)
+SETGID 30;43 # file that is setgid (g+s)
+CAPABILITY 30;41 # file with capability
+STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
+OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
+STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
+# This is for files with execute permission:
+EXEC 01;32
+# List any file extensions like '.gz' or '.tar' that you would like ls
+# to colorize below. Put the extension, a space, and the color init string.
+# (and any comments you want to add after a '#')
+# If you use DOS-style suffixes, you may want to uncomment the following:
+#.cmd 01;32 # executables (bright green)
+#.exe 01;32
+#.com 01;32
+#.btm 01;32
+#.bat 01;32
+# Or if you want to colorize scripts even if they do not have the
+# executable bit actually set.
+#.sh 01;32
+#.csh 01;32
+ # archives or compressed (bright red)
+.tar 01;31
+.tgz 01;31
+.arj 01;31
+.taz 01;31
+.lzh 01;31
+.lzma 01;31
+.tlz 01;31
+.txz 01;31
+.zip 01;31
+.z 01;31
+.Z 01;31
+.dz 01;31
+.gz 01;31
+.lz 01;31
+.xz 01;31
+.bz2 01;31
+.bz 01;31
+.tbz 01;31
+.tbz2 01;31
+.tz 01;31
+.deb 01;31
+.rpm 01;31
+.jar 01;31
+.rar 01;31
+.ace 01;31
+.zoo 01;31
+.cpio 01;31
+.7z 01;31
+.rz 01;31
+# image formats
+.jpg 01;35
+.jpeg 01;35
+.gif 01;35
+.bmp 01;35
+.pbm 01;35
+.pgm 01;35
+.ppm 01;35
+.tga 01;35
+.xbm 01;35
+.xpm 01;35
+.tif 01;35
+.tiff 01;35
+.png 01;35
+.svg 01;35
+.svgz 01;35
+.mng 01;35
+.pcx 01;35
+.mov 01;35
+.mpg 01;35
+.mpeg 01;35
+.m2v 01;35
+.mkv 01;35
+.ogm 01;35
+.mp4 01;35
+.m4v 01;35
+.mp4v 01;35
+.vob 01;35
+.qt 01;35
+.nuv 01;35
+.wmv 01;35
+.asf 01;35
+.rm 01;35
+.rmvb 01;35
+.flc 01;35
+.avi 01;35
+.fli 01;35
+.flv 01;35
+.gl 01;35
+.dl 01;35
+.xcf 01;35
+.xwd 01;35
+.yuv 01;35
+.cgm 01;35
+.emf 01;35
+# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
+.axv 01;35
+.anx 01;35
+.ogv 01;35
+.ogx 01;35
+# audio formats
+.aac 00;36
+.au 00;36
+.flac 00;36
+.mid 00;36
+.midi 00;36
+.mka 00;36
+.mp3 00;36
+.mpc 00;36
+.ogg 00;36
+.ra 00;36
+.wav 00;36
+# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
+.axa 00;36
+.oga 00;36
+.spx 00;36
+.xspf 00;36
diff --git a/infest/profiles/makefu/vim/vimrc b/infest/profiles/makefu/vim/vimrc
new file mode 100755
index 00000000..69ff3f58
--- /dev/null
+++ b/infest/profiles/makefu/vim/vimrc
@@ -0,0 +1,105 @@
+" not so original .vimrc
+" 2011-11-29
+"
+" Vundle
+set nocompatible
+filetype off
+set rtp+=~/.vim/bundle/vundle
+call vundle#rc()
+
+Bundle 'gmarik/vundle'
+Bundle 'SudoEdit.vim'
+Bundle 'snipMate'
+Bundle 'tpope/vim-fugitive'
+Bundle 'pyflakes'
+
+filetype plugin indent on
+
+"
+set vb
+let g:snips_author = 'Bob Ross <root@syntax-fehler.de>'
+let g:makefu_author = 'makefu'
+
+""" just for tex
+
+let g:compiler_gcc_ignore_unmatched_lines=1 " ignore for gcc and SCONS
+" compiler gcc
+set foldenable
+set foldmethod=syntax
+" shows matching braches etc
+set showmatch
+set matchtime=3
+" highlight search
+set hlsearch
+
+let g:load_doxygen_syntax=1
+
+" we do not want any filename~ files
+" set noswapfile
+" set nobackup
+set backupdir=~/.vim/backup
+set directory=~/.vim/backup
+
+" turn off F1
+"
+inoremap <F1> <ESC>
+nnoremap <F1> <ESC>
+vnoremap <F1> <ESC>
+
+" save on focus lost
+au FocusLost * :wa
+
+"let TlistAddFilesRecursive = /home/makefu/repos/P2P_MDS " *.cpp *.hpp
+let Tlist_Exit_OnlyWindow =1 " exit if other window is closed
+nnoremap <silent> <F8> :TlistToggle<CR>
+set spelllang=en
+" use set spell to enable spelling
+
+" press ttt to rot16 the whole file
+nmap ttt ggg?G
+
+colorscheme darkblue
+set background=dark
+
+set number
+set mouse=
+set textwidth=9001
+set ignorecase
+set incsearch
+set wildignore=*.o,*.obj,*.bak,*.exe,*.os
+set shiftwidth=2
+
+syntax on
+"For tabstop = 2 spaces
+
+set tabstop=2
+set et
+set sw=2
+set smarttab
+set autoindent
+" end tabstop
+
+
+set backspace=indent,eol,start
+set nocp
+
+
+" python stuff
+" run python code with f5
+"autocmd FileType python map <F5> :w<CR>:!python "%"<CR>
+" pydiction
+"let g:pydiction_location = '~/.vim/plugin/pydiction/complete-dict'
+
+" automatically open and close the popup menu / preview window
+au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
+set completeopt=menuone,menu,longest,preview
+
+" somewhere before nowrap is set
+set wrap
+
+autocmd BufRead *.json set filetype=json
+autocmd FileType json set equalprg=json_reformat
+autocmd FileType json set makeprg=jsonval\ %
+autocmd FileType json set errorformat=%E%f:\ %m\ at\ line\ %l,%-G%.%#
+
+au BufNewFile,BufRead *.mustache set syntax=mustache
diff --git a/infest/profiles/makefu/vimrc b/infest/profiles/makefu/vimrc
new file mode 120000
index 00000000..3f2626c5
--- /dev/null
+++ b/infest/profiles/makefu/vimrc
@@ -0,0 +1 @@
+.vim/vimrc \ No newline at end of file
diff --git a/infest/profiles/makefu/zshrc b/infest/profiles/makefu/zshrc
new file mode 100644
index 00000000..a60313e5
--- /dev/null
+++ b/infest/profiles/makefu/zshrc
@@ -0,0 +1,44 @@
+
+# Path to your oh-my-zsh configuration.
+export ZSH=$HOME/.oh-my-zsh
+
+# Look in ~/.oh-my-zsh/themes/
+export ZSH_THEME="gallifrey"
+
+# Comment this out to disable weekly auto-update checks
+export DISABLE_AUTO_UPDATE="true"
+
+# export DISABLE_LS_COLORS="true"
+
+plugins=(git ssh-agent)
+source $ZSH/oh-my-zsh.sh
+test -e $HOME/.bash_alias && source $HOME/.bash_alias
+
+# Customize to your needs...
+export PATH=$PATH:/krebs/bin:$HOME/bin
+HISTFILE=~/.histfile
+HISTSIZE=900001
+SAVEHIST=900001
+
+export EDITOR=vim
+
+export JAVA_HOME=/opt/java/jre
+
+GREP_COLOR="1;33"
+alias grep='grep --color=auto'
+
+export MANPATH=$MANPATH:$HOME/man
+
+if [ -f "$HOME/.dircolors" ] ; then
+ eval `dircolors -b "$HOME/.dircolors"`
+ export LS_COLORS
+fi
+
+which fortune >/dev/null && fortune -a
+which task >/dev/null && task
+echo "--"
+test -r ~/TODO && cat ~/TODO
+
+test -r ~/Dropbox/shared_shell && source ~/Dropbox/shared_shell
+setopt menu_complete
+unsetopt correct_all
diff --git a/punani/README.md b/punani/README.md
new file mode 100644
index 00000000..1b70eab7
--- /dev/null
+++ b/punani/README.md
@@ -0,0 +1,30 @@
+Overview
+=======
+Punani is a meta packagemanager comprising a server which resolves package
+requests and a client containing the logic to find the best suitable packer
+on the host system. Packagenames in Punani are binaries in the PATH. All
+library packages are named in the Principle of Least Surprise[1]. Different
+package names can resolve into the same package.
+
+If you want to install the `hostname` tool, the query is
+ punani install hostname
+on an archlinux this will result in the call :
+ pacman --noconfirm -Sy --needed inetutils
+
+[1] http://de.wikipedia.org/wiki/Principle_of_Least_Surprise
+
+Punani Client
+============
+The punani client will determine which packer are available on the system
+and then send a request to the punani server to find out how the given
+package is called with the given packer. In addition to that, the client
+will add flags to the packers call in order to install packages only when
+needed and disable user interaction.
+
+Punani Server
+============
+
+The punani server is a web-service which resolves request in the following
+manner:
+ localhost/$packer/$package
+The result is the package-name with the given packer or 404 if not found.
diff --git a/punani/bin/punani b/punani/bin/punani
index 058331f1..3f11cec8 100755
--- a/punani/bin/punani
+++ b/punani/bin/punani
@@ -1,276 +1,68 @@
#! /bin/sh
-#
-# punani - filesystem scienteer
-#
-# Engineering Operations
-# -E -i spec insert a package to the target filesystem
-# -E -r spec remove a package
-#
set -euf
-godmode() {
- if test "${nosudo-false}" != true -a `id -u` != 0; then
- echo "!! we require god mode..." >&2
- exec sudo "$0" "$@"
- exit 23 # go to hell
- fi
-}
-# return the 'system' variable
-# currently be:
-# arch-like
-# debian-like
-guess_system()
-{
- if [ -f "/etc/arch-release" ] ;then
- system="${system+$system, }arch-like"
- fi
- if [ -f "/etc/lsb-release" -o -f "/etc/debian_version" ] ;then
- system="${system+$system, }debian-like"
- fi
+PUNANI_HOST="${PUNANI_HOST-http://euer.krebsco.de:9111}"
+ACTION="$1"; shift
+PKGS="$*"
-}
+## find package manager
+if ! :; then : # dummy case, so the rest has a common format
-arch_aur_helper()
-{
- # pacman is the last fallback helper
- manager="yaourt clyde packer bauerbill tupac pacaur paktahn pbfetch aurget aurora cower powaur pacman"
- for i in $manager;do
- mgr=`which $i`
- if [ "$mgr" ] ;then
- echo $mgr
- return 0
- fi
- done
- echo "!! no helper found, this should never happen(tm)."
- return 1
-}
-
-handle_system () {
- case "$system" in
- (*arch-like*)
- # dryrun
- # TODO dryrun not dry enough for aur helper
- if [ "${dryrun-}" ];then
- pacman () { echo "pacman $@" ; }
- pkgfile () { echo "pkgfile $@"; }
- yaourt () { echo "yaourt $@" ; }
- fi
-
- # get dependencies :
- # we need pkgfile
- if ! [ `which pkgfile` ] ; then
- pacman -S --needed --noconfirm pkgtools
- pkgfile -u
- fi
- punani_Scientist_update() {
- pacman -Sy
- pkgtool -u
- }
- punani_Scientist_search() {
- pkgfile -s -b $1
- if [ "${hard-}" ] ; then
- mgr=`arch_aur_helper`
- $mgr -Ss $1
- fi
+elif for PACKER_CMD in yum
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='-y install'
+ REMOVE_PARAM='-y remove'
- }
-
- punani_Engineer_insert() {
- # punani under archlinux first tries to load the packages with the given file name
- # it needs pkgfile for that
- #
- # when trying harder it tries to load the package with the given name directly via yaourt
- echo "** trying to find package with given file"
- pkgs=$(pkgfile -s -b -r $1 | tr "\n" "|" )
- if [ "$pkgs" ];then
- echo "** found one or more packages matching, skip the ones you do not need!"
- OLDIFS=$IFS
- IFS='|'
- for to_install in $pkgs;do
- if pacman -S --needed "$to_install"; then
- echo "++ finished"
- fi
- done
- IFS=$OLDIFS
- else
- echo "!! nothing found in base repos"
- if [ "${hard-}" ] ; then
- echo "** trying harder"
- echo "** trying yaourt directly with given package"
- mgr=`arch_aur_helper`
- if $mgr -S $1 ;then
- echo "++ finished"
- return 0
- else
- echo "!! giving up...i am sorry"
- return 1
- fi
- echo
- else
- echo "?? When in doubt try $0 -h -Ei $1 "
- fi
- fi
- }
- punani_Engineer_remove() {
- pacman -Rcs "`pacman -Ql | grep $1$ | awk '{print $1}'`"
- if [ "${hard-}" ] ; then
- echo "** trying harder"
- echo "** directly delete given package name"
- pacman -Rcs "$1"
- fi
- }
- ;;
- (*debian-like*)
- #if [ "${dryrun-}" ]; then
- # apt-file () { echo $@; }
- # apt-get () { echo $@; }
- #fi
- if ! which apt-file; then
- echo "** installing dependencies: apt-file"
- apt-get install --yes apt-file
- echo "** update the apt-file tool"
- apt-file update
- fi
- punani_Scientist_update() {
- apt-get update
- apt-file update
- }
-
- punani_Scientist_search() {
- apt-file search -l -x $1\$ && exit 0
- if [ "${hard-}" ] ; then
- apt-cache search $1
- fi
- }
- punani_Engineer_insert() {
- echo "trying to install $1"
- pkgs=$(apt-file search -l -x $1\$ | tr "\n" "|" )
- if [ "$pkgs" ];then
- echo "** found one or more packages matching, skip the ones you do not need!"
- OLDIFS=$IFS
- IFS='|'
- for to_install in $pkgs;do
- if apt-get install $to_install;then
- echo "++ finished"
- fi
- done
- IFS=$OLDIFS
- else
- if [ "${hard-}" ] ; then
- echo "** trying harder"
- apt-get install $1
- fi
- fi
- }
- punani_Engineer_remove() {
- apt-get remove --purge "`apt-file search -l -x /$1\$`"
- if [ "${hard-}" ] ; then
- echo "** trying harder"
- echo "** directly delete given package name"
- apt-get remove --purge "$1"
- fi
- }
- ;;
- (*)
- email='krebs@syntax-fehler.de'
- irc_host='irc.freenode.org'
- irc_channel='#tincspasm'
- cat >&2 <<EOF
-Error 2: Your System Will Be Supported ASAP
-1. send us a bug report
-1.1 your operating system's name and version
-1.2 this message: $0 $*
-1.3 mailto:$email
-2. join the relevant IRC channel
-2.1 /connect $irc_host
-2.2 /join $irc_channel
-EOF
- exit 23
- esac
-}
-help(){
- cat <<EOF
-Usage: $0 [Options] [role][command]
+elif for PACKER_CMD in brew
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='install'
+ REMOVE_PARAM='remove'
-Options:
- -f force
- -h hard
- -v verbose
- -d dryrun
- -? this message
+elif for PACKER_CMD in bauerbill packer yaourt pacman
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='--noconfirm -S --needed'
+ REMOVE_PARAM='-Rcs'
-Role:
- -E Engineer
- -S Scientist
+elif for PACKER_CMD in aptitude apt-get
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='--yes install'
+ REMOVE_PARAM='--yes remove'
-Engineer:
- i insert
- r remove
+else
+ echo "Error 2: no known package manager found; no punani for you!" >&2
+ exit 23
+fi
-Scientist:
- s search
- y update
-EOF
- exit 1
-}
-punani (){
- ns=punani
- role=undefined
- while getopts 'dfhvSsopEir?' OPT; do
- case $OPT in
- (f) force=true; continue;;
- (h) hard=true; continue;;
- (v) set -x; continue;;
- (d) dryrun=true; continue;;
- (\?) help;continue ;;
- esac
- case ${role-Manager} in
- (Engineer)
- case $OPT in
- (i) command="${ns}_${role}_insert";;
- (r) command="${ns}_${role}_remove";;
- (*)
- echo 'Error 1: You are made of stupid!' >&2
- exit 23;;
- esac;;
- (Scientist)
- case $OPT in
- (s) command="${ns}_${role}_search";;
- (y) command="${ns}_${role}_update";;
- (*)
- echo 'Error 1: You are made of stupid!' >&2
- exit 23;;
- esac ;;
- (undefined)
- case $OPT in
- (E) role=Engineer;;
- (S) role=Scientist;;
- (*)
- exit 23;;
- esac
- ;;
- (*)
- echo 'Error 1: You are made of stupid!' >&2
- exit 23
- ;;
- esac
+## find package name
+if test -n "$PKGS"; then
+ for PKG in $PKGS; do
+ RES="`wget -O- $PUNANI_HOST/$PACKER_CMD/$PKG 2>/dev/null || :`"
+ if [ ! "$RES" ]; then
+ echo "Error 2: could not resolve '$PKG'; no punani for you!" >&2
+ exit 23
+ fi
+ RESOLVED="${RESOLVED+$RESOLVED }$RES"
done
-}
-punani $@
+else
+ echo "Error 1: no PACKAGE specified." >&2
+ ACTION="usage"
+fi
-case $role in
- (Engineer) godmode $@;;
- (Scientist)
- case $command in
- (*_update) godmode $@;;
- esac;;
+## dispatch
+case "$ACTION" in
+ install)
+ set -x
+ for PKG in $RESOLVED; do
+ sudo $PACKER_CMD $INSTALL_PARAM $PKG || echo "Cannot install $PKG!"
+ done
+ ;;
+ remove)
+ set -x
+ for PKG in $RESOLVED; do
+ sudo $PACKER_CMD $REMOVE_PARAM $PKG || echo "Cannot remove $PKG!"
+ done
+ ;;
+ *)
+ echo "usage: `basename $0` (install|remove) PACKAGE..."
+ exit 23
esac
-
-shift `echo $OPTIND-1 | bc`
-
-guess_system
-handle_system
-
-for name in "$@"; do
- "$command" "$name" || echo "!! could not install $name"
-done
diff --git a/punani/bot/__init__.py b/punani/bot/__init__.py
new file mode 100755
index 00000000..13d4c20b
--- /dev/null
+++ b/punani/bot/__init__.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+from Queue import Queue
+from SocketServer import BaseRequestHandler, ThreadingTCPServer
+from threading import Thread
+from time import sleep, strftime, strptime
+
+from ircbot import SingleServerIRCBot
+from irclib import nm_to_n
+
+class PunaniRequestHandler(BaseRequestHandler):
+ """Handler for Punani messages."""
+
+ def handle(self):
+ try:
+ msg = self.request.recv(1024).strip()
+ except ValueError:
+ msg = 'Invalid message.'
+ else:
+ self.server.queue.put((self.client_address, msg))
+ print ('%s:%d' % self.client_address), str(msg)
+
+
+class PunaniReceiveServer(ThreadingTCPServer):
+ """UDP server that waits for Punani messages."""
+
+ def __init__(self):
+ ThreadingTCPServer.__init__(self, ('127.0.0.1', 5555), PunaniRequestHandler)
+ self.queue = Queue()
+
+class PunaniBot(SingleServerIRCBot):
+
+ def __init__(self, server_list, channel_list, nickname='punani-ircbot',
+ realname='Bob Ross'):
+ SingleServerIRCBot.__init__(self, server_list, nickname, realname)
+ self.channel_list = channel_list
+
+ def on_welcome(self, conn, event):
+ """Join channels after connect."""
+ print 'Connected to %s:%d.' % conn.socket.getsockname()
+ for channel, key in self.channel_list:
+ conn.join(channel, key)
+
+ def on_nicknameinuse(self, conn, event):
+ """Choose another nickname if conflicting."""
+ self._nickname += '_'
+ conn.nick(self._nickname)
+
+ def on_ctcp(self, conn, event):
+ """Answer CTCP PING and VERSION queries."""
+ whonick = nm_to_n(event.source())
+ message = event.arguments()[0].lower()
+ if message == 'version':
+ conn.notice(whonick, 'Punani2irc')
+ elif message == 'ping':
+ conn.pong(whonick)
+
+ def on_privmsg(self, conn, event):
+ """React on private messages.
+
+ Die, for example.
+ """
+ whonick = nm_to_n(event.source())
+ message = event.arguments()[0]
+ if message == 'die!':
+ print 'Shutting down as requested by %s...' % whonick
+ self.die('Shutting down.')
+
+ def say(self, msg):
+ """Say message to channels."""
+ for channel, key in self.channel_list:
+ self.connection.privmsg(channel, msg)
+
+def process_queue(announce_callback, queue, delay=2):
+ """Process received messages in queue."""
+ while True:
+ sleep(delay)
+ try:
+ addr, msg = queue.get()
+ except Empty:
+ continue
+ #do something with the addr?
+ announce_callback(str(msg))
+if __name__ == '__main__':
+ # Set IRC connection parameters.
+ irc_servers = [('supernode', 6667)]
+ irc_channels = [('#retiolum','')]
+
+ # Prepare and start IRC bot.
+ bot = PunaniBot(irc_servers, irc_channels)
+ t = Thread(target=bot.start)
+ t.daemon = True
+ t.start()
+ announce = bot.say
+
+ receiver = PunaniReceiveServer()
+ t = Thread(target=process_queue,args=(announce,receiver.queue))
+ t.daemon = True
+ t.start()
+ receiver.serve_forever()
diff --git a/punani/db/punani b/punani/db/punani
new file mode 100644
index 00000000..df471f3a
--- /dev/null
+++ b/punani/db/punani
@@ -0,0 +1,64 @@
+{
+ "packer-symlinks" : {
+ "packer" : "yaourt",
+ "aptitude" : "apt-get",
+ "bauerbill" : "yaourt"
+ },
+ "super-packer" : {
+ "yaourt" : "pacman"
+ },
+ "vim" : {
+ "apt-get" : "vim",
+ "pacman" : "vim",
+ "brew" : "vim",
+ "yum" : "vim"
+ },
+ "unison" : {
+ "apt-get" : "unison",
+ "pacman" : "unison"
+ },
+ "python" : {
+ "apt-get" : "python",
+ "pacman" : "python2"
+ },
+ "python2" : {
+ "apt-get" : "python",
+ "pacman" : "python2"
+ },
+ "python3" : {
+ "apt-get" : "python3",
+ "pacman" : "python"
+ },
+ "tinc" : {
+ "apt-get" : "tinc",
+ "yaourt" : "tinc"
+ },
+ "python-notify" : {
+ "pacman" : "python-notify",
+ "apt-get" : "python-notify"
+ },
+ "python-dbus" : {
+ "pacman" : "dbus-python",
+ "apt-get" : "python-dbus"
+ },
+ "w3m" : {
+ "pacman" : "w3m",
+ "apt-get" : "w3m"
+ },
+ "make" : {
+ "pacman" : "make",
+ "apt-get" : "make"