summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorYves Fischer <yves.fischer@cern.ch>2016-01-15 19:27:34 +0100
committerYves Fischer <yves.fischer@cern.ch>2016-01-15 19:27:34 +0100
commit23c57ff24840c6f612ffd19effbac70a2c218865 (patch)
tree8d1360d385258599586bf3f9568d77ec8cdb6f92 /packages
parent3b7cbbd6a5652b055aa680a1fc4dc1369079c78d (diff)
downloaddebian-packages-23c57ff24840c6f612ffd19effbac70a2c218865.tar.gz
debian-packages-23c57ff24840c6f612ffd19effbac70a2c218865.zip
cern-scripts: package
Diffstat (limited to 'packages')
-rw-r--r--packages/cern-scripts/build.gradle6
-rw-r--r--packages/cern-scripts/src/main/resources/bin/activate.inc.sh68
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/database-tunnels.sh48
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/dmenu-pass.sh40
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/dmenu-software.sh13
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/git-forest641
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/gnome-commands.sh19
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/grails-d5
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/kpcli-open-ais-pm.sh7
-rw-r--r--packages/cern-scripts/src/main/resources/bin/muttrc5
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/restart-gwt.sh16
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/smtp-server.py20
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/telepath-setpresence.sh6
-rw-r--r--packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint1
-rw-r--r--packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint.old1
15 files changed, 896 insertions, 0 deletions
diff --git a/packages/cern-scripts/build.gradle b/packages/cern-scripts/build.gradle
new file mode 100644
index 0000000..d8848ae
--- /dev/null
+++ b/packages/cern-scripts/build.gradle
@@ -0,0 +1,6 @@
+version '1.0'
+
+ospackage {
+ into "/opt/${project.name}"
+ from files('src/main/resources')
+}
diff --git a/packages/cern-scripts/src/main/resources/bin/activate.inc.sh b/packages/cern-scripts/src/main/resources/bin/activate.inc.sh
new file mode 100644
index 0000000..79bed6b
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/activate.inc.sh
@@ -0,0 +1,68 @@
+
+# non-interactive activate
+ __activate_env() {
+ for func in $(typeset -F | cut -f 3 -d ' ' | grep -E '^__env_'); do
+ if [[ "$func" == "__env_$1" ]]; then
+ $func
+ echo "Activated $1"
+ return 0
+ fi
+ done
+ echo "Error: Environment not found $1" >&2
+ return 1
+}
+
+# print all defined envs
+list_envs() {
+ for env in $(typeset -F | sed -n -e 's/^declare -f __env_//p'); do
+ active=false
+ for env_active in $ENV_ACTIVE; do
+ if [ "$env_active" == "$env" ]; then
+ active=true
+ fi
+ done
+ if $active; then
+ echo -n "${env}* "
+ else
+ echo -n "$env "
+ fi
+ done
+ echo ""
+}
+
+plain_list_envs() {
+ typeset -F | sed -n -e 's/^declare -f __env_//p'
+}
+
+# Interactive activate
+activate() {
+ err=false
+ for env in $*; do
+ if ! typeset -F | grep -q -E "^declare -f __env_${env}$"; then
+ echo "Environment not defined: $env"
+ err=true
+ fi
+ done
+ if $err; then
+ return 1
+ fi
+
+ for env in $*; do
+ if typeset -F | grep -q -E "^declare -f __env_${env}$"; then
+ export ENV_ACTIVE="$ENV_ACTIVE${ENV_ACTIVE:+ }$env"
+ __env_${env}
+ fi
+ done
+ echo "Active: $ENV_ACTIVE"
+}
+
+# initialization
+for env_request in $ENV_ACTIVE; do
+ __activate_env $env_request
+done
+
+# bash-completion for `activate'
+_activate() {
+ _init_completion -s || return
+ COMPREPLY=( $(compgen -W "$(list_envs)" -- $cur) )
+} && complete -F _activate activate
diff --git a/packages/cern-scripts/src/main/resources/bin/database-tunnels.sh b/packages/cern-scripts/src/main/resources/bin/database-tunnels.sh
new file mode 100755
index 0000000..034ecf5
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/database-tunnels.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+REMOTE_UNC_PATH="//cerndfs.cern.ch/dfs/Applications/Oracle"
+AISADM_IP=128.142.153.100
+AISADM_FINGERPRINT="`dirname \"$0\"`/../lib/aisadm-fingerprint"
+SSH_USER=$USER
+TNSNAMES="$HOME/.cache/tnsnames"
+LOCAL=false
+TEMP=`getopt -o phl: --long help,local,user: \
+ -n '$0' -- "$@"`
+if [ $? != 0 ] ; then echo "Failed to parse arguments..." >&2 ; exit 1 ; fi
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+function print() { echo -e "\e]0;$1\a"; echo "$1"; }
+
+while true ; do
+ case "$1" in
+ -p|--local) LOCAL=true ; shift ;;
+ -l|--user) shift; SSH_USER=$1; shift ;;
+ -h|--help) echo "$0 [--help|--local] [-l <name>|--user <name>]"; exit 0;;
+ --) shift ; break ;;
+ *) echo "Internal error! ($*)" ; exit 1 ;;
+ esac
+done
+
+if ! $LOCAL; then
+ print "Mirror tnsnames.ore files to $TNSNAMES" &&
+ mkdir -p "$TNSNAMES/admin" "$TNSNAMES/admin_localhost" &&
+ smbclient -k "$REMOTE_UNC_PATH" -D ADMIN_localhost -TXc - 'ADMIN_localhost/OLD' | tar --strip-components=2 -x -C "$TNSNAMES/admin_localhost" &&
+ smbclient -k "$REMOTE_UNC_PATH" -D ADMIN -TXc - 'ADMIN/OLD'| tar --strip-components=2 -x -C "$TNSNAMES/admin" ||
+ echo "failed to mirror tnsnames to $TNSNAMES" >&2
+fi
+
+if $LOCAL; then
+ SSH_EXTRAOPTS="-oProxyCommand=ssh -l \"$SSH_USER\" lxplus.cern.ch nc $AISADM_IP 22"
+else
+ true
+fi
+
+print "Database Tunnel" &&
+ ssh -l "$SSH_USER" \
+ -L 10301:cman1.cern.ch:10300 -L 10302:cman2.cern.ch:10300 \
+ -o UserKnownHostsFile=$AISADM_FINGERPRINT \
+ ${SSH_EXTRAOPTS:+"$SSH_EXTRAOPTS"} \
+ $AISADM_IP \
+ "date; echo tunnel is running; cat"
+
diff --git a/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh b/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh
new file mode 100755
index 0000000..bb3be7a
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+shopt -s nullglob globstar
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
+
+[[ -n $password ]] || exit
+
+while true; do
+ pass show "$password" 2>&1 \
+ | sed -e 's/^pass:.*/pass: XXXX/' \
+ | xmessage -file - \
+ -buttons "Done:1,Copy 'login':2,Copy 'pass':3,Copy all:4" \
+ -default "Done" \
+ -nearmouse -timeout 10
+ case "$?" in
+ 2)
+ pass show "$password" 2>&1 \
+ | sed -ne 's/^login: \(.*\)/\1/p' \
+ | xclip -i -verbose -l 1 2>/dev/null
+ ;;
+ 3)
+ pass show "$password" 2>&1 \
+ | sed -ne 's/^pass: \(.*\)/\1/p' \
+ | xclip -i -verbose -l 1 2>/dev/null
+ ;;
+ 4)
+ pass show "$password" 2>&1 \
+ | xclip -i -verbose -l 1 2>/dev/null
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
diff --git a/packages/cern-scripts/src/main/resources/bin/dmenu-software.sh b/packages/cern-scripts/src/main/resources/bin/dmenu-software.sh
new file mode 100755
index 0000000..bca5b54
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/dmenu-software.sh
@@ -0,0 +1,13 @@
+#!/bin/bash -l
+
+sysenv='System native environment'
+
+env=`(echo "$sysenv"; plain_list_envs) | dmenu`
+
+test -f "$HOME/.cache/dmenu_run" && rm -f "$HOME/.cache/dmenu_run"
+
+if [ "$env" == "$sysenv" ]; then
+ dmenu_run
+else
+ bash -l -c "activate $env; dmenu_run"
+fi
diff --git a/packages/cern-scripts/src/main/resources/bin/git-forest b/packages/cern-scripts/src/main/resources/bin/git-forest
new file mode 100755
index 0000000..bf17f8b
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/git-forest
@@ -0,0 +1,641 @@
+#!/usr/bin/perl
+#
+# git-森林
+# text-based tree visualisation
+# Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008
+#
+# 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 or 3 of the license.
+#
+use Getopt::Long;
+use Git;
+use strict;
+use utf8;
+use Encode qw(encode);
+my $Repo = Git->repository($ENV{"GIT_DIR"} || ".");
+my $Pretty_fmt = "format:%s";
+my $Reverse_order = 0;
+my $Show_all = 0;
+my $Show_rebase = 1;
+my $Style = 1;
+my $Subvine_depth = 2;
+my $With_sha = 0;
+my %Color = (
+ "default" => "\e[0m", # ]
+ "at" => "\e[1;30m", # ]
+ "hhead" => "\e[1;31m", # ]
+ "head" => "\e[1;32m", # ]
+ "ref" => "\e[1;34m", # ]
+ "remote" => "\e[1;35m", # ]
+ "sha" => "\e[0;31m", # ]
+ "tag" => "\e[1;33m", # ]
+ "tree" => "\e[0;33m", # ]
+);
+
+&main();
+
+sub main
+{
+ &Getopt::Long::Configure(qw(bundling pass_through));
+ &GetOptions(
+ "all" => \$Show_all,
+ "no-color" => sub { %Color = (); },
+ "no-rebase" => sub { $Show_rebase = 0; },
+ "a" => sub { $Pretty_fmt = "format:\e[1;30m(\e[0;32m%an\e[1;30m)\e[0m %s"; }, # ]]]]
+ "pretty=s" => \$Pretty_fmt,
+ "reverse" => \$Reverse_order,
+ "svdepth=i" => \$Subvine_depth,
+ "style=i" => \$Style,
+ "sha" => \$With_sha,
+ );
+ ++$Subvine_depth;
+ if (substr($Pretty_fmt, 0, 7) ne "format:") {
+ die "If you use --pretty, it must be in the form of --pretty=format:";
+ }
+ $Pretty_fmt = substr($Pretty_fmt, 7);
+ while ($Pretty_fmt =~ /\%./g) {
+ if ($& eq "\%b" || $& eq "\%n" || ($&.$') =~ /^\%x0a/i) {
+ die "Cannot use \%b, \%n or \%x0a in --pretty=format:";
+ }
+ }
+ if ($Show_all) {
+ #
+ # Give --all back. And add HEAD to include commits
+ # in the rev list that belong to a detached HEAD.
+ #
+ unshift(@ARGV, "--all", "HEAD");
+ }
+ if ($Reverse_order) {
+ tie(*STDOUT, "ReverseOutput");
+ }
+ &process();
+ if ($Reverse_order) {
+ untie *STDOUT;
+ }
+}
+
+sub get_line_block
+{
+ my($fh, $max) = @_;
+
+ while (scalar(@h::ist) < $max) {
+ my $x;
+
+ $x = <$fh>;
+ if (!defined($x)) {
+ last;
+ }
+ push(@h::ist, $x);
+ }
+
+ my @ret = (shift @h::ist);
+ foreach (2..$max) {
+ push(@ret, $h::ist[$_-2]);
+ }
+ return @ret;
+}
+
+sub process
+{
+ my(@vine);
+ my $refs = &get_refs();
+ my($fh, $fhc) = $Repo->command_output_pipe("log", "--date-order",
+ "--pretty=format:<%H><%h><%P>$Pretty_fmt", @ARGV);
+
+ while (my($line, @next_sha) = get_line_block($fh, $Subvine_depth)) {
+ if (!defined($line)) {
+ last;
+ }
+ chomp $line;
+ my($sha, $mini_sha, $parents, $msg) =
+ ($line =~ /^<(.*?)><(.*?)><(.*?)>(.*)/s);
+ my @next_sha = map { ($_) = /^<(.*?)>/ } @next_sha;
+ my @parents = split(" ", $parents);
+
+ &vine_branch(\@vine, $sha);
+ my $ra = &vine_commit(\@vine, $sha, \@parents);
+
+ if (exists($refs->{$sha})) {
+ print &vis_post(&vis_commit($ra),
+ $Color{at}."m".$Color{default});
+ &ref_print($refs->{$sha});
+ } else {
+ print &vis_post(&vis_commit($ra, " "));
+ }
+ if ($With_sha) {
+ print $msg, $Color{at}, encode('UTF-8', "──("), $Color{sha}, $mini_sha,
+ $Color{at}, ")", $Color{default}, "\n";
+ } else {
+ print $msg, "\n";
+ }
+
+ &vine_merge(\@vine, $sha, \@next_sha, \@parents);
+ }
+ $Repo->command_close_pipe($fh, $fhc);
+}
+
+sub get_refs
+{
+ my($fh, $c) = $Repo->command_output_pipe("show-ref");
+ my $ret = {};
+
+ while (defined(my $ln = <$fh>)) {
+ chomp $ln;
+ if (length($ln) == 0) {
+ next;
+ }
+
+ my($sha, $name) = ($ln =~ /^(\S+)\s+(.*)/s);
+ if (!exists($ret->{$sha})) {
+ $ret->{$sha} = [];
+ }
+ push(@{$ret->{$sha}}, $name);
+ if ($name =~ m{^refs/tags/}) {
+ my $sub_sha = $Repo->command("log", "-1",
+ "--pretty=format:%H", $name);
+ chomp $sub_sha;
+ if ($sha ne $sub_sha) {
+ push(@{$ret->{$sub_sha}}, $name);
+ }
+ }
+ }
+
+ $Repo->command_close_pipe($fh, $c);
+
+ my $rebase = -e $Repo->repo_path()."/.dotest-merge/git-rebase-todo" &&
+ $Show_rebase;
+ if ($rebase) {
+ if (open(my $act_fh, $Repo->repo_path().
+ "/.dotest-merge/git-rebase-todo")) {
+ my($curr) = (<$act_fh> =~ /^\S+\s+(\S+)/);
+ $curr = $Repo->command("rev-parse", $curr);
+ chomp $curr;
+ unshift(@{$ret->{$curr}}, "rebase/cn");
+ close $act_fh;
+ }
+
+ chomp(my $up = $Repo->command("rev-parse", ".dotest-merge/upstream"));
+ chomp(my $onto = $Repo->command("rev-parse", ".dotest-merge/onto"));
+ chomp(my $old = $Repo->command("rev-parse", ".dotest-merge/head"));
+ unshift(@{$ret->{$up}}, "rebase/upstream");
+ unshift(@{$ret->{$onto}}, "rebase/onto");
+ unshift(@{$ret->{$old}}, "rebase/saved-HEAD");
+ }
+
+ my $head = $Repo->command("rev-parse", "HEAD");
+ chomp $head;
+ if ($rebase) {
+ unshift(@{$ret->{$head}}, "rebase/new");
+ }
+ unshift(@{$ret->{$head}}, "HEAD");
+
+ return $ret;
+}
+
+#
+# ref_print - print a ref with color
+# @s: ref name
+#
+sub ref_print
+{
+ foreach my $symbol (@{shift @_}) {
+ print $Color{at}, "[";
+ if ($symbol eq "HEAD" || $symbol =~ m{^rebase/}) {
+ print $Color{hhead}, $symbol;
+ } elsif ($symbol =~ m{^refs/(remotes/[^/]+)/(.*)}s) {
+ print $Color{remote}, $1, $Color{head}, "/$2";
+ } elsif ($symbol =~ m{^refs/heads/(.*)}s) {
+ print $Color{head}, $1;
+ } elsif ($symbol =~ m{^refs/tags/(.*)}s) {
+ print $Color{tag}, $1;
+ } elsif ($symbol =~ m{^refs/(.*)}s) {
+ print $Color{ref}, $1;
+ }
+ print $Color{at}, encode('UTF-8', "]──"), $Color{default};
+ }
+}
+
+#
+# vine_branch -
+# @vine: column array containing the expected parent IDs
+# @rev: commit ID
+#
+# Draws the branching vine matrix between a commit K and K^ (@rev).
+#
+sub vine_branch
+{
+ my($vine, $rev) = @_;
+ my $idx;
+
+ my($matched, $master) = (0, 0);
+ my $ret;
+
+ # Transform array into string
+ for ($idx = 0; $idx <= $#$vine; ++$idx) {
+ if (!defined($vine->[$idx])) {
+ $ret .= " ";
+ next;
+ } elsif ($vine->[$idx] ne $rev) {
+ $ret .= "I";
+ next;
+ }
+ if (!$master && $idx % 2 == 0) {
+ $ret .= "S";
+ $master = 1;
+ } else {
+ $ret .= "s";
+ $vine->[$idx] = undef;
+ }
+ ++$matched;
+ }
+
+ if ($matched < 2) {
+ return;
+ }
+
+ &remove_trailing_blanks($vine);
+ print &vis_post(&vis_fan($ret, "branch")), "\n";
+}
+
+#
+# vine_commit -
+# @vine: column array containing the expected IDs
+# @rev: commit ID
+# @parents: array of parent IDs
+#
+sub vine_commit
+{
+ my($vine, $rev, $parents) = @_;
+ my $ret;
+
+ for (my $i = 0; $i <= $#$vine; ++$i) {
+ if (!defined($vine->[$i])) {
+ $ret .= " ";
+ } elsif ($vine->[$i] eq $rev) {
+ $ret .= "C";
+ } else {
+ $ret .= "I";
+ }
+ }
+
+ if ($ret !~ /C/) {
+ # Not having produced a C before means this is a tip
+ my $i;
+ for ($i = &round_down2($#$vine); $i >= 0; $i -= 2) {
+ if (substr($ret, $i, 1) eq " ") {
+ substr($ret, $i, 1) = "t";
+ $vine->[$i] = $rev;
+ last;
+ }
+ }
+ if ($i < 0) {
+ if (scalar(@$vine) % 2 != 0) {
+ push(@$vine, undef);
+ $ret .= " ";
+ }
+ $ret .= "t";
+ push(@$vine, $rev);
+ }
+ }
+
+ &remove_trailing_blanks($vine);
+
+ if (scalar(@$parents) == 0) {
+ # tree root
+ $ret =~ tr/C/r/;
+ }
+
+ return $ret;
+}
+
+#
+# vine_merge -
+# @vine: column array containing the expected parent IDs
+# @rev: commit ID
+# @next_rev: next commit ID in the revision list
+# @parents: parent IDs of @rev
+#
+# Draws the merging vine matrix between a commit K (@rev) and K^ (@parents).
+#
+sub vine_merge
+{
+ my($vine, $rev, $next_rev, $parents) = @_;
+ my $orig_vine = -1;
+ my @slot;
+ my($ret, $max);
+
+ for (my $i = 0; $i <= $#$vine; ++$i) {
+ if ($vine->[$i] eq $rev) {
+ $orig_vine = $i;
+ last;
+ }
+ }
+
+ if ($orig_vine == -1) {
+ die "vine_commit() did not add this vine.";
+ }
+
+ if (scalar(@$parents) <= 1) {
+ #
+ # A single parent does not need a visual. Update and return.
+ #
+ $vine->[$orig_vine] = $parents->[0];
+ &remove_trailing_blanks($vine);
+ return;
+ }
+
+ #
+ # Put previously seen branches in the vine subcolumns
+ # Need to keep at least one parent for the slot algorithm below.
+ #
+ for (my $j = 0; $j <= $#$parents && $#$parents > 0; ++$j) {
+ for (my $idx = 0; $idx <= $#$vine; ++$idx) {
+ if ($vine->[$idx] ne $parents->[$j] ||
+ !grep { my $z = $vine->[$idx]; /^\Q$z\E$/ }
+ @$next_rev) {
+ next;
+ }
+ if ($idx == $orig_vine) {
+ die "Should not really happen";
+ }
+ if ($idx < $orig_vine) {
+ my $p = $idx + 1;
+ if (defined($vine->[$p])) {
+ $p = $idx - 1;
+ }
+ if (defined($vine->[$p])) {
+ last;
+ }
+ $vine->[$p] = $parents->[$j];
+ str_expand(\$ret, $p + 1);
+ substr($ret, $p, 1) = "s";
+ } else {
+ my $p = $idx - 1;
+ if (defined($vine->[$p]) || $p < 0) {
+ $p = $idx + 1;
+ }
+ if (defined($vine->[$p])) {
+ last;
+ }
+ $vine->[$p] = $parents->[$j];
+ str_expand(\$ret, $p + 1);
+ substr($ret, $p, 1) = "s";
+ }
+ splice(@$parents, $j, 1);
+ --$j; # outer loop
+ last; # inner loop
+ }
+ }
+
+ #
+ # Find some good spots to split out into and record columns
+ # that will be used soon in the @slot list.
+ #
+ push(@slot, $orig_vine);
+ my $parent = 0;
+
+ for (my $seeker = 2; $parent < $#$parents &&
+ $seeker < 2 + $#$vine; ++$seeker)
+ {
+ my $idx = ($seeker % 2 == 0) ? -1 : 1;
+ $idx *= int($seeker / 2);
+ $idx *= 2;
+ $idx += $orig_vine;
+
+ if ($idx >= 0 && $idx <= $#$vine && !defined($vine->[$idx])) {
+ push(@slot, $idx);
+ $vine->[$idx] = "0" x 40;
+ ++$parent;
+ }
+ }
+ for (my $idx = $orig_vine + 2; $parent < $#$parents; $idx += 2) {
+ if (!defined($vine->[$idx])) {
+ push(@slot, $idx);
+ ++$parent;
+ }
+ }
+
+ if (scalar(@slot) != scalar(@$parents)) {
+ die "Serious internal problem";
+ }
+
+ @slot = sort { $a <=> $b } @slot;
+ $max = scalar(@$vine) + 2 * scalar(@slot);
+
+ for (my $i = 0; $i < $max; ++$i) {
+ str_expand(\$ret, $i + 1);
+ if ($#slot >= 0 && $i == $slot[0]) {
+ shift @slot;
+ $vine->[$i] = shift @$parents;
+ substr($ret, $i, 1) = ($i == $orig_vine) ? "S" : "s";
+ } elsif (substr($ret, $i, 1) eq "s") {
+ ; # keep existing fanouts
+ } elsif (defined($vine->[$i])) {
+ substr($ret, $i, 1) = "I";
+ } else {
+ substr($ret, $i, 1) = " ";
+ }
+ }
+
+ print &vis_post(&vis_fan($ret, "merge")), "\n";
+}
+
+#
+# vis_* - transform control string into usable graphic
+#
+# To cut down on code, the three vine_* functions produce only a dumb,
+# but already unambiguous, control string which needs some processing
+# before it is ready for public display.
+#
+
+sub vis_commit
+{
+ my $s = shift @_;
+ my $f = shift @_;
+ $s =~ s/ +$//gs;
+ if (defined $f) {
+ $s .= $f;
+ }
+ return $s;
+}
+
+sub vis_fan
+{
+ my $s = shift @_;
+ my $b = shift(@_) eq "branch";
+
+ $s =~ s{s.*s}{
+ $_ = $&;
+ $_ =~ tr/ I/DO/;
+ $_;
+ }ei;
+
+ # Transform an ODODO.. sequence into a contiguous overpass.
+ $s =~ s{O[DO]+O}{"O" x length($&)}eg;
+
+ # Do left/right edge transformation
+ $s =~ s{(s.*)S(.*s)}{&vis_fan3($1, $2)}es ||
+ $s =~ s{(s.*)S}{&vis_fan2L($1)."B"}es ||
+ $s =~ s{S(.*s)}{"A".&vis_fan2R($1)}es ||
+ die "Should not come here";
+
+ if ($b) {
+ $s =~ tr/efg/xyz/;
+ }
+
+ return $s;
+}
+
+sub vis_fan2L
+{
+ my $l = shift @_;
+ $l =~ s/^s/e/;
+ $l =~ s/s/f/g;
+ return $l;
+}
+
+sub vis_fan2R
+{
+ my $r = shift @_;
+ $r =~ s/s$/g/;
+ $r =~ s/s/f/g;
+ return $r;
+}
+
+sub vis_fan3
+{
+ my($l, $r) = @_;
+ $l =~ s/^s/e/;
+ $l =~ s/s/f/g;
+ $r =~ s/s$/g/;
+ $r =~ s/s/f/g;
+ return "${l}K$r";
+}
+
+sub vis_xfrm
+{
+ # A: branch to right
+ # B: branch to right
+ # C: commit
+ # D:
+ # e: merge visual left (╔)
+ # f: merge visual center (╦)
+ # g: merge visual right (╗)
+ # I: straight line (║)
+ # K: branch visual split (╬)
+ # m: single line (─)
+ # O: overpass (≡)
+ # r: root (╙)
+ # t: tip (╓)
+ # x: branch visual left (╚)
+ # y: branch visual center (╩)
+ # z: branch visual right (╝)
+ # *: filler
+
+ my $s = shift @_;
+ my $spc = shift @_;
+ if ($spc) {
+ $s =~ s{[Ctr].*}{
+ $_ = $&;
+ $_ =~ s{ }{\*}g;
+ $_;
+ }esg;
+ }
+
+ if ($Reverse_order) {
+ $s =~ tr/efg.rt.xyz/xyz.tr.efg/;
+ }
+
+ if ($Style == 1) {
+ $s =~ tr/ABCD.efg.IKO.mrt.xyz/├┤├─.┌┬┐.│┼≡.─└┌.└┴┘/;
+ } elsif ($Style == 2) {
+ $s =~ tr/ABCD.efg.IKO.mrt.xyz/╠╣╟═.╔╦╗.║╬═.─╙╓.╚╩╝/;
+ } elsif ($Style == 10) {
+ $s =~ tr/ABCD.efg.IKO.mrt.xyz/├┤├─.╭┬╮.│┼≡.─└┌.╰┴╯/;
+ } elsif ($Style == 15) {
+ $s =~ tr/ABCD.efg.IKO.mrt.xyz/┣┫┣━.┏┳┓.┃╋☰.━┗┏.┗┻┛/;
+ }
+ return $s;
+}
+
+#
+# vis_post - post-process/transform vine graphic
+# Apply user-specific style transformation.
+#
+sub vis_post
+{
+ my $s = shift @_;
+ my $f = shift @_;
+
+ $s = vis_xfrm($s, defined $f);
+ $f =~ s/^([^\x1b]+)/vis_xfrm($1)/e;
+ $f =~ s/(\x1b.*?m)([^\x1b]+)/$1.vis_xfrm($2)/eg;
+ if (defined $f) {
+ $s =~ s/\*/$f/g;
+ $s =~ s{\Q$Color{default}\E}{$&.$Color{tree}}egs;
+ $s .= $f;
+ }
+
+ return $Color{tree}, encode('UTF-8', $s), $Color{default};
+}
+
+sub remove_trailing_blanks
+{
+ my $a = shift @_;
+
+ while (scalar(@$a) > 0 && !defined($a->[$#$a])) {
+ pop(@$a);
+ }
+}
+
+sub round_down2
+{
+ my $i = shift @_;
+ if ($i < 0) {
+ return $i;
+ }
+ return $i & ~1;
+}
+
+sub str_expand
+{
+ my $r = shift @_;
+ my $l = shift @_;
+
+ if (length($$r) < $l) {
+ $$r .= " " x ($l - length($$r));
+ }
+}
+
+package ReverseOutput;
+require Tie::Handle;
+@ReverseOutput::ISA = qw(Tie::Handle);
+
+sub TIEHANDLE
+{
+ my $class = shift @_;
+ my $self = {};
+
+ open($self->{fh}, ">&STDOUT");
+
+ return bless $self, $class;
+}
+
+sub PRINT
+{
+ my $self = shift @_;
+ my $fh = $self->{fh};
+
+ $self->{saved} .= join($\, @_);
+}
+
+sub UNTIE
+{
+ my $self = shift @_;
+ my $fh = $self->{fh};
+
+ print $fh join($/, reverse split(/\n/s, $self->{saved}));
+ print $fh "\n";
+ undef $self->{saved};
+}
diff --git a/packages/cern-scripts/src/main/resources/bin/gnome-commands.sh b/packages/cern-scripts/src/main/resources/bin/gnome-commands.sh
new file mode 100755
index 0000000..ab9de7d
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/gnome-commands.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+here=`dirname "$0"`
+here=`realpath "$here"`
+set -x
+dconf write /org/mate/marco/keybinding-commands/command-1 "'$here/telepath-setpresence.sh available'"
+dconf write /org/mate/marco/global-keybindings/run-command-1 "'<Super>n'"
+
+dconf write /org/mate/marco/keybinding-commands/command-2 "'$here/telepath-setpresence.sh busy'"
+dconf write /org/mate/marco/global-keybindings/run-command-2 "'<Super>b'"
+
+dconf write /org/mate/marco/keybinding-commands/command-3 "'mate-terminal'"
+dconf write /org/mate/marco/global-keybindings/run-command-3 "'<Super>Return'"
+
+dconf write /org/mate/marco/keybinding-commands/command-4 "'$here/dmenu-software.sh'"
+dconf write /org/mate/marco/global-keybindings/run-command-4 "'<Super>c'"
+
+dconf write /org/mate/marco/keybinding-commands/command-5 "'$here/dmenu-pass.sh'"
+dconf write /org/mate/marco/global-keybindings/run-command-5 "'<Super>p'"
+
diff --git a/packages/cern-scripts/src/main/resources/bin/grails-d b/packages/cern-scripts/src/main/resources/bin/grails-d
new file mode 100755
index 0000000..2fb380c
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/grails-d
@@ -0,0 +1,5 @@
+#!/bin/bash
+#like grails-debug but without suspend=y
+
+JAVA_OPTS="-Xdebug -Xnoagent -Dgrails.full.stacktrace=true -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" \
+ grails $@
diff --git a/packages/cern-scripts/src/main/resources/bin/kpcli-open-ais-pm.sh b/packages/cern-scripts/src/main/resources/bin/kpcli-open-ais-pm.sh
new file mode 100755
index 0000000..4d0fb0e
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/kpcli-open-ais-pm.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+d="`mktemp -d`"
+cd "$d"
+smbclient -k '\\cerndfs.cern.ch\dfs' -D '/Departments/GS/Groups/AIS/Sections/PM' -c 'get ais-pm-passwords.kdbx'
+kpcli --kdb ais-pm-passwords.kdbx
+cd "$HOME"
+rm -rvf "$d"
diff --git a/packages/cern-scripts/src/main/resources/bin/muttrc b/packages/cern-scripts/src/main/resources/bin/muttrc
new file mode 100644
index 0000000..bdcb477
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/muttrc
@@ -0,0 +1,5 @@
+# mutt -F mutt.config
+set mbox_type=Maildir
+set folder="./Maildir"
+set mbox="./Maildir"
+set spoolfile="./Maildir"
diff --git a/packages/cern-scripts/src/main/resources/bin/restart-gwt.sh b/packages/cern-scripts/src/main/resources/bin/restart-gwt.sh
new file mode 100755
index 0000000..3870874
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/restart-gwt.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -x
+pid=`jps | grep DevMode | cut -f 1 -d ' '`
+if [ -z "$pid" ]; then
+ echo "no running gwt-client found" >&2
+ exit 1
+fi
+
+cwd=`readlink "/proc/${pid}/cwd"`
+cmd=`cat "/proc/${pid}/cmdline" | tr '\0' ' '`
+cd "$cwd"
+kill -9 "$pid"
+
+sleep 1
+$cmd >/dev/null 2>&1 &
+disown -ar
diff --git a/packages/cern-scripts/src/main/resources/bin/smtp-server.py b/packages/cern-scripts/src/main/resources/bin/smtp-server.py
new file mode 100755
index 0000000..1cfef81
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/smtp-server.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+import sys, os, mailbox, email, smtpd, asyncore
+
+class MaildirServer(smtpd.PureProxy):
+ def __init__(self, localaddr, remoteaddr):
+ smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
+ self.maildir = mailbox.Maildir("./Maildir", create=True)
+ def _deliver(self, mailfrom, rcpttos, data):
+ mail = email.message_from_string(data)
+ maildirMail = Message(mail)
+ self.maildir.add(maildirMail)
+
+if __name__ == '__main__':
+ muttrc = os.path.join(os.path.dirname(__file__), "muttrc")
+ print("Use `mutt -F {}' to read mails".format(muttrc))
+ smtpd.DEBUGSTREAM = sys.stderr
+ server = MaildirServer(("0.0.0.0", 8025), (None, None))
+ asyncore.loop()
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/packages/cern-scripts/src/main/resources/bin/telepath-setpresence.sh b/packages/cern-scripts/src/main/resources/bin/telepath-setpresence.sh
new file mode 100755
index 0000000..5187bb6
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/telepath-setpresence.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# $1 can be 'available' or 'busy' or ?
+qdbus org.freedesktop.Telepathy.Connection.haze.sipe.yves_2efischer_40cern_2ech_2cyfischer \
+ /org/freedesktop/Telepathy/Connection/haze/sipe/yves_2efischer_40cern_2ech_2cyfischer \
+ org.freedesktop.Telepathy.Connection.Interface.SimplePresence.SetPresence \
+ "$1" ""
diff --git a/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint b/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint
new file mode 100644
index 0000000..23becf9
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint
@@ -0,0 +1 @@
+|1|OsR/sAjrVPr+fcFcuD9RvXs5VdQ=|WV2xLsZ+NDr54Iuyxcl8sghHhtM= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw==
diff --git a/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint.old b/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint.old
new file mode 100644
index 0000000..cb8744c
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/lib/aisadm-fingerprint.old
@@ -0,0 +1 @@
+128.142.153.100 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA13n7R0mBmTepw4tk66Szc+nyQGF7b5QkS3HpCx8KmvYHFJcIrjfR5v7rVMenCxhNH5ZrsNmlVfF6uUbPgaPsPbJvJk5R/2H2QsxpMWZKk4fAjHGwqTsm48aZtkcZAyaZORmLvCvVOuPDSR5WlcpYVad/dy4R+zSppZgDPIFoAtiKfOS5sd5pxBvPK8CfLcgxqQKKv0NQgj3iOuKKnqqREEnLJee47EhGZ/zr6lefmRzzlmQrWPKc/xZRSxwHB9w6GT9LFOGM4N9NsJjBRFQ3uicIi8cVh5bzpH09h3fX7slpJeXzsX/uu/BIML3zc2k52Z3yga+bPjAwqWprZZrjww==