Running mattermost in docker

Ive set this up a few times and the permissions issues get me every time
For reference this seems to be a winning recipe

git clone
cd mattermost-docker
Edit the docker-compose.yml and change the UID and the GID to your current running user
IMPORTANT! docker-compose build to build the new image
mkdir -pv ./volumes/app/mattermost/{data,logs,config,plugins,client-
You dont need to set the file/folder ownerships with chown now, as you used your current user
docker-compose up


Original article

FreeOTP backup notes

Enabling Developer Options & USB Debugging

The following steps will require you to connect your mobile phone to a computer in order to send commands, and you’ll need to perform a few tasks before we can continue.

First, enable the developer options on your mobile phone:

Launch the Settings app on your phone
Locate the “About” phone option on the menu that appears. The option is usually found towards the bottom of the menu
Locate the “Build Number” option and tap it 7 times. A message will appear and inform you that developer mode has been enabled
Navigate back to the main settings screen and tap the “Developer Options” menu
Locate and enable the “USB Debugging” option.

Enabling the USB Debugging option allows your phone to respond to requests over a USB connection, and we’ll install a piece of software on your computer that will issue requests to the phone next.

adb shell
Once you see a device continue to next step

Backing up FreeOTP’s Data

With ADB installed and the necessary phone options in place, you’ll be able to back up FreeOTP’s configuration data with the following command:

adb backup -f ~/freeotp.ab -noapk org.fedorahosted.freeotp

The command will save the app’s data to a file on your computer, and I suggest that you perform all work in a clean directory to avoid any confusion. Running the command will cause a prompt to appear on your phone, asking you to confirm the backup – click “Back up my data” on your phone and the backup will begin:

Backup command and resulting backup file.

The backup process takes only a few seconds and once complete you’ll see the newly created file.
Making FreeOTP’s Data Usable

You now have a backup of FreeOTP’s data, but it isn’t in a usable state. Running the following commands will create a tar file, that when uncompressed, will reveal the app data – including your tokens.

dd if=freeotp.ab bs=1 skip=24 > compressed-data
printf “\x1f\x8b\x08\x00\x00\x00\x00\x00” | cat – compressed-data | gunzip -c > decompressed-data.tar

The first command uses the Unix dd utility to rewrite the new file, saving it as “compressed-data” and skipping the first 24 bytes of data from the source:

The second command appends new header information to the file and saves it as decompressed-data.tar:

The resulting tar file contains the usable FreeOTP configuration data, and the added header allows us to decompress its contents properly. Decompress the tar file with the following command:

tar -xvf decompressed-data.tar

Once the tar file has been decompressed, a listing of the files extracted will appear at your command prompt:

The “tokens.xml” file contains the configuration data we’ll need to import the 2FA tokens to a new phone. You can go ahead and view the file in any text editor; don’t alter the file in any way or it won’t work for the next step. It’s also worth securely storing this file in case you need it in the future:

I’m not talking about the future where we all have jetpacks, I’m talking about a few weeks from now when your phone slips from your hands and breaks. Phones get lost or damaged. It happens, and keeping a copy of this file for safekeeping will make things easier if you find yourself setting up a new phone. Be prepared.
Importing Your 2FA Tokens

Viljo Viitanen wrote a really handy Javascript-based tool that will generate QR codes from the tokens.xml file. The tool runs completely within your browser and does not transmit any sensitive information to a 3rd party, so there’s no concern of data leakage.

Select your tokens.xml file and the script will output QR codes that can be used to import your 2FA tokens to FreeOTP on your new mobile phone via the built-in QR code scanner.

While this may seem like a fairly involved process, it only takes a few minutes and will save tons of time vs. having new tokens issued or finding other workarounds to migrate FreeOTP’s data.


tcpdump on each interface individually

Original article here:

# USAGE: [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
# - In 1.1 VLAN's would not be shown if a single interface was dumped.
# NOTES: ---
# - 1.2 git initial
# AUTHOR: Sebastian Haas
# COMPANY: pharma mall
# VERSION: 1.2
# CREATED: 16.09.2014
# REVISION: 22.09.2014

# When this exits, exit all background processes:
trap 'kill $(jobs -p) &> /dev/null && sleep 0.2 && echo ' EXIT
# Create one tcpdump output per interface and add an identifier to the beginning of each line:
if [[ $@ =~ -i[[:space:]]?[^[:space:]]+ ]]; then
tcpdump -l $@ | sed 's/^/[Interface:'"${BASH_REMATCH[0]:2}"'] /' &
for interface in $(ifconfig | grep '^[a-z0-9]' | awk '{print $1}')
tcpdump -l -i $interface -nn $@ | sed 's/^/[Interface:'"$interface"'] /' &
# wait .. until CTRL+C

Converting a Generation 2 HyperV VM to boot in KVM\Openstack

Brining a HyperV Gen2 VM into Openstack

Convert the vhdx to raw and into ceph
qemu-img convert -f vpc -O raw AC-TS01-C.VHD rbd:volumes/AC-TS01.raw

Attach the old(Existing) disk and the new blank disk to a linux box
Install clonezilla from apt
On the new disk create a new partition(This will be an MBR partition not a GPT partition and is key to being able to boot in KVM)
Clone the Windows volume(Just the big volume, ignore the small piss-ant recovery volumes)
Might then need to mount this volume on a windows box to check the NTFS partition is ok, if it’s not showing a drive letter I had some success with resizing the partition with Easus partition manger, which presumable re-wrote the ntfs partition headers and then the disk appeared in windows
THEN you need to boot the os, it’ll fail

Attach a windows server ISO, boot to recovery(Needs to be the correct OS recovery environment. I tried using a 2016 DVD to recover 2012 R2 and it didn’t work)

bcdboot C:\windows
bcdboot C:\windows /s c: /f ALL



Then reboot and all good
If you haven’t preinstalled virtio might need to boot on sata then install virtio drivers

Running CollectD as a container


FROM ubuntu:18.04
RUN apt update
RUN apt-get --no-install-recommends install collectd -y
RUN apt install -y python-pip
RUN pip install collectd-gnocchi

Running the container

docker run -it --net=host --privileged -v:collectd.conf: /etc/collectd/collectd.conf collectDContainerImage collectd -C /etc/collectd/collectd.conf -f

Run cryptominer while the screen is locked

dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" | 
while read MSG; do
LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
if [[ "$LOCK_STAT" == "true" ]]; then
echo "was locked"
killall ethdcrminer64
screen -d -m /home/user/Downloads/Claymore/ethdcrminer64 -epool -ewal 0xaddresshere/m3 -epsw x -allpools 1 -gser 2 -allcoins exp
echo "was un-locked"
killall ethdcrminer64

Swap space notes

Whats using swap space

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

Who is eating all of my RAM?

ps aux --sort=-%mem | head

Where are my swap files

 cat /proc/swaps

How to add more swap space

1. Create empty file:
This file will contain virtual memory contents so make file big enough for your needs. This one will create 1Gb file which means +1Gb swap space for your system:

dd if=/dev/zero of=/media/fasthdd/swapfile.img bs=1024 count=1M

If you want to make 3Gb file then change count value to count=3M. See man dd for more information.

2. Bake swap file:
Following command is going to make “swap filesystem” inside your fresh swap file.

mkswap /media/fasthdd/swapfile.img

3. Bring up on boot:
To make sure that your new swap space is activated while booting up computer you should add it to filesystem configuration file /etc/fstab. Add it to end of file, this is recommended because other filesystems (at least one that contains swap file) must be mounted in read-write mode before we can access any files.

# Add this line to /etc/fstab
/media/fasthdd/swapfile.img swap swap sw 0 0

4. Activate:
You can either reboot your computer or activate new swap file by hand with following command:

swapon /media/fasthdd/swapfile.img

Original articles

Putty SSH settings to stop garbled output

Using ubuntu 18 and tools like glances and iftop would often mangle the output

Changing the default Puttty settings
‘Connection > Data > ‘Terminal-type string’ to ‘putty’ instead of ‘xterm’
and setting your PuTTY settings under Translation and ensure that you have UTF-8 set as the character set then save this as the default profile and enjoy 🙂

Copy files from Andorid phone using ADB – Quicker than MTP

When backing up photos form my Android phone i found that the phone didn’t present as a mass storage device, it would only appear as a MTP\PTP device and the file copy speed was terrible.

So some research led me to using the ADB command, you’ll need to enable USB debugging before this will work.


Find your files

adb shell ls /storage/

Back em up

adb pull /storage/self/primary/DCIM/Camera /home/user/photos/