summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schulthess2017-05-18 12:02:29 +0200
committerJonathan Bauer2021-06-25 14:48:24 +0200
commit70f09ec3ac4a48742646b5158dd0460460fae0b4 (patch)
treef725485fee91d053d5554da37da8cdd46b0421e6
parent[openjdk-8-jre-headless] Remove NOME from accessibility.properties (diff)
downloadmltk-70f09ec3ac4a48742646b5158dd0460460fae0b4.tar.gz
mltk-70f09ec3ac4a48742646b5158dd0460460fae0b4.tar.xz
mltk-70f09ec3ac4a48742646b5158dd0460460fae0b4.zip
[clientrequest] add remote debugging modul from Christoph Schulthess
startdebug bash script
-rwxr-xr-xcore/modules/clientrequest/data/opt/openslx/remotedebug/.templaterc13
-rwxr-xr-xcore/modules/clientrequest/data/opt/openslx/remotedebug/startdebug_noxterm.sh63
-rw-r--r--core/modules/clientrequest/module.build13
-rw-r--r--core/modules/clientrequest/module.conf7
4 files changed, 96 insertions, 0 deletions
diff --git a/core/modules/clientrequest/data/opt/openslx/remotedebug/.templaterc b/core/modules/clientrequest/data/opt/openslx/remotedebug/.templaterc
new file mode 100755
index 00000000..cf5bee4d
--- /dev/null
+++ b/core/modules/clientrequest/data/opt/openslx/remotedebug/.templaterc
@@ -0,0 +1,13 @@
+display :0
+ssl TMP
+sslonly
+accept popup
+quiet
+
+#see "x11vnc -opts" or "http://www.karlrunge.com/x11vnc/x11vnc_opts.html" for complete list of options
+#xrandr option adds polling overhead and should only be used if xrandr events are expected
+#ncache -n adds to the memory requirements, left to testing in productive context. Also, pixelcache is implemented in a awkward way by ssvnc viewer.
+#viewonly option might be of use in productive context
+
+###GENERATED OPTS FROM /opt/openslx/remotedebug/clientrequest.sh###
+#expected: clip WxH+X+X, rmflag PIDFILE, connect IP:PORT
diff --git a/core/modules/clientrequest/data/opt/openslx/remotedebug/startdebug_noxterm.sh b/core/modules/clientrequest/data/opt/openslx/remotedebug/startdebug_noxterm.sh
new file mode 100755
index 00000000..af4ecd67
--- /dev/null
+++ b/core/modules/clientrequest/data/opt/openslx/remotedebug/startdebug_noxterm.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+declare -rg ROOT_DIR="/opt/openslx/remotedebug"
+declare -rg UUID=$(cat /run/system-uuid)
+declare -rg RCTEMPLATE="${ROOT_DIR}/.templaterc"
+declare -rg PIDFILE="${ROOT_DIR}/vncpid"
+declare -rg RCFILE="${ROOT_DIR}/.x11vncrc"
+declare -rg SAT_URI="/slx-admin/api.php/?do=debugrequest"
+
+function cleanup {
+ trap - INT TERM EXIT
+ echo -e "Cleaning up..."
+ killall x11vnc
+ rm -rf ${PASSWD_DIR}
+ rm -rf ${RCFILE}
+ exit
+}
+
+function errc {
+ "$@"
+ local STATUS=$?
+ if [ ${STATUS} -ne 0 ]; then
+ echo -e "ERROR: ${FUNCNAME[1]} threw exit code ${STATUS}. Exiting."
+ exit ${STATUS}
+ fi
+}
+
+function set_opts {
+ cp ${RCTEMPLATE} ${RCFILE}
+ echo -e "rmflag ${PIDFILE}" >> ${RCFILE}
+ echo -e "o ${VNC_LOG}" >> ${RCFILE}
+ #echo -e "flag ${PORTFILE}" >> ${RCFILE}
+
+ local CLIP=$(xrandr --current | grep primary | grep -o '[0-9]\+[x][0-9]\+[+][0-9]\+[+][0-9]\+')
+ echo -e "clip ${CLIP}" >> ${RCFILE}
+}
+
+function send_request {
+ #local RESPONSE=$(curl -k -X POST -w %{http_code} -d ${UUID}:0 https://${SAT}${SAT_URI})
+ local RESPONSE=$(curl -k -X POST -d ${UUID}:0 https://${SAT}${SAT_URI})
+ if [ "${RESPONSE}" = 403 ]; then
+ echo -e "Your debugging request has been rejected by the local satellite server."
+ echo -e "Either remote debugging is disabled or your client is not known to the satellite server."
+ exit 1
+ elif [ "${RESPONSE%=*}" != "PORT" ]; then
+ echo -e "An error has occured when sending the debug request to the local satellite server."
+ echo -e "Response: ${RESPONSE}"
+ exit 1
+ fi
+ echo -e "connect ${SAT}:${RESPONSE#PORT=}" >> ${RCFILE}
+}
+
+function run_rdbg {
+ source /opt/openslx/config
+ declare -rg SAT=${SLX_PXE_SERVER_IP}
+ set_opts
+ errc send_request
+ errc x11vnc -rc ${RCFILE}
+}
+
+#set -x
+trap cleanup INT EXIT TERM
+run_rdbg
diff --git a/core/modules/clientrequest/module.build b/core/modules/clientrequest/module.build
new file mode 100644
index 00000000..0fdfdf28
--- /dev/null
+++ b/core/modules/clientrequest/module.build
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+fetch_source() {
+ :
+}
+
+build() {
+ pinfo "Static module, nothing to build."
+}
+
+post_copy() {
+ :
+}
diff --git a/core/modules/clientrequest/module.conf b/core/modules/clientrequest/module.conf
new file mode 100644
index 00000000..25c065fb
--- /dev/null
+++ b/core/modules/clientrequest/module.conf
@@ -0,0 +1,7 @@
+#!/bin/bash
+REQUIRED_MODULES="
+ x11vnc
+"
+REQUIRED_DIRECTORIES="
+ /opt/openslx/remotedebug/
+"