09 September 2020

Remote desktop Mac to Ubuntu

It should be easy, and it is, but first a few hoops:

Using in build in 'vino'

  1. On Ubuntu install vino: sudo apt-get install -y vino
  2. Use 'Settings' app (top right via preferences, or apps, select Sharing
  3. Switch on at the top, and desktop sharing
    1. Set a password
    2. Ensure selected:
      1. "Allow other users to view your desktop"
      2. "Allow other users to control your desktop"
    3. Ensure NOT selected: "You must confirm each access to the this machine"
  4. Disable encryption on Ubuntu: gsettings set org.gnome.Vino require-encryption false
  5. Restart Ubuntu and log into it locally (Vino doesn't start until user logged in)

Using VNC

Vino is ok, but having to login first on the actual machine, and screen resolution pushed me to find another method: using VNC
  1. Install vnc: sudo apt update && sudo apt install -y xfce4 xfce4-goodies
  2. sudo apt install tightvncserver
  3. Setup default password: vncserver
    1. enter password
  4. Reconfigure vnc display:
    1. vncserver -kill :1
    2. copy config: mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
    3. create startup script: vi ~/.vnc/xstartup
    4. Enter startup script:
      #!/bin/bash
      xrdb $HOME/.Xresources
      startxfce4 &
    5. Change to executable: sudo chmod +x ~/.vnc/xstartup
    6. Now connect...

To Connect

  1. Get Ubuntu ip address: apt-get install -y net-tools && ifconfig -a
  2. Connect using Screen Sharing app on Mac and ip address of Ubuntu machine

Installing Kubernetes (minikube) on Ubuntu

Prerequisites

Kubernetes

Optionally you might need to adjust the amount of memory kubernetes has:
  • minikube config set memory 8192
  • minikube delete
  • minikube start

Install Multiple Ubuntu Versions on the Same Computer

 You can have multiple versions of Ubuntu on the same computer using grub to switch between them.

  1. Install the first OS to the first disk
  2. Install the second OS to the second disk
If using multiple disks for different versions, after installing the second OS use grub to select the default using the first OS/disk. e.g. to select the second OS/disk as default boot:
  1. Log into the first OS/disk
  2. Edit grub: sudo vi /etc/default/grub
  3. Edit timeout to sufficient to see the menu e.g. 5
  4. Save, exit and run: update-grub
  5. Reboot and note the number of the second install in the list (index 1), but load the first
  6. Edit grub: sudo vi /etc/default/grub
  7. Edit default option

03 December 2018

Update packages for Ubuntu 18.04

Default package list is a bit short, so if you want to use standard packages you'll need to amend it:
  • Confirm it's release (you'll need this in the next step)
    cat /etc/*-release
  • For 18.04 Package isn't included in the default sources.
  • Search for it e.g. https://packages.ubuntu.com/search?keywords=xen-hypervisor&searchon=names
  • Modify the package sources list to include it's source:
    • sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    • vi /etc/apt/sources.list
    • Add:
      deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
      deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
      deb http://archive.canonical.com/ubuntu bionic partner
    • sudo apt-get update

01 December 2018

Install XenProject

UPDATE: In the end I just went with Citrix XenServer as I found the open source version too difficult to get working:

  • Documentation out of date, instructions no longer apply to the Host
  • Unable to get guest OS installed
  • Unable to reattach previous guest OS installs
  • Conflicting information about toolsets and Host OS


Additional notes supplementing:

Install Host (Dom0) and XenServer

  • Install Ubuntu (see previous post Ubuntu install checklist)
  • Install Xen:
    • sudo apt-get install xen-hypervisor-amd64
      If package isn't found see below (Update packages)
    • reboot
  • Setup Network as bridged:
    • sudo systemctl stop network-manager
      (it may not be in use)
    • If your system is using netplan backup the conf:
      sudo cp /etc/network/interfaces /etc/network/interfaces.backup
    • Install ifupdown
      sudo apt install ifupdown
    • Set the config for ifupdown:
      vi /etc/network/interfaces (then see below)
    • The default timesout at 5mins (boot) so reduce that:
      cp /lib/systemd/system/networking.service /lib/systemd/system/networking.service.backup
      vi /lib/systemd/system/networking.service
      TimeoutStartSec=30sec

/etc/network/interfaces

auto lo eth0 xenbr0
iface lo inet loopback

iface xenbr0 inet dhcp
  bridge_ports eth0

iface eth0 inet manual

Troubleshooting

25 October 2018

Autopost Blogger to Twitter

Back in 2012 I wrote about sharing posts to other social media via Google+ (Auto post Google+ to Twitter, Facebook, LinkedIn etc.) but now that that service is shutting down it can't operate as a central hub.

I've instead switched to using IFThisThenThat (IFTTT). There are many 'recipes' on there but I went with what appeared to be the most popular: Share your new Blogger posts to Twitter by dude3966.

Its laughably simple: sign up with IFTTT, authenticate with Blogger and Twitter then turn it on.

23 October 2018

LF would be replaced by CRLF

Introduction

When collaborating across environments with Git you'll often get the insanely annoying:
"Fatal: LF would be replaced by CRLF in..."

To my mind this message is both backwards and lacking information:
If you check it out/or clone to another folder with your current core.autocrlf configuration, LF will be replaced by CRLF

The file will have its original line endings in your (current) working directory.

Ultimately it all comes down to the line endings used by both systems explained in detail on the pages:

Fixing The Problem

Convert individual files' line endings:

  • Windows: Notepad++
    Edit
    EOL Conversion: choose the one you want.
  • Mac: dos2unix
    CRLF to LF: unix2dos [filename]
    LF to CRLF: dos2linx [filename] 

Set autocrlf setting

Default is false which won't change anything BUT this won't work cross platform: if you create a file on Windows it will be left as CRLF.
  • Check the setting: git config --global core.autocrlf
  • Ensure you have line endings in the repo:
    • git config --global core.autocrlf input
  • Add guard comparing if the reversed newline transformation would result in the same file:
    • git config --global core.safecrlf warn

Add a .gitignore file

Convenient list of files by alexkaratarakis here
Example for a c# project:
text=auto

# These files are text and should be normalized (convert crlf => lf)
*.cs      text diff=csharp
*.xaml    text
*.csproj  text
*.sln     text
*.tt      text
*.ps1     text
*.cmd     text
*.msbuild text
*.md      text

# Images should be treated as binary
# (binary is a macro for -text -diff)
*.png     binary
*.jepg    binary

*.sdf     binary

Reset the Git repository

If you've got a repository with mixed line endings. you'll need to reset all the files to use LF:
  • Linux: 
    • git config --global core.safecrlf warn
    • dos2unix **
    • git add -u
  • GitHub for Windows has dedicated "normalize your repo's CRLF" setting
See also:

Check Your Editor Settings

  • VSCode: "files.eol": "\n"