Tiny Core Extensions > TCE Tips & Tricks

How to get a virtual remote desktop working.

(1/3) > >>

bigpcman:
[updated May 23rd, 2009
 - Added information related to 'Refresh Screen' script changes
 - Changed the tcz-uninstall command line
 - Added Turn ON and Off Remote Desktop menu Button description]

It's Friday and time to wrap up another week working with Tinycore. I thought it might be useful to sum up my experience getting a remote desktop working that is the same as the local one. The same meaning the flwm background, wbar and menu are in sync. Applications can be installed at either the local or remote end and will be seen at the other end. I tried using both realvnc and tightvnc as the remote desktop server and ended up using tightvnc with the tightvncviewer on a windows machine. I use a secure vpn to my router for remote access to my home network so I don't need a ssl connection to the Xvnc server.

I should point out that my primary application for Tinycore is a webserver so I keep all applications that are not needed for the webserver in the tce/optional directory. I use only tcz applications since I am very limited in memory and install them only when needed. I created the following script to install/start, stop/uninstall and restart the remote desktop. I'm not a script writter so I don't claim that this script is flawless.

Anyway the start function replaces wbar.sh, flwm_restart and 'Refresh Screen' with changed versions, per some excellent advice from Robert and curaga, to accommodate a two display environment. The two displays being local (display=:0.0) and remote (display=:1.0). Without changes to these three files wbar updates and menu updates fall out of sync. Also the updates shutdown the local or remote wbar or flwm processes depending on circumstances. It gets quite confusing.

Next the start function installs the tightvnc application and then activates the Xvnc server. The Xvnc server needs the screen size and color depth set in the command line.

Once the Xvnc server is running the remote display needs to be configured. The conf function sets the background color and activates a wbar and flwm instantiation for the remote display (display=:1.0).

The stop function kills the Xvnc server process and transfers control to the tcz uninstall script. My intent here was to perform the uninstall of tightvnc but the tcz-uninstall script doesn't support this yet. [update- I changed the uninstall command to make use of Jason's latest tcz-uninstall.tcz version.] 

--- Code: ---#!/bin/sh

 stop()
    {
    echo "Stopping tvnc..."
    sudo killall Xvnc 2>&1 > /dev/null &
    tcz-uninstall tightvnc 2>&1 > /dev/null &
    }

 start()
   {
   echo  "Starting tvnc..."
   sudo cp -f /mnt/sdc1/wbar.sh /usr/bin  2>&1 > /dev/null &
   sudo cp -f /mnt/sdc1/flwm_restart /usr/bin 2>&1 > /dev/null &
   sudo cp -f /mnt/sdc1/'Refresh Menu' /home/tc/.wmx 2>&1 > /dev/null &
   tce-load /mnt/sdc1/tce/optional/tightvnc.tcz &
   sleep 2
   Xvnc -geometry 1024x768 -depth 16 :1 2>&1 > /dev/null &
   sleep 3
   DISPLAY=:1.0 config
   }

 restart()
  {
  echo  "Restarting tvnc.."
  stop
  sleep 3
  start
  }

 config()
 {
  xsetroot -solid "#4f5f82"
  /usr/bin/wbar -bpress -config /usr/local/tce.wbar 2>&1 > /dev/null &
  /usr/bin/flwm 2>&1 > /dev/null &
 }

case "$1" in
  start) start;;
  stop) stop;;
  restart) restart;;

  *)
   echo "Usage: $0 {start|stop|restart}"
   esac

--- End code ---
Here is the changed version of the wbar.sh script. It starts wbar from within the DISPLAY command for both the local and remote display. The remote display wbar is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.

--- Code: ---#!/bin/sh
cd "$HOME"
if [ $(awk '/icons:/{print $2}' "$HOME"/.desktop) == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   DISPLAY=:0.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
   [ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
fi
--- End code ---
Here is what I changed in the flwm_restart script. It starts flwm from within the DISPLAY command for both the local and remote display. The remote display flwm is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.

--- Code: ---#!/bin/sh

restart() {
 killall flwm
 DISPLAY=:0.0 flwm &
 [ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 flwm &
 }

 WBARPID=$(pidof flwm)
 [ -n "$WBARPID" ] && restart
--- End code ---

Here is what I changed in the 'Refresh Screen' tool script. It starts flwm from within the DISPLAY command for both the local and remote display. The remote display flwm  is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.


--- Code: ---#!/bin/sh
pkill flwm
DISPLAY=:0.0 flwm &
[ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 flwm &
--- End code ---

Although I have attempted to have all command output sent to the null device the Xvnc server still sends information to the console as shown below. Other messages appear as well.

--- Code: ---tc@box:/mnt/sdc1$ ./tvnc start
Starting tvnc...
/mnt/sdc1/tce/optional/tightvnc.tcz
22/05/09 15:13:00 Xvnc version TightVNC-1.3.9
22/05/09 15:13:00 Copyright (C) 2000-2007 TightVNC Group
22/05/09 15:13:00 Copyright (C) 1999 AT&T Laboratories Cambridge
22/05/09 15:13:00 All Rights Reserved.
22/05/09 15:13:00 See http://www.tightvnc.com/ for information on TightVNC
22/05/09 15:13:00 Desktop name 'x11' (box:1)
22/05/09 15:13:00 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
22/05/09 15:13:00 Listening for VNC connections on TCP port 5901
Font directory '/usr/lib/X11/fonts/Speedo/' not found - ignoring
Font directory '/usr/lib/X11/fonts/Type1/' not found - ignoring
Font directory '/usr/lib/X11/fonts/100dpi/' not found - ignoring
tc@box:/mnt/sdc1$ Xlib:  extension "Generic Event Extension" missing on display ":1.0".

tc@box:/mnt/sdc1$
22/05/09 15:13:16 Got connection from client 192.168.0.114
22/05/09 15:13:16 Using protocol version 3.8
22/05/09 15:13:16 Enabling TightVNC protocol extensions
22/05/09 15:13:16 Pixel format for client 192.168.0.114:
22/05/09 15:13:16   16 bpp, depth 16, little endian
22/05/09 15:13:16   true colour: max r 31 g 63 b 31, shift r 11 g 5 b 0
22/05/09 15:13:16   no translation needed
22/05/09 15:13:16 Using hextile encoding for client 192.168.0.114
22/05/09 15:13:16 rfbProcessClientNormalMessage: ignoring unknown encoding 8
22/05/09 15:13:16 Enabling X-style cursor updates for client 192.168.0.114
22/05/09 15:13:16 Enabling cursor position updates for client 192.168.0.114
22/05/09 15:13:16 Using image quality level 9 for client 192.168.0.114
22/05/09 15:13:16 Enabling LastRect protocol extension for client 192.168.0.114
22/05/09 15:13:16 rfbProcessClientNormalMessage: ignoring unknown encoding -223

--- End code ---
I will do more testing but so far the local and remote desktops seem to be cooperating.

I created a turn On and Off remote desktop toggle menu button as a convenience. I created a file in the /home/tc/.wmx/Tools folder with the content shown below. Note the file name is changed by the script as a way to toggle the name in the menu.


--- Code: ---#!/bin/sh

 start(){
  /mnt/sdc1/tvnc start 2>&1 > /dev/null &
  sleep 4
  mv /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop'  /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop'  2>&1 > /dev/null &
  /usr/bin/flwm_restart 2>&1 > /dev/null &
 }

 stop(){
  /mnt/sdc1/tvnc stop 2>&1 > /dev/null &
  sleep 4
  mv /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop'  /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop'  2>&1 > /dev/null &
  /usr/bin/flwm_restart 2>&1 > /dev/null &
     }

 PID=$(pidof Xvnc)
 [ -n "$PID" ] && stop || start
--- End code ---

roberts:
Very interesting. Thanks for sharing.

bigpcman:
After a little more testing I found an obvious problem. The "Refresh Menu" tool script was also "pkilling" off all instantiations of flwm. So I had to change that file as well:

#!/bin/sh
pkill flwm
DISPLAY=:0.0 flwm &
[ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 flwm &

I will update my original post.

bigpcman:
I created a TurnOn and TurnOff RemoteDeskTop toggle menu button to manage the remote desktop script described in my original post. I'll update the original post.


--- Code: ---#!/bin/sh

 start(){
  /mnt/sdc1/tvnc start 2>&1 > /dev/null &
  sleep 4
  mv /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop'  /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop'  2>&1 > /dev/null &
  /usr/bin/flwm_restart 2>&1 > /dev/null &
 }

 stop(){
  /mnt/sdc1/tvnc stop 2>&1 > /dev/null &
  sleep 4
  mv /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop'  /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop'  2>&1 > /dev/null &
  /usr/bin/flwm_restart 2>&1 > /dev/null &
     }

 PID=$(pidof Xvnc)
 [ -n "$PID" ] && stop || start

--- End code ---

edit: The menu button script when activated by the menu creates console output as shown below. How can I prevent this?


--- Code: ---tc@box:~/.wmx/Tools$  PID=$(pidof Xvnc)
tc@box:~/.wmx/Tools$  [ -n "$PID" ] && stop || start
[2] - Done                       mv -i /home/tc/.wmx/Tools/"TurnOn RemoteDeskTop" /home/tc/.wmx/Tools/                                                      RemoteDeskTop" 2>&1 1>/dev/null
--- End code ---

edit 2: I have not been able to repeat this behavior. The output showed up on my remote ssh terminal. I restarted the ssh session and now there is no output to either the local or remote ssh console. Very strange.

bigpcman:
08/10/2009 - Update Edit: As of tc 2.2 the background color on the remote display was no longer being set by xsetroot. I had to add the -display :1 option to the command as shown below in the "start()" part of the tvnc script.
----------------------------------------------------------------------------------------------------------------------------
This is an update to my previous posts on this subject. Now that the final 2.0 tc has gone back to jwm as the default window manager I did too. However, that caused some problems in my remote desktop connection manager.

Previously I had to change flwm_restart and wbar.sh to accommodate a local and remote monitor. With tc2.0 I had to change wbar.sh and jwm_restart since the jwm window manager is being used. See the changes below. Please keep in mind I don't claim what I am posting to be flawless.


--- Code: ---original /usr/bin/jwm_restart
#!/bin/sh
pidof jwm >/dev/null && jwm -restart
--- End code ---

--- Code: ---Modified  /usr/jwm_restart
#!/bin/sh

restart() {
  jwm -restart &
  [ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 /usr/bin/jwm &
   }

pidof jwm >/dev/null  &&  DISPLAY=:0.0 restart
--- End code ---


--- Code: ---original  /usr/bin/wbar.sh
#!/bin/sh
cd "$HOME"
if [ $(cat /etc/sysconfig/icons) == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   wbar -bpress -config /usr/local/tce.wbar > /dev/null &
fi
--- End code ---


--- Code: ---Modified  /usr/bin/wbar.sh
#!/bin/sh
cd "$HOME"
if [ $(cat /etc/sysconfig/icons) == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   DISPLAY=:0.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
   [ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
fi
--- End code ---

I also cleaned up the remote desktop connection manger script a bit. The script handles the install/start and the stop/uninstall of tightvnc as I have described in previous posts. See below.


--- Code: ---#!/bin/sh
# bigpcman June 7, 2009
# Remote Desktop Xvnc Server install/start and stop/uninstall
# Download tightvnc.tcz to tce/optional
# My usb persistent storage = /mnt/sdc1
# The script manages a wbar button that toggles between on/off images
# The on/off images are initialized by the bootlocal.sh script
# Modified versions of wbar.sh and jwm_restart are required to activate remote monitor.

 stop()
    {
    echo "Stopping tvnc..."
    sudo killall Xvnc 2>&1 > /dev/null &
    sleep 2
    sudo cp -f /mnt/sdc1/mywbar/tvnc-wbar-off.png /mnt/sdc1/mywbar/tvnc-wbar-active.png 2>&1 > /dev/null &
    tcz-uninstall tightvnc --force --purge 2>&1 > /dev/null &
    }

 start()
   {
   echo  "Starting tvnc..."
   sudo cp -a /mnt/sdc1/wbar.sh /usr/bin  2>&1 > /dev/null &
   sudo cp -a /mnt/sdc1/jwm_restart /usr/bin 2>&1 > /dev/null &
   sleep 2
   tce-load /mnt/sdc1/tce/optional/tightvnc.tcz
   sudo cp -a  /mnt/sdc1/mywbar/tvnc-wbar-on.png /mnt/sdc1/mywbar/tvnc-wbar-active.png 2>&1 > /dev/null &
   Xvnc -geometry 1024x768 -depth 16 :1  2>&1 > /dev/null &
   sleep 3
   xsetroot -display :1 -solid "#4f5f82"
   /usr/bin/jwm_restart
   sleep 2
   /usr/bin/wbar.sh
   }

 restart()
  {
  echo  "Restarting tvnc.."
  stop
  sleep 3
  start
  }

case "$1" in
  stop) stop;;
  restart) restart;;
  start)  PID=$(pidof Xvnc)
             [ -n "$PID" ] && echo "Xvnc already started" || start;;

  *)
   echo "Usage: $0 {start|stop|restart}"
   esac
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version