Teamviewer 11 for Ubuntu Server 15.10 running in Virtualbox

In Teamviewer 11 a feature to manage a headless server has been introduced. The trouble is that Teamviewer’s FAQ leaves out a crucial piece of information on how to get this going.

The following instructions are for Ubuntu Server 15.10 running on Virtualbox 5.0.14, using Teamview 11.0.53254

1. Install Ubuntu Server 64bit as per normal.

2. Log in with the account you created during the install.

3. sudo to root

$sudo -i

4. Activate the root account with passwd

#passwd

5. Bring Ubuntu up to date with

#apt update

#apt upgrade

With following if necessary

#apt-get dist-upgrade

#apt-get autoremove

6. Now install Teamviewer

#dpkg --add-architecture i386

#apt-get update

7. Now download the latest version of Teamviewer. This URL appears to point always to the latest copy.

#wget http://download.teamviewer.com/download/teamviewer_i386.deb

8. Install Teamviewer. This will most likely fail. Do not install gdebi as this will add a whole lot of unnecessary libraries to your server.

#dpkg -i teamviewer_i386.deb

9. Repair the install with

#apt-get install -f

10. Repeat the install Teamviewer. This will succeed.

#dpkg -i teamviewer_i386.deb

11. Try to run Teamserver headless setup. This will hang and fail.

#teamviewer setup

You'll get a message saying the /dev/fb0 can't be found.

Teamviewer's FAQ makes no mention of this or how to fix it.

What Teamviewer is expecting is Framebuffer Console turned on in the Kernel.

Carry out the following to activate uvesafb. Note you do not need Xorg.

Do not install Xorg as your Teamviewer account will not connect to the framebuffer console if you run X.
12. Install v86d, so that we can use uvesafb:

#apt-get install v86d

13. Edit the file /etc/initramfs-tools/modules and add this line. 1024X768 is a convient size but the depth of 32 is a requirement of Teamviewer.

#uvesafb mode_option=1024x768-32

14. Edit /etc/default/grub to this

GRUB_CMDLINE_LINUX_DEFAULT=""

GRUB_TERMINAL=console

GRUB_GFXMODE=1024x768

15. Update the boot image and grub.

#update-initramfs -u

16. Update grub. At the time of writing update-grub gives some error messages, but does not stop the actual operation.

#update-grub

17. Disable plymouth daemon. Possibly not necessary.

mv /etc/init/plymouth.conf /etc/init/plymouth.conf.disabled

18. Optional.

#dpkg --remove-architecture i386

19. Now reboot. During the boot, the Virtualbox window will increase to 1024x768.

#reboot

20. Login in again as root and check for the presence of /dev/fb0
#ll /dev/f*

21. Now run Teamviewer, accept the licence and enter your account details.

#teamviewer setup

22. Now ensure that Teamviewer will start on boot

#teamviewer –daemon enable

23. Now reboot again to check.

#reboot

Go to your Teamviewer account and see that the hostname of the Ubuntu Virtualbox instance is present. Activate and see that Teamview will duplicate the Virtualbox console.

If you chose a NAT network note that you are connecting without any routing to the NAT network from you local network – the beauty of Teamviewer!

Enjoy!

References:

https://www.teamviewer.com/en/help/1111-How-do-I-install-TeamViewer-on-a-Linux-system-with-no-graphical-user-interface

http://www.ubuntumaniac.com/2015/12/install-teamviewer-11-on-ubuntu-1604.html

https://github.com/wyldckat/wyldckat.github.io/wiki/Fixing-problems-no-tty-in-Ubuntu-15.10---fglrx

 

PDF Version - Teamview-Ubuntu-Virtualbox.pdf (34.3KB)

 

X2go Server on Ubuntu 15.04

X2go is a great way of remotely connecting to a headless Ubuntu server (assuming you’re the type of person that wants to manage Ubuntu graphically). In my case my headless Ubuntu is just a hobbyist’s server and I think it’s cheaper to have one hosted for me, than to pay for the electricity and with the added fire risk of hosting a physical server myself. (Except for disk space considerations).
I’ve been using DigitalOcean droplets and I think their control panel is great.

I’m just writing up the steps here, because I’m sure to forget if I need to create another one sometime in the future,

Ubuntu 15.04 now uses systemd. (well that could be another post, because it’s a bit of a kludge it seems to me. But it might be a stepping stone).

1. Create the Ubuntu 15.04 droplet.

2. Ensure you can connect with PuTTY (ssh) or equivalent.

3. Update the droplet with apt-get as per normal.

4. Install Lubuntu. I installed lubuntu.desktop and then removed it as I thought I had problems. I’m sure lubuntu.core is sufficient. [TBA]

5. Now reboot. You’ll see that a graphical login is shown in the DigitalOcean’s console. But it is unusable as the mouse cursor does not align properly.
DigitalOcean’s support don’t help here if you ask, as they say they don’t support graphical droplets.
You can now see why PuTTY must be working! This means SSH is working too.

6. Go to /etc/default and edit grub with nano to this
GRUB_CMDLINE_LINUX_DEFAULT="4"
GRUB_CMDLINE_LINUX="4"
this puts the droplet into a non-graphical mode on the next reboot.
[TBA. I did a few other things while testing this, but I think this is the key change. I’ll need to update once I’ve repeated this procedure once again]

7. You might as well reboot to see the effect.
Once logged back in again, ps –ef will show the parameters passed to init
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 19:05 ?        00:00:01 /sbin/init 4 4
This run level 4 is supposed to be a custom level same as 3, where 5 is the graphical level we don’t want.

8. Install X2goserver, as follows
     sudo add-apt-repository ppa:x2go/stable
     sudo apt-get update
     sudo apt-get install x2goserver x2goserver-xsession

9. The install process has started the x2goserver already. You can check with
     systemctl –l status x2goserver.
But this is where a pure Arch system and Ubuntu differ.
A startup file has been put in /etc/init.d, x2goserver, and Ubuntu’s handling has created a x2goserver.service.
I did a
     systemctl enable x2goserver.service
to be consistent and sure!

10. Now try and connect using the X2goclient. I bet it will fail with a “kex error”.
It seems it can be fixed with adding the below to /etc/sshd_config, and restarting sshd or rebooting.
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
PuTTY has the great feature of a right click paste into nano to avoid typing all this!

11. Set your X2goclient to LXDE of course, and you should be in.
Great!

References:
http://wiki.x2go.org/doku.php/doc:installation:x2goserver
http://wiki.x2go.org/doku.php/doc:faq
https://wiki.archlinux.org/index.php/X2Go
https://bbs.archlinux.org/viewtopic.php?id=189535

Nginx, PHP FPM, try_files and path_info

In the post, http://wiki.nginx.org/PHPFcgiExample, the author gives an URL example for testing various parameters, especially PATH_INFO and $fastcgi_path_info.

This URL is, http://lemp.test/test.php/foo/bar.php?v=1 (this URL is not a hyperlink and does not work, of course)

I was interested to find what Location clause would be necessary to test this on my own server.

In my case, I wanted to test in a separate sub-directory, so the test string becomes:-

http://mydomain.co.uk/mytest/test.php/foo/bar.php?v=1 (this URL does not work either. It’s intended you construct a test on your own server)

As the article says, the test.php file is:-

<pre>
    <?php
        var_export($_SERVER)
    ?>
</pre>

I’m the type of person that fears Regex. I don’t know why, but with a lot of patience and a late night, I’ve got this:-

location ~* ^/mytest/(.+\.php)(/.*)?$

and the steps are:-

“~*” the nginx command for case insensitive matching.
”^/mytest/” the sub-directory off the site’s root where the test.php file is present.
”(.+\.php)” the regex specification that will match one or more characters before the .php extension of the filename, where \. escapes the dot. This protects against a file, “.php” being processed.
“(/.*)?” the regex specification that will match zero or more characters after a slash, where the ? makes this optional.
”$” and finally the $ marks the end of the string. Note that the “?v=1” is never considered by the location matching.

If you think that two php filenames in the URL is a bit odd, various authors suggest it’s a possible construct and give OwnCloud as an example (I’ve not investigated this).

Now we have got the Location sorted, we need to consider whether try_files being included in the location block where fastcgi_split_path_info is also used.
It would appear there is a bug/feature, that PATH_INFO will not be correct if both are present.
And it’s true – I’m using version 1.8.0 when writing this.
Seems it won’t be fixed – see http://trac.nginx.org/nginx/ticket/321


My complete but minimalistic Location block I’ve used to test and correct the issue is as follows:-

    #At least one char before the .php, then an optional / with 0 or more chars after
    location ~* ^/mytest/(.+\.php)(/.*)?$
    {       
        index index.php;       
        try_files $uri $uri/ /mytest/index.php$args; #You can comment this out, and PATH_INFO will be same
        include fastcgi_params; #Put here first so we can override
        fastcgi_split_path_info ^(.+\.php)(/.*)$; #Slightly different from others, and matches my Location regex command
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        set $real_script_name $fastcgi_script_name;
        if ($document_uri ~* "^(.+?\.php)(/.*)$") #Note using $document_uri as this avoids including the query string in the test
        {
            set $real_script_name $1;
            set $path_info $2;
        }
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        #Check to see if the file does really exist
        if (!-f $document_root$real_script_name)
        {
            return 404;
        }
    }

