Headless Bit Totternt / Web server / NAS / FTP

Tayonas

Provider
Joined
Dec 16, 2005
Posts
173
Avatar Name
Barry Tayonas Marshall
Using old junk I built something that I decided was overpriced, at the time at least. The junk I had kept from old builds in boxes anyway.

This needs updated slightly, I lost my HDD a few months back and this wasn't on the list of backups because it was a side project. Parts missing are how to use a Dynamic DNS service so you can control it from anywhere on the planet via the net, FTP, adding an HDD to keep all your files seperate from the OS and torrent client plugins so that it automatically stops seeding after x amount of share ratio and the RSS plugin so that it automatically downloads from sites. I will edit them in later.

Duron 900
Old iWill RAID mobo
512MB RAM
64MB something ancient AGP video card
30GB HDD thats actually 9 years old and I remember buying it 9 years ago and I have no idea how it turned up
Ubuntu 9.04 Server Edition which is free anyway

Now all I need are a couple of big disks :) Right now Im thinking 2 x 1TB and I wonder, if this is archived and read in 2 years how 2TB total sounds lol.

This 'guide' assumes your network is already setup correctly, your client machines are XP and you, like me, have little experience with any of this. This is my 2nd day (less than 20hrs) with Ubuntu, so difficulty level is set to easy.

You may run into trouble and need to open up ports on your router, generally the ports you are working on are the ones that need opened/forwarded/virtual servered. Your gonna need the instruction manual for that if you havent done it before :)

I wont go into the basic obvious setup stuff unless its referred to later.

Code:
Hostname: The name you want to call your box (I sometimes refer to it as yourboxname).

Guided - Use entire partition.

Username and password: This will be your main account for logging on and doing 'stuff'.

http proxy: if you dunno what it is you prolly dont have one.

At software selection only select these:

LAMP server
Openssh server
Samba server

MySQL root password: I use a different here than from my username/password earlier.

Now go download PuTTY for windows while waiting and after reboot login using the Username and password from setup like this.

Start PuTTY and in the Hostname/IP box type the name you gave your box earlier, dont hit return yet though.
Click SSH > X11 > Tick Enable X11 forwarding and in X display location put 127.0.0.1

Go back to the sessions page and under Saved Sessions put in your box name and then hit SAVE. Now you can hit open and connect.


Now put these in:

Code:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xauth
sudo apt-get install azureus
sudo apt-get install screen
sudo apt-get install beep

In PuTTY lets make a shared folder called shared that everyone can eventually use:

Code:
sudo mkdir /shared
sudo chmod 0777 /shared

Now lets backup and remake the config file for samba:

Code:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo nano /etc/samba/smb.conf

Paste this in:

Code:
[global]
    ; General server settings
    netbios name = hostname
    server string = ishare
    workgroup = MSHOME
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_$

    passdb backend = tdbsam
    security = user
    null passwords = true
    username map = /etc/samba/smbusers
    name resolve order = hosts wins bcast

    wins support = yes

    printing = CUPS
    printcap name = CUPS

    syslog = 1
    syslog only = yes

; NOTE: If you need access to the user home directories uncomment the
; lines below and adjust the settings to your hearts content.
;[homes]
;    valid users = %S
;    create mode = 0600
;    directory mode = 0755
;    browseable = no
;    read only = no
;    veto files = /*.{*}/.*/mail/bin/

; NOTE: Only needed if you run samba as a primary domain controller.
; Not needed as this config doesn't cover that matter.
;[netlogon]
    ;path = /var/lib/samba/netlogon
    ;admin users = Administrator
    ;valid users = %U
    ;read only = no

; NOTE: Again - only needed if you're running a primary domain controller.
;[Profiles]
    ;path = /var/lib/samba/profiles
    ;valid users = %U
    ;create mode = 0600
    ;directory mode = 0700
    ;writeable = yes
    ;browseable = no

; NOTE: Inside this place you may build a printer driver repository for
; Windows - I'll cover this topic in another HOWTO.
[print$]
    path = /var/lib/samba/printers
    browseable = yes
    guest ok = yes
    read only = yes
    write list = root
    create mask = 0664
    directory mask = 0775

[printers]
    path = /tmp
    printable = yes
    guest ok = yes

; Uncomment if you need to share your CD-/DVD-ROM Drive
;[DVD-ROM Drive]
    ;path = /media/cdrom
    ;browseable = yes
    ;read only = yes
    ;guest ok = yes

[Share Name]
    path = /shared
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0644
    directory mask = 0755
;    force user = yourlogin
;    force group = yourlogin


Parts to change

Code:
[global]
    ; General server settings
    netbios name = hostname		<- The Hostname of your box
    server string = ishare		<- A description for your box
    workgroup = MSHOME			<- The workgroup your computers are on, this is the most common XP

[Share Name]	<------------------------- This is what it will be called on the network			
    path = /shared			<- The shared folder you made
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0644
    directory mask = 0755
;    force user = yourlogin		<- I have these commented out, if at the end yours doesnt work 
;    force group = yourlogin		<- delete both the ; and put your PuTTY/root login name there

Press
Code:
control + x
to save then yes etc. to exit.

Restart Samba:

Code:
sudo invoke-rc.d samba restart

Add a pass to your own samba logon details, the pass can be different from Windows or your box:

Code:
sudo smbpasswd -L -a yourlogin
sudo smbpasswd -L -e yourlogin

Add user logons so everyone/all the computers can get access to the share, replace newuser with the username you desire and the new smb password thats requested with one you want:

Code:
sudo useradd -s /bin/true newuser
sudo smbpasswd -L -a newuser
sudo smbpasswd -L -e newuser

Done this way so that Windows isnt storing my boxes root user details.

Back to XP and in 'My Computer' goto Tools > Map Network Drive
Pick a letter
Click on Connect using a dofferent username. Now in there put in one of the logins you just created under samba, ok it and then for the folder enter \\boxhostname\Share Name hit finish and it should take you right in. Remember the share name is the one in [brackets] from earlier.

And thats your shared space.

You actually probably need to give your box a sudo reboot about now, youve essentially just changed what network it is on etc. The default it is installed with is workgroup and xp go for MSHOME.


Now get the torrent client up and running, for this we need XMing and its fontsso our windows machine can connect for a quick log on to do some setting up before we put it to bed.

Basically install them and then launch XMing, leave it running in the background and then its back to PuTTY. This is where the extra setting up and saving comes in handy from earlier. Close any PuTTY session you have and then restart one. After your logged on type
Code:
azureus
and up should come an Azureus GUI. This will be the only time you see this. Get the updates and setup your speeds, also in tools/options setup your folder in transfers so its pointing to your shared folder and tell it to automatically download (or is it upload)/no confirmation needed, theres only the one anyway. Goto the plugin installation wizard and download azhtmlwebui and once its installed go to tools > options > plugins, click on its box and configure your settings. Youll want to put a pass on it since right now anyone can log one and probably change to https. Once its done and settings are saved its time to close it down and make a daemon for it. Before we do though lets get our browsers and go to https://localhost:6886/ and the Azureus webgui should appear and you will be able to log on, if not you have to check port settings on your router or anything that maybe blocking. If you get your external IP then you should be able to access it from anywhere on the planet, youll need a dynamic ip account at somewhere like dynip.

I couldnt find a startup feature or anything that worked so I went right ahead to try and rip off, I mean use, someone elses great one and that never went well at all so I made a basic one and its all you really need. This also uses a method I couldnt see anywhere so any and all improvements welcome, if someone could show me how to do if statements in this then that would be a result.

In PuTTY:

Code:
sudo nano /usr/share/java/azureus_daemon

Now in there paste:

Code:
#! /bin/sh

 #The user that will run Azureus
 AZ_USER=anybody

 #Name of the screen-session
 NAME=cackles_azureus_daemon

 #executable files in the following paths that are perhaps needed by the script
 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/share/java

 #your path to the azureus directory, where Azureus2.jar is located
 DIR=/usr/share/java/

 #Description
 DESC="Azureus Daemon"


 set -e


 case "$1" in
 start)
       echo "Starting $DESC: $NAME"
       su $AZ_USER -c "cd $DIR; screen -dmS $NAME java -jar ./Azureus2.jar --ui=console"
       su $AZ_USER -c "screen -S $NAME -X start all"
       echo "Azureus Daemon Started"
    ;;
 stop)
       su $AZ_USER -c "screen -S $NAME -X quit"
       echo " Daemon Has Been Stopped"
    ;;
 check)
        su $AZ_USER -c "screen -S $NAME -X show torrents all"
    ;;
 daemons)
         su $AZ_USER -c "screen -list"
    ;;
 esac

 exit 0

Then change anybody to your root logon name, no need for pass or anything.

Code:
AZ_USER=anybody
Control + X to get out and save that and then:

Code:
sudo chmod a+x /usr/share/java/azureus_daemon

Ok so I used the wiki one only made it run on my machine and mines also automatically resumes your torrents :)

Lets see if it works. Make sure you are in /usr/share/java/ and type:

Code:
sudo ./azureus_daemon start

That should start the server. Use your browser and goto http://localhost and make sure its working.

Code:
sudo ./azureus_daemon daemons

will let you see your daemon running.

Code:
sudo ./azureus_daemon check

will let you see any torrents that are downloading.

Code:
sudo ./azureus_daemon stop

Stops ... There are no safeties built into this but if you play with and rack up too many daemons theres always reboot with no harm done :)

Now we need to get it to run at startup.

Code:
sudo nano /etc/rc.local
And make sure yours is like this:

Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

sudo /usr/share/java/azureus_daemon start
beep -r 5

exit 0

You should have only needed to add one line for azureus, but we added two so that our headless machine beeps 5 times when its has started up and loaded everything. Remove the beep line if you dont want it. You can also add log on messages here with echo "message including the quotes". exit 0 should always be the last thing.


Code:
sudo reboot

And that should be that!
 
Notes 'n' Stuff

Notes:

If this tut looks familiar it's because I wrote it about 3 years ago, but it's mine.

Because Ubuntu has moved on a few versions since I originally wrote this somethings maybe a little off, but it does work if you follow it. Also waiting on some features being reverted/fixed to implement them again.

Computer config has changed to:

P4 2.4
4GB RAM
30GB HDD with 1.5TB storage


Umm could a mod please change the title to
Headless Bit Torrernt / Web server / NAS / FTP / Ubuntu

Seeings how I managed to call it Bit Tottent ...

'But I was drunk'
 
Last edited:
Great tutorial. Too bad I can`t rep you cos you posted in offtopic section.:)
 
Haven't used the forum enough to know exactly where to post it.
 
Back
Top