Binary Static

How to install Redmine from SVN with Apache Passenger and Postgresql

Posted in Applications, Linux, SysAdmin, Web by Chris on September 1, 2012

System: debian 6.0.5

Redmine’s standard debian packages are pretty outdated, so here’s how I installed its latest stable version. I used postgresql as database.

Get the latest stable version from the projects subversion. Do a checkout and keep the .svn directory for later updates on this branch:

# svn co http://redmine.rubyforge.org/svn/branches/2.0-stable /usr/share/redmine

Make sure ruby and rubygems and necessary libraries are installed:

# apt-get install ruby rubygems libpq-dev libmagickcore-dev libmagickwand-dev

Install bundler, which is ruby’s dependency manager, and rake, which is its build tool and conveniently to their executables:

# gem install bundler
# ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle
# gem install rake
# ln -s /var/lib/gems/1.8/bin/rake /usr/local/bin/rake

Change to the Redmine root directory and install all needed libraries with bundler:

# bundle install --without development test mysql sqlite

Configure /usr/share/redmine/config/database.yml:

production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: password
  encoding: utf8

Create the role and user in the postgresql database:

# su postgres
$ psql
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD \
'password' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' \
OWNER=redmine;

Logout from the database and its user and generate the session token (again as root in /usr/share/redmine):

# rake generate_secret_token

Generate the database schema and load the fixtures:

# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data

Allow the Apache user (assuming www-data) access to relevant directories:

# mkdir tmp public/plugin_assets
# sudo chown -R redmine:redmine files log tmp public/plugin_assets
# sudo chmod -R 755 files log tmp public/plugin_assets

Test your installation by starting the built-in-server webrick, stop it with Ctrl-C:

# ruby script/rails server webrick -e production

Configure the named virtual host in
/etc/apache2/sites-available/tracking.codeways.org:

<VirtualHost *:80>
     ServerName tracking.codeways.org
     ServerAdmin admin@codeways.org

     DocumentRoot /usr/share/redmine/public

     RailsEnv production
     RailsBaseURI /
     <Location "/">
         Options ExecCGI FollowSymLinks
         Order allow,deny
         Allow from all
     </Location>
</VirtualHost>

At first, I linked to the Redmine root directory. This became unnecessary as I made it the document root of the vhost:

# ln -s /usr/share/redmine/public /srv/tracking.codeways.org

I configured e-mail (using exim4 and tls) in /usr/share/redmine/config/configuration.yml:

default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: mail.codeways.org
      port: 25
      domain: mail.codeways.org
      authentication: :plain
      user_name: "redmine"
      password: password

Start Redmine by restarting Apache:

# a2ensite tracking.codeways.org
# /etc/init.d/apache2 restart

Log into Redmine under http://tracking.codeways.org. Default username admin and password admin.

Tagged with:

Install Redmine on Debian Squeeze with Apache Passenger

Posted in Applications, Linux, SysAdmin, Web by Chris on August 30, 2012

This is how I installed redmine on my server, which runs debian 6.0.5. Get the packages:

# apt-get install redmine redmine-sqlite rails rake ruby \
librmagick-ruby libapache2-mod-passenger ruby-passenger

Debian should activate the passenger module during install.  Also during install you should set the defaults for the database module. This should be simple if you use sqlite3.  Strangely enough, the package does not touch a log file for the production environment.  I did this manually:

# mkdir /usr/share/redmine/log/log
# touch /usr/share/redmine/log/production.log

Try running webrick; kill with Ctrl+C:

# cd /usr/share/redmine
# ruby script/server -e production

At first I symlinked to the public directory of redmine.  Yet, this seems to have become unneccessary later:

# ln -s /usr/share/redmine/public /srv/tracking.codeways.org

Create a named virtual host /etc/apache2/sites-available/tracking.codeways.org:

<VirtualHost *:80>
     ServerName tracking.codeways.org
     ServerAdmin admin@codeways.org

     DocumentRoot /usr/share/redmine/public

     RailsEnv production
     RailsBaseURI /
     <Location "/">
         Options ExecCGI FollowSymLinks
         Order allow,deny
         Allow from all
     </Location>
</VirtualHost>

Configure e-mail service (exim4, tls) in /etc/redmine/default/email.yml:

