X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=tuerctlsh;h=de9adc6843f88146ced261d78d57073bad315658;hp=3cadfcdb96daf1b97b6a36334dba0bcd20ec6ef8;hb=9148b190d80a15e5393f7ef8c5bd6997c4b40bb2;hpb=b14a9db037e1f8a1a146bdc77b7b351c2a0e521a diff --git a/tuerctlsh b/tuerctlsh index 3cadfcd..de9adc6 100755 --- a/tuerctlsh +++ b/tuerctlsh @@ -1,8 +1,31 @@ -#!/bin/bash +#!/bin/zsh # # make this the default shell for user tuerctl and add # the following line to sudoers file: # # tuerctl ALL=(tuer) NOPASSWD: /flash/tuer/tuer_socat.sh -sudo -u tuer /flash/tuer/tuer_socat.sh +setopt histsubstpattern +#local TUERCHAN="sudo -u tuer /flash/tuer/tuer_socat.sh" +local TUERCHAN="sudo -u tuer /flash/tuer/door_client_zmq" + +[[ $1 == "-c" ]] && shift +if [[ -z $1 ]]; then + ${(z)TUERCHAN} +else + if [[ -z $SSH_ORIGINAL_COMMAND ]]; then + echo "Usable commands are: open, close, toggle status" + read -A CMD + else + CMD=("${=SSH_ORIGINAL_COMMAND}") + fi + if [[ $CMD == "status" ]]; then + local EXT="" + else + local EXT=" ssh $1" + fi + + ${(z)TUERCHAN} <<< "${${CMD[1]}:gs/[^a-zA-Z]//}${EXT}" + [[ $CMD == status ]] && sleep 1 +fi +