Tuesday, July 11, 2017

autossh and systemd to start a reverse ssh tunnel

I have a machine behind my firewall. When I turn this machine on, I want it to make a reverse ssh connection to another machine, which is available from outside the firewall. I use autossh to make and maintain the connection, and systemd to start the task on boot. The systemd unit file looks like:

cat /etc/systemd/system/autossh.service
Description=Keeps a tunnel to 'MYEXTERNALDOMAIN.com' open

ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -i /root/.ssh/id_rsa -R 22222:localhost:22 -p 23 USER@MYEXTERNALDOMAIN.com


And then do:

systemctl start autossh
systemctl enable autossh

Thursday, April 28, 2016

booting a sd card image in qemu

I want to boot an AArch64 sd card image in qemu. The image has uefi boot and is from here http://mirror.centos.org/altarch/7/isos/aarch64/

To do this, I needed to grab some firmware to support UEFI booting on ARM. I got this from here:

This page has the details:

Once I did that, I could run the following command to get the image to boot.

qemu-system-aarch64 -M virt -cpu cortex-a57 -m 1024 -smp 1 -bios ./QEMU_EFI.fd -serial stdio -drive if=none,file=./CentOS-aarch64.img,id=hd0 -device virtio-blk-device,drive=hd0

Tuesday, December 9, 2014

GNOME planner page size work-around

It seems GNOME planner has a few bugs that means I can't manage to get a decent export from it. The bugs I am apparently observing include:
 + characters 'fi' are do not appear in the export to PDF.
 + specify printing to a page size that is not about Letter size.

The work-around is to:

1. Install cups-pdf driver.
2. Modify /etc/cups/cups-pdf.conf to hi-jack the in intermediatory Postscript and redirect it to a file. By default the postscript is converted to pdf, which then misses the 'fi' characters.

/etc/cups/cups-pdf.conf must contain:

### Key: GhostScript
##  location of GhostScript binary (gs)
##  MacOSX: for using pstopdf (recommended) set this to /usr/bin/pstopdf
##          or its proper location on your system

GhostScript /usr/bin/echo

### Key: GSCall
## command line for calling GhostScript (!!! DO NOT USE NEWLINES !!!)
## MacOSX: for using pstopdf set this to %s %s -o %s %s

GSCall %s %s; cat > %s < %s

With these configurated values, after selecting the 'cups-pdf' printer, I end up with a postscript file in /home/rhenwood/Desktop probably called something like 'Planner_job__2.pdf' or something.

The file is a postscript file, to load it into inkscape for editing, you'll need to rename it '.ps'.

Friday, September 19, 2014

hidden forums 404 with bbpress

BBpress allows private forums. I configured a private forum and the default behavior was undesirable: if you are not logged in, visiting a link to the forum returns the generic 404 page.

I was happy with the 404 page, but I wanted some special when people visited the private forum - that encouraged them to register or login.

I hacked this into my 404.php:


  if ('/forums/forum/someforum/' == $_SERVER['REQUEST_URI']) {
        _e('You need to be registered and logged in to participate in the forum.');
        } else { 
        _e( 'It looks like nothing was found at this location. Maybe try a search', 'twentyfourteen' ); echo '
'; get_search_form();
  } ?>


Sadly, this blog publishing software doesn't do syntax highlighting, so good luck.

Thursday, September 19, 2013

htlatex and pdflatex

I'm a big fan of the gnuplot tool that has an output terminal of pdflatex. This produces a pdf figure with an overlay of latex for beautiful results. Similarly, inkscape has an output format with pdf overlayed with latex.

I had a problem with htlatex. I use pdflatex and so everything is a pdf in my figures. My overlayed output from latex, with the file extension 'pdf_tex' uses an import file and then includegraphics at the bottom. htlatex complained it couldn't find the bounding box of my pdf file... which is reasonable enough as htlatex calls pdftex and apprently doesn't support including pdfs.

My solution was to include the following in my preamble. This allows the file to continue to work as previously with 'pdflatex' and when 'htlatex' is called, the convert program is called to generate a eps file.


% call as:
% htlatex myfile.tex  "" "" "" -enable-write18
        \immediate\write18{s=\Ginput@path; (IFS='{}'; for i in $s; do convert ${i}#2 ${i}#2.eps; done)}%

  • you must call htlatex with -enable-write18 so it can execute commands in the shell.
  • you must include your graphics path setup before this gubbins.

Monday, July 29, 2013

scribus, latex, and bibtex

I've been playing with scribus. I managed to get bibtex working with my rendered frame and am recording the steps here.

1. create your latex frame, and include your bibliography stuff at the end of the document as you would for a normal document. i.e.


2. Find out what the current temporary filename scribus is using for rendering is. It will be mentioned in the 'Program Messages' listing. The file will be in the $TEMP directory.

3. Jump into that directory and copy your bib file into the $TEMP directory.
4. Run bibtex on the temporary filename.
5. Run latex again, and again, using the 'Update' button on the Editor dialogue.

Thursday, April 18, 2013

I wanted to find the difference between accessed and modified epochs of a bunch of files. The incantation below gives you this number for each item in a directory:

$ stat -c "%X %Y %N" ~/* | awk '{diff = $1 - $2; print diff, $3}'
40449 '/home/home/my_cgi'
2173034 '/home/home/run_pvr.sh'
124618 '/home/home/tools'