Skip to content

Commit

Permalink
Merge branch 'master' of github.molgen.mpg.de:mariux64/mxtools
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwutz committed Sep 1, 2021
2 parents fbf3872 + 0157d2c commit 844cfc9
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
setuid/setuid
prun/*.1
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ INSTALL=install -v
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644

all:
@echo 'Nothing to be done. Ready for "make install"'
manpages += prun/prun.1 prun/pman.1 prun/ptype.1

install:
all: $(manpages)

clean:
@rm -f $(manpages)

install: all
@prefix="$(prefix)" usr_prefix="$(usr_prefix)" usrlocal_prefix="$(usrlocal_prefix)" \
root_exec_prefix="$(root_exec_prefix)" root_bindir="$(root_bindir)" root_sbindir="$(root_sbindir)" \
usr_exec_prefix="$(usr_exec_prefix)" usr_bindir="$(usr_bindir)" usr_sbindir="$(usr_sbindir)" \
usr_mandir="$(usr_mandir)" \
usrlocal_exec_prefix="$(usrlocal_exec_prefix)" usrlocal_bindir="$(usrlocal_bindir)" usrlocal_sbindir="$(usrlocal_sbindir)" \
sysconfdir="$(sysconfdir)" systemdunitdir="$(systemdunitdir)" \
udev_rulesdir="$(udev_rulesdir)" udev_helperdir="$(udev_helperdir)" \
Expand All @@ -79,6 +84,8 @@ install:
DESTDIR="$(DESTDIR)" \
./install.sh

.PHONY: all install

.PHONY: all install clean

%.1: %.md
@if [ "$$UID" = 0 ]; then echo "Please build (\`make\`) as non-root before running \`make install\` as root" >&2;exit 1;fi
pandoc --standalone --to man $< -o $@
5 changes: 5 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fi
: ${usr_exec_prefix:=$usr_prefix}
: ${usr_bindir:=$usr_exec_prefix/bin}
: ${usr_sbindir:=$usr_exec_prefix/sbin}
: ${usr_mandir:=$usr_exec_prefix/man}

: ${usrlocal_exec_prefix:=$usrlocal_prefix}
: ${usrlocal_bindir:=$usrlocal_exec_prefix/bin}
Expand Down Expand Up @@ -222,6 +223,10 @@ install_data mxshadow/mxshadow.cert.pem "$DESTDIR$sysconfdir/m
install_data mxshadow/mxshadow.conf "$DESTDIR$sysconfdir/mxshadow.conf"
install_data mxshadow/mxshadow.service "$DESTDIR$systemdunitdir/mxshadow.service"
install_data misc_etc_files/nsswitch.conf "$DESTDIR$sysconfdir/nsswitch.conf"
install_exec vmcontrol/vmcontrol.pl "$DESTDIR$usr_bindir/vmcontrol.pl"
install_data prun/prun.1 "$DESTDIR$usr_mandir/man1/prun.1"
install_data prun/ptype.1 "$DESTDIR$usr_mandir/man1/ptype.1"
install_data prun/pman.1 "$DESTDIR$usr_mandir/man1/pman.1"

postinstall
exit
4 changes: 2 additions & 2 deletions misc_systemd_units/enable_overcommit_memory.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ConditionHost=|flughafenberlinbrandenburgwillybrandt.molgen.mpg.de
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/sysctl vm.overcommit_memory=0
ExecStop=/usr/sbin/sysctl vm.overcommit_memory=2
ExecStart=/sbin/sysctl vm.overcommit_memory=0
ExecStop=/sbin/sysctl vm.overcommit_memory=2

[Install]
WantedBy=graphical.target
117 changes: 117 additions & 0 deletions mxsnoop/mxsnoop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

#
# +--------------+ (!) +----------------------+ +---****
# | | | br01 | |
# | THE SUSPECT O]===X===[O SCHNUEFFELSTUECK O]======[O WIS-NET
# | | |INLET OUTLET| |
# +--------------+ +----------------------+ +---****
# (MX_NETDEV)

# Basics: https://wiki.archlinux.org/title/Network_bridge

# GATEWAY=10.0.3.1
# BROADCAST=10.0.3.255
# NETMASK=255.255.255.0
# NIDL=24

GATEWAY=141.14.16.128
BROADCAST=141.14.31.255
NETMASK=255.255.240.0
NIDL=20

INLET=${INLET:-}
OUTLET=${OUTLET:-}
BRIDGE=br01

TRANSPARENT=${TRANSPARENT:-}
STP=${STP:-}

function die() { echo $1; exit 1; }

type ip > /dev/null || \
die 'Error: Tools not available, check for ip command.'

MXHOSTCONF=${MXHOSTCONF:-/etc/local/mxhost.conf}
source $MXHOSTCONF || die "# Error: No 'mxhost.conf' ?"
test -n "$MX_IPADDR" || die '# Error: MX_IPADDR missing.'

if [ -z "$OUTLET" ]; then
test -n "$MX_NETDEV" || die '# Error: MX_NETDEV missing?'
test -e /sys/class/net/$MX_NETDEV || die "# Error: $MX_NETDEV missing."
OUTLET=$MX_NETDEV
fi


# inlet was present at boot time -> netXY, or plugged later -> Search for ethX
if [ -z "$INLET" ]; then # find the (sole) inlet
for D in net{00..09} eth{0..9}; do
test -e /sys/class/net/$D || continue
test $D = $OUTLET && continue
test -n "$INLET" && \
die 'Error: Too many network devices (netXY) present, use INLET=dev (OUTLET=dev ?).'
INLET=$D
done
fi

test -z "$INLET" && die '# Error: no second network device found.'

echo "# Note: about to setup/destroy $BRIDGE between $INLET (INLET) and $OUTLET (OUTLET), IP: $MX_IPADDR"

cmd="$1"

case "$cmd" in

start)

if [ -z "$STP" ]; then
ip link add dev $BRIDGE type bridge
else
ip link add dev $BRIDGE type bridge stp_state 1
fi

ip address flush dev $INLET
ip address flush dev $OUTLET

ip link set $INLET master $BRIDGE
ip link set $OUTLET master $BRIDGE

if [ -z "$TRANSPARENT" ] ; then
ip addr add $MX_IPADDR/$NIDL broadcast $BROADCAST dev $BRIDGE
ip link set up dev $BRIDGE
ip route add default via $GATEWAY dev $BRIDGE
fi

ip link set dev $INLET up
ip link set dev $OUTLET up

;;

stop)

ip link set $INLET nomaster
ip link set $OUTLET nomaster
ip link delete $BRIDGE type bridge

ip addr add $MX_IPADDR/$NIDL broadcast $BROADCAST dev $OUTLET
ip link set dev $OUTLET up
ip route add default via $GATEWAY

;;

restart)

$0 stop
sleep 1
$0 start
;;

*)

echo "# usage: [INLET=dev] [OUTLET=dev] $0 [start|stop|restart]"
echo "# options: TRANSPARENT=1 doesn't bind IP on the bridge"
echo "# STP=1 enables Spanning Tree"
;;

esac

37 changes: 37 additions & 0 deletions prun/pman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% PMAN(1) | Mariux Tools Documentation

NAME
====

**pman** - view manual pages installed in Mariux packages.

SYNOPSIS
========

| **pman command**

DESCRIPTION
===========

**pman** uses the PATH set in the package wrapper and tries to find a manual page in the package directory.

EXAMPLES
========

**display manpage found in /pkg/stellarium-0.21.0-0/share/man/man1**
: pman stellarium


BUGS
====

**pman** is very naive in looking up man pages, so your mileage may vary.

See GitHub Issues: <https://github.molgen.mpg.de/mariux64/mxtools>

SEE ALSO
========

**prun(1)**, **ptype(1)**, **man(1)**


96 changes: 96 additions & 0 deletions prun/prun.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
% PRUN(1) Version n/a | Mariux Tools Documentation

NAME
====

**prun** - Run Mariux packages (reads 'Package RUN').

SYNOPSIS
========

| **prun package command** [COMMANDOPTION]...

DESCRIPTION
===========

Runs applications, scripting languages, compilers, etc., from a dedicated directory.

The main usage is to run software in a specific version, or to provide a given environment. See **EXAMPLES** below.

There are some advantages over so called 'virtual environments' and the like. Packages are immutable, once installed they never change, thereby increasing the chances that an old program/script will also run in a few years. The packages also use a standardized call procedure, independent of personal (un-)settings, thus an existing pipeline may be shared between different users.

The whole 'magic' behind **prun** is, that it transparently sets the PATH variable and possibly LD_LIBRARY_PATH for the actual call without spoiling the default environment.

EXAMPLES
========


**Run R-Studio with a brand new R version**

: prun R-4.1.0-0 rstudio

**Use an ancient python to run an unmaintained script**

: prun python-2.7.13-2 /project/cruft/bin/old_script.py

**Run nvidia nvcc from cuda-11.3 and list supported architectures**

: prun cuda-11.3 nvcc --list-gpu-code

**Start a plain shell with gcc-10.2 in the PATH**

: prun gcc-10.2.0-0 bash --norc

**Or just show the manual page for gcc-10.2**

: prun gcc-10.2.0-0 man gcc

**Create an own alias for a scripting language**

: alias myperl='prun perl-5.18.2-0 perl'

**Use prun in a script shebang**

: `#! /usr/bin/prun perl-5.18.2-0 perl`

**Alternatively using source**

: An alternative way to set a distinct environment is to source the profile from /pkg/FooBar-12.3.
But beware, such a source command should **never** make it into the **\~/.bashrc** - in the worst case it may inhibit your login!
(N.b. the alias method mentioned above is safe)

\
: source /pkg/gcc-10.2.0-0/profile


FILES
=====

*/package/FOO* or */pkg/BAR*

