wget

When using wget with a proxy that requires authentication, special characters need to be URI encoded, e.g. # becomes %23. Using for example pa##word:

https_proxy='http://username:pa%23%23word@proxy:8080' wget https://google.com

On top of that when using gem the colon seperator between the username and pasword needs to be escaped, e.g. \::

http_proxy='http://username\:pa%23%23word@proxy:8080' gem fetch hiera-eyaml

Also note, gem will use the http_proxy environemt variable even if it is connecting to a https:// url.

But when using gem from a puppetlabs installation, e.g. /opt/puppetlabs/puppet/bin/gem, you must not escape the colon, but use HTTP_PROXY.

When installing gems into puppetserver 4, pass -p to gem install:

puppetserver gem install -p http://username\:pa%23%23word@proxy:8080 hiera-eyaml

puppet here

Tired of typing puppet://$server/module/$module/...? Here to the rescue:

module Puppet::Parser::Functions
	newfunction(:here, :type => :rvalue) do |args|
		"puppet://%s/modules/%s/%s" % [ lookupvar('servername'), lookupvar('module_name'), args[0] ]
	end
end

Put it in $module/lib/puppet/parser/functions/here.rb, use with:

file {
	ensure => ...
	...
	source => here('foo.txt');
}

raspberry pi pxe boot

Following this RPi U-Boot Howto.

I setup a cross compile chroot to build u-boot for my Raspberry 1:

sudo debootstrap sid sid
sudo chroot sid
dpkg --add-architecture armhf
apt-get update
apt install git-core gcc-arm-linux-gnueabi
cd /tmp
git clone git://git.denx.de/u-boot.git
cd u-boot
export CROSS_COMPILE=arm-linux-gnueabi-
make rpi_defconfig
make -j5 -s

Download the latest Jessie Lite Image and wrote it to my SDCARD (/dev/sdb in my case):

cd /tmp

wget https://downloads.raspberrypi.org/raspbian_lite_latest -O raspbian_lite_latest.zip
unzip raspbian_lite_latest.zip
dd if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdb bs=1M

Setup NFS root, copy the Kernel to the tftproot and install u-boot:

cd /tmp
mkdir pi

mount /dev/sdb2 pi
mount /dev/sdb1 pi/boot

mkdir  /var/lib/tftpboot/pi
cp pi/boot/kernel.img /var/lib/tftpboot/pi/zImage
cp pi/boot/*.dtb /var/lib/tftpboot/pi/

mv pi/boot/kernel.img{,.old}
cp /tmp/sid/tmp/u-boot/uboot.bin pi/kernel.img

cp -a pi /mnt

umount pi/boot
umount pi

Setup NFS export:

/mnt/pi         10.0.0.1(rw,no_root_squash,async,no_subtree_check)

Configure dhcp:

host pi1 {
	hardware ethernet TH:AT:IS:MY:MA:C0;
	fixed-address 10.0.0.1;
	filename "/pi/boot.scr.uimg";
	option root-path "/mnt/pi";
}

Create the boot script that actually loads and boots the kernel /var/lib/tftpboot/pi/boot.scr:

setenv fdtfile /pi/bcm2708-rpi-b.dtb
setenv tftpblocksize 1024

usb start
tftp ${kernel_addr_r} /pi/zImage
tftp ${fdt_addr_r} ${fdtfile}

setenv bootargs earlyprintk console=ttyAMA0 console=tty1 ip=dhcp root=/dev/nfs rootwait smsc95xx.macaddr=TH:AT:IS:MY:MA:C0

bootz ${kernel_addr_r} - ${fdt_addr_r}

I needed to set my MAC as it would generate a new one on every boot.

Convert boot script to something u-boot can handle:

cd /var/lib/tftpboot/pi
mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg

Boot the Pi, interrupt u-boot and setup it’s environment:

setenv bootcmd 'dhcp; source ${fileaddr}'
saveenv
reset

I havn’t found a way to set config.txt options though.

freebsd

While trying to install FreeBSD via the bootonly image resulted in

mount failed with error 19

But using

  • dhcp/tftp servers on Wheezy
  • packages syslinux, syslinux-common and pxeboot from Jessie
  • mfsBSD SE USB memstick Image

I was able to install FreeBSD via netboot with ZFS on /.

Copy syslinux files to the tftp root:

cp -r /usr/lib/syslinux/modules/bios /var/lib/tftpboot/syslinux

Download mfsBSD image, gzip and copy to /var/lib/tftpboot/syslinux/freebsd

Configure pxelinux:

label freebsd
menu label freebsd
kernel memdisk
initrd freebsd/mfsbsd-se-10.0-RELEASE-i386.img.gz

After booting, look for disk and install:

geom disk list

Geom name: ada0
Providers:
1. Name: ada0

zfsinstall -d /dev/ada0 -s 256M -u http://www1.de.freebsd.org/freebsd/releases/i386/10.3-RELEASE/

plesk

Exporting configured mail accounts and their aliases from the PSA database to csv:

SELECT
	concat(mail.mail_name,"@",domains.name) AS address,
	group_concat(mail_aliases.alias) AS aliases,
	mail.account_id
INTO OUTFILE
	'/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM
	mail,domains,accounts,mail_aliases
WHERE
	mail.dom_id=domains.id
	AND mail.account_id=accounts.id
	AND mail_aliases.mn_id = mail.id
GROUP BY
	address
ORDER BY
	address;

icinga2 zones and endpoints

If you have multiple hosts in one zone …

  • … upstream of you, it’s HA
  • … downstream of you, it’s Loadbalancing

pandoc

Using the xelatex engine fixed the following error for me, when generating a PDF from markdown via pandoc:

pandoc: Error producing PDF from TeX source.
! Package inputenc Error: Unicode char \u8:° not set up for use with LaTeX.

perl

While working with Curses and Mouse I found, that my Mouse error message will not be displayed. I worked around it by capturing the message via eval, calling endwin; directly and displaying the error after that.

#!/usr/bin/perl

package Foo;
use Mouse;

use Curses::UI;

has _cui => (
    isa => 'Curses::UI',
    is => 'ro',
    default => sub { return new Curses::UI ( -clear_on_exit => 0 ) },
);

has _screen => (
    # _screen should be a 'Curses::UI::Window'
    isa => 'Curses::UI',
    is => 'ro',
    default => sub { return shift->_cui->add( 'screen', 'Window' ) },
);

package main;

use Curses;

eval { my $f = Foo->new(); };

if ($@) {
	endwin;
	print $@;
}