aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-02-15 14:53:06 +0100
committerToni Uhlig <matzeton@googlemail.com>2018-02-15 14:53:06 +0100
commitd7fceedbb7bea2681ac22221a5eb4f62135d4344 (patch)
tree724d48ea7d0c27833d16abe24d707572522d7691
parent4516416d3d0263891896488d2831f2dc4bdf79ee (diff)
new stuff
-rwxr-xr-xgo-setenv.sh35
-rwxr-xr-xprocess.py24
2 files changed, 59 insertions, 0 deletions
diff --git a/go-setenv.sh b/go-setenv.sh
new file mode 100755
index 0000000..beb6cd6
--- /dev/null
+++ b/go-setenv.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+set -e
+
+DEFAULT_GOPATH="$(realpath .)"
+DEFAULT_GOARCH="${GOARCH}"
+DEFAULT_GOARM="${GOARM}"
+DEFAULT_GOOS="${GOOS:-linux}"
+
+dialog \
+ --backtitle "GOLANG SETENV" \
+ --title "golang - setenv" \
+ --form "\nSet required env vars for go." \
+ 25 60 16 'GOPATH:' 1 1 "${DEFAULT_GOPATH}" 1 25 25 30 \
+ 'GOARCH:' 2 1 "${DEFAULT_GOARCH}" 2 25 25 30 \
+ 'GOARM' 3 1 "${DEFAULT_GOARM}" 3 25 25 30 \
+ 'GOOS' 4 1 "${DEFAULT_GOOS}" 4 25 25 30 \
+2>/tmp/form.$$
+clear
+
+export GOPATH="$(cat /tmp/form.$$ | head -n 1)"
+export GOARCH="$(cat /tmp/form.$$ | head -n 2 | tail -n 1)"
+export GOARM="$(cat /tmp/form.$$ | head -n 3 | tail -n 1)"
+export GOOS="$(cat /tmp/form.$$ | head -n 4 | tail -n 1)"
+
+echo "[*] EXPORT GOPATH=${GOPATH}"
+echo "[*] EXPORT GOARCH=${GOARCH}"
+echo "[*] EXPORT GOARM=${GOARM}"
+echo "[*] EXPORT GOOS=${GOOS}"
+echo "export GOPATH=\"$(cat /tmp/form.$$ | head -n 1)\"; export GOARCH=\"$(cat /tmp/form.$$ | head -n 2 | tail -n 1)\"; export GOARM=\"$(cat /tmp/form.$$ | head -n 3 | tail -n 1)\"; export GOOS=\"$(cat /tmp/form.$$ | head -n 4 | tail -n 1)\""
+
+
+if [ "x${1}" != "x" ]; then
+ echo "[*] EXEC ${*}"
+ eval "${*}"
+fi
diff --git a/process.py b/process.py
new file mode 100755
index 0000000..effcbbc
--- /dev/null
+++ b/process.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import os
+
+start_pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
+print 'PIDs', str(start_pids)
+
+while True:
+ cur_pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
+ for pid in cur_pids:
+ if pid in start_pids:
+ continue
+ try:
+ cmdline = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read().replace('\x00', ' ')
+
+ if len(cmdline) == 0 or cmdline.startswith('bash') is True or \
+ cmdline.endswith('sh') is True:
+ continue
+ start_pids.append(pid)
+ outstr = 'NEW[%s]: ' % (pid) + cmdline
+ print outstr
+ except IOError:
+ print 'PID', pid, '!exist'
+ continue