: Mountpoint (top directory) for selected package.

*/package/FOO/profile* or */pkg/BAR/profile*

: Contains settings for PATH, libraries, and possibly other stuff.

*/usr/local/package/lib/\**

: Primary wrappers for individual packages.

*/usr/local/package/admin/config*

: Definition of binaries provided and optional shortcuts.


BUGS
====

See GitHub Issues: <https://github.molgen.mpg.de/mariux64/mxtools>

SEE ALSO
========

**ptype(1)**, **pman(1)**, **bash(1)**, **ld.so(8)**


42 changes: 42 additions & 0 deletions prun/ptype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
% PTYPE(1) | Mariux Tools Documentation

NAME
====

**ptype** - small **type** like tool for Mariux packages.

SYNOPSIS
========

| **ptype command**

DESCRIPTION
===========

Similar to **type** or **which**. **ptype** gives information about a package binary. **type** would only tell something about the package wrapper, and not about the package where the real program is.

```
#> type snakemake
snakemake is /usr/local/package/bin/snakemake
#> ptype snakemake
snakemake is /pkg/python-3.8.9-1/bin/snakemake ...
... (/usr/local/package/lib/python.profile)
```

BUGS
====

**ptype** only handles true wrapper scripts from /usr/local/package/bin, not the aliases. I.e. **ptype R** works, **ptype R4** not.

See GitHub Issues: <https://github.molgen.mpg.de/mariux64/mxtools>

SEE ALSO
========

**prun(1)**, **pman(1)**


Loading

0 comments on commit 844cfc9

Please sign in to comment.