2011-09-28

Fixing the DropBox Client for GNU/Linux

I had experienced an issue with the DropBox client for Ubuntu 10.04 where PSD files over 1MB were not consistently syncing. Here is a solution which seems to have fixed the problem.

Keep in mind that this involves making changes to /etc/fstab, which if not done properly, could cause loss of data or other disasters. First, be sure to backup your /etc/fstab file, and read up on some fstab documentation.

In /etc/fstab find the root mount point which should have a forward slash as the 2nd field. Fields are separated by spaces or tabs on a line. Mine looks like this:

/dev/sda3 / ext3 errors=remount-ro 0 1

The 4th field is the options field. You will want to append the user_xattr option to these options. Options are separated by commas, with no space between them. So, in my case, it would look like this:

/dev/sda3 / ext3 errors=remount-ro,user_xattr 0 1

After saving this file, restart your computer and DropBox should work correctly.

2011-09-12

Installing Erlang and Agner Package Manager from Source on Ubuntu 10.04

I have had many problems using the default erlang package on ubuntu, so I have found it best to install from source. I also use the Agner package manager which simplifies Erlang package management. You will need to run most of these commands as sudo.
> apt-get purge erlang
> apt-get build-dep erlang
> apt-get install curl
> apt-get install libc6-dev
> apt-get install libncurses5-dev
> apt-get install m4
> apt-get install libssl-dev
> apt-get install erlang-mode
> apt-get install openjdk-6-jdk
> cd /usr/local/src/
> git clone --recursive git://github.com/erlang/otp.git erlang-otp
> cd erlang-otp
> ## Replace this with newer version if you wish
> git checkout OTP_R14B01
> ./otp_build autoconf
> ./configure --prefix=/usr/local
> make
> make install
> curl https://raw.github.com/agner/agner/master/scripts/oneliner | sh
> export ERL_LIBS="/usr/local/agner/packages"
> echo >> /etc/environment
> echo 'ERL_LIBS="/usr/local/agner/packages"' >> /etc/environment

2011-08-11

Installing RabbitMQ with Management Plugin from Source on Ubuntu 10.04

These should be run as sudo...
$ apt-get purge rabbitmq-*
$ userdel -fr rabbitmq
$ apt-get install xsltproc xmlto
$ useradd -M -r -s /bin/bash -d /var/lib/rabbitmq rabbitmq
$ mkdir -p /usr/local/lib/rabbitmq/plugins/
$ mkdir -p /var/log/rabbitmq/ /var/lib/rabbitmq/ /etc/rabbitmq/
$ chown -R root:root /usr/local/lib/rabbitmq/ /etc/rabbitmq/
$ chown -R rabbitmq:rabbitmq /var/log/rabbitmq/ /var/lib/rabbitmq/
$ chmod -R 775 /usr/local/lib/rabbitmq/ /var/log/rabbitmq/
$ chmod -R 700 /var/lib/rabbitmq/
$ cd /usr/local/src/
$ hg clone http://hg.rabbitmq.com/rabbitmq-public-umbrella
$ cd rabbitmq-public-umbrella
$ hg checkout rabbitmq_v2_5_1
$ make co
$ make release
$ make test
$ cp -fr rabbitmq-server/ebin /usr/local/lib/rabbitmq/
$ cp -f rabbitmq-server/scripts/rabbitmqctl /usr/local/sbin/
$ cp -f rabbitmq-server/scripts/rabbitmq-env /usr/local/sbin/
$ cp -f rabbitmq-server/scripts/rabbitmq-server /usr/local/sbin/
$ cp -f rabbitmq-management/dist/amqp_client-*.ez /usr/local/lib/rabbitmq/plugins/
$ cp -f rabbitmq-management/dist/mochiweb-*.ez /usr/local/lib/rabbitmq/plugins/
$ cp -f rabbitmq-management/dist/rabbitmq_management_agent-*.ez /usr/local/lib/rabbitmq/plugins/
$ cp -f rabbitmq-management/dist/rabbitmq_management-*.ez /usr/local/lib/rabbitmq/plugins/
$ cp -f rabbitmq-management/dist/rabbitmq_mochiweb-*.ez /usr/local/lib/rabbitmq/plugins/
$ cp -f rabbitmq-management/dist/webmachine-*.ez /usr/local/lib/rabbitmq/plugins/
$ bash -c 'echo "export HOME=/var/lib/rabbitmq" >> /etc/rabbitmq/rabbitmq-env.conf'
$ bash -c 'echo "export RABBITMQ_HOME=/usr/local/lib/rabbitmq" >> /etc/rabbitmq/rabbitmq-env.conf'
If you want to run RabbitMQ as a background service, add it as a supervisord service. Supervisord can be installed by doing:
apt-get install supervisor

