Notes on installing Gitorious on Ubuntu 10.10

June 4th, 2011 § 0 comments § permalink

A few notes from my experience installing Gitorious on Ubuntu Maverick 10.10. I used soundmaster’s fork of the gitorious-ubuntu-sprinkle script. I used ruby 1.8 and rubygems from the Ubuntu repository.

Edit Config Files

The sprinkle readme doesn’t mention it, but you need to edit the config files before running. Add your mysql password to config/database.yml and change your hostname and email in config/gitorious.yml.
Beware that if the script already installed the files to /var/www/gitorious/config it won’t overwrite the existing files, so you will need to make your changes to the files at /var/www/gitorious/config (or delete the files and re-run the sprinkle script).

Sprinkle Script Overview

The sprinkle script will

  • Install required gems
  • Download and configure gitorious
  • Install and start startup scripts (stomp, git-poller, git-daemon)
  • Setup gitorious mysql database
  • Create a user named “git” (whose home dir is /var/www/gitorious)
  • Setup apache for use with gitorious

Deciphering Errors

I had a bunch of problems running

bundle exec sprinkle -s gitorious.rb

Ruby/capistrano spits out some long error messages, which you have to decipher to figure out which line in gitorious.rb failed to run.

Bundle couldn’t install the latest version of echoe (0.4.6) because Ubuntu’s rubygems (1.3.7) isn’t recent enough, so I installed an older version of echoe.

sudo gem install echoe -v="0.4.5"

I then removed echoe from the list of gitorious_dependencies in gitorious.rb. In hindsight, I think I could have added an entry to Gemfile specifying the echoe version, but I’m a Ruby noob, and just hacked the script to get it to work.

Then Rake couldn’t setup my database (some error about having activated rake 1.9.1 but the script required rake 1.8.7). Turns out I need to call bundle exec rake instead of /var/lib/gems/1.8/bin/rake. I modified the lines in gitorious.rb:

    #post :install, 'su - git -c "/var/lib/gems/1.8/bin/rake db:setup RAILS_ENV=production"'
    post :install, 'su - git -c "bundle exec rake db:setup RAILS_ENV=production"'

Miscellaneous notes

Make sure your server is getting ports 80 and 443 (for ssl).

I also had to set up my server to properly route email so that Gitorious could send emails (e.g. registration confirmation). I used this guide to setup postfix to route mail through Gmail’s smtp.

Redmine on Ubuntu Maverick

February 4th, 2011 § 1 comment § permalink

Redmine is a project management software. There’s existing documentation on the web about installing Redmine on Ubuntu, but much of it is out of date and confusing. Redmine is in the Ubuntu repos now so the installation is really quite simple.

sudo tasksel install lamp-server
sudo apt-get install redmine

Select sqlite for the database (redmine-sqlite is installed as a dependency by apt-get and it’s simpler to setup than mysql).

Now to configure the Apache bits.

sudo ln -s /usr/share/redmine/public /var/www/redmine
sudo apt-get install libapache2-mod-passenger
sudo vim /etc/apache2/mods-available/passenger.conf

Add the PassengerDefaultUser www-data line to /etc/apache2/mods-available/passenger.conf. It should look like this:

<IfModule mod_passenger.c>
  PassengerDefaultUser www-data
  PassengerRoot /usr
  PassengerRuby /usr/bin/ruby
</IfModule>

Configure apache by adding these lines to /etc/apache2/sites-available/default

<Directory /var/www/redmine>
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on
</Directory>

Configure email

cd /etc/redmine/default
sudo cp /usr/share/redmine/config/email.yml.example email.yml
sudo vim email.yml

If you want to use gmail, delete the default settings and uncomment the gmail section settings. Add the line

    enable_starttls_auto: true

after the tls: true line. (see Redmine Email Config for more info.)

Restart Apache (you will have to restart Apache after you make any redmine config file changes)

sudo service apache2 restart

Now see if your install worked. Try http://localhost/redmine or http://server.com/redmine. Login with username admin and password admin.

