Personal tools

Headless Linux Fileserver

From Dtella Wiki

Jump to: navigation, search

This is a quickstart tutorial on getting a headless dtella fileserver running quickly on Linux distributions.

Contents

Overview of Steps

  1. Download microdc2 from your distribution repository (or compile)
  2. Run microdc2 once to generate configuration files
  3. Edit ~/.microcd2/config to set up sharing
  4. Download Dtella from www.dtella.org. Get the one for Linux
  5. Start a 'screen' and start microdc2 and dtella
  6. Create a script to easily start dtella and microdc2.


Installation

Software you'll need:

  • microdc2 - a lightweight no frills DC++ client that is perfect for setting up a small dtella server on.
  • screen - a tool commonly used to keep applications running on a computer after a user logs out (sometimes already installed)
  • SysV or systemd - program that starts all other programs (usually already installed)
  • dtella

Configuration

microdc2

  • Get dtella and place it in your home directory
wget http://dtella.googlecode.com/files/dtella-purdue-1.2.7.tar.bz2
tar xvf dtella-purdue-1.2.7.tar.bz2
rm dtella-purdue-1.2.7.tar.bz2
  • Run microdc2 in the terminal to generate the config directory, then close it.
    microdc2
  • Open up ~/.microdc2/config with your favorite text editor. Here is an example configuration. Be sure to replace the fields in brackets with proper values.
set listenport 1555
set active on
set auto_reconnect on
# The following enables logging. Replace the logfile with wherever you want it to log to. You can of course turn it off by leaving the following two lines blank
set log_charset UTF-8
set logfile /home/[USER]/.microdc2/log
# These should all be pretty self-explanatory. Nick is your nickname. If the hub requires a password, specify one here.
set description A dtella filesharing server
set nick [NICK]
set downloaddir /home/[USER]/downloads
# The set speed option doesn't actually change anything, it only changes your REPORTED speed that other users see. The slot is how many simultaneous downloads people can get from you.
set speed somerandomstring
#This is how many people can download from you at any given time
set slots 4
#This is the hub connect command, it should be left until last
connect 127.0.0.1:7314
#Set your shared directories here
share /home/[USER]/Music
share /home/[USER]/Games
share /home/[USER]/Movies

Network Configuration

Dtella uses two ports for its connection (TCP for file transfer, and UDP for connecting to the hub). We will use ports 1555 (TCP) and 1666 (UDP) for consistency with other tutorials, but they can be set to whatever you want (You will have to change these if you want to run two clients from the same subnet). Remember to port forward these.


You already set port 1555 in microdc2's config, so now run the dtella python script to set the other port.

python /path/to/dtella/dtella.py

Now in the dtella.py shell, run:

 !udp 1666 

the changes are now written to the dtella.py config.


Connecting to Dtella

With the dtella python script still running, open up microdc2 and test your connection to dtella.

microdc2

You should see a loading bar appear briefly and then the message "Sync Complete; You're Online!"


Your server is now online and sharing files with other users! You can also get files using microdc2 with the search, results, browse and get commands. You must have shared at least 5GB to download from other users.


Creating a Script

In your dtella folder, create a script to launch dtella.py and microdc2

#!/bin/bash
python /home/[USER]/dtella-purdue-1.2.7/dtella.py &
microdc2 -c /home/[USER]/.microdc2/config

Make sure this script is executable

sudo chmod +x [dtella_microdc2]

Run this script to make sure that it works.

Run at Startup

You don't want to manually run your script every time your computer starts up, so well use an init system to do this automatically. systemd is currently the recommended way of doing this, but you can use SysV for systems that don't support it.

systemd

Create a new file in "/etc/systemd/system/dtella.service" with the following contents".

[Unit]
Description=microdc2 Dtella Server
After=network.target
[Service]
Type=forking
User=[USER]
WorkingDirectory=/home/[USER]/dtella-purdue-1.2.7
ExecStart=/usr/bin/screen -L -d -m -S dtella /home/[USER]/dtella-purdue-1.2.7/dtella_microdc2
ExecStop=/usr/bin/screen -S dtella -X quit
Restart=on-failure
[Install]
WantedBy=multi-user.target

Now execute these commands to reload systemd and enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable dtella.service
sudo systemctl start dtella.service

SysV init

Open the file "/etc/rc2.d/S99local" and append the following line, adding in the complete path to your startup script. If the file does not already exist, create it.

su - [USER] -c "screen -dmS dtella /home/[USER]/dtella-purdue-1.2.7/dtella_microdc2"

Make the script executable.

sudo chmod +x /etc/rc2.d/S99local

Fin

Your script should now start at reboot. You can connect to your server using

screen -x dtella

Detach by either closing the window or typing "Ctrl+a" and then hit "d".

Congraturrations! Yuu now dterra masta.

Bowing.jpg