M-x Kelsin

servers

Tag: servers

Using God as a monitor service for my VPS

Despite some issues I do like god as a monitoring solution for my vps. I understand the config files and feel comfortable with it’s commands and logging. I don’t currently like my rvm solution for running it so this morning I converted over to using rbenv.

Murmur Virtual Servers

I’ve been running my own mumble server for a while. I installed the ubuntu mumble-server packages and it’s been completely stable ever since. Recently however I needed to setup a second murmur server. Murmur comes with this ability built it but it’s not available via the config file. The config file only sets up default configuration. To actually setup a second server you need to interface with the murmur server via dbus (deprecated) or ice.

Instant PhpBB3 Speed Improvements

Recently at work we’ve installed a php accelerator onto one of our php apps. We were having load problems on the box (Moodle installs) and the accelerator helped solve the problem. This got me thinking and I decided to install an accelerator on my Linode in order to speed up my World of Warcraft guild forums (a phpbb3 install)

After doing some reading I decided to try out Xcache. I don’t have ANY opinions on which accelerator is better (this isn’t the one we chose at work for Moodle). I chose this one for the SOLE reason that Debian Lenny had it in the repository. Installing it was DEAD simple:


sudo aptitude install php5-xcache

sudo /etc/init.d/apache2 restart

Can’t get any simpler. Now my phpbb forum pages load INSTANTLY. It’s absolutely amazing and awesome.

This is making me want to move this blog over to the Linode very fast!

Apache and SSL

I’m going to be moving my mail to my linode soon (basically want to stop using GMail for most things) and in the process I’m learning about setting up webmail. To do this properly I did want to get my apache set up using a self-signed certificate. Clearly I don’t need my personal server to be signed by a CA since it’s only for me, I just don’t want people sniffing packets.

I used the following two links to do this. The guide is great and worked flawlessly for me!

http://www.tc.umn.edu/~brams006/selfsign.html

http://www.tc.umn.edu/~brams006/selfsign_ubuntu.html

My variation of Git branch in bash prompt

After reading another cool blog post about putting your current git branch in your bash prompt I decided I needed to try this out. Once I got it working I added in color coding to see the status of the current checkout as well!

First off, you need bash-completion and git installed on your server (bash-completion and git-core on Debian/Ubuntu). Once installed you can enable bash completion in the system wide bash file (/etc/bash.bashrc) or in your own ~/.bashrc by adding these lines (Clearly if you are not on Debian/Ubuntu double check file paths):

# Completion

if [ -f /etc/bash_completion ]; then

    . /etc/bash_completion

fi

Once this is all set you should have a function called __git_ps1 available. Try it out by just running “__git_ps1” on your command line from a git repo. You should get the branch name returned inside parenthesis’s.

Now comes my variations on how to include this in your prompt. My entire ~/.bash_prompt file can be found on my git repo. I source this file into my ~/.bashrc. The two most interesting parts are the function that determines the color of the branch based on git-status output and the function that gets the branch name. Branch name is pretty simple. We check that the __git_ps1 function is available and if it is, check that we’re in a branch using it. If we are we echo the branch name. Pretty clean.

prompt_git_branch() {

    if type -p __git_ps1; then

        branch=$(__git_ps1 '%s')

        if [ -n "$branch" ]; then

            echo -e "$branch"

        fi

    fi

}

The next function has to grep stuff out of git status to determine what state the repo is in. If we are completely up to date we use green. If I have local changes it’s blue. If we have files in our index ready to be committed I use red. This is really great with my home directory cause it helps remind me to add new dotfiles that I don’t care about to .gitignore (or commit them if they should be public config files).

prompt_git_branch_color() {

    if type -p __git_ps1; then

        branch=$(__git_ps1 '%s')

        if [ -n "$branch" ]; then

            status=$(git status 2> /dev/null)



            if $(echo $status | grep 'added to commit' &> /dev/null); then

            # If we have modified files but no index (blue)

                echo -e "\033[1;34m"

            else

                if $(echo $status | grep 'to be committed' &> /dev/null); then

                # If we have files in index (red)

                    echo -e "\033[1;31m"

                else

                # If we are completely clean (green)

                    echo -e "\033[1;32m"

                fi

            fi

        fi

    fi

}

It took some playing but I finally found the right final line to correctly tell bash which characters in the prompt are visible. If anyone has a good way of making these functions smaller or faster I’d love to hear it. I had some trouble making sure that the functions were always executed (not just on a new shell’s creation, but on every display of PS1). The delay this causes is not noticeable on all of my computers but more speed never hurts.

Emacs as a fast $EDITOR

I’ve been using vim as my $EDITOR setting for quite some time, and recently started using emacsclient. Two things about this setup bothered me. First I would have to switch to my emacs workspace in Xmonad in order to reach the editor, and when working on svn or git commits my cursor would be where it was last time I edited a commit. Not wanting to change the way Xmonad keeps emacs windows appearing on the same workspace or the way emacs saves my cursor position I found a way around both problems.

Install Xmonad on Debian Lenny

I want to install a newer version of Xmonad than packaged with Debian Lenny on my Lenny systems in the cleanest way possible. I tried a bunch of things today and it turned out that the solution is really simple.

It turns out that the Haskell cabal-install program solved all of my problems:

  1. It can install it's packages into my home directory. Binaries in ~/.cabal/bin and all libraries needed.
  2. These libraries take precedence over system installed ghc libraries.
  3. No non-stable packages are needed at all.
  4. Installs the most recent versions of xmonad, xmonad-contrib and xmobar and any libraries they need.
  5. Cabal-install itself builds with the version of ghc in Debian Lenny (this wasn't the case in previous releases and Ubuntu Hardy).

This procedure installs the newest released version of Xmonad in my home directory along with all required libraries, xmonad-contrib and xmobar. My steps I used are as follows (Please check versions for cabal-install so that the wget command is correct):

# First install ghc and the dev libraries that cabal-install needs

sudo aptitude install ghc libghc6-network-dev libghc6-mtl-dev zlib1g-dev



# Goto a temp dir and download cabal

cd ~/tmp

wget http://hackage.haskell.org/packages/archive/cabal-install/0.6.2/cabal-install-0.6.2.tar.gz

tar -xzvf cabal-install-0.6.2.tar.gz

cd cabal-install-0.6.2



# Now run the bootstrap.sh script (as your user)

./bootstrap.sh



# Make sure to add ~/.cabal/bin to your patch

# I do this via this next line in my .bashrc

export PATH="$HOME/.cabal/bin:$PATH"



# Some needed libraries to build Xmonad and Xmobar

sudo aptitude install libx11-dev libxft-dev



# Now we install xmonad!

cabal update

cabal install xmonad

cabal install xmonad-contrib

cabal install xmobar

I’m extremely happy with this setup. All of my non-packaged files are in my home directory safely away from my Debian Stable system. This is due to cabal install being able to seemlessly install into ~/.cabal which really does work great. I’m very excited for this tool to be included in ghc soon!