Update: Until Ubuntu updates to Redmine 1.0.4 (currently it installs 1.0.0), there is a bug where dates get displayed as {{count}} if you have the Ruby gem i18 v0.5.0 installed instead of v0.4.2. Quick fix:

sudo gem install i18n -v=0.4.2
sudo gem uninstall i18n -v=0.5.0

How to setup a SparkleShare Private Server on Ubuntu

February 1st, 2011 § 10 comments § permalink

*Feb 3, 2011: This is a work in progress...
*Todo: nautilus integration not working - missing dependencies? (no ubuntu python-nautilus-dev package?)
*Todo: compile a release build instead of a debug build?
*Todo: build a ubuntu/debian package?

SparkleShare is dropbox-like software that can sync to your own private server. The SparkleShare documentation recommends syncing to GitHub or Gitorius, but all you need is a server with ssh and git. By using your own private server, your files won’t be publicly viewable and you can use as much storage space as you have on your server. Here’s how to setup SparkleShare with a private server on Ubuntu.

First setup the server. You will need to have ssh access to the server because
SparkleShare will sync to an existing git repository using ssh public key login. To setup ssh public key login (passwordless login) run this on your local box

ssh-copy-id user@server.com

If you get an error, you may need to create a ssh key first. Run ssh-keygen and create a key without a password. Then run ssh-copy-id again.

If you don’t have a server, you can test on the same machine. Just use localhost for the server address.

ssh-copy-id user@localhost

Now create a git repository on your server.

#If your public key setup worked, you should
#be able to login to ssh without entering a password
ssh user@server.com
git init --bare sparkle.git
exit

Then set up SparkleShare. You will need sudo privileges for this.

# There may be more missing dependencies here
sudo apt-get install git build-essential intltool mono-devel gtk-sharp2 nant python-nautilus
mkdir ~/install
cd ~/install
git clone https://github.com/hbons/SparkleShare.git
cd SparkleShare
./autogen.sh --prefix=/usr
make
sudo make install
sparkleshare start

SparkleShare pops up a welcome dialog with some setup. Fill in user@server.com for the server and use /home/user/sparkle.git for the folder location. Then click Sync. When SparkleShare finishes syncing you should have a SparkleShare folder at ~/SparkleShare/sparkle where you can put files.

To redo the setup, stop sparkleshare sparkleshare stop then remove the sparkleshare config directory rm -rf ~/.config/sparkleshare and remove sparkleshare’s synced directory rm -rf ~/SparkleShare and restart sparkleshare sparkleshare start

To uninstall

sparkleshare stop
cd ~/install/SparkleShare
sudo make uninstall
sudo rm -rf /usr/{lib,share/gnome/help,share}/sparkleshare
rm -rf ~/SparkleShare
rm -rf ~/.config/sparkleshare

Vim: Save and Run Shortcut

January 21st, 2011 § 2 comments § permalink

Make Vim more IDE-like by assigning F5 to save and run your current script. Just add this to your ~/.vimrc

map <F5> <Esc>:w<CR>:!%:p<CR>

This maps the F5 key to run two things: :w, which saves your file, and :!%:p, which will run your current script (! runs a shell command and %:p expands to the path of your current file).

A test example

echo "#!/bin/bash" > test.sh
echo "echo hello world" >> test.sh
chmod +x test.sh
vim test.sh

Now pressing F5 while in Vim will save test.sh and run the file in Vim’s internal shell. Just press enter when the script is done to return to Vim.

code based on discussion at stackoverflow

Password-less SSH Login

July 15th, 2010 § 0 comments § permalink

ssh-copy-id moose@moosechips.com

If you get ERROR: No identities found, you need to create a ssh key. (Create one without a password when prompted.)

ssh-keygen -t rsa

Then run ssh-copy-id again.

If your remote user has a different login name, you can setup a ssh config file so it will use the right user name. Create a text file at ~/.ssh/config with

Host moosechips.com
  User moose

Now you can login via ssh

ssh moosechips.com

Running Mathematica Over SSH Using Cygwin

April 2nd, 2010 § 1 comment § permalink

When trying to run Mathematica over SSH using Cygwin, you will probably get some error message like

