#!/bin/sh # do we have stdin? if [[ -t 0 ]] then echo "usage: ssh clidle@home.codevoid.de \"publish,This is a the title of the thing!,path/to/song.mp3|\" < source.tar" exit 1 fi # lazy splitting... _split() { echo "$SSH_ORIGINAL_COMMAND" | cut -d";" -f $1; } # grab stuff command="$(_split 1)" title="$(_split 2)" filename="$(_split 3)" # do we have everything? ( test -z "$command" || \ test -z "$title" || \ test -z "$filename" ) \ && echo "Eingabe unvollständig... " \ && exit 1 # do the thing. _publish() { sleep 1 echo echo "Gut, dann geht's jetzt los:" echo "-> Kommando: $command" echo "-> Titel: $title" echo "-> Dateiname: $filename" echo echo "Entpacke:" cat - | tar tf - } # sanitizing.... :P case "$title" in *[Ss][Ee][Xx]*\ |*[Ff][Uu][Cc][Kk]*\ |*[Dd][Rr][Oo][Gg][Ee][Nn]*) title="$(echo "$title" | sed 's/[Ss][Ee][Xx]/Liebe/g' \ | sed 's/[Ff][Uu][Cc][Kk]/Scheibenkleister/g' \ | sed 's/[Dd][Rr][Oo][Gg][Ee][Nn]/Medizin/g')" sleep 1 echo "!!! Profane Ausdrucksweise erkannt. Blümchenfilter aktiviert." sleep 1 ;; esac # all fun and games until here, let's do something... case "$command" in publish) _publish ;; *) echo "Kommmando unbekannt: $command" exit 1 ;; esac