From 3d87c2f37d51b50f47ccccccc3d59ae742e13953 Mon Sep 17 00:00:00 2001 From: Marco Zanon Date: Tue, 13 Mar 2012 22:14:14 +0000 Subject: [PATCH] Released version 0.2. --- skeleton | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/skeleton b/skeleton index ab31e9c..8548782 100644 --- a/skeleton +++ b/skeleton @@ -14,17 +14,42 @@ ## 3 Vnc server binary not extracted. ## 4 Execution permission not set. ## 5 Vnc connection error. +## 6 Invalid command line argument. ## 1. Define constants. -SINGLE_CLICK_REMOTE_HELP_VERSION="1.x" +SINGLE_CLICK_REMOTE_HELP_VERSION="0.x" VNC_SERVER="x11vnc-0.9.13_i686-Linux" INPUT_BOX_TITLE="__YOUR_TEXT_HERE__" INPUT_BOX_MESSAGE="__YOUR_TEXT_HERE__" LABEL_COLUMN_TITLE="__YOUR_TEXT_HERE__" CONNECTIONS[0]="__YOUR_LABEL_HERE__|__YOUR_VNC_SERVER_COMMAND_ARGUMENTS_HERE__" CONNECTIONS[1]="__YOUR_LABEL_HERE__|__YOUR_VNC_SERVER_COMMAND_ARGUMENTS_HERE__" +CLIENT_CONNECTED_MESSAGE="__YOUR_TEXT_HERE__" +CLIENT_GONE_MESSAGE="__YOUR_TEXT_HERE__" -## 2. Get Vnc server command arguments, or terminate. +## 2. Evaluate command line arguments. +if [ -n "$1" ]; then + if [ "client_connected" == "$1" ]; then + M="$CLIENT_CONNECTED_MESSAGE" + elif [ "client_gone" == "$1" ]; then + M="$CLIENT_GONE_MESSAGE" + fi + if [ -z "$M" ]; then + echo "Invalid command line argument, exiting." + exit 6 + fi + if [ -x /usr/bin/zenity ]; then + N=`eval $"zenity --title=\"$INPUT_BOX_TITLE\" --info --text=\"$M\""` + elif [ -x /usr/bin/kdialog ]; then + N=`eval $"kdialog --title \"$INPUT_BOX_TITLE\" --msgbox \"$M\""` + else + echo "Gui scripting tool not found, exiting." + exit 1 + fi + exit 0 +fi + +## 3. Get Vnc server command arguments, or terminate. echo "single_click_remote_help $SINGLE_CLICK_REMOTE_HELP_VERSION (bundled with $VNC_SERVER as Vnc server)" VALUES="" OLD_IFS="$IFS" @@ -54,38 +79,38 @@ VNC_SERVER_COMMAND_ARGUMENTS=${VV[1]} IFS="$OLD_IFS" echo "Vnc server command arguments: $VNC_SERVER_COMMAND_ARGUMENTS." -## 3. Create temporary directory. +## 4. Create temporary directory. TEMPORARY_DIRECTORY=`mktemp -d /tmp/single_click_remote_help.XXXXXXXXXX` -if [ "$?" -ne "0" ]; then +if [ "0" -ne "$?" ]; then echo "Temporary directory not created, exiting." exit 2 fi echo "Temporary directory created: $TMP_DIR." -## 4. Extract Vnc server binary and make it executable. +## 5. Extract Vnc server binary and make it executable. BINARY_LINES=`awk '/^__BINARY_BELOW__/ { print NR + 1; exit 0; }' $0` tail -n+$BINARY_LINES $0 > $TEMPORARY_DIRECTORY/vncserver -if [ "$?" -ne "0" ]; then +if [ "0" -ne "$?" ]; then echo "Vnc server binary not extracted, exiting." exit 3 fi echo "Vnc server binary extracted." chmod +x $TEMPORARY_DIRECTORY/vncserver -if [ "$?" -ne "0" ]; then +if [ "0" -ne "$?" ]; then echo "Execution permission not set, exiting." exit 4 fi echo "Execution permission set." -## 5. Run Vnc server. +## 6. Run Vnc server. echo "Starting Vnc server." -$TEMPORARY_DIRECTORY/vncserver $VNC_SERVER_COMMAND_ARGUMENTS -if [ "$?" -ne "0" ]; then +$TEMPORARY_DIRECTORY/vncserver $VNC_SERVER_COMMAND_ARGUMENTS -afteraccept "$0 client_connected" -gone "$0 client_gone" +if [ "0" -ne "$?" ]; then echo "Vnc connection error, exiting." exit 5 fi -## 6. Remove temporary directory and terminate. +## 7. Remove temporary directory and terminate. rm -rf $TEMPORARY_DIRECTORY echo "Removed temporary directory." exit 0 -- 2.30.2