rpi_autism

Media Ditorium ─ AUTiSM Rainbow

Name: AUTiSM Rainbow (official) | 라몽 (korean)


Model: Raspberry Pi 2 Model B+ | Raspbierry Pi Model B

Storages — Storage in details

  • 500G~/storage partition
  • 500G~/repository partition

Live status of storages

Mounted on            Type  Size  Used Avail Use%
~/repository          ext4  459G  237G  199G  55%
~/storage             ext4  459G  190G  246G  44%

Júne's home network

  • Wired (AUTiSM-enx001)
  • Wireless (AUTiSM-wlx001)
  • Wired (AUTiSM-enx003)

Video streaming and archives


  • Disable transmission web port, 9090 & 9091 and build proxy_pass pages — Updated on 2020/07/11 03:22
  • Plugin Wired Giga LAN — Updated on 2020/02/22 03:34
  • physically exchange hard disk enclosures — Updated on 2019/06/23 22:57
  • replace HDD enclosure for ~/repository & ~/storage — Updated on 2018/09/04 20:33
  • fresh installation of Raspbian OS — Updated on 2018/09/01 17:32
  • change microSD memory for Raspbian OS — Updated on 2018/05/09 12:59
  • static IP using dhcpcd.conf with fallback option — Updated on 2018/02/25 09:28

+Que to do

  • Register user-create shell script for autocomplete enabled — bash-completion
  • List up the aliases and create user-defined command
  • FlexGet configuration before fresh installation

Update systems with latest packages

sudo apt update && sudo apt dist-upgrade -y 

Install Samba service and related components

sudo apt install samba samba-common-bin 

Add Samba user

sudo smbpasswd -a userid 

Set user's password correctly.

Set configuration

Edit Samba configuration file — /etc/samba/smb.conf

Live Configuration

[userid]
  comment = Any description showing your sharing
  path = /home/userid
  valid user = userid
  #writable = yes
  read only = no
  browseable = yes

If you need to specify Workgroup name with Windows machines,

  workgroup = MYWORKGROUP 

Restart Samba service

sudo /etc/init.d/smbd restart     

or

sudo systemctl restart smbd.service 

Build up Transmission (daemon + web remote) and configuration. Reference: Fundamental information on BitTorrent in Korean (한국어). User should understand basic operation on BitTorrent. If not, your server will have tremendous traffics, which reduce your network resource.

Install transmission

sudo apt install transmission-daemon 

Setup working directories

Decide a few directories to store torrent files for downloads. Do not use directory located on SD memory but use directories mount on USB attached storage. Assume external USB HDD is /dev/sda and mount on /home/userid/BitTorrent

sudo mount /dev/sda /home/userid/BitTorrent 

Create three directories (arbitrary names) for transmission to work efficiently.

mkdir /home/userid/BitTorrent/Downloaded 
mkdir /home/userid/BitTorrent/Downloading 
mkdir /home/userid/BitTorrent/WillDownload 

Downloaded is for the finished files, Downloading is for the downloading files (still downloading or seeding) and WillDownload is used for watching directory, where you put .torrent file will start downloading automatically.

Basically, transmission daemon is operated by user named debian-transmission and also group debian-transmission. Therefore, next step you have to set folder and file permission.

sudo chgrp debian-transmission /home/userid/BitTorrent/Downloaded 
sudo chgrp debian-transmission /home/userid/BitTorrent/Downloading 
sudo chgrp debian-transmission /home/userid/BitTorrent/WillDownload 
 
sudo chmod 770 /home/userid/BitTorrent/Downloaded
sudo chmod 770 /home/userid/BitTorrent/Downloading 
sudo chmod 770 /home/userid/BitTorrent/WillDownload 

BitTorrent directories allow full permission to owner and debian-transmission group and userid is also its member. So debian-transmission and userid users have full permission to create, edit and delete.

Set configuration

Edit /etc/transmission-daemon/settings.json

Live Configuration

    "download-dir": "/home/userid/BitTorrent/Downloaded", 
    "incomplete-dir": "/home/userid/BitTorrent/Downloading",
    "incomplete-dir-enabled": true,    
  
    "rpc-authentication-required": true, 
    "rpc-bind-address": "0.0.0.0", 
    "rpc-enabled": true, 
    "rpc-password": "TYPE_YOUR_OWN_PASSWORD_HERE", 
    "rpc-port": 9090, 
    "rpc-url": "/transmission/", 
    "rpc-username": "userid", 
    "rpc-whitelist": "127.0.0.1", 
    "rpc-whitelist-enabled": false, 
    
    "umask": 6,

umask is sensitive matter to security. If you want to copy/move through samba connection, Set umask as 1 with no further consideration. Append two lines before }

    "watch-dir": "/home/userid/BitTorrent/WillDownload", 
    "watch-dir-enabled": true

Last string line does not have ,. Save settings.json

Restart Transmission

sudo systemctl restart transmission-daemon.service

If there is no error, transmission daemon works correctly and you can access transmission web remote in your browser. Assume machine's IP address (internal) is 192.168.50.10. Transmission Web Interface can be accessed with http://192.168.50.10:9090. Port number can be changed “rpc-port”: 9090 and it could be better when it comes to security.

Set download/upload speed limits in options.

Edit service webpages

Page for Transmission Web is /usr/share/transmission/web/index.html


