====== Media Ditorium ─ AUTiSM Rainbow ====== {{:rpi_autism.jpg?nolink&250|}} Name: {{mdi>cards?28&color=#37000A}} ''**AUTiSM** Rainbow'' (official) | {{mdi>creation?28&color=#37000A}} ''라몽'' (korean) ---- ===== Specification ===== {{mdi>raspberry-pi?32&color=#37000A}} Model: [[https://www.raspberrypi.org/products/raspberry-pi-2-model-b//|Raspberry Pi 2 Model B+]] | [[wp>Raspberry_Pi#Model_B|Raspbierry Pi Model B]] {{mdi>database-plus?32&color=#37000A}} Storages --- {{mdi>harddisk}} [[SECURED:JUNE_HARDWARE#data_storage|Storage in details]] {{fa>lock}} * {{mdi>database?color=#37000A}} ''**500G**'' --- ''~/storage'' partition {{fa>usb?14&color=#005eb8}} * {{mdi>database?color=#37000A}} ''**500G**'' --- ''~/repository'' partition {{fa>usb?14&color=#005eb8}} === Live status of storages === Mounted on Type Size Used Avail Use% ~/repository ext4 459G 289G 147G 67% ~/storage ext4 459G 179G 257G 42% {{mdi>server-network?32&color=#37000A}} --- {{mdi>wifi-strength-3-lock}} [[SECURED:HOME_NETWORK#dhcp_assigned_ip|Júne's home network]] {{fa>lock}} * {{mdi>lan?color=#37000A}} Wired (''AUTiSM-enx001'') * {{mdi>wifi?color=#37000A}} Wireless {{fa>usb?14&color=#030303}} (''AUTiSM-wlx001'') * {{mdi>lan?color=#37000A}} Wired {{fa>usb?14&color=#030303}} (''AUTiSM-enx003'') {{mdi>video-wireless-outline?32&color=#37000A}} Video streaming and archives ---- ==== +Work logs ==== * Fixed ''conveyance daemon'' due to wrong lib sharing --- Updated on //2023/05/06 21:11// * Disable ''transmission web'' port, ''9090'' & ''9091'' and build ''proxy_pass'' pages --- Updated on //2020/07/11 03:22// * Plugin Wired Giga LAN {{fa>usb}} --- 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 ---- ===== Operation manuals ===== ==== Install Samba service ==== 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'' [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 ---- ==== Setup Transmission ==== Build up Transmission (daemon + web remote) and configuration. Reference: Fundamental [[http://meson.in/2gTAppK|information on BitTorrent]] in {{flag>kr}} 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 {{mdi>micro-sd}} but use directories mount on USB {{fa>usb?color=#000000}} attached storage. Assume external USB {{fa>usb?color=#000000}} 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'' "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 === {{mdi>web?color=#52325d}} Page for Transmission Web is ''/usr/share/transmission/web/index.html'' ---- ==== Dual Transmissions in single machine ==== 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. "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. ---- ==== Notify completion of downloading ==== When downloading finishes in Transmission, get **notification** via message services. === Getting API from PushBullet === Get API key from PushBullet service --- [[https://www.pushbullet.com/#settings/account|Create Access Token]] * API key is like ''o.8jh96v9p49vW73X3U4HByxo87MLVw4kM'' === Getting API from Telegram === To get API from {{mdi>telegram?color=#0088cc}} **Telegram**, need to create Telegram Bot by which notification is sending. Create Telegram Bot --- [[https://telegram.me/botfather|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/bot**977114901: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: == 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 {{mdi>slack?color=#e9a820}} provide #!/bin/bash curl -X POST --data-urlencode "payload={\"channel\": \"#helpdesk\", \"username\": \"Sender Name\", \"text\": \"The File(s) in is(are) finished.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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 WebHook address and setup instruction is guided by Slack (tm). === Restart Transmission === sudo systemctl start transmission-daemon.service ---- ===== Solved problems ===== ==== hash sum mismatch during apt-get update ==== {{fa>bug}} **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. {{fa>lightbulb-o}} **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. [[https://www.raspbian.org/RaspbianMirrors|Raspbian Mirrors]] {{mdi>source-repository-multiple?color=#000000}} This is a kind of temporary problem due to network condition. ----