DigitalOcean droplet without X running on Console

Since my Ubuntu DigitalOcean droplet is for non-serious use I find it useful to have X running so I can use graphical tools to manage it, and I’ve installed LXDE.

It works really well. With X2GoServer installed and X2GoClient on my Windows 8.1 laptop, server maintenance is very convenient.

Unfortunately, once I installed LXDE, the Console window available via the DigitalOcean web control panel also showed the X server and the lightdm login prompt.

This couldn’t be used successful. There were two offset cursors and the click points didn’t coincide. Since I mainly use Windows as the client I could kill X running on the console with Ctrl-Alt-F1, but it was annoying me.

What I really wanted was X not to start on the DigitalOcean console and X to only start for the X2GoClient logins.

I eventually got this to work as follows:-

1. /etc/default/grub
edit the lines to this

GRUB_CMDLINE_LINUX_DEFAULT="text"
GRUB_CMDLINE_LINUX="text"

2. run update-grub

3. run systemctl set-default multi-user.target
this sets a symbolic link

Success!
Now the DigitalOcean console does not run X, and can be used in emergencies to log into the server when might not have my laptop available.
X2Go starts it’s own startlxde session.
No more tty7!

The downside, is that TeamViewer now does not work, as there is no “display” for TeamViewer to connect to. But since there is no phyiscal display, TeamViewer gave such a limited screen  resolution, that it’s probably not much of a problem.
X2Go is great as the screen resolution can be maximised to my laptops’s screen resolution.
Hope this helps you.

Caliburn.Micro and SimpleContainer

If you don’t want to use a fully fledged IoC container, then you can use the simple one Caliburn.Micro contains. It’s needed to support the Windows Phone development, but works with WPF, which is my interest.  It’s a source release, and you can get from Nuget, as Caliburn.Micro.Container.


Of course, Caliburn.Micro has it’s own direct access to any IoC, like this in a ViewModel ctor:-

public ShellViewModel()
{
windowsmgr = Caliburn.Micro.IoC.Get<IWindowManager>();
}

But it makes testing difficult and this direct use should be avoided.

What SimpleContainer allows you to do is this:-

public ShellViewModel(IEventAggregator events, IWindowManager wm)
{ 
this.events = events;
this.windowsmgr = wm;
}

Where SimpleContainer will inject the EventAggregator and WindowManager automatically, if set up in the Bootstrapper.

I’m attaching two examples, which work with CM 1.4.1, and for VS2012 and Net4.5.
One I wrote myself, and the other was added as a sample within Caliburn.Micro’s discussions, which I’ve updated.

It’s easier for you to read the code in the examples than for me to write any more here.

Have fun!

CM-SimpleContainerDemo.zip (2.81 mb)

CM-SimpleContainer-Sample.zip (2.81 mb)

EventAggregator Comparison Demo

Ever since I started using Caliburn.Micro I was puzzled why the EventAggregator used an interface in the ViewModel signature, like this

public class ShellViewModel : Screen, IShell, IHandle<YourMessageOne>, IHandle<YourMessageTwo>{}

Agreed, the documentation is clear, in that you can Cast to see if the view model supports messaging, and if so automatically subscribe. But is that the only advantage? In the few EventAggregators I describe here it’s the only one using this technique. Anyway, a quick search showed that I was not the only person to wonder if it could be used without IHandle, as Thomas Oosterkamp shows. I created a small demo to test the idea, and decided I’d go a bit further to make a comparison with a few others. In fact, once you start searching there are many implementations of the Publish/Subscribe paradigm. I was also interested in publishing a message which was subscribed to in an independently loaded MEF module.
So attached is my simple demo of six EventAggregators. If your’s is not shown, do say and I’ll include it!

The demo is very basic. Each EventAggregator publishes your message when you press Send, and it is subscribed to in the same ShellViewModel and an MEF loaded module. The MEF module then re-publishes a new message with the same content, which is subscribed to back in the ShellViewModel. By the way, the MEF module is copied into the demo’s bin/Debug folder by a Build Event and so is entirely idependent. If your EventAggregator is shown, do let me know of any idea to enhance the demo to show off the best feature(s) of your implementation!

To be continued…

EventAggregatorDemo.zip (573.36 kb)