ssh -Y user@host
mathematica
xset: bad font path element (#23), possible causes are:
   Directory does not exist or has wrong permissions
   Directory missing fonts.dir
   Incorrect font server address or syntax

This is because you need to install the Mathematica fonts into Cygwin’s X server. This solution worked for me using the latest Cygwin 1.7.2: » Read the rest of this entry «

Install Gitweb to a Subdirectory

March 8th, 2010 § 0 comments § permalink

Reach gitweb at a subdirectory, i.e. “http://moosechips.com/gitweb”. The gitweb README and INSTALL files come with instructions on setting up access to your root web directory, but chances are you’re already using that for your homepage. Here’s the setup for installing to a subdirectory. (This worked for me with git-1.7.0.1)
» Read the rest of this entry «

Linux Font DPI Help from Mozilla

May 12th, 2009 § 0 comments § permalink

Thanks to Mozilla for providing excellent linux font DPI support.

On my Gentoo setup, I added a Xft.dpi setting go my ~/.Xdefaults file. Now my fonts look normal again. :)

Xft.dpi: 108

Before:

screenshot-fonts-before

After:

screenshot-fonts-after

X and Hal on Gentoo

May 10th, 2009 § 0 comments § permalink

Instructions for installing xorg-server and hal on gentoo.

I’m writing this because the gentoo documentation for X setup is very outdated. Gentoo now uses xorg 1.5 which uses hal to setup devices automatically instead of having to configure /etc/X11/xorg.conf. The Xorg 1.5 update guide might be a little helpful, but it’s missing some info and is a bit vague in places.

Xorg-server 1.5 setup

Make sure your kernel is compiled with Event interface support. (If not, see Gentoo Handbook: Configuring the kernel for help recompiling your kernel)

Device Drivers --->
 
Input device support --->
 
--- Input device support
[*]     Event interface

Add X and hal USE flags (the “–alpha-order” is optional, but I like to keep my USE flags organized)

flagedit --alpha-order +hal +X

(or equivalently with euse. euse is from the app-portage/gentoolkit package)

euse -E hal X

Add to /etc/make.conf

INPUT_DEVICES="evdev"
# Change the video driver to match your video card
# or install a bunch and let hal choose
VIDEO_DRIVER="nv nvidia radeon radeonhd intel sis via vesa fbdev"

Install xorg-server (which will also install hal since the hal USE flag is now enabled)

emerge -av xorg-server

Add hal policy files so hal can auto-detect your devices. Doesn’t hurt to add them all, hal will figure out what it needs.

cp /usr/share/hal/fdi/policy/10osvendor/* /etc/hal/fdi/policy

Add hald to startup and start hald

rc-config add hald default
/etc/init.d/hald start

Don’t need any /etc/X11/xorg.conf file

mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

Now startx

startx

Intel 4965 Wireless on Gentoo

May 10th, 2009 § 0 comments § permalink

I recently configured the wireless on my X61 Tablet for Gentoo. I have a Intel 4965 AGN wireless card.

lspci | grep -i wireless
03:00.0 Network Controller: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)

Relevant kernel options (from gentoo-sources 2.6.28-r5 kernel)

Device Drivers  --->
  [*] Network device support  --->
    Wireless LAN  --->
      {*} Intel Wireless Wifi Core
      <M> Intel Wireless WiFi Next Gen AGN
        [*]   Intel Wireless WiFi 4965AGN

Install wpa_supplicant and wireless-tools

emerge -av wpa_supplicant wireless-tools

Create symlink so Gentoo will initialize the wlan0 at startup

cd /etc/init.d
ln -s net.lo net.wlan0

/etc/conf.d/net

modules=( "wpa_supplicant" )
iwconfig_wlan0="mode managed"
wpa_supplicant_wlan0="-Dwext"

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
 
network={
  ssid="MySSID"
  scan_ssid=1
  key_mgmt=WPA-PSK
  psk="password"
  priority=5
}

I was getting SCICSIFFLAG File Not Found errors when trying to bring up my wlan0 interface. A look at the dmesg log revealed that the iwlagn module was trying to access iwlwifi-4965-2.ucode, so I emerged iwl4965-ucode to fix that.

emerge -av iwl4965-ucode

Reinitialize the interface to see if everything worked

/etc/init.d/net.wlan0 restart

Bootable Gparted USB Stick

May 7th, 2009 § 7 comments § permalink

Creating a bootable usb stick with the Gparted live iso in Ubuntu. Gparted is a graphical partition editor which can resize, move, copy, create, delete your hard drive partitions.

Overview:

  • Format your usb stick to Fat16 and make it bootable using gparted.
  • Install the gparted-live*.iso using unetbootin. (unetbootin also automatically installs the syslinux bootloader)
  • Reinstall syslinux onto usb stick. (Gparted’s live cd requires syslinux newer than ver 3.71. Currently (May 7 2009) Ubuntu 9.04 Jaunty has syslinux 3.63. Use apt-cache show syslinux | grep "^Filename" to check Ubuntu’s version)

Installation Steps

1. Install gparted and unetbootin

sudo aptitude install gparted unetbootin

2. Download the gparted live iso and the latest syslinux.

wget http://superb-west.dl.sourceforge.net/sourceforge/gparted/gparted-live-0.4.4-1.iso
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.80.tar.bz2

3. Insert your usb stick into the computer, and copy any files you want to save to your hard drive. You will be reformatting your stick and will lose all the files on the usb drive.

4. Run gparted.

sudo gparted

Select your usb drive. (Probably something like /dev/sdc). Right click on the partition and select Unmount to unmount the drive. Format the drive to Fat16 and apply. Then make the usb drive bootable by going to Manage Flags and selecting the boot flag.

screenshot-gparted

Exit gparted.

5. Remount your usb drive by unplugging and replugging your usb stick.

6. Run unetbootin

unetbootin

Select Diskimage ISO and locate the gparted-*.iso that you downloaded. Make sure the correct partition is selected at the bottom and click OK.

screenshot-unetbootin

Don’t reboot yet. Just exit unetbootin.

7. Now, you would be done, except that Ubuntu’s syslinux is version 3.63 and the gparted live iso requires at least syslinux version 3.71, so you need to reinstall syslinux onto your usb stick.

Unpack the syslinux tarball you downloaded.

tar xjvf syslinux-3.80.tar.bz2

Now install syslinux onto your usb stick

cd syslinux-3.80/linux
sudo ./syslinux -s /dev/sdc1

8. Now you’re done. Reboot using your new gparted bootable usb stick.

End Notes:

This method should work on other bootable isos too.

You could try to use Fat32 if your motherboard supports booting from Fat32 USB devices. Fat16 is generally more compatible though.

If your USB stick is bigger than the the allowable Fat16 size (2gb), make two partitions: first a 1-2gb Fat16 partition for your boot drive, and a second Fat32 partition with the rest of the space.

grep and less with color

April 17th, 2009 § 0 comments § permalink

Add these lines to your ~/.bashrc to make colorful grep | less output.

alias grep='grep --color=always'
export LESS='-R'

Emacs Experimentation

April 7th, 2009 § 0 comments § permalink

My experiences as a [g]vim user trying out emacs.

Day 1:

Emacs commands

Running emacs was no problem, as it was already installed from Fedora’s repository. Reading through some emacs tutorials, I found Emacs For VI Users very helpful.  Probably my most used  vi commands are delete line (dd), yank line (yy), and put (p or P).  Emacs  confusingly uses “yank”  to describe the  vi equivalent “put” command of inserting saved text into the document.  Getting used to the sequences of ctrl / alt + key is strange when I’m used to the efficient vi commands.  ”yy” becomes “Ctrl+a  Ctrl+k Ctrl+k Ctrl+/”.

Tab behavior

Started trying to edit some c++ files using emacs, but found that the default tabbing behavior was messing up my indentation.  The default emacs uses 2 spaces per indentation, and will use the tab key to automatically indent code instead of inserting a tab character.  I like to tab-indent my code and view it as 4 spaces / tab.  This was frustratingly difficult to solve, as emacs has so many options, and many of the emacs options have cryptic names and unclear descriptions.  I finally found some sane lines to put into my ~/.emacs file from Emacs Tips N Tricks For Everybody.  The

(global-set-key "\C-m" 'newline-and-indent)

line is really nice to emulate vi’s autoindent feature. Understanding GNU Emacs and Tabs is also useful for understanding emacs’s special tabbing behavior.

Day 2:

Antialiased fonts

Discovered that emacs 23 supports antialiased fonts, but there’s no stable release yet, and no Fedora 8 rpm.  So, I downloaded the source from cvs and built.  Now running

emacs --font="monospace-10"

works, and emacs looks great.

Start in background

I wrote a bash wrapper to always start emacs in the background (similar to gvim) with the monospace font.

#!/bin/bash
# start emacs in the background with the monospace font
exec emacs-23.0.92.1 --font="monospace-10" "$@" &

My ~/.bashrc has an alias to run this wrapper. (I put the wrapper in ~/bin/emacs)

# .bashrc alias
alias emacs="~/bin/emacs"

Matlab files

Opening a matlab .m file tries to use the ObjC mode. You can add the matlab mode to emacs using the matlab.el file from matlab-emacs. I put the file at ~/.emacs_addons/matlab.el and added these lines to my ~/.emacs file:

; Add addons dir to path
(setq load-path
      (append (list nil "~/.emacs_addons")
              load-path))
; Add matlab.el module
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)

Regular expressions

Emacs offers search and replace with regular expressions using the Ctrl-Alt-% command, with some caveats

Tab bar

Opening multiple files in emacs puts each file into a buffer, but there is no [g]vim/firefox-like tab bar which shows the open files. You have to go through the list of buffers or split your window. But at least there is the TabBar mode addon.

Linux: Find Motherboard Information

November 19th, 2008 § 0 comments § permalink

Find the manufacturer and version of your motherboard with this command:

sudo dmidecode | grep "Base Board" -A 13

Example output:

Base Board Information
        Manufacturer: ASUSTeK Computer INC.
        Product Name: Maximus Formula
        Version: Rev 1.xx
        Serial Number: XXXXXXXXXXX
        Asset Tag: To Be Filled By O.E.M.
        Features:
                Board is a hosting board
                Board is replaceable
        Location In Chassis: To Be Filled By O.E.M.
        Chassis Handle: 0x0003
        Type: Motherboard
        Contained Object Handles: 0

Fedora: Rebuild A Source Package

October 23rd, 2008 § 0 comments § permalink

General instructions to rebuild a Fedora source rpm.

Note: This example uses the vlc source rpm, but it doesn’t work on my Fedora 8 system because there are problems installing dependencies, but the general commands should work on other packages

  1. Install build tools
    su -c 'yum install yum-utils rpmdevtools'
  2. Download source package. Either use yumdownloader to download from an existing repository:
    yumdownloader --source vlc

    or download directly from a server

    wget -nd ftp://ftp.pbone.net/mirror/rpm.livna.org/fedora/development/SRPMS/\
    vlc-0.9.0-0.5.20080802git.lvn10.src.rpm
  3. Install the source package. This will unpack the source into your /$HOME/rpmbuild directory.
    rpm -Uvh vlc-0.8.6i-1.lvn8.src.rpm
  4. Install build dependencies for the source package
    su -c 'yum-builddep vlc-0.8.6i-1.lvn8.src.rpm'
  5. Edit the spec file
    cd ~/rpmbuild/SPECS
    vim vlc.spec
  6. Add the new source package
    cd ../SOURCES
    wget -nd http://download.videolan.org/pub/videolan/vlc/0.9.2/vlc-0.9.2.tar.bz2
  7. Build the rpm
    cd ../SPECS
    rpmbuild -bb vlc.spec
  8. Install the rpm
    cd ../RPMS/x86_64
    rpm -Uvh vlc-0.9.2.fc8.x86_64.rpm

References:
Building a kernel from the src rpm
Fedora rpm guide