bc-bd.org

Not a blog

Roundcube, Connection to Storage Server Failed

Using imaps and getting:

Could not connect to ssl://localhost:993: Unknown reason in
/usr/share/roundcube/program/lib/Roundcube/rcube_imap.php

check that your configured servername matches the certificate’s cn.

Hiera, Puppet and Invalid Yaml Files

If you are running into this error:

Error: Could not run: undefined method `[]' for false:FalseClass

one of your yaml files in hiera is invalid, maybe empty.

Windws 7 SP 1 Not Updating

Windows 7 SP 1 fresh installed and not updating? svchost stuck at 100% CPU? PC-WELT-Fix Windows Update not helping? WSUS Offline Update not working?

This HOWTO from skanthak worked for me:

[...] Download at least the last cumulative (security) update package for Internet
Explorer 8, 3124275 alias MS16-001, and the latest (security) update package for
the Windows Update Client, currently (September 20, 2016) 3161647; the latter is
available only as part of the "July 2016" (optional) update rollup package
3172605. [...]

Firefox, Flash, HTML5 and Sound via HDMI Subdevice

# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC671 Analog [ALC671 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

/etc/asound.conf

pcm.dmixer {
    type dmix
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0660
    slave {
        pcm "hw:0,7"
        rate 48000
        channels 2
        period_time 0
        period_size 1024
        buffer_time 0
        buffer_size 4096
    }
}

pcm.!default {
    type plug
    slave.pcm "dmixer"
}

Wget, Gems, Puppetserver Proxies and Authentication

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 With Uboot and Root on NFS

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.

Installing FreeBSD via PXE From Debian Wheezy

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, Mails and Aliases

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;