Register now and start sharing your code snippets.
-->

ImageMagick and OpenEXR

Shell Script (Bash) posted 3 months ago by marko

I could not get OpenEXR delegate to work in ImageMagick. There was no reason for it in config.log. It just silently refused to get configured. I debugged the configure script and found out that PKG _CONFIG was unset. So this fixed it. The—enable-hdri should be optional.

   1  ./configure PKG_CONFIG=/usr/bin/pkg-config --prefix=/usr/local/stow/imagemagick --enable-hdri

Tagged openexr, imagemagick

Fixing how nginx sends request URI to the backend server.

Shell Script (Bash) posted 3 months ago by marko

I needed to send an URI through Nginx to the backend servers (Mongrel) intact. However Nginx was constantly unescaping the URI , and removed slashes in the process. That resulted in an invalid URL at the backend server. The fix was simple, but extremely hard to find. Just remove the trailing slash from the proxy_pass directive, like below.

Invalid URI is sent to the backend server with this configuration of Nginx.

   1  proxy_pass         http://backend1:3000/;

Valid, untampered URI is sent with this configuration of Nginx.

   1  proxy_pass         http://backend1:3000;

Tagged nginx, uri unescape fix

Installing ImageMagick from sources and using xstow to handle the installation.

Shell Script (Bash) posted 3 months ago by marko

I really hate installing software outside of the package manager, because that is not the way of a stable system. Xstow helps the agony those times that sourceball installations are necessary (e.g for new features). Here’s how to install imagemagick with xstow. If you haven’t installed xstow yet, then follow the relevant instructions in this snippet

   1  sudo apt-get install libmagick9-dev # needed for sane image support
   2  cd /tmp
   3  wget ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/ImageMagick-6.4.2-7.tar.bz2
   4  tar xjvf ImageMagick-6.4.2-7.tar.bz2
   5  sudo mv ImageMagick-6.4.2 /usr/src
   6  cd /usr/src
   7  sudo ln -s ImageMagick-6.4.2 imagemagick
   8  cd imagemagick
   9  ./configure --prefix=/usr/local/stow/imagemagick
  10  make
  11  sudo make install
  12  cd /usr/local/stow
  13  sudo xstow imagemagick

Tagged xstow, imagemagick

Using expect for automation of bulk scp copying.

Shell Script (Bash) posted 4 months ago by marko

Expect can come in handy when you can’t configure ssh public key authentication on the servers :) (and the system “architect” hasn’t yet realized the wonderfulness of a log host).

   1  #!/bin/bash
   2  #
   3  # Usage: script <username> <password> <build>
   4  #
   5  # Example ./copy_logs_from_production.sh marko hubbabubba current
   6  #
   7  
   8  username=$1
   9  password=$2
  10  build=$3
  11  mkdir $build
  12  
  13  instance_1_server=10.0.0.1
  14  instance_2_server=10.0.0.1
  15  instance_3_server=10.0.0.2
  16  instance_4_server=10.0.0.2
  17  instance_5_server=10.0.0.3
  18  instance_6_server=10.0.0.3
  19  instance_7_server=10.0.0.4
  20  instance_8_server=10.0.0.4
  21  instance_9_server=10.0.0.5
  22  
  23  servers=("$instance_1_server" "$instance_2_server" "$instance_3_server" "$instance_4_server" "$instance_5_server" "$instance_6_server" "$instance_7_server" "$instance_8_server" "$instance_9_server" )
  24  i=1
  25  for server in ${servers[@]}; do
  26    expect -c "
  27              # exp_internal 1 # uncomment for debugging
  28              spawn /usr/bin/scp $username@$server:/var/logs/application/$build/server${i}/error.log $build/error-${i}.log
  29              expect { 
  30                "*password:*" { send $password\r\n; interact } 
  31                eof { exit }
  32              }
  33              exit
  34              "
  35    let "i=i+1"
  36  done
  37  

Tagged expect, bash, automation, scp, bulk

Resizing LVM partition that is on a crypted device.

Shell Script (Bash) posted 4 months ago by marko

I installed sysrescd on an USB stick to resize a partition that had too little space on it. The hitch was that it was on an encrypted partition. This is the correct order of the commands that needed to be issued.

sda3 is the encrypted device systemvg is the name of the volume group lv_usr is the name of the logical volume

   1  cryptsetup luksOpen /dev/sda3 crypt
   2  vgcreate systemvg /dev/mapper/crypt
   3  lvm vgchange --ignorelockingfailure -P -a y
   4  lvextend -L+2G /dev/systemvg/lv_usr
   5  e2fsck -f /dev/systemvg/lv_usr
   6  resize2fs /dev/systemvg/lv_usr

Tagged encrypted device, resize partition, lvm