Skip to content

Instantly share code, notes, and snippets.

@gtwy
Last active November 24, 2019 23:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtwy/a3e0b29435abeee8a8da8b0b211daef5 to your computer and use it in GitHub Desktop.
Save gtwy/a3e0b29435abeee8a8da8b0b211daef5 to your computer and use it in GitHub Desktop.
Ubuntu ISO Host Server
########################################################################
############################## Ubuntu ISO Server v0.2.0 ### 2018-10-21 #
########################################################################
# These notes explain how I built an open source Ubuntu ISO server.
# ISOs are large files that are needed to install open source software.
# These notes are updated frequently and I use them each time I
# rebuild my server.
#
# Because linux is free, using my computer to share various linux
# ISOs helps the open source community. To do this, I am using the
# torrent protocol. The torrent protocol allows anyone with an Internet
# connection to help.
#
# WARNING:
# The purpose of this document is to share linux ISOs. Using these
# commands for anything other than sharing open source software is
# strictly prohibited.
#
# In fact, this document is not a guide at all. This gist exists soley
# as my own personal notes. You do not have authorization from me to
# follow these notes. Do not use this document for anything.
#
# This document comes with no warranty or guarantee, expressed or
# otherwise. You have been warned!
# Fresh install of Ubuntu. (Latest tested: Ubuntu 18.04)
- Enable 3rd party repos.
- Make username "tor"
- Make computer name "isohost"
# GUI Only: Once installed, at login screen, press Ctrl Alt F1 to exit GUI
# Login as tor
sudo -i
apt-get update
apt-get dist-upgrade
reboot
# GUI Only: Ctrl Alt F1 again to exit GUI.
# Login as tor
sudo -i
apt full-upgrade
apt autoremove
apt install openssh-server
systemctl enable ssh
systemctl start ssh
ip address # Write down the IP address
exit
exit
# Open connection to new server with ssh (putty on windows)
# Connect to the ip address of the server
# Login as tor
sudo -i
# Create directories and set permissions
mkdir -p /storage/Downloads/.rtsession/
mkdir /storage/Uploads
chmod -R g+rw /storage && chown -R tor:tor /storage
# Setup crontab to fix permissions once a day
crontab -e
# crontab (append this line to the bottom of the crontab)
33 3 * * * chmod -R g+rwX /storage && chown -R tor:tor /storage > /dev/null 2>&1
##
# Install all the packages
apt install apache2 libapache2-mod-scgi libapache2-mod-xsendfile screen mediainfo ffmpeg unrar samba git-all php libapache2-mod-php php7.2-curl php7.2-geoip php7.2-xml php7.2-mbstring unzip pkg-config build-essential automake checkinstall libtool libncursesw5-dev libncurses5-dev libxmlrpc-c++8-dev libcurl4-openssl-dev zlib1g-dev libcrypto++-dev libssl-dev curl rar sox
# Go to home directory and download sources for rtorrent/libtorrent
cd
git clone https://github.com/rakshasa/rtorrent.git
git clone https://github.com/rakshasa/libtorrent.git
# Compile and install rtorrent/libtorrent
cd libtorrent/
./autogen.sh
./configure
make
make install
cd ../rtorrent
ldconfig
./autogen.sh
./configure --with-xmlrpc-c
make
make install
# Add tor and www-data to each other's groups
adduser tor www-data
adduser tor tor
adduser www-data tor
adduser www-data www-data
# Configure apache
vim /etc/apache2/apache2.conf
# apache2.conf (add this, change nothing else)
<Directory "/var/www/ruTorrent">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
##
vim /etc/apache2/sites-enabled/000-default.conf
# 000-default.conf (completely replace file with this)
<VirtualHost *:80>
ServerAdmin user@isohosts.domain.tld
DocumentRoot "/var/www/ruTorrent"
SCGIMount /RPC2 127.0.0.1:5000
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
##
# Configure rTorrent
vim /home/tor/.rtorrent.rc
# .rtorrent.rc (create new file with this)
network.scgi.open_port = 127.0.0.1:5000
network.port_range.set = 18000-18100
trackers.use_udp.set = yes
network.port_random.set = yes
protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext
directory.default.set = /storage/Downloads/
session.path.set = /storage/.rtsession/
schedule2 = watch_directory,5,5,load.start=/storage/Uploads/*.torrent
schedule2 = untied_directory,5,5,stop_untied=
protocol.pex.set = no
encoding.add=UTF-8
system.daemon.set = true
pieces.hash.on_completion.set = no
throttle.global_down.max_rate.set_kb = 20480
throttle.global_up.max_rate.set_kb = 51200
##
# Set owner of rTorrent config
chown tor:tor /home/tor/.rtorrent.rc
# Download and configure ruTorrent.
cd /var/www/
git clone https://github.com/Novik/ruTorrent.git
vim ruTorrent/conf/config.php
# config.php (verify these lines, usually only profile mask needs adjusted)
$saveUploadedTorrents = true;
$overwriteUploadedTorrents = false;
$topDirectory = '/';
$scgi_port = 5000;
$scgi_host = "127.0.0.1";
$XMLRPCMountPoint = "/RPC2";
$localhosts = array(
"127.0.0.1",
"localhost",
);
$profileMask = 0775;
$tempDirectory = null;
$canUseXSendFile = true;
$locale = "UTF8";
##
#Set permissions of ruTorrent folder
chown -R www-data:www-data /var/www/
chmod -R g+rw ruTorrent
# Create system service for rTorrent
cd /etc/systemd/system
vim rtorrent.service
# rtorrent.service (create file with this)
[Unit]
Description=rTorrent Daemon
Wants=network.target
After=network.target
[Service]
Type=simple
KillMode=process
User=tor
ExecStart=/usr/local/bin/rtorrent
WorkingDirectory=/home/tor/
Environment=/home/tor/
Restart=on-failure
UMask=002
[Install]
WantedBy=multi-user.target
##
# Set permissions and enable services for webserver and rTorrent
chmod a+wx rtorrent.service
systemctl daemon-reload
systemctl start rtorrent
systemctl enable rtorrent
systemctl enable apache2
systemctl start apache2
# Configure samba (file sharing)
cd /etc/samba/
mv smb.conf smb.conf.backup
vim smb.conf
# smb.conf (create file with this)
[global]
workgroup = WORKGROUP
server role = standalone server
server string = ISO Server
netbios name = isoserver
security = user
map to guest = bad user
dns proxy = no
guest account = tor
create mask = 0664
directory mask = 0775
force user = tor
force group = tor
[Downloads]
path = /storage/Downloads
available = yes
browseable = yes
writeable = no
guest ok = yes
read only = yes
[Uploads]
path = /storage/Uploads
available = yes
browseable = yes
writeable = yes
guest ok = yes
##
# Enable service for Samba (file sharing)
systemctl enable smbd
systemctl start smbd
# Allow ports through ufw (required in newer versions of Ubuntu)
ufw allow http
ufw allow 18000:18100/tcp
ufw allow 18000:18100/udp
ufw allow 137
ufw allow 138
ufw allow 139
ufw allow 445
# Reload the ufw firewall rules
ufw disable
ufw enable
# GUI Only: Create desktop shortcut for user tor
exit
ln -s /storage/ ~/Desktop/Storage
exit
# Recommended:
- Set a static IP on the isohost OR static DHCP lease on your router
- Forward ports 18000-19000 TCP/UDP to the IP of the isohost
# Changelog:
* 2018-10-21
- Updated to work with Ubuntu 18.04 and php 7.2:
- Added packages to apt install: php7.2-curl php7.2-geoip php7.2-xml php7.2-mbstring (Line 47)
- Please note that above packages are dependent on php 7.2. Adjust accordingly for future releases!!
- For additional details: https://github.com/Novik/ruTorrent/issues/1779
- Converted scgi port in .rtorrent.rc to new syntax (Line 98)
- Please note: after upgrading from 17.10 to 18.04, changes with curl broke rTorrent.
- To fix, update the source for both libtorrent and rtorrent and build each again.
- For additional details: https://github.com/rakshasa/rtorrent/issues/778
- Fixed an incorrect comment. (Line 39)
- Replaced ifconfig with ip address. (Line 24)
* 2017-11-24
- Changed crontab to run once a day instead of every 5 minutes. (Line 42)
* 2017-11-11
- Added curl & rar packages to apt install (Line 47)
- Added upload and download bandwidth limits to .rtorrent.rc. (20MB/50MB) (Lines 111-112)
- Added ufw commands to allow ports through firewall (Lines 233-244)
- Tested script with Ubuntu 17.10.
* 2017-10-18
- Put "apt autoremove" back. (Line 20)
- Changed .rtorrent.rc config from 18000-19000 to 18000-18100 (Line 99)
* 2017-10-02
- Changed "apt dist-upgrade" to "apt-get dist-upgrade" (Line 13)
- Removed "apt autoremove" and changed "apt upgrade" to "apt full-upgrade" (Line 19)
* 2017-10-01
- The current stable version of rTorrent does not support daemon mode. This broke my script. We must build from source.
- The new version of rTorrent (built from source) uses a different configuration syntax.
- The new version of rTorrent will be located in /usr/local/bin/ instead of the old path /usr/bin/
- Added dependencies for building rTorrent to apt install (Line 47)
- Added instructions for downloading and compiling rTorrent/libtorrent source
- Updated rTorrent configuration to new syntax
- Updated systemd service configuration
- For additional details: https://gist.github.com/gtwy/48cd571502256429d4b571d270961c95
* 2017-07-27
- Fixed a typo in a file path for ruTorrent config
* 2017-04-27
- Removed instructions for editing /etc/groups and replaced with adduser command
* 2017-04-26
- Changed installation method for ruTorrent from wget/unzip to git clone.
This resolved many issues with ruTorrent as they have stopped updating
the zip file version of ruTorrent.
- Changed rTorrent service to inbuilt daemon instead of running inside tmux
See here: https://github.com/rakshasa/rtorrent/pull/446
* 2017-04-14
- Fixed formatting of comments to make reading easier
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment