Skip to content

Instantly share code, notes, and snippets.

@scottopell
Last active February 24, 2020 08:03
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 scottopell/0b863ebdf369527ad5497616ba17b521 to your computer and use it in GitHub Desktop.
Save scottopell/0b863ebdf369527ad5497616ba17b521 to your computer and use it in GitHub Desktop.
Setup torrent + media server on Orange Pi HC2

Orange pi HC2 setup

This is my 3rd iteration of this guide, and now it appears that armbian officially supports the orange pi pc2!

Goals

  • rtorrent
  • plex
  • flood (or similar rtorrent web interface)
  • support external usb3 hd with exfat

Process

I'm going to do my best to document everything start -> finish.

Linux Install

Base image: armbian

I set up static dhcp routing beforehand, so I already know the ip, but if you didn't do this then check your connected devices on your router page, or run a portscan on your subnet before and after plugging in the device.

Example nmap command: nmap -p 22 192.168.1.0-255

Check the armbian page for initial login credentials, currently its user root and password 1234

Follow the prompt to create a user account, then once you've done that kill the ssh connection and start a new one with the new user account.

Now its ready for specific software.

Plex

I remember plex being easy, so lets give that a shot. @uglymagoo has an awesome repo for this.

Actual link is here https://www.dev2day.de/projects/

wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -

I used the armbian bionic which is ubuntu bionic which is ~ debian stretch I believe.

I have in my notes from last year that this implies architecture armhf, which I'm just going to trust, but there are links below.

I'm not super clear on the finer points of arm64 vs armhf (arm hard-float) vs armv7 and how multiarch works in debian. More reading here and here and here and here

Note that even though some of the above links claim you need to do dpkg --add-architecture armhf, I didn't find this necessary. For reference, dpkg --print-architecture returns arm64 and dpkg --print-foreign-architectures returns armhf.

echo "deb [arch=armhf] https://dev2day.de/pms/ stretch main" | sudo tee /etc/apt/sources.list.d/pms.list

# Not sure why this one is needed, its new on the dev2day.pe site from last time. Figure it can't hurt
sudo apt-get install apt-transport-https

sudo apt update

sudo apt install plexmediaserver-installer -y

Check service plexmediaserver status and make sure it doesn't display any errors. If it does, try restarting it via sudo service plexmediaserver restart

Now you should be able to go to http://<your-orange-pi-ip-addr>:32400/web and login to plex.

External ExFat drive

I like exFat because its the best modern filesystem that I've found for multi-platform usage (windows and osx support it out of the box, linux supports it pretty easily).

  1. Plugin usb drive
  2. udevadm info --query=property -n /dev/sda2 for each /dev/sda* until you find your drivename in the output.
  3. sudo apt install exfat-fuse
  4. sudo mkdir /media/myExternalDisk
  5. sudo mount -t exfat /dev/sd? /media/myExternalDisk

Now just make sure you can ls /media/myExternalDisk and see what you want to see.

Now you probably want to go into plex and add your libraries so they can start indexing.

Rtorrent && Web Interface

Here I attempted to get some of the existing rtorrent + flood docker images working on aarch64, but couldn't.

So here are the plain ubuntu instructions:

sudo apt install rtorrent
basedir="$HOME/rtorrent"
mkdir -p "$basedir"/{.session,download,log,watch/load,watch/start}
curl -Ls "https://raw.githubusercontent.com/wiki/rakshasa/rtorrent/CONFIG-Template.md" \
    | sed -ne "/^######/,/^### END/p" \
    | sed -re "s:/home/USERNAME:$HOME:" >~/.rtorrent.rc

Enable xml-rpc by adding this to your .rtorrent.rc scgi_port = localhost:5000

rtorrent is hard to daemonize, I opt for a start.sh script that runs it inside a tmux session

sudo apt install tmux

start.sh:

tmux new-session -s rtorrent -d rtorrent

Rtorrent should be set at this point, now for flood.

Flood

# install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# install node 8.x per flood readme
# use `nvm ls-remote --lts` to find latest long term support branches
nvm install v8.12.0
# clone flood
git clone https://github.com/jfurrow/flood.git ~/flood
cd flood

Follow the rest of the instructions on https://github.com/jfurrow/flood#configuration

Note that flood added a dependency on argon2, which requires node-gyp, which in turn requires python, so you'll probably need to do sudo apt install python as well.

Make sure to change the server address in config.js to 0.0.0.0.

libsass sillyness

Flood uses node-sass to do a production build, which is fine, except node-sass doesn't support arm64.

Node-sass is a node binding into the native lib libsass.

So what you have to do is install everything locally on the orange pi (which builds argon2), then also build on a supported machine (since sass is a build-time dependency, not run-time), then merge the two.

On the orange pi

  1. git clone https://github.com/jfurrow/flood.git ~/flood
  2. sudo apt install python
  3. npm install (to build argon2)

On a libsass supported machine

  1. git clone https://github.com/jfurrow/flood.git ~/scratch/flood
  2. cd ~/scratch/flood
  3. npm install
  4. npm run build
  5. tar -cf ~/scratch/flood_built.tar ~/scratch/flood
  6. scp ~/scratch/flood_built.tar orangepi:~/flood_built.tar

On the orange pi

  1. tar -xf ~/flood_built.tar ~/flood_built
  2. rm -rf ~/flood/node_modules/argon2
  3. cp -r ~/flood_built/node_modules/argon2 ~/flood/node_modules

Now, after a million steps, you should be able to execute npm start in ~/flood just fine.

Now, in the browser, make a user and password, then put in 127.0.0.1 and 5000 assuming you didn't change the default scgi_port in the .rtorrent.rc config.

And now add another line to you trusty start.sh tmux new-session -s flood -d cd ~/flood && npm start

DHT on rtorrent

This is disabled by default. To get it working, I removed the following lines from my .rtorrent.rc

dht.mode.set = disable
protocol.pex.set = no

trackers.use_udp.set = no

And add the following:

dht=auto
dht_port=6881

and then in a running session of rtorrent, I hit ctrl+x to input a command, then ran the following command to bootstrap dht: dht.add_node = dht.transmissionbt.com

Also don't forget to forward the ports via your router.

Plex config tweaks

I always want to have subtitles available, so follow this guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment