Posts Tagged ‘linux’

Keeping your Varnish farms configuration in sync

I spend some of my free time helping out with server administration and programming for the Swedish Pirate Party, Piratpartiet (look ma, X-Varnish), and we use Varnish for our caches. At the moment it’s just used on some of our projects, but we’re going to migrate most of our projects to be behind our Varnish caches.

The thing is though that we got two hosts running the exact same configuration, and we’d like to keep those hosts in sync. A quick search on Google gave me nothing for syncing varnish configuration over several hosts, or a farm as it were. So I took matters into my own hands and wrote varnishsync, a little bash script that uses rsync and ssh to sync the configuration folder and then to load and use the new configuration.

Please have a look at the Github project for the latest version and usage, and if you’ve any questions or suggestions drop a line here or on Github.

How to: Setting up a Wikileaks mirror

Yesterday I wrote a quick step-by-step guide for installing apache and setting your system up for Wikileaks mass-mirror project in Swedish and I’ve had requests for it to be translated into English.

This guide assumes you’re running Ubuntu or a Debian based system.

I’ve made a script that does all the steps below, feel free to use it!
The script: http://sanitarium.se/files/wikileaks-mirror.sh
Usage: wget http://sanitarium.se/files/wikileaks-mirror.sh && chmod +x wikileaks-mirror.sh && ./wikileaks-mirror.sh

Installing Apache and adding the wikileaks user

# is the prompt as root:

youruser$ sudo -s

Install apache if it’s not installed

# apt-get install apache2

Add a wikileaks user, write down where the home folder is created.

# adduser --disabled-password wikileaks
# su wikileaks
wikileaks$ mkdir ~/.ssh ~/www
wikileaks$ chmod 0700 ~/.ssh
wikileaks$ wget http://213.251.145.96/IMG/id_rsa.pub -O ~/.ssh/authorized_keys
wikileaks$ exit

Time to add the apache site for wikileaks

# cd /etc/apache2/sites-available/
# wget http://sanitarium.se/files/wikileaks

Open the file wikileaks with an editor and change the path to the wikileaks users home folder if it’s not /home/wikileaks.
This file assumes you want to host wikileaks.org, if you want to host wikileaks.yourdomain.com you’ll need to set ServerName accordingly and if necessary ServerAlias, ServerAlias is optional and you can remove that row if you don’t use it.
When that is done you just need to activate the site in apache:

# a2ensite wikileaks

And reload apache so it knows that the new site has been added:

# /etc/init.d/apache2 reload

The wikileaks file downloaded from this server looks like this:

<VirtualHost *:80>
        DocumentRoot /home/wikileaks/www
        ServerName wikileaks.org
        ServerAlias www.wikileaks.org
        ErrorLog /dev/null
        CustomLog /dev/null common

        <Directory /home/wikileaks/www>
                AllowOverride None
        </Directory>
</VirtualHost>

Now tell Wikileaks about your mirror

Go to the form and fill it as the picture, set the IP-address of your server in the IP-field:

If you’re having any troubles don’t hesitate to ask in the comments!

How to: Sätta upp en Wikileaksspegling

A translation of this post is available in English.

En kommentar i Rick Falkvinges inlägg Fullt krig om informationen så efterfrågades en snabbguide för att dra igång en Wikileaksspegling i ett vanligt Linuxssystem.

Jag utgår från Ubuntu eftersom det är vanligt och vad jag själv använder.

Uppdatering 2010-12-05: Jag har gjort ett script som utför alla stegen nedan, använd gärna det!
Filen: http://sanitarium.se/files/wikileaks-mirror.sh
Användning: wget http://sanitarium.se/files/wikileaks-mirror.sh && chmod +x wikileaks-mirror.sh && ./wikileaks-mirror.sh

Installera Apache

# är prompten som root:

dinanvändare$ sudo -s

Installera apache om det inte är installerat

# apt-get install apache2

