Fun experiment - FUSE read-only FS backed by tar file

I wanted to play around with virtual filesystems and I also was working on huge tar files at that time. Untaring some file just to copy out all of it content (more tar files) and then cleaning up was a bit PITA, so I decided to see if I can write a virtual filesystem that will show the insides of the tar file without wasting space. 
I decided to do this using FUSE and I only cared about extracting data so the filesystem is read-only.

The script is here. It is using the llfuse python module. 
It was a very nice way to understand a bit better how filesystems in *NIX environments work. 

Usage for the script is straight forward:

$ ./ -h
usage: [-h] [--mountpoint MOUNTPOINT] [--debug] [--debug-fuse]

positional arguments:
  tarfile               tarfile to mount

optional arguments:
  -h, --help            show this help message and exit
  --mountpoint MOUNTPOINT
                        Where to mount the file system
  --debug               Enable debugging output
  --debug-fuse          Enable FUSE debugging output 

By default it can handle tar, tgz, tar.bz2 and tar.xz. Obviously access times will differ between the different formats. If the mount point is not specified it tries to create a folder in a current working directory with the name of file but without the suffix.

simple tmux helper script to work simultaneously on many ssh sessions

I recently found a nice way to work on multiple servers using tmux and OpenSSH (not only, but who uses something else?). 

The script looks like this:


if [ $# -gt 0 ]; then
  for host in $(egrep '^host' ~/.ssh/config | grep -v '\*' | pcregrep -o "\s+$1\S*?(\s|$)")
    STYLE=$(pcregrep -A1 "\s$host(\s|$)" ~/.ssh/config | grep -o 'tmux-style: .*' | cut -d' ' -f2-)
    tmux send-keys "ssh $host $2" \; select-pane -P "$STYLE" \; split-window \; select-layout tiled
  if [ $OK = "1" ]; then
    tmux set-window-option synchronize-panes \; send-keys ENTER
    tmux kill-pane \; select-layout tiled

The script reads your ~/.ssh/config file and based on host entries it creates panes in a single tmux window and synchronises inputs to them. This allows for a simultaneous work done on multiple machines.

It also supports for setting styles for different hosts in your ~/.ssh/config file.


Assuming you have a ~/.ssh/config file that looks like this:

host abc-*
  User root

host abc-prod
  # tmux-style: bg=red

host abc-dr
  # tmux-style: bg=blue

host def-vm-*
  User admin

host def-vm-1

host def-vm-2

host def-vm-3

host def-vm-4

host def-vm-5

And also assuming that you saved the script in ~/bin/st then running this command:

$ st abc

will spawn to synchronised panes in your current window one with red and one with blue background

if you run:

$ st def-vm 


$ st def-

it will spawn five panes to each one of the def-vm machines.