production:
  delivery_method: :smtp
  smtp_settings:
    ssl: true
    enable_starttls_auto: true
    address: mail.codeways.org
    port: 25
    domain: mail.codeways.org
    authentication: :plain
    user_name: "redmine"
    password: password

Activate the whole she-bang:

# a2ensite tracking.codeways.org
# /etc/init.d/apache2 restart

Start redmine with http://tracking.codeways.org. Default username admin and password admin.

Tagged with:

Interleaving two PDF files…

Posted in Applications, Hacking, Linux by Chris on October 17, 2010

Lightbulb…with no scripting required.  You’ll need the pdftk package though.  Say you’ve got a PDF file that has a two-sided layout and you want to trim the pages.  You could do this with pdfnup — however, your file may cut off from the even pages what it adds to the odd ones.  What now?  The solution is simple:

1. Use pdftk to split the file in even and odd pages seperately:

pdftk in.pdf cat 1-endeven output out.even.pdf
pdftk in.pdf cat 1-endodd output out.odd.pdf

2. Now would be the time to apply some pdfnup trimming magic to the two new files.

3. Use pdftk to burst these two files into single pages:

pdftk out.odd.pdf burst output %04d_A.pdf
pdftk out.even.pdf burst output %04d_B.pdf

4. Use pdftk to merge the pages back into one file, e.g.:

pdftk *.pdf cat output out.pdf

The important point here lies in step 3 when appending A or B to the odd and even page file names, because this allows glob sorting the pages like 0001_A.pdf 0001_B.pdf 0002_A.pdf 0002_B.pdf and so on.  I can’t believe I started to write a script before I realized how to solve this the simple way…

Tagged with: , , ,

Make the TrackPoint play nice with Fedora 13

Posted in Linux, SysAdmin by Chris on May 28, 2010

Moving faster
Speed and sensitivity defaults leave my Thinkpad’s trackpoint excruciatingly slow. So first thing is to create /etc/udev/rules.d/10-trackpoint.rules containing one line:

SUBSYSTEM=="serio", DRIVERS=="psmouse", ATTR{speed}="220", ATTR{sensitivity}="190"

Scrolling
I also like to scroll with the help of the middle button. For this Fedora 13 now uses user config files for X like /etc/X11/xorg.conf.d/20-thinkpad.conf reading e.g.:

Section "InputClass"
    Identifier      "Trackpoint Wheel Emulation"
    MatchProduct    "TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint"
    MatchDevicePath "/dev/input/event*"
    Option	    "EmulateWheel"       "true"
    Option	    "EmulateWheelButton" "2"
    Option	    "Emulate3Buttons"    "false"
    Option	    "XAxisMapping"       "6 7"
    Option	    "YAxisMapping"       "4 5"
EndSection

Tagged with: , , , ,

Smooth Transition to Goddard

Posted in Linux, SysAdmin by Chris on May 27, 2010

Fedora LogoYesterday, I upgraded my main system to Fedora 13.  Coming from the excellent Fedora 12, this was a smooth transisition indeed.  Everything’s working fine, the whole operation took less than two hours (4 min to install the new system from a pen drive, ca. 90 min to reinstall my package collection, including 2 GB downloads).  I was expecially impressed with the new auto-installing language packages, which gave me a localized desktop from the first login.   As exepected, on my Thinkpad X200 everything worked right out of the box.  No horrible Macification surprises either.  Thank you very much, Fedora team!  Keep up the great work!

My Linux Video Toolchain

Posted in Linux, Multimedia by Chris on May 15, 2010

Ok, not perfect. But here are some notes about my way so far…

Concept You’ll want to compress the video & audio streams and wrap them in a flexible container, which should be capable of holding additional information like chapter markers and titles, audio subtitles, cover images, and archive information tags. For now, my choice is to encode the video with the H.264/AVC codec and use AAC for audio. Ideally, I would like to add subtitles as text in SubRip’s srt-Format. All this gets wrapped up in a Matroska stream container, which holds the meta information as well.

Backup So you got a DVD with some family videos from your last birthday and you want to back up the contents on your hard drive? First thing you do, is to copy everything as is — which may take a lot of disk space (up to 8 GB). I had good results with this simple tool:

dvdcpy -s skip -m -o My_Birthday /dev/sr0

After some time, you’ll find the DVD directory structure copied in your present working directory. With Fedora this handy gem comes in the ogmrip package.

Compression Next comes the crucial part: compressing the raw data into something usable.  After trying different options, I now rely on HandBrake for this, which in turn builds on the x264 library. Handbrake saves the streams directly into a Matroska container, allows editing chapter titles and adding extra subtitles from external files.  It works very fast and comes with reasonable default options.  Usually I stick with the Regular/Normal preset, just kicking out superfluous tracks and downmixing the audio to AAC 128bit Stereo.   I let Handbrake figure out the video quality by setting the target size to 700 MB, which in most cases results in slightly degraded but more than watchable video quality around 1000 kbps.  As I’m only interested in SD video quality, I usually choose a 624px-width based resolution.  You might want to consult this detailed video conversion table.

Subtitles I would prefer to store subtitle data efficiently as text, i.e. using SubRip‘s srt format (while more advanced xml-based formats seem to lack acceptance). HandBrake does not mess with OCR (which is excusable), it extracts subtitles as bitmaps in VobSub format.  The following command from the handy MKVToolnix package extracts from the mkv container the bitmaps and sync information in two files (*.vob and *.idx):

mkvextract tracks My_Birthday.mkv 3:subtitles.vob

These subtitles need to be scanned and ocr’ed: the best way to do this is Avidemux. Simpy hit “Tools > OCR(VobSub -> SRT)” and follow the instructions – be prepared though to invest some time helping with character recognition.  Don’t forget to check the spelling in the resulting SRT file.

Re-Muxing Handbrake leaves us with a usable Matroska container, however we’d like to replace subtitles and add some additional data for archiving purposes: at least a cover image and descriptive tags. The MKVToolnix package mentioned above provides the excellent mkvmerge utility featuring a graphical interface. With mkvmerge we remove the VobSub tracks and add our new SRT file as a subtitle track. You might also want to attach a file cover.jpg to the container. It will show up as the container’s thumbnail preview in a recent file browser. Moreover, we’d like to add some descriptive tags as suggested by the Matroska specification. However, I haven’t yet been able to find any player support for this feature. Anyway, for the tag file, you may use this template. Then merge the xml file into the container with mkvmerge (under the “global” tab for global tags).

How to Convert Git Log to ChangeLog

Posted in Coding, Linux by Chris on February 18, 2010

Git Logo

This is quite a useless endeavor, of course.  Since every fork from Git contains the whole change history, GNU-style ChangeLogs are pretty obsolete.  However, if you want to distribute your source files in a traditional tarball, you might want to add a ChangeLog file – and you might want it to look like the ones in the GNU coding standard.  This is where my shell script comes in, which I wrote yesterday while doing some serious procrastination:


#!/bin/sh
# Convert git log to GNU-style ChangeLog file.
# (C) Chris
if test -d ".git"; then
    git log --date-order --date=short | \
    sed -e '/^commit.*$/d' | \
    awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
    sed -e 's/^Author: //g' | \
    sed -e 's/>Date:   \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
    sed -e 's/^\(.*\) \(\)\t\(.*\)/\3    \1    \2/g' > ChangeLog
    exit 0
else
    echo "No git repository present."
    exit 1
fi

This code goes conveniently in a Makefile template for Autotools, so you can create the ChangeLog on the fly, include it in the distribution tarball and have it unlinked afterwards. Again, there’s no need to have a ChangeLog lie around with Git.

Tagged with: , , , ,

Comfortably ripping CDs in the Linux console

Posted in Linux by Chris on December 2, 2009

Since I’m still converting my CD-Collection to listen to them on my iPod, I spent some time figuring out the easiest way to do this — in the background, with reasonable audio quality, and of course on Linux. My workflow now comes down to this:

  1. using the abcde script to rip the cd, some customizations apply
  2. using MusicBrainz through picard for tuning folder hierarchy and tags
  3. using Amazon’s API to download the cover files

This might be a bit more work than other approaches, but I get kick-ass audio files, clean tags and file names. This is my ~/.abcde.conf:

DEVICE=/dev/sr0
OUTPUTTYPE=mp3:" -V2 --vbr-new -q0 --lowpass 19.7 -b96"
PADTRACKS=y
OUTPUTFORMAT='${ARTISTFILE}/${ALBUMFILE}/${TRACKNUM} - ${TRACKFILE}'
EJECTCD=Y
mungefilename ()
{
echo "$@" | sed s,:,\ -,g | tr -d \'\"\?\[:cntrl:\]
}

Your device is probably named differently. The OUTPUTTYPE parameter sets the settings for lame. I chose a variable bitrate and basically cut off everything the ear can’t hear. The OUTPUTFORMAT parameter names and sorts the files into a iTunes-style hierarchy. I tweaked the mungefile() method to get Windows-style filenames, i.e. I want whitespace in my filenames.

I run abcde from a sandbox folder on my hard drive. It’s easy to put it in the background by starting it with screen. Having collected new music, I filter the whole stuff through picard to get top-notch MP3 tags. What picard can’t find I’ll add to the MusicBrainz database myself from the original CD.

As I use boxee to play and display my audio files on my media box, I want neat high-resolution cover images in each folder. I wrote a short python script to retrieve the covers from Amazon via their store API. Currently, I’m trying to add a GUI, which allows to scan whole music collections and provide missing or wrong images in batch mode. Once I’m done, I’m going to roll this into a Ubuntu package and distribute it.

Tagged with: , ,

Recent Chromium build for Ubuntu introduces extensions and bookmarks sync

Posted in Google, Linux, Web by Chris on November 17, 2009

… but kills essential development features (which didn’t work anyway). Chromium 4.0.250.0 (Ubuntu build 32056) was distributed via Launchpad the other day. There is no official repository for extensions yet. However, you may find other resources to mess with your browser. The syncing feature seems still somewhat immature, since your stuff will actually sync with a Google Docs document – and not with Google Bookmarks or another well established service like Delicio.us which would seem more plausible. Anyway, syncing via Google Docs works o.k., if all you want is to work with instances of Chromium across different machines. Since I still need Firefox from time to time, I prefer the Delicious bookmarklet to Chrome’s new built-in sync. And why would I still need Firefox? There’s still no serious web development on (Ubuntu) Linux with Chrome – which is too bad, really. The scripting console didn’t work before, and now Google seems to have killed the relevant entry in the developer tools menu. This is no solution, of course. OK, so in a new build I got the menu entries back – but there is still no chrome://devtools/devtools.html. Please Chromium Team, Firebug in all its glory is the one extension that ties me to Firefox (yeah, I know about Firebug Lite). I could easily dispense with the rest and work with javascript bookmarks for other vital functionality.

Tagged with: , , , ,

Some minor issues with the Karmic Koala

Posted in Linux, SysAdmin by Chris on October 31, 2009

After upgrading from Jaunty to Koala by clean install I experienced some minor annoyances – some of which I’m still working around.

The onion router package tor is MIA from the official repositories. To make things worse, there is no karmic build in the tor project’s repository either. Luckily, the debian sid build works. So adding

deb http://deb.torproject.org/torproject.org sid main

to /etc/apt/sources.list did the trick. Tor is up and running again.

DNS lookup was slow all over the system. And I mean really slow. It took Chromium up to 30 seconds to connect to a server. OpenArena was even completely timed-out in multiplayer mode. I have no clue what the problem is here. Strangely enough, providing alternative nameserver addresses did the trick. I used OpenDNS by adding

prepend domain-name-servers 208.67.222.222,208.67.220.220;

to /etc/dhcp3/dhclient.conf. Now IP resolving works well. But I don’t like this.

Some strange messages show up during boot, which seem to be harmless:

One or more of the mounts listed in /etc/fstab cannot yet be mounted:
(ESC for recovery shell)

Everything is then mounted ok. It still costs a couple of seconds in boot time. There is some discussion about this being a bug in mountall. What for it’s worth, I’m running version 1.0 of mountall.

Installing apache2 with apt-get now provides the package apache2-mpm-prefork, which doesn’t work with libapache2-mod-php5. This apache needs libapache2-mod-php5filter to parse PHP. Too bad I had simply copied all package selections from my previous install. This kept me busy for a while.

Tagged with: ,
Follow

Get every new post delivered to your Inbox.