Tuesday, January 31, 2017

Minikube on Windows - teething troubles

The .minikube folder location

So I was recently getting Minikube on my work laptop. As it happens, this did not go painlessly. My C drive has a measly 100G (free 8G) so almost all tools I install, if their dot file folder is going to hold anything significant like virtualbox images, I usually symlink it off to my D drive which is a lot roomier.

DON'T DO THAT WITH MINIKUBE YET.... it does not work :(. I tried symlinking the .minikube folder when that didn't work, then the .minikube/machines folder - neither worked. If you're really desperate, you could use Virtualbox media manager to move the disk to some other drive. Of course, this isn't really a solution since you need to have enough space in C in the first place.

There's a ticket to have a MINIKUBE_HOME which will let you move the config folder around - so go subscribe to it if you need this. The second PITA is that the minikube.exe as well as the kubectl all have to be on C drive as well - but symlinks work for that.

SSH client

I also ran into trouble with ssh - minikube vm provisioning was using my external SSH client that it found on PATH and was calling that without quoting properly which resulted in the provisioning failing. Turning on verbose logging with --v 9 showed what was happening and the easiest way out was to make sure there's no ssh.exe on path - this forces minikube to use it's internal ssh client and provisioning proceeded.

Once you have Minikube up though, it's quite nice to work with.

Monday, January 30, 2017

Torrent download notifications with Pushover

Last weekend I setup torrent complete push notifications to be delivered via pushover. I have my media center box running ubuntu 16.04 with Kodi. It also serves as my torrent box with qbittorrent.

On Android Transdroid is great to manage torrents but it doesn't have auto refresh. Given that I rediscovered my pushover account last week, it seemed just begging to be used.

Here's a shell script to send push notifications - just set it up in in qbittorrent (or whatever you use) to run at torrent completion - like so /bin/user/bin/push.sh "%N" completed

Friday, January 27, 2017

Azure VM - start/stop using automation

So this is just sharing my long time azure automation script to start/stop a vm. I have this on a schedule so it starts on weekdays in the morning and is shutdown in the evening. There's also a couple of webhooks so I can start/shutdown using my phone.

The latest addition is integrating push notifications to my phone - I have a Pushover which offers a nice api to send push notifications to your devices.

Note that to set this up, you will have to set up a user in Azure AD and add those credentials to automation assets.

I absolutely love the push notifications :)

Thursday, January 26, 2017

Syncthing - run your own sync server

What I'm after

I'm trying out syncthing - I've become frustrated that none of the other options seem to tick all the boxes of my needs. Here's what I need and it doesn't seem that I'm asking for a lot here:

  1. Bi directional file syncing
  2. Security & privacy - at rest and in motion
  3. Windows client
  4. Linux desktop client
  5. Android client.

The competitors

Here's what I've tried so far:

  1. Dropbox - fails on privacy
  2. Google Drive - no linux desktop client - so a non starter.
  3. OneDrive - ditto AFAIK
  4. Mega - Android client won't autosync changes.

And so I've been looking at setting up my own sync/cloud storage. I used to run BTSync but dropped it since it wasn't open source. Apparently, it's now renamed to 'Resilio'. I've also been interested in OwnCloud - but it seems an overkill - I don't need calendaring and such.

I've also heard good things about seafile as well - but that will have to wait for another day.

Syncthing - installation

So today being a holiday, thought of giving syncthing a try. It's basically an open source BTSync like application. It looked interesting and seemed to tick all my boxes so worth a try. However, installation wasn't as smooth - and getting it to work

  1. Linux Desktop- Deb packages are available; setup was a snap. Getting it configured and running as a systemd service took some going through the online manual
  2. Windows - Used SyncTrayzor. Getting it installed wasn't problematic.
  3. Android - there's a syncthing app on the play store. It works but seems a little crashy (clicking on the folder icon always crashes it.)
  4. Linux server - so I have a cloud vm and decided to have each of the machines above sync with it... so I can make changes anywhere and I can get it on the other devices. Once again, after I added the apt source, getting syncthing installed was a breeze.

Configuration