If need more than one Transmission Web service, duplicate daemon in a single machine. Each service can be serviced with different port number.

Stop the Transmission

sudo systemctl stop transmission-daemon.service

Update with the latest ones

sudo apt update && sudo apt dist-upgrade -y 

Duplicate Transmission daemon

Copy daemon resources and scripts. Call the second daemon as conveyance-daemon

sudo cp /usr/bin/transmission-daemon /usr/bin/conveyance-daemon 
sudo cp /etc/init.d/transmission-daemon /etc/init.d/conveyance-daemon
sudo cp -a /var/lib/transmission-daemon /var/lib/conveyance-daemon
sudo cp -a /etc/transmission-daemon /etc/conveyance-daemon
sudo cp /etc/default/transmission-daemon /etc/default/conveyance-daemon

Create symbolic link for second daemon.

sudo ln -sf /etc/conveyance-daemon/settings.json /var/lib/conveyance-daemon/info/settings.json

Edit the second daemon

Edit /etc/init.d/conveyance-daemon and change NAME with conveyance-daemon

  NAME=conveyance-daemon

Edit /etc/conveyance-daemon/settings.json. Compare and check settings with default values.

Live Configuration

  "download-dir": "new download path of conveyance-daemon"
  "peer-port": 51414, 
  "rpc-username": "NEW_USER",
  "rpc-password": "TYPE_YOUR_NEW_PASSWORD_HERE", 
  "rpc-port": 9092,
  "rpc-whitelist-enabled": false,

Edit /etc/default/conveyance-daemon

  CONFIG_DIR="/var/lib/conveyance-daemon/info"

Update init.d to let conveyance-daemon start at

sudo update-rc.d conveyance-daemon defaults

Restart services

Start the original and the duplicated daemon to check any errors or conflicts

sudo systemctl start transmission-daemon.service
sudo systemctl start conveyance-daemon.service 

If no error, check with Transmission Web Interface. Original one is http://server.ip:9090 and Second one is http://server.ip:9092 according to your port settings.


When downloading finishes in Transmission, get notification via message services.

Getting API from PushBullet

Get API key from PushBullet service — Create Access Token

  • API key is like o.8jh96v9p49vW73X3U4HByxo87MLVw4kM

Getting API from Telegram

To get API from Telegram, need to create Telegram Bot by which notification is sending.

Create Telegram Bot — Create your own Bot with /newbot command.

Finish with specific information in settings such as Bot Name, Description, Profile image and so on.

After finishing Bot, find the API key from BotFather.

  • API key is like 977114901:279gLSo-d7XZokF4QqM69ZfF3xBKtnYQqMk

To create script, it requires chat_id from API key. To figure out chat_id,

Goto https://api.telegram.org/bot977114901:279gLSo-d7XZokF4QqM69ZfF3xBKtnYQqMk/getUpdates

If result returns nothing like chat_id, go to Telegram and give some chats with your Bot. Of course, your Bot never answers you.

Then visit again and it shows something like {“id”:29329664,“first_name”: ….}, and id is your chat_id is 29329664

Modify Transmission service

Stop Transmission

sudo systemctl stop transmission-daemon.service

Append the following lines in /etc/transmission-daemon/settings.json

    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/opt/script/download-done.sh",

Make executive script

sudo mkdir /opt/script   
sudo touch /opt/script/download-done.sh 
sudo chown debian-transmission:debian-transmission /opt/script/download-done.sh
sudo chmod +x /opt/script/download-done.sh
sudo vi /opt/script/download-done.sh

Put script with the following option:

Live Scripts

Script for Pushbullet
#!/bin/bash
curl -u o.8jh96v9p49vW73X3U4HByxo87MLVw4kM: \
        -X POST https://api.pushbullet.com/v2/pushes \
        --header 'Content-Type: application/json' \
        --data-binary "{
                        \"type\": \"note\", 
                        \"title\": \"Transmission in EPiGEN\",
                        \"body\": \"$TR_TORRENT_NAME file is ready @ $TR_TIME_LOCALTIME.\"
        }"
Script for Telegram
#!/bin/bash
TEXT="$TR_TORRENT_NAME is finished"
curl -d "chat_id=29329664&text=$TEXT" \
         https://api.telegram.org/bot977114901:279gLSo-d7XZokF4QqM69ZfF3xBKtnYQqMk/sendMessage
Script with Webhook

Webhook is HTTP push API for general purpose. Message services such as Slack provide

#!/bin/bash
curl -X POST --data-urlencode "payload={\"channel\": \"#helpdesk\", \"username\": \"Sender Name\", \"text\": \"The File(s) in <http://bit.torrent/|Transmission Web> is(are) finished.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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

WebHook address and setup instruction is guided by Slack ™.

Restart Transmission

sudo systemctl start transmission-daemon.service

Symptom: Error hash sum mismatch shows during updating. This problem has something to do with slow connection or connection failure due to bad network situation.

Solution:

sudo vi /etc/apt/source.lists 

Remove downloaded repository information from the /var/lib/apt/lists/ directory.

sudo rm -rf /var/lib/apt/lists/*

Change mirror address seemingly to be fast.

Raspbian Mirrors

This is a kind of temporary problem due to network condition.


  • rpi_autism
  • Last modified: 2020/08/28 18:10
  • by Júne Park