0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OpenWRT(LEDE)使いこなし : rtorrent + LINE Notify

Posted at

はじめに

OpenWRT/LEDEのNASサーバーにrtorrentとLINE Notify環境を構築したので、
折角なので連携させてみました。

前記事:
中華ファンレスNASをOpenWRT(LEDE)で使う
OpenWRT(LEDE)使いこなし : rtorrent
OpenWRT(LEDE)使いこなし : LINE Notify

前準備

やりたいことは、
「rtorrentでファイルのダウンロードが終わったタイミングで、完了したファイル名をLINEに通知して欲しい」
です。

LINE Notify自体の前準備は適当にggるか、
Qiitaであればこの記事辺りです。
LEDEへのLINE Notify環境構築は、前記事を参照してください。

先ずはrtorrentにフックをかけて実行する為の
LINE Notify実行スクリプトを用意します。

line-nortify.sh
# !/bin/bash
# Script for LINE nortify
token=XXXXXX
curl -X POST -H "Authorization: Bearer ${token}" -F "message=$1" https://notify-api.line.me/api/notify

LEDEは環境が貧弱で/home すらないので、
/root/sh 等、適当に配置して実行出来るようにしておきます。
尚、私はbashをinstallしていますが、標準のOpenWRT/LEDEではashだと思うので、
bashをinstallするか、読み替えるか、等して下さい。

rtorrentへのフック

.rtorrent.rc にコードを書いていきます。
勉強したい方は、マニュアルとしては、以下を解読すれば良い様です。
https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html

今回はダウンロード完了時にフックをか掛けたいだけですので、
以下の1行を、/root/.rtorrent.rc に追記します。

/root/.rtorrent.rc
method.set_key=event.download.finished,notify_me,"execute2=/root/sh/line-nortify.sh,$d.name="

結構便利

私は、RaspberryPi等のinstallイメージファイルを色々と落として来る事が多く、
サーバーによっては物凄く(半日以上、等)時間がかかる為、
push通知でダウンロード完了タイミングを知る事が出来るのはとても便利です。

また、私の環境ではLEDEのrtorrent向けGUI(luci-app)がアクセス出来なくなる事が多いですが、
この場合でも、ダウンロード完了を知る事が出来る為、
安心してリセット・リブートを実施する事が出来ます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?