Lägg till en användare för Wikileak och anteckna var wikileaks hemmap skapas!

# adduser --disabled-password wikileaks
# su wikileaks
wikileaks$ mkdir ~/.ssh ~/www
wikileaks$ chmod 0700 ~/.ssh
wikileaks$ wget http://213.251.145.96/IMG/id_rsa.pub -O ~/.ssh/authorized_keys
wikileaks$ exit

Nu är det dags att lägga till siten för wikileaks

# cd /etc/apache2/sites-available/
# wget http://sanitarium.se/files/wikileaks

Öppna filen wikileaks med en editor och ändra sökvägen till användaren wikileaks hemmapp om det är något annat än /home/wikileaks.
Den här filen förutsätter att du vill hosta wikileaks.org, om du vill hosta wikileaks.dindomän.se eller något sådant så får du ändra ServerName och eventuellt ServerAlias.
När det är klart är det bara att aktivera siten för apache:

# a2ensite wikileaks

Och till sist ladda om apache så det är redo att ta emot information:

# /etc/init.d/apache2 reload

Innehållet i filen wikileaks som du tankar från den här servern är:

<VirtualHost *:80>
        DocumentRoot /home/wikileaks/www
        ServerName wikileaks.org
        ServerAlias www.wikileaks.org
        ErrorLog /dev/null
        CustomLog /dev/null common

        <Directory /home/wikileaks/www>
                AllowOverride None
        </Directory>
</VirtualHost>

Hur du säger till Wikileaks att allt är klart

Surfa in på formuläret och fyll i det enligt nedan, byt ut ip-adress mot IP:t för din server:

Om det är några oklarheter eller funderingar så fråga på i kommentarsfältet nedan så ska jag försöka hjälpa till att reda ut!

Uppdatering: Henrik Rouhivuori upplyste om att aptitude inte finns i Ubuntu 10.10 så jag ändrade till apt-get istället. Övertydligt att jag fortfarande hänger på 10.04. :)
Uppdatering 2: Henrik Holst berättade att du kan välja att inaktivera lösenordsinloggning när du skapar nya användare, så nu görs det istället för att rekommendera ett slumpmässigt långt lösenord!
Uppdatering 3: David Vrensk påminner om att sshd är lite petig på att det bara är användaren som ska ha rättigheter till .ssh-mappen.
Uppdatering 4: Av bara farten så hade jag missat att lägga till att man måste skapa mappen www som wikileaks-filen pekar på, samt common efter loggraden. Tack till Gustav Wetter som jobbet igenom hela guiden!

How to get your HP un2400 3G modem to work in Ubuntu on a HP 110c-1020SO netbook

I bought a HP netbook this week with the explicit intent to use GNU/Linux on it. I wagered that someone had gotten the built-in 3G modem working and while it was a pain to get installed I was right, someone had made it work!

To help anyone who would be in the same position as I was a couple of days ago I’ve written down the steps I followed to get my modem working on my own wiki and also packed all the files I need to get this working up as a download.

So for the meat of this post please see the HP un2400 3G modem in Linux page on the wiki.

How to disable bold fonts in xterm

I’ve so far in all my travels never found a terminal I like better than xterm, maybe urxvt, but I’ve had a problem disabling bold fonts for a very long time. Update: Seems this is a known bug for xterm.

There are a lot of X resource configuration options that makes you think you can disable bold fonts, but alas, I’ve had no luck with any of them. But if you set the same font for both normal and bold fonts it’ll work! This little gem of knowledge I found as an off-hand remark on a configuration page by Emil Mikulic, thank you!

I like the normal fixed font, I’ve tried many terminal fonts but I’ve always gotten back to it. So I simply tucked:

xterm*font: fixed
xterm*boldFont: fixed

Into my ~/.Xresources and afterwards ran xrdb -load ~/.Xresources and started up a new xterm loaded with awesomeness!

xterm with bold font and xterm without bold font

The before and after shot.