And now coming to configuration - this is where I feel Syncthing's UX will scare away most people (probably except those who're just running windows desktops). Here's my nits:

  1. Adding a remote machine - you need to provide a 50- 55 key machine Id. In my case, I needed to provide the key of my headless server to the local linux desktop service. This in itself wasn't a problem - I just picked the key from the logs on the server journalctl -e -u syncthing.service and pasted it. Thing is, that once you add a remote machine, you then get prompted on the web interface that a machine wants to share. On my headless server, I could see my desktop trying to connect (from logs) but it was waiting for authorization. I finally had to dig into syncthing's configuration syntax and edit ~/.config/syncthing/config.xml and add device id nodes for my desktop, windows machine and android phone and restart each time after editing the config.
  2. Syncthing's scheme is that not only does a remote machine have to be added, but you also have to specifically mark what folders are shared with each machine. This means that you have to configure each machine with folders with teh same id otherwise they won't sync. This caused some confusion - esp since the windows app decided to create a folder with a random id where as the linux just had default as the id. I finally just went with default everywhere.
  3. There's something called an introducer.. I read the description of what it's supposed to do and did not understand.. Better docs/graphic would help a lot here. For the moment though, I decided to stay away from it.

Anyway, after I sorted those out, it seems to be working... I tried editing files on Android and it got pushed to other nodes and vice-versa. It feels a little sluggish in detecting changes - but I can live with that.

I also need to understand it's n-way sync process... maybe I can go peer to peer. Syncthing definitely has a diamond in the rough feel to it and I'd rather support an open source project if it can job done (albeit with some initial pain getting it set up)

What can be done better

  1. Getting a headless central node working painlessly would go a long way. I expect a lot of people are using syncthing this way... something along the lines of :
    1. Get all your clients installed,
    2. install on headless syncbox;
    3. Provide a cli tool that will configure a device for the default folder. syncthing-cli add folder=<folder-id> <device-id1>, <deviceid2>... All this does is update your config & restart syncthing service. folder defaults to default if not specified.

It's open source - and given that I like what I see (for the most part), I'll probably try my hand at sending in a PR.

Happy syncing!

Zsh constantly crashes on Msys64

So, I wanted to try out Zsh as a bash replacement after using it on and off. Now I don't write a lot of scripts - but mostly for running apps etc. The only real improvement that I needed was cross shell history... I can never remember where I typed a command and hitting Ctrl-R and finding the command is super nice.

On my msys64 install, did a pacman -Su zsh and zsh was installed. Now, since I'm on pre windows 10, everything's a little more painful if you want to run bash/linux tools

Anyway, since I use Conemu as my shell, had to change my Conemu Task to something like

set MSYSTEM=MSYS & \
set MSYS2_PATH_TYPE=inherit & \
set HOME=c:\users\raghuramanr & \
d:\msys64\usr\bin\conemu-msys2-64.exe usr\bin\zsh -i -l

Everything was great. Also installed a zsh customization framework - zprezto and had a decent prompt, reverse history search going on. Everything was good for a couple of days - but then I couldn't leave it at that, could I?

And then, I did a pacman -Su - this updated msys runtime. Now zsh segfaults with an access violation at startup. Starting a blank .zshrc works - so definitely some init scripts were causing it.

Tried a bunch of things - getting rid of zprezto (github stars nonetheless, it seems unmaintained - and was hoping that a replacement would fix the crash); replaced it with Zim - Zsh Improved. That didn't help either. Got rid of it as well and started customizing zsh by hand. What I found that running compinit crashes zsh everytime - so finally gave up and am back to bash

Tuesday, January 24, 2017

Posix compatible PTY in Windows

Get a real Posix compatible PTY in Windows

If you do any work on hte console in WIndows and are not on Windows 10, then you should probably use Conemu.

If you're a linux shell fan and are using Msys2 or Cygwin on windows, then an additional tweak is to enable the experimental Posix compatible PTY support in ConEmu.

I've been a long term ConEmu user and did not know about this till yesterday. Enable it and you get full xterm-256color TERM.

So cat $ConEmuBaseDir/Addons/AnsiColors256.ans now produces img

Here's how the tasks are set up in ConEmu - this one's for MSYS2

set MSYSTEM=MINGW64 & set MSYS2_PATH_TYPE=inherit & set HOME=c:\users\raghuramanr & d:\msys64\usr\bin\conemu-msys2-64.exe /usr/bin/zsh -l -i

See here for directions