2011-07-29

Sharing a Terminal Session Between 2 Users Behind a Firewall

Imaging that you have 2 users both using Ubuntu 10.04: UserA@HostA and UserB@HostB. HostB is behind a firewall, and UserA would like to SSH into HostB and share a terminal with UserB to collaborate on some kind of task. This article will attempt to explain how to do this.

  1. Make sure both users have SSH access to a "middle" server. We will call this HostC...

    root@HostC$ sudo useradd -m -s /bin/bash UserA
    root@HostC$ sudo useradd -m -s /bin/bash UserB
  2. Install OpenSSH Server on HostB...

    UserB@HostB$ sudo apt-get install ssh

    Keep in mind that this could cause potential security issues, so you should also familiarize yourself with how to secure OpenSSH server. Specifically, make sure you disable the "PermitRootLogin" option.

  3. Install GNU Screen on HostB and setuid root for GNU Screen...

    UserB@HostB$ sudo apt-get install screen
    UserB@HostB$ sudo chmod u+s /usr/bin/screen
    UserB@HostB$ sudo chmod -R 755 /var/run/screen
  4. Add a new user on for UserA@HostB...

    UserB@HostB$ sudo useradd -m -s /bin/bash UserA
    UserB@HostB$ sudo passwd UserA

    Be sure to remember the password for UserA which was set here.

  5. Have UserB SSH into HostC, setting up a remote forward...

    UserB@HostB$ ssh -R 20022:localhost:22 UserB@HostC

    UserB will need to keep this terminal window open, but will not need to enter commands here.

  6. Have UserA SSH into HostC.

    UserA@HostA$ ssh UserA@HostC
  7. Now, from HostC, have UserA SSH into HostB...

    UserA@HostC$ ssh -p 20022 UserA@localhost

    Keep in mind that UserA will be asked for a password at this point. This will be the password which was set earlier.

  8. At this point, UserA should now be logged in to HostB. Now UserA will need to setup a named screen session.

    UserA@HostB$ screen -S foobar
    UserA@HostB$ screen -X multiuser on
    UserA@HostB$ screen -X acladd UserB
  9. In a new terminal window, on HostB, have UserB join the screen session...

    UserB@HostB$ screen -x UserA/foobar

At this point, both users will share a terminal session on HostB.

If you plan on doing this often, you should familiarize yourself with iptables so as to properly setup a firewall for added security.

2011-05-25

Shell Scripting with GNU Screen

This launches a program in a new screen, method 1. Does not close window after program terminates...
screen -t "my-program" -p "-"
screen -p "my-program" -X stuff "/path/to/program
"
screen -X select "my-program"
This launches a program in a new screen, method 2. Closes window after program terminates...
screen -t "my-program" -p "-" "/path/to/program"
screen -X select "my-program"
This kills a process in another screen. This depends on screen-session which can be found at https://github.com/skoneka/screen-session ...
sudo screen-session kill "INT" "my-program"
This kills a screen window...
screen -p "my-program" -X kill
screen -wipe

2011-01-10

Compiling Nginx from Source on Ubuntu 10.04

This needs to be run as root.
## Basic stuff
apt-get update
apt-get install build-essential git-core wget

## Install PCRE for rewriting
apt-get install libpcre3 libpcre3-dev

## Install ssl
apt-get install openssl libssl-dev

## Download nginx sources
cd /usr/local/src/
svn checkout svn://svn.nginx.org/nginx/trunk nginx
cd nginx/

## Configure
./configure \
    --prefix="/usr/local" \
    --conf-path="/usr/local/etc/nginx/nginx.conf" \
    --with-http_ssl_module \
    --with-cc-opt="-I /usr/include/" \
    --with-cc-opt="-I /usr/include/openssl/"

## Build and install
make && make install

## Install init script
cd /usr/local/src/
git clone git://github.com/brendoncrawford/nginx-init-ubuntu.git
chmod +x nginx-init-ubuntu/nginx
mkdir -p /usr/local/etc/init.d/
cp nginx-init-ubuntu/nginx /usr/local/etc/init.d/nginx
ln -s /usr/local/etc/init.d/nginx /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults

## Cleanup stuff
rm -f /usr/local/etc/nginx/*.default