AvalonDock v2 and Caliburn Micro

 AvalonDockCaliburnMicro.zip (2.16 mb)

A new version of AvalonDock is due to be released early March. See  http://avalondock.codeplex.com/.
I thought I would attempt to integrate with Caliburn Micro, which should be easier now, as v2 of AvalonDock is MVVM compatible.

To integrate there are two ways that I know of,

(a.) to create a Custom Attached Property or Behaviour as suggested by Felice Pollano, http//www.felicepollano.com/Trackback.aspx?guid=9dcc8717-eb83-45b5-ac89-2f0d0cf05bde

(b.) to create a Custom Convention along the lines that Valeriu Caraulean has done for Telerik controls,
http://blog.caraulean.com/2011/06/05/integration-of-caliburn-micro-and-teleriks-silverlight-controls/

I thought I’d do both. I’ve used the same test program that Valeriu created.

In the attached Zip, I have included both the associated Caliburn.Micro sources and AvalonDock as at 28th Feb, 88810, which is why the Zip might be a bit big. But I hope it means you can compile and test the solution without fishing for other components.

(a.) Works very well. Simple Activate and Deactivate Message Boxes enable you to track how the Conductor OnActive tracks the usage of the tabs.

(b.) Has a bug I can’t find! The Active ViewModel is Deactivated twice when the application closes down.
In certain circumstances, it can cause the app to crash on shutdown. Solution (a.) does not suffer from this.

I hope you find it useful and interesting. Perhaps you can fix the bug!
I’ll attempt to keep this updated as newer versions of AvalonDock are released

Updated 6th March
I've updated AvalonDock to 89121.
Also updated the Zip with an improved version of how Tab Closing is handled in the Caliburn Convention version.
Still has the closedown problem however.

Updated 8th March
I've changed TestBehaviour to hold a collection of ViewModels instead of Views as in the original.
It's brought out the Style and Template for the Header to the Tab View to better handle the closing.
I've made a small change to Screen.cs to prevent the double Deactivate on shutdown of the app.

John

Entity Framework Starter Kit alternative

 

The Entity Framework 4 has superb  features for custom code generation and there are now quite a few different T4 code generators being released. You can see them easily in VS2010 Extension Manager, and include the ADO.NET C# POCO and C# Web Site POCO Entity Generators and the one I particularly like, Rob Hallett’s method of Unit testing Entity Framework classes, see  http://blogofrab.blogspot.com/2010/08/unit-testing-entity-framework-40.html

To start writing your own generator, a Entity Framework Starter Kit is available, as documented here http://code.msdn.microsoft.com/DesignerExtStartKit  and here http://msdn.microsoft.com/en-us/library/ee373851.aspx.  However  I could not get the starter kit to show and assume it’s due to it being written for VS2010 RC and the VSIX is set up for a version of VS2010 I don’t have.

I decided therefore to recreate the starter kit and to enhance it to include a do nothing T4 template.
I’ve based the mode of operation from the VSIX available at http://t4csla.codeplex.com/.  and so thanks to that team as it proved very helpful.

The Zip is the source of the project and is not a project template, so you’ll need to download and compile it. It’s set up to debug in the experimental instance, so you’ll need the VS2010 SDK installed. Once you have VS2010 running add a Class Library project and a Entity Framework blank model.  Add an Entity from the toolbox, click on the design surface and notice the additional property called, “StarterKit design surface property”. Click on the Entity and notice the two Example properties.

Now right click on the design surface and select Add Code Generation Item….  In the Add Item dialogue that opens the StarterKit item template should now show. It will only show on the top Visual C# menu. Select it and it will add StartupExtention.tt to the project and when the model is save the t4 code will run to create a related cs file.

In developing this starter kit, the thing that caught me out was the item template’s VsTemplate must have a filename starting with, ADONETArtifactGenerator.

Hope you find this useful as a basis for your own work.
John

Update 7th May 2013
I have upgraded the VS2010 VSIX to VS2012 and it worked without issue.
Below are the Starter Kits for VS2010 and VS2012 (they will only install on their respective versions)
The VS2012 is already built and you can find the VSIX in the bin/Debug directory.
The third zip is a test program for you to see the added Properties in the Entity Designer.
Have fun!

StarterKitExtensionVS2010.zip (67.90 kb)

StarterKitExtensionVS2012.zip (300.68 kb)

StarterKitTest2ForAfterYouHaveInstalledTheVSIX.zip (2.79 mb)

At the moment the attachment links are broken.
Try getting files from my GitHub repository, https://github.com/jradxl?tab=repositories