📜 ⬆️ ⬇️

Realization of some tasks for self-assembled NAS

Hi, Habr. I finally matured in order to collect my own network storage. The goals and objectives are simple - download torrents, distribute content via DLNA to the IP-TV console MAG-245, iPad Mini, the first generation and smartphone on Windows Phone OS. Given the fact that I already had the necessary base, namely, the Intel D425KT mini-ITX motherboard with a built-in dual-core Atom processor with passive cooling; 2 gigabytes of notebook RAM, and notebook HDD Seagate 750Gb. I bought only the 3Cott M01 case, complete with which was a laptop-type power supply unit and an adapter for it.

During the "combat" tests, it turned out that in a tight case without a single fan, the hard disk warms indecently, so it was decided to take it out of the case and attach it to the adapter from the SSD. This design lives on the closet in the hallway next to the router and does not bother anyone.



The starting point for the experiments was the article on Habré "Home media server based on Ubuntu Server 12.04 LTS" by PaulZi . She was my main guide.
')
Actually, I don’t want to do copy-pasting, for this article Ubuntu Server 14.04 were installed, the simplest Samba-ball, the Transmission torrent client and the MiniDLNA service were set up. But then there were other tasks.

1. Automatic mounting of usb devices when connected, unmounting by pressing the power key


The automatic mount was solved using the udev configuration, for which the rule /etc/udev/rules.d/10-automount.rules was created with the following parameters:

SUBSYSTEM=="block", KERNEL=="sd[bz][0-9]", ACTION=="add", RUN+="/bin/mount -o iocharset=utf8,codepage=866,uid=1000 /dev/%k /mnt/flash" SUBSYSTEM=="block", KERNEL=="sd[bz][0-9]", ACTION=="remove", RUN+="/bin/umount /mnt/flash" 

Since the power button is practically not used, it was decided to hang up on it the task of unmounting the connected USB drives. First you need to edit the file /etc/systemd/logind.conf and replace
 #HandlePowerKey=poweroff 
on
 #HandlePowerKey=ignore 

Then bring / etc / acpi / events / powerbtn to the form:

 event=button[ /]power action=/etc/acpi/powerbtn.sh 

And at the end of /etc/acpi/powerbtn.sh edit to:

 #!/bin/sh umount /dev/sdb1 

Run:

 sudo udevadm control --reload-rules sudo service systemd-logind restart 

Done!

Now, when connected to the front usb connector, any device will be automatically mounted to / mnt / flash , and if you briefly press the power button, it will be unmounted. Keep in mind that my rules for one disk, if there are more, you need to edit the sd [.. z] field.

What is it for? For example, I have a friend who lives in the village, and there is no fast, and especially unlimited internet there. So I download movies to him on the flash drive and all that I ask. Of course, copying is faster on the local host than through the entire network, but there is no desire to manually mount and unmount the drives each time the USB flash drive is connected to the NAS. This is such a small automation.

2. Torrent control from iPad to iOS 7.1.2 without jailbreak


I found the basis of the method here , refer to it in order not to copy-paste. The idea is for Transmission to automatically pick up torrent files from a specific folder (in this case from Dropbox) and start downloading them. It would seem, and here iPad? So, from him I want to add files to the queue. For this, I use the iCab Mobile browser (paid), the functionality of which is much broader than that of Safari. In particular, iCab can download torrent files from trackers, as well as connect Dropbox. Then everything is simple:

- download torrent file:



- tap on it in “Downloads” and select “Upload file to Dropbox” (whose account we have already connected in the iCab settings):



- the torrent file appears on the NAS, it is captured by Transmission, which we can verify by opening the web interface - and the download starts:



To play a video from a NAS, I use the AVPlayerHD iOS program, which reproduced everything I offered to it, and which can play on DLNA. Bonus is the ability to run on the iPad FTP-server and upload video over Wi-Fi, without using iTunes.



That's all, thank you for your attention.

Source: https://habr.com/ru/post/256173/


All Articles