From a307e0474e78c51590aeac95dbc5587a87ef6501 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 27 Feb 2016 15:58:12 +0100 Subject: refactor scripts packages --- build.gradle | 10 ++-- packages/cern-scripts/build.gradle | 6 -- .../cern-scripts/resources/bin/database-tunnels.sh | 48 --------------- packages/cern-scripts/resources/bin/dmenu-pass.sh | 40 ------------- .../cern-scripts/resources/bin/dmenu-software.sh | 13 ----- .../cern-scripts/resources/bin/gnome-commands.sh | 19 ------ packages/cern-scripts/resources/bin/restart-gwt.sh | 16 ----- packages/cern-scripts/resources/bin/smtp-server.py | 20 ------- .../resources/bin/telepath-setpresence.sh | 6 -- .../cern-scripts/resources/lib/activate.inc.sh | 68 ---------------------- .../cern-scripts/resources/lib/aisadm-fingerprint | 5 -- .../cern-scripts/resources/lib/environments.inc.sh | 46 --------------- packages/scripts-cern/build.gradle | 6 ++ .../scripts-cern/resources/bin/database-tunnels.sh | 48 +++++++++++++++ packages/scripts-cern/resources/bin/restart-gwt.sh | 16 +++++ .../scripts-cern/resources/lib/aisadm-fingerprint | 5 ++ packages/scripts/build.gradle | 6 ++ packages/scripts/resources/bin/dmenu-pass.sh | 40 +++++++++++++ packages/scripts/resources/bin/dmenu-software.sh | 13 +++++ packages/scripts/resources/bin/gnome-commands.md | 19 ++++++ packages/scripts/resources/bin/smtp-server.py | 20 +++++++ .../scripts/resources/bin/telepath-setpresence.sh | 6 ++ packages/scripts/resources/lib/activate.inc.sh | 68 ++++++++++++++++++++++ packages/scripts/resources/lib/environments.inc.sh | 46 +++++++++++++++ 24 files changed, 298 insertions(+), 292 deletions(-) delete mode 100644 packages/cern-scripts/build.gradle delete mode 100755 packages/cern-scripts/resources/bin/database-tunnels.sh delete mode 100755 packages/cern-scripts/resources/bin/dmenu-pass.sh delete mode 100755 packages/cern-scripts/resources/bin/dmenu-software.sh delete mode 100755 packages/cern-scripts/resources/bin/gnome-commands.sh delete mode 100755 packages/cern-scripts/resources/bin/restart-gwt.sh delete mode 100755 packages/cern-scripts/resources/bin/smtp-server.py delete mode 100755 packages/cern-scripts/resources/bin/telepath-setpresence.sh delete mode 100644 packages/cern-scripts/resources/lib/activate.inc.sh delete mode 100644 packages/cern-scripts/resources/lib/aisadm-fingerprint delete mode 100644 packages/cern-scripts/resources/lib/environments.inc.sh create mode 100644 packages/scripts-cern/build.gradle create mode 100755 packages/scripts-cern/resources/bin/database-tunnels.sh create mode 100755 packages/scripts-cern/resources/bin/restart-gwt.sh create mode 100644 packages/scripts-cern/resources/lib/aisadm-fingerprint create mode 100644 packages/scripts/build.gradle create mode 100755 packages/scripts/resources/bin/dmenu-pass.sh create mode 100755 packages/scripts/resources/bin/dmenu-software.sh create mode 100755 packages/scripts/resources/bin/gnome-commands.md create mode 100755 packages/scripts/resources/bin/smtp-server.py create mode 100755 packages/scripts/resources/bin/telepath-setpresence.sh create mode 100644 packages/scripts/resources/lib/activate.inc.sh create mode 100644 packages/scripts/resources/lib/environments.inc.sh diff --git a/build.gradle b/build.gradle index 75f4766..856347d 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { sshUser = 'yvesf' sshHost = 'xapek.org' sshTargetDir = 'public_html/public/debian/files' - sshRebuildCommand = 'cd public_html/public/debian && make' + sshReindexCommand = 'cd public_html/public/debian && make' } allprojects { @@ -36,8 +36,8 @@ allprojects { } } -def rebuildRepositoryIndex = tasks.create('rebuildRepositoryIndex') -rebuildRepositoryIndex << { +def reindex = tasks.create('reindex') +reindex << { ant.taskdef( name: 'antSsh', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', @@ -48,7 +48,7 @@ rebuildRepositoryIndex << { username: sshUser, keyfile: file(sshKeyfile), knownhosts: file(sshKnownHosts), - command: sshRebuildCommand, + command: sshReindexCommand, verbose: true) } @@ -84,4 +84,4 @@ subprojects { project.afterEvaluate { ospackage.version = "${project.version}-${new Date().format("yyyyMMdd-HHmmss")}" } -} \ No newline at end of file +} diff --git a/packages/cern-scripts/build.gradle b/packages/cern-scripts/build.gradle deleted file mode 100644 index d10b19e..0000000 --- a/packages/cern-scripts/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -version '1.0' - -ospackage { - into "/opt/${project.name}" - from files('resources') -} diff --git a/packages/cern-scripts/resources/bin/database-tunnels.sh b/packages/cern-scripts/resources/bin/database-tunnels.sh deleted file mode 100755 index 1f74c84..0000000 --- a/packages/cern-scripts/resources/bin/database-tunnels.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -REMOTE_UNC_PATH="//cerndfs.cern.ch/dfs/Applications/Oracle" -AISADM_IP=aisadm.cern.ch -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 |--user ]"; 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/resources/bin/dmenu-pass.sh b/packages/cern-scripts/resources/bin/dmenu-pass.sh deleted file mode 100755 index bb3be7a..0000000 --- a/packages/cern-scripts/resources/bin/dmenu-pass.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/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/resources/bin/dmenu-software.sh b/packages/cern-scripts/resources/bin/dmenu-software.sh deleted file mode 100755 index bca5b54..0000000 --- a/packages/cern-scripts/resources/bin/dmenu-software.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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/resources/bin/gnome-commands.sh b/packages/cern-scripts/resources/bin/gnome-commands.sh deleted file mode 100755 index ab9de7d..0000000 --- a/packages/cern-scripts/resources/bin/gnome-commands.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 "'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 "'b'" - -dconf write /org/mate/marco/keybinding-commands/command-3 "'mate-terminal'" -dconf write /org/mate/marco/global-keybindings/run-command-3 "'Return'" - -dconf write /org/mate/marco/keybinding-commands/command-4 "'$here/dmenu-software.sh'" -dconf write /org/mate/marco/global-keybindings/run-command-4 "'c'" - -dconf write /org/mate/marco/keybinding-commands/command-5 "'$here/dmenu-pass.sh'" -dconf write /org/mate/marco/global-keybindings/run-command-5 "'p'" - diff --git a/packages/cern-scripts/resources/bin/restart-gwt.sh b/packages/cern-scripts/resources/bin/restart-gwt.sh deleted file mode 100755 index 3870874..0000000 --- a/packages/cern-scripts/resources/bin/restart-gwt.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/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/resources/bin/smtp-server.py b/packages/cern-scripts/resources/bin/smtp-server.py deleted file mode 100755 index 1cfef81..0000000 --- a/packages/cern-scripts/resources/bin/smtp-server.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/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/resources/bin/telepath-setpresence.sh b/packages/cern-scripts/resources/bin/telepath-setpresence.sh deleted file mode 100755 index 5187bb6..0000000 --- a/packages/cern-scripts/resources/bin/telepath-setpresence.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/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/resources/lib/activate.inc.sh b/packages/cern-scripts/resources/lib/activate.inc.sh deleted file mode 100644 index 79bed6b..0000000 --- a/packages/cern-scripts/resources/lib/activate.inc.sh +++ /dev/null @@ -1,68 +0,0 @@ - -# 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/resources/lib/aisadm-fingerprint b/packages/cern-scripts/resources/lib/aisadm-fingerprint deleted file mode 100644 index d913b51..0000000 --- a/packages/cern-scripts/resources/lib/aisadm-fingerprint +++ /dev/null @@ -1,5 +0,0 @@ -# Host aisadm found: line 139 type RSA -|1|yTV5M0N1SGVLpMKcu6+OfkwvC4o=|60gdtP9Qcp26ITFRkvKHIr/UMic= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== -# Host aisadm.cern.ch found: line 140 type RSA -|1|3Dv9PqxtXlsVD96Sc4b/l/XLc10=|hsaJh8u7r0/1olKy6ihcAQuOSfc= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== -|1|dK7Pv86oW5bQku5Of07RsXiG/Ik=|nn2+VzNvPlFlokTOiShBTSLlqi0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== diff --git a/packages/cern-scripts/resources/lib/environments.inc.sh b/packages/cern-scripts/resources/lib/environments.inc.sh deleted file mode 100644 index 8960d95..0000000 --- a/packages/cern-scripts/resources/lib/environments.inc.sh +++ /dev/null @@ -1,46 +0,0 @@ - -function __sub_java7() { - export JAVA_HOME=/usr/lib/jvm/java-7-oraclejdk - export PATH=$JAVA_HOME/bin:$PATH -} - -function __sub_java8() { - export JAVA_HOME=/usr/lib/jvm/java-8-oraclejdk - export PATH=$JAVA_HOME/bin:$PATH -} - -function __sub_tools() { - export PATH=/opt/idea-iu15/bin:$PATH - export PATH=/opt/gwt-chromium/bin:$PATH - - export PATH=/opt/grails3/bin:$PATH - - export PATH=/opt/cern-scripts/bin:$PATH - - export TNS_ADMIN=/home/yfischer/.cache/tnsnames/admin_localhost - export JAVA_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" - export GRADLE_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" -} - -function __env_ideajava8() { - __sub_java8 - __sub_tools -} - -function __env_ideajava7() { - __sub_java7 - __sub_tools -} - -function __env_fwk24() { - __sub_java7 - - export PATH=/opt/idea-iu15/bin:$PATH - export PATH=/opt/gwt-chromium/bin:$PATH - export PATH=/opt/grails2.2.1/bin:$PATH - export PATH=/opt/cern-scripts/bin:$PATH - - export TNS_ADMIN=/home/yfischer/.cache/tnsnames/admin_localhost - export JAVA_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" - export GRADLE_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" -} diff --git a/packages/scripts-cern/build.gradle b/packages/scripts-cern/build.gradle new file mode 100644 index 0000000..d10b19e --- /dev/null +++ b/packages/scripts-cern/build.gradle @@ -0,0 +1,6 @@ +version '1.0' + +ospackage { + into "/opt/${project.name}" + from files('resources') +} diff --git a/packages/scripts-cern/resources/bin/database-tunnels.sh b/packages/scripts-cern/resources/bin/database-tunnels.sh new file mode 100755 index 0000000..1f74c84 --- /dev/null +++ b/packages/scripts-cern/resources/bin/database-tunnels.sh @@ -0,0 +1,48 @@ +#!/bin/bash +REMOTE_UNC_PATH="//cerndfs.cern.ch/dfs/Applications/Oracle" +AISADM_IP=aisadm.cern.ch +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 |--user ]"; 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/scripts-cern/resources/bin/restart-gwt.sh b/packages/scripts-cern/resources/bin/restart-gwt.sh new file mode 100755 index 0000000..3870874 --- /dev/null +++ b/packages/scripts-cern/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/scripts-cern/resources/lib/aisadm-fingerprint b/packages/scripts-cern/resources/lib/aisadm-fingerprint new file mode 100644 index 0000000..d913b51 --- /dev/null +++ b/packages/scripts-cern/resources/lib/aisadm-fingerprint @@ -0,0 +1,5 @@ +# Host aisadm found: line 139 type RSA +|1|yTV5M0N1SGVLpMKcu6+OfkwvC4o=|60gdtP9Qcp26ITFRkvKHIr/UMic= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== +# Host aisadm.cern.ch found: line 140 type RSA +|1|3Dv9PqxtXlsVD96Sc4b/l/XLc10=|hsaJh8u7r0/1olKy6ihcAQuOSfc= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== +|1|dK7Pv86oW5bQku5Of07RsXiG/Ik=|nn2+VzNvPlFlokTOiShBTSLlqi0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== diff --git a/packages/scripts/build.gradle b/packages/scripts/build.gradle new file mode 100644 index 0000000..d10b19e --- /dev/null +++ b/packages/scripts/build.gradle @@ -0,0 +1,6 @@ +version '1.0' + +ospackage { + into "/opt/${project.name}" + from files('resources') +} diff --git a/packages/scripts/resources/bin/dmenu-pass.sh b/packages/scripts/resources/bin/dmenu-pass.sh new file mode 100755 index 0000000..bb3be7a --- /dev/null +++ b/packages/scripts/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/scripts/resources/bin/dmenu-software.sh b/packages/scripts/resources/bin/dmenu-software.sh new file mode 100755 index 0000000..bca5b54 --- /dev/null +++ b/packages/scripts/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/scripts/resources/bin/gnome-commands.md b/packages/scripts/resources/bin/gnome-commands.md new file mode 100755 index 0000000..56ff017 --- /dev/null +++ b/packages/scripts/resources/bin/gnome-commands.md @@ -0,0 +1,19 @@ + +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 "'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 "'b'" + +dconf write /org/mate/marco/keybinding-commands/command-3 "'mate-terminal'" +dconf write /org/mate/marco/global-keybindings/run-command-3 "'Return'" + +dconf write /org/mate/marco/keybinding-commands/command-4 "'$here/dmenu-software.sh'" +dconf write /org/mate/marco/global-keybindings/run-command-4 "'c'" + +dconf write /org/mate/marco/keybinding-commands/command-5 "'$here/dmenu-pass.sh'" +dconf write /org/mate/marco/global-keybindings/run-command-5 "'p'" + diff --git a/packages/scripts/resources/bin/smtp-server.py b/packages/scripts/resources/bin/smtp-server.py new file mode 100755 index 0000000..1cfef81 --- /dev/null +++ b/packages/scripts/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/scripts/resources/bin/telepath-setpresence.sh b/packages/scripts/resources/bin/telepath-setpresence.sh new file mode 100755 index 0000000..5187bb6 --- /dev/null +++ b/packages/scripts/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/scripts/resources/lib/activate.inc.sh b/packages/scripts/resources/lib/activate.inc.sh new file mode 100644 index 0000000..79bed6b --- /dev/null +++ b/packages/scripts/resources/lib/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/scripts/resources/lib/environments.inc.sh b/packages/scripts/resources/lib/environments.inc.sh new file mode 100644 index 0000000..8960d95 --- /dev/null +++ b/packages/scripts/resources/lib/environments.inc.sh @@ -0,0 +1,46 @@ + +function __sub_java7() { + export JAVA_HOME=/usr/lib/jvm/java-7-oraclejdk + export PATH=$JAVA_HOME/bin:$PATH +} + +function __sub_java8() { + export JAVA_HOME=/usr/lib/jvm/java-8-oraclejdk + export PATH=$JAVA_HOME/bin:$PATH +} + +function __sub_tools() { + export PATH=/opt/idea-iu15/bin:$PATH + export PATH=/opt/gwt-chromium/bin:$PATH + + export PATH=/opt/grails3/bin:$PATH + + export PATH=/opt/cern-scripts/bin:$PATH + + export TNS_ADMIN=/home/yfischer/.cache/tnsnames/admin_localhost + export JAVA_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" + export GRADLE_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" +} + +function __env_ideajava8() { + __sub_java8 + __sub_tools +} + +function __env_ideajava7() { + __sub_java7 + __sub_tools +} + +function __env_fwk24() { + __sub_java7 + + export PATH=/opt/idea-iu15/bin:$PATH + export PATH=/opt/gwt-chromium/bin:$PATH + export PATH=/opt/grails2.2.1/bin:$PATH + export PATH=/opt/cern-scripts/bin:$PATH + + export TNS_ADMIN=/home/yfischer/.cache/tnsnames/admin_localhost + export JAVA_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" + export GRADLE_OPTS="-Doracle.net.tns_admin=$TNS_ADMIN" +} -- cgit v1.2.1