The Perfect Server - Ubuntu Linux 9.04 32bit

What is the perfect linux server?

The perfect linux server to me is something that can maintain all of my downloads, whatever it may be (Torrent, newsgroups, soulseek, ect) that can be controlled and accessed from VPN, LAN or Internet via HTTP... and have it all running when it boots up! (That was the hardest part actually)

In this video tutorial, i walk you through installing:

- Webmin (HTTP Adminstration of your server)

- Torrentflux (HTTP Front-end for Torrent downloads)

- SABnzbd Plus (HTTP Front-end for Newsgroup downloads)

- irssi (Text based IRC Chat client)

- Museek (Soulseek music download daemon)

- Eggdrop IRC Bot (*does the robot*)

- Hamachi VPN (Free and easy VPN solution that even my grandma can understand)

1) Update

# sudo apt-get update

# sudo apt-get upgrade

# sudo apt-get dist-upgrade

1a) Reboot

# sudo shutdown now -r

2) Compiling tools

# sudo apt-get install build-essential linux-headers-`uname -r`

3) SSH access

# sudo apt-get install openssh-server

4) Install Webmin

4a) Webmin Dependencies

# sudo apt-get install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl

4b) Download Webmin Deb package

# wget http://prdownloads.sourceforge.net/webadmin/webmin_1.490_all.deb

4c) Install Webmin Deb package

# sudo dpkg -i webmin_1.490_all.deb

4d) Manage your server via Webmin

# Browse to: https://host.name.or.ip:10000/

5) Install Torrentflux

# sudo apt-get install torrentflux

5a) Setup Torrentflux

Browse to: http://host.name.or.ip/torrentflux

6) Install SABnzbd

# sudo apt-get install sabnzbdplus sabnzbdplus-theme-smpl sabnzbdplus-theme-plush sabnzbdplus-theme-iphone

6a) Edit SABnzbd config and add your user name, 0.0.0.0 as your host and 8080 as your port

# nano /etc/default/sabnzbdplus

6b) Setup SABnzbd

Browse to: http://host.name.or.ip:8080/sabnzbd

7) Install irssi IRC chat client

# sudo apt-get irssi

7a) Run irssi in Screen

# screen irssi

7b) Add the OMGIRC Network

/network add OMGIRC

7c) Add the OMGIRC server

/server add -auto -network OMGIRC irc.omgirc.com 6667

7d) Auto join #chatzone channel on connect

/channel add -auto #chatzone OMGIRC

7e) Test connection

/server OMGIRC

7f) Change to #chatzone window

Hit Alt-2

7g) Exit from screen back to terminal

CTRL-A D

7h) Add irssi in a screen session on boot

# crontab -e

Add the following line:

@reboot /usr/bin/screen -d -m irssi

Press CTRL-X to save and Exit the Nano text editor.

You may re-attache the screen session by typing:

# screen -r

You may detach from the screen by pressing:

CTRL-A D

When the server boots up, it will automatically launch irssi in a detached screen which you can reattach at your own will.

8) Install Museekd SoulSeek P2P Daemon

# sudo apt-get install museekd

8a) Setup Museekd

# musetup

Press 1 for "SoulSeek Server", Press 3 for "Username" and pick any username you wish (you don't need to register for it, just choose what you wish), Press 4 and do the same for "Password". Again, you don't need to register this user/pass, just pick one. Press 0 to exit back to the main setup menu.

Press 3 for "Interface listeners", Press 1 and choose a password you will use to connect to your server from your laptop or desktop. Press 2 to "Add new interface listener", choose option 1 "Add TCP socket listener", put in your servers ip address when asked "Local address to bind to" and pick port 2240. Repeat this step and instead of using the servers ip address, use the hostname: localhost - Press 0 to exit back to the main setup menu.

Press 5 for "Download and incomplete file directory" and choose where you would like to store mp3's that have completed downloading as well as a incomplete directory. Press 0 to exit back to the main setup menu.

Press 6 for "Shared directories", Press 3 to add a shared directory, type the path to your Download folder you did in the last step, this will share out the music you've collected to others on SoulSeek. Press 0 to exit back to the main setup menu.

Press 0 for "Exit museek setup", Press 1 for "Save changes".

8b) Create museekd startup script

# sudo touch /etc/init.d/museekd

# sudo nano /etc/init.d/museekd

Paste the following: (NOTE: Change the MUSEEKD_USER to your username and MUSEEKD_CONFIG to your user folder!)

#! /bin/sh

# Written by chopeen
#
# Based on SeeSchloss' museek & mulog init.d scripts for Gentoo
#

MUSEEKD_USER=foobar
MUSEEKD_CONFIG=/home/foobar/.museekd/config.xml
MUSEEKD_PATH=/usr/bin

case "$1" in
start)
echo "Starting museekd as user $MUSEEKD_USER"
start-stop-daemon --start --quiet --exec $MUSEEKD_PATH/museekd --chuid $MUSEEKD_USER --background --pidfile /var/run/museekd.pid --make-pidfile -- -c $MUSEEKD_CONFIG
;;
stop)
echo "Stopping museekd"
start-stop-daemon --stop --quiet --pidfile /var/run/museekd.pid
;;
esac

exit 0

Press CTRL-X to save and Exit the Nano text editor.

8c) Make museekd startup script executable

# sudo chmod +x /etc/init.d/museekd

8d) Add the museekd script to startup

# sudo update-rc.d museekd defaults

The Museek Daemon should now start automatically when the server boots up

8e) Connect to Museek and download music via Murmur

# sudo apt-get install murmur

# murmur

Settings -> Museek Settings

Replace "localhost" with the ip address or hostname of your server retaining the port 2240 at the end

Type in your password and hit OK

File -> Connect

9) Install an eggdrop irc bot (NOTE: if you don't want an eggdrop IRC bot, you can skip this step!)

9a) Change to your home folder

# cd ~

9b) Download eggdrop files

# wget ftp://ftp.eggheads.org/pub/eggdrop/source/1.6/eggdrop1.6.19+ctcpfix.tar.gz

9c) Extract eggdrop files

# tar zxvf eggdrop1.6.19+ctcpfix.tar.gz

9d) Change to eggdrop folder

# cd eggdrop1.6.19

9e) Run configure before compiling the bot

# sudo ./configure

9f)Compile the config

# sudo make config

9g) Compile the bot

# sudo make

9h) Install the bot

# sudo make install DEST=/home/$USER/eggdrop

9i) Change to installed bot directory

# cd ~/eggdrop

9j) Edit the bot config (NOTE: Please read the ENTIRE config, you need to comment out some lines that say "DIE" at the beginnging or the bot wont run)

# nano eggdrop.conf

Add the omgirc server: irc.omgirc.com
Add the omgirc channel: #chatzone and #bots

9k) Run the bot

# ./eggdrop -m eggdrop.conf

The bot will connect to the OMGIRC irc network and join the channels you entered into the config file.

9l) Add yourself as the master of the bot

Resume irssi screen session

# screen -r

Message the bot

/msg bots_name hello

Bot didn't show up?

Check the log file -> ~/eggdrop/logs/eggdrop.log

9m) Add bot to start on boot

# cd ~/eggdrop/scripts

# chmod 700 autobotchk

# ./autobotchk eggdrop.conf -dir /home/$USER/eggdrop -noemail

Confirm the added crontab for the bot

# crontab -l

10) Install Hamachi VPN

10a) Install tun module

# sudo modprobe tun

10b) Add tun to modules list

# sudo nano /etc/modules

Your file should look something like this:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
rtc
tun

Press CTRL-X to save and Exit the Nano text editor.

10c) Check if tun has been sucessfully installed

# ls /dev/net/tun

You should get the following output:

/dev/net/tun

If you recieved something along the lines of "No such file or directory", then manualy create it with step 11d. If not, skip to step 11e.

10d) Manually create tun

# sudo mkdir /dev/net
# sudo mknod /dev/net/tun c 10 200

10e) Download hamachi

# wget http://www.timashley.me/files/hamachi-0.9.9.9-20-lnx.tar.gz

10f) Extract hamachi

# tar zxvf hamachi-0.9.9.9-20-lnx.tar.gz

10g) Change to hamachi folder

# cd hamachi-0.9.9.9-20-lnx/

10h) Install hamachi

# sudo make install

10i) Run tunnel

# sudo tuncfg

10j) Create hamachi group

# sudo groupadd hamachi

10k) Add yourself to the group

# sudo gpasswd -a $USER hamachi

10l) Add root to the group

# sudo gpasswd -a root hamachi

10m) Add correct permissions to tuncfg socket

# sudo chmod 760 /var/run/tuncfg.sock

10n) Change the owner of tuncfg socket

# sudo chgrp hamachi /var/run/tuncfg.sock

10m) Initalize hamachi vpn

# sudo hamachi-init -c /etc/hamachi

10o) Start hamachi vpn

# sudo hamachi -c /etc/hamachi start

10p) Identify your server on the vpn

# sudo hamachi -c /etc/hamachi set-nick "COMPUTER NAME"

10q) Login to hamachi vpn

# sudo hamachi -c /etc/hamachi login

10r) Create hamachi vpn network

sudo hamachi -c /etc/hamachi create NETWORKNAME PASSWORD

10s) Touch init.d hamachi boot script

# sudo touch /etc/init.d/hamachi

10t) Create init.d hamachi boot script

# sudo nano /etc/init.d/hamachi

Insert the following:

#!/bin/sh

hamachi_start() {
echo "Starting hamachi..."
/sbin/tuncfg
/usr/bin/hamachi -c /etc/hamachi start
/bin/chmod 760 /var/run/tuncfg.sock
/bin/chgrp hamachi /var/run/tuncfg.sock
}

hamachi_stop() {
echo "Stopping hamachi..."
killall tuncfg
/usr/bin/hamachi -c /etc/hamachi stop
}

hamachi_restart() {
hamachi_stop
sleep 1
hamachi_start
}

case "$1" in
'start')
hamachi_start
;;
'stop')
hamachi_stop
;;
'restart')
hamachi_restart
;;
*)
hamachi_start
esac

Press CTRL-X to save and Exit the Nano text editor.

10u) Give execution permission to hamachi boot script

# sudo chmod +x /etc/init.d/hamachi

10v) Add hamachi vpn to boot startup

# sudo update-rc.d hamachi defaults

Repeat steps on every computer, desktop, laptop or server to join it to the vpn.

To join the network:

# sudo hamachi -c /etc/hamachi join NETWORKNAME PASSWORD


Teh haps'

Type your Nick

User login