scripts: Enable shodan renode multi-session simulation Allow access the kata shell from different renode sessions Use renode port as the input argument to determine which emulated pty device to access. If no port is set, it assumes the port of :1234 (just like before). The GDB server port is also adjusted accordingly. Change-Id: I639891c5d2e81483697d70368a03729300c42ab8
diff --git a/create-kshell-device.sh b/create-kshell-device.sh new file mode 100755 index 0000000..8ec63a9 --- /dev/null +++ b/create-kshell-device.sh
@@ -0,0 +1,14 @@ +#! /bin/bash +# Create kata shell pty device based on the renode port number as the input +# argument. + +TERM_PORT=${1:-0} +if [[ ${TERM_PORT} -gt 0 ]]; then + TERM_DEV="/tmp/term${TERM_PORT}" +elif [[ ${TERM_PORT} -eq 0 ]]; then + TERM_DEV="/tmp/term" +else + TERM_DEV="/tmp/term1337" +fi + +echo "${TERM_DEV}"
diff --git a/generate-renode-port-cmd.sh b/generate-renode-port-cmd.sh new file mode 100755 index 0000000..19dce0b --- /dev/null +++ b/generate-renode-port-cmd.sh
@@ -0,0 +1,16 @@ +#! /bin/bash +# Create renode port command for shodan.resc based on the renode port number as +# the input argument. + +PORT=${1:-1234} +DIR_NAME=$(dirname $(realpath $0)) +TERM_PORT_INPUT=$((${PORT} - 1234)) +TERM_DEV=$(${DIR_NAME}/create-kshell-device.sh ${TERM_PORT_INPUT}) + +if [[ ${TERM_PORT_INPUT} -ge 0 ]]; then + GDB_PORT=$((${TERM_PORT_INPUT} + 3333)) +else + GDB_PORT=4670 # 3333 + 1337 +fi + +echo "\\\$term_port = \\\"${TERM_DEV}\\\"; \\\$gdb_port = ${GDB_PORT};"
diff --git a/kshell.sh b/kshell.sh index 9ec8644..17a1b20 100755 --- a/kshell.sh +++ b/kshell.sh
@@ -1,3 +1,9 @@ -#! /bin/sh +#! /bin/bash # Connect to the kata console shell -stty sane -echo -icanon; socat - /tmp/term,raw; stty sane + +PORT=${1:-1234} +DIR_NAME=$(dirname $(realpath $0)) +TERM_PORT_INPUT=$((${PORT} - 1234)) +TERM_DEV=$(${DIR_NAME}/create-kshell-device.sh ${TERM_PORT_INPUT}) +echo "Access ${TERM_DEV}" +stty sane -echo -icanon; socat - "${TERM_DEV}",raw; stty sane