とりあえず日記

VIM→秀丸エディタ→VIM→秀丸エディタ→VIM→秀丸エディタ→VIM→秀丸エディタ→VIM→秀丸エディタ→VIM→秀丸エディタ(いまここ🍄)

Raspberry Pi3 Model B+上でCentOS7が動いたよ

はじめに

Raspberry Pi3 Model B+を入手しました。
日本の技適を通過していないのでWifiを利用できないのが難点ですが。。。


さて本題です、
Raspberry Pi3 Model B+ を既存のCentOS7イメージでブートすると虹色の画面で止まったままになります。
困った困った😖

状況
ファイル名 bootするか?
CentOS-Userland-7-armv7hl-Minimal-1611-test-RaspberryPi3.img.xz 虹色の画面で止まる
CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img.xz 虹色の画面で止まる

解決方法

FabianArrotin氏がRaspberry Pi3 Model B+で動くようにビルドしたイメージを利用します。


(ファイル)
https://buildlogs.centos.org/rolling/7/isos/armhfp/CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-sda.raw.xz


単にソースをビルドしただけのようでリリース前のテストが十分に行われているのか不明です。
利用時はご注意を。

まとめ

Arm版CentOSで困ったときはArm-devのMLを読み書きするのが良いと思います。

【Raspberry Pi3+CentOS7】NIC2枚差しの設定をした

はじめに

Raspberry Pi3+CentOS7の環境にSoftEtherVPNを設定したときの自分用メモです。

なぜNICを2枚差したのか?

SoftetherVPNの公式にはVPN専用のNICを追加した方が良いと書いてあり、言われるがママ素直にRaspberry PiにUSB-NICを1つ追加しました。
3.6 ローカルブリッジ - SoftEther VPN プロジェクト

まあ当然、追加しただけでは正しく動作しないのでネットの情報を鵜呑み参考にしながら設定を行いました。


以下、作業メモです。

Raspberry Piのネットワーク

192.168.30.40  12:34:56:11:11:11  eth0 (Raspberry Piに元からあるLANポート)
192.168.30.50  ab:cd:ef:22:22:22  eth1 (USB-NIC)

DHCPで固定アドレスを割り当ててます。

問題の発生

WindowsコマンドプロンプトからARPテーブルを確認したところ、

> arp -a
インターネット アドレス 物理アドレス   
192.168.30.40           12-34-56-11-11-11
192.168.30.50           12-34-56-11-11-11

あれ??
異なるIPアドレスに対して同じMACアドレスが割当たってます。
正解は以下の通りです。

192.168.30.40         12-34-56-11-11-11
192.168.30.50         ab-cd-ef-22-22-22

では、ネットワークの設定が正解になるように対応を行います。

異なるIPアドレスMACアドレスが同じになる原因

eth1で受けた通信をeth0から返信しているため。

//tcpdumpコマンドで確認済です。
//ログは省略。

対応方法の概要

NICを2枚を差したときに発生するありがちな問題のようで、マルチホーミング設定を行います。
http://d.hatena.ne.jp/hirose31/20120822/1345626743
http://takumicloud.jp/blog/2015/11/30/nw/
http://ibucket.blogspot.jp/2010/07/centos.html

手順

$cat  /etc/iproute2/rt_tables

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep

100     subroute-eth1   <- 追加
$ ip rule add from 192.168.30.50 table subroute-eth1 prio 100
$ ip route add table subroute-eth1 192.168.30.0/24 dev eth1 scope link proto kernel
$ ip route add table subroute-eth1 default via 192.168.30.1 dev eth1

反映されているか確認します。

$ ip route show table subroute-eth1
default via 192.168.30.1 dev eth1
192.168.30.0/24 dev eth1 proto kernel scope link
$ ip rule
0:      from all lookup local
100:    from 192.168.30.50 lookup subroute-eth1
32766:  from all lookup main
32767:  from all lookup default

OSの再起動対応

以下ファイルを作りCentOSの再起動で設定が消えないようにします。
/etc/sysconfig/network-scripts/{rule,route}-eth1

手作業でファイルを作ると間違う可能性があるので、
CentOS7ではnmcliコマンドを使うのを推奨されていますが、
何故か、nmcliコマンドでポリシーベースの設定は出来ないようです(注意、2015年の古い情報です)
https://www.centos.org/forums/viewtopic.php?t=50400
https://mano.xyz/2033/

nmcliコマンドで設定が可能なら誰か教えて欲しい・・・

しかたないので今回は以下のファイルを手作業で作りました。

$ cat /etc/sysconfig/network-scripts/route-eth1
192.168.30.0/24 dev eth1 src 192.168.30.50 table subroute-eth1
default via 192.168.30.1 dev eth1 table subroute-eth1
$ cat /etc/sysconfig/network-scripts/rule-eth1
from 192.168.30.50 table subroute-eth1 priority 100

NetworkManager-config-routing-rulesの起動

CentOS7をMinimalで構築している場合は以下パッケージをインストールして起動します。

$ yum install NetworkManager-config-routing-rules
$ systemctl enable NetworkManager-dispatcher
$ systemctl start NetworkManager-dispatcher

こうしないと /etc/sysconfig/network-scripts/{rule,route}-eth1 の設定がネットワークに反映されません。

NetworkManagerの再起動

$ systemctl restart NetworkManager

再起動後の設定を確認する

$ ip route show table subroute-eth1
default via 192.168.30.1 dev eth1
192.168.30.0/24 dev eth1 scope link src 192.168.30.50
$ ip route
default via 192.168.30.1 dev eth0 proto static metric 100
192.168.30.0/24 dev eth0 proto kernel scope link src 192.168.30.40 metric 100
192.168.30.0/24 dev eth1 proto kernel scope link src 192.168.30.50 metric 101
$ ip rule
0:      from all lookup local
100:    from 192.168.30.50 lookup subroute-eth1
32766:  from all lookup main
32767:  from all lookup default

その他

VPN接続はパケット転送をおこなわなくても出来るはずなので無効化しています。

$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

VPN接続

SoftEtherの設定、サービス起動(systemctlコマンド)とファイヤウォールの設定(firewall-cmd)を行って、Android端末からVPN接続出来ることを確認できました。
めでたしめでたし

最後に

CentOSWindowsと比べるとネットワークを細かく制御できる分めんどうですね。
少しずつ勉強します、めでたしめでたし、



と終わりたいところですが、
OSを再起するとNICを認識する順序によってVPN接続できなくなります、ググるCentOS界隈ではよくある現象でNICの名前(ifcgf-eth0, ifcfg-eth1)を固定する設定が必要になります。
おいおい初見殺しだな


(参考)
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/deployment_guide/appe-Consistent_Network_Device_Naming
RHEL7のNICのネーミングルール - めもめも
mrwk update: systemd-udevdによるNIC命名とbiosdevnameがまざって混乱する件
CentOS7におけるNIC命名ルール - 雑木林

【Raspberry Pi3 + CentsOS7】irqbalanceのメモリリークなおったよ

はじめに

先日、irqbalanceが派手にメモリリークしているという日記を書きましたが、
http://d.hatena.ne.jp/ohtorii/20180403/p1

irqbalanceをバージョンアップしたらメモリリークが直りました。

irqbalanceのバージョン情報

メモリリークなし版

$ yum list|grep irqbalance
irqbalance.armv7hl                          3:1.0.7-10.el7              @updates

メモリリークあり版

$ yum list|grep irqbalance
irqbalance.armv7hl 2:1.0.7-1.el7.centos @centos-base_rbf

irqbalanceのメモリ状態

起動直後

$ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 217 0.0 0.2 4212 2084 ? Ss 12:30 0:01 /usr/sbin/irqbalance --foreground

1日経過後

$ ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root       231  0.0  0.2   4212  2148 ?        Ss   03:00   0:08 /usr/sbin/irqbalance --foreground

まとめ

irqbalanceが派手にメモリリークしていたのは、ハズレのバージョンを引いたのが原因でした。
そもそもCentOSは会社の業務で利用しているので、安定しているイメージを持っていましたが認識を改めるきっかけになりました。

【Raspberry Pi3 + CentOS7】irqbalanceがメモリリークする

メモリリーク直りました。(2018/04/11)
http://d.hatena.ne.jp/ohtorii/20180411


以下はメモリリークしていた当時の状況です。

はじめに

当方の家庭内LANでは、Raspberry Pi 3 Model B にCentOS7をインストールして運用しています。


運用しているとRaspberry Piの使用メモリが増えていくので原因を調べたところ、
irqbalanceというデーモンがメモリリークしていました。

メモリリークの状態

Raspberry Pi起動直後のメモリ状態(約58MBのメモリ消費)

$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       220  0.0  5.9  58280 56172 ?        Ss   03:00   0:18 /usr/sbin/irqbalance --foreground


こちらは、一日経過後のメモリ状態(約452MBのメモリ消費)

$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       225  0.0 47.6 454380 452352 ?       Ss   Feb21   2:29 /usr/sbin/irqbalance --foreground


Raspberry Piはメモリが1GBなので約半分の領域がリークしたメモリという状況でした。

とりあえずメモリリークを調査してみる

運用中のirqbalanceが古すぎてバグ修正されていないかもしれないので、
手始めにバージョンを確認。

$ yum list|grep irqbalance
irqbalance.armv7hl                       2:1.0.7-1.el7.centos           @centos-base_rbf

version 1.0.7ですね。

irqbalanceの更新履歴によると最新版は1.3.0です、更に1.0.7以降でメモリリークの修正が行なわれています。
https://github.com/Irqbalance/irqbalance/releasesirqbalance

バージョンが古いのが原因かも?
yumではirqbalanceの新バージョンが落ちてこないので、ソースコードからビルドするしか手が無いのかな?

回避策

irqbalanceを1時間毎に再起動(crontab)させて回避しています。

今後について

irqbalanceが yum で落ちてきたらまた記事にします。

注意

Unix系のOSは初心者なので派手に勘違いしていることがあります。
ご注意ください🙏

久しぶりにclang-interpreterを試してみた

何年も前にC++interpreterであるclang-interpreterを試した記事を書きました。
http://d.hatena.ne.jp/ohtorii/20110716/1310783800
秀丸エディタからclang-interpreterを呼び出してみた - とりあえず日記


当時は、STLWindowsのヘッダファイルを扱うことが出来ない状況でした。
あれからClang/LLVMも相当バージョンアップされてるので、
気まぐれで久しぶりにビルドして動作を試してみました。

結果

相変わらず、STLWindowsのヘッダファイルを扱えないです。
まあ、clang-interpreterはサンプルという位置づけなので真面目に実装されていないのかもしれません。

環境

LLVM 5.0.1
Microsoft Visual Studio Community 2017 Version 15.5.7

ビルド手順

VisualStudio2017でビルドしてclang-interpreter.exeを作ります。
(Clang/LLVMのマニュアルに従えば簡単に実行ファイルを作れます、なのでビルド手順は省略します。)

動かしてみた。(printf)

//sample_0.cpp
include<stdio.h>

int main(int argc, char*argv[]){
	for(int i=0; i!=4 ; ++i){
		printf("i=%d\n",i);
	}
	return 0;
}
> clang-interpreter.exe sample_0.cpp
i=0
i=1
i=2
i=3

おっ、正しく動いています。

動かしてみた。(file i/o)

//sample_1.cpp
#include<stdio.h>

int main(int argc, char*argv[]){
	FILE* fp=fopen("out.txt","wt");
	fprintf(fp,"%s\n","hello clang");
	fprintf(fp,"%s\n","こんにちわ、clang");
	fclose(fp);
	return 0;
}
> clang-interpreter.exe sample_1.cpp
sample_1.cpp:4:11: warning: 'fopen' is deprecated: This function or variable may
      be unsafe. Consider using fopen_s instead. To disable deprecation, use
      _CRT_SECURE_NO_WARNINGS. See online help for details.
      [-Wdeprecated-declarations]
        FILE* fp=fopen("out.txt","wt");
                 ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\stdio.h:206:20: note:
      'fopen' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(fopen_s)
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\vcruntime.h:255:55: note:
      expanded from macro '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\vcruntime.h:245:47: note:
      expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
1 warning generated.
> type out.txt
hello clang
こんにちわ、clang

fopen関数じゃなくてfopen_s関数を使えと警告されましたが正しい結果を得られました。

動かしてみた。(class)

//sample_2.cpp
#include<stdio.h>

template<class T>
class add{
public:
	add(T v) : m_base(v){
	}
	T operator()(T v)const{
		return v + m_base;
	};
private:
	T	m_base;
};

int main(int argc, char*argv[]){
	add<int>	obj(10);
	printf("value=%d\n", obj(20));
	return 0;
}
> clang-interpreter.exe sample_2.cpp
value=30

こちらも、ちゃんと動いています。

動かしてみた。(Global ctor/dtor)

//sample_3.cpp
#include<stdio.h>

class foo{
public:
	foo(){
		printf("ctor\n");
	}
	~foo(){
		printf("dtor\n");
	}
};

foo g;	//  <------- Global ctor/dtor.

int main(int argc, char*argv[]){
	printf("Enter main.\n");
	return 0;
}
> clang-interpreter.exe sample_3.cpp

LLVM ERROR: Undefined temporary symbol

エラーです。

動かしてみた。(STL)

//sample_4.cpp
#include<vector>
int main(int argc, char*argv[]){
	std::vector<int> v;
}
> clang-interpreter.exe sample_4.cpp
LLVM ERROR: Undefined temporary symbol

またまた、エラーです。

動かしてみた。(windows.h)

//sample_5.cpp
#include<windows.h>
int main(int argc, char*argv[]){
    DWORD t=MessageBox(NULL,"foo","bar", MB_OK);
    return 0;
}
>clang-interpreter.exe sample_5.cpp
In file included from sample_5.cpp:1:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\windows.h:171:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared\windef.h:24:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared\minwindef.h:182:
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h:959:5: error:
      MS-style inline assembly is not available: Unable to find target for this
      triple (no targets are registered)
    __asm    {
    ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h:975:5: error:
      MS-style inline assembly is not available: Unable to find target for this
      triple (no targets are registered)
    __asm {
    ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h:991:5: error:
      MS-style inline assembly is not available: Unable to find target for this
      triple (no targets are registered)
    __asm    {
    ^
3 errors generated.

__asm構文で怒られました。

試したこと

幾つかエラーが発生したので回避できないかソースコードをいじくって試行錯誤してみました。
雰囲気でソースコードを変更しているので期待する動作は得られませんでした。

対象のソースコード
\llvm\tools\clang\examples\clang-interpreter\main.cpp


試行錯誤した痕跡。

#if 0 /* Original */
  // FIXME: This is a hack to try to force the driver to do something we can
  // recognize. We need to extend the driver library to support this use model
  // (basically, exactly one input, and the operation mode is hard wired).
  SmallVector<const char *, 16> Args(argv, argv + argc);
  Args.push_back("-fsyntax-only");
#else /* Modify */
  SmallVector<const char *, 256> Args(argv, argv + argc);
  Args.push_back("-fsyntax-only");
  Args.push_back("-fms-compatibility-version=19.00");
  Args.push_back("-fms-compatibility");
  Args.push_back("-fms-extensions");
  //Args.push_back("-fmsc-version=1912");
  //Args.push_back("--target=x86_64-windows-msvc");    //Clash.
  //Args.push_back("--target=i686-windows-msvc");      //LLVM ERROR: Program used external function '___stdio_common_vfprintf' which could not be resolved!
  //Args.push_back("--target=i686-pc-win32");          //LLVM ERROR: Program used external function '___stdio_common_vfprintf' which could not be resolved!
  //Args.push_back("--target=x86_64-pc-windows-msvc"); //Crash.
  //Args.push_back("--target=x86_64");                 //sample_0.cpp:1:9: fatal error: 'stdio.h' file not found
  //Args.push_back("--target=");
#endif

最後に

元々、深入りするつもりもないのでこの辺にしておきます。

CentO7にonedrive-devをインストールしてみた

CentOS7でOneDriveを利用するために、onedrived-devのパッケージをインストールしたときの作業メモです。

結果

onedrived-devを手作業でインストールしてOneDriveのアカウント追加まで行いました。
ローカルドライブとクラウド側のOneDriveとファイルを同期するには、ngrokのインストールとアカウント登録が必要らしいので、
面倒になって絶賛放置中です。


以下、作業メモです。

CentOSのイメージ

CentOS-7-x86_64-Minimal-1708.iso

手順

yum -y install git

yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install -y python34 python34-libs python34-devel python34-pip python34-dbus python34-tools
yum install -y gccngrok - secure introspectable tunnels to localhost

yum search libssl-devは見つからず。

yum search libssl-dev
snip
警告: 一致するものが見つかりません: libssl-dev
No match found

libssl-devはOpenSSLだと思うのでインストール

yum -y install openssl-libs openssl-devel

yum -y install inotify-tools

build-essentialは、

To install those dependencies on Ubuntu, use apt-get command:
# Install gcc and other C-level pre-requisites.
$ sudo apt-get install build-essential python3-dev libssl-dev inotify-tools python3-dbus

build-essentialは、多分Ubuntuで必要なパッケージなので、CentOSでは無視していいかも。
私はとりあえず以下ページを参考にしてCentOSにインストールしました。
http://blog.64p.org/entry/2013/07/22/142457

yum groupinstall "Development Tools"
yum install kernel-devel kernel-headers

sudo pip3 install -U keyrings.alt
Collecting keyrings.alt
Downloading keyrings.alt-2.3-py2.py3-none-any.whl
Requirement already up-to-date: six in /root/.local/lib/python3.4/site-packages (from keyrings.alt)
Installing collected packages: keyrings.alt
Successfully installed keyrings.alt-2.3

Install onedrived

pip3 install --user git+https://github.com/xybu/onedrived-dev.git

checking for DBUS... no
configure: error: Package requirements (dbus-1 >= 1.6) were not met:

No package 'dbus-1' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables DBUS_CFLAGS
and DBUS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-sh0vgtxc/dbus-python/setup.py", line 106, in 'build_ext': BuildExt,
File "/root/.local/lib/python3.4/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/root/.local/lib/python3.4/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib64/python3.4/distutils/command/install.py", line 539, in run self.run_command('build')
File "/usr/lib64/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-build-sh0vgtxc/dbus-python/setup.py", line 62, in run
cwd=builddir)
File "/usr/lib64/python3.4/subprocess.py", line 558, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/tmp/pip-build-sh0vgtxc/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/usr/bin/python3.4', '--prefix=/tmp/pip-build-sh0vgtxc/dbus-python/build/temp.linux-x86_64-3.4/prefix']' returned non-zero exit status 1

----------------------------------------
Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_fpfln70/dbus-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-bfx2au8s-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-_fpfln70/dbus-python/
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

え〜〜〜〜

configure: error: Package requirements (dbus-1 >= 1.6) were not met:

エラーは、No package 'dbus-1' found なので、yumdbus-1をインストール。

yum install dbus-devel

pip3 install --user git+https://github.com/xybu/onedrived-dev.git
configure: error: Package requirements (dbus-glib-1 >= 0.70) were not met:

No package 'dbus-glib-1' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables DBUS_GLIB_CFLAGS
and DBUS_GLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-zrls2wle/dbus-python/setup.py", line 106, in
'build_ext': BuildExt,
snip

今度は、dbus-glib-1が見つからないのでyumで追加インストールして、pip3...を再実行。

yum install dbus-glib-devel
pip3 install --user git+https://github.com/xybu/onedrived-dev.git

snip

Installing collected packages: dbus-python, onedrived
Running setup.py install for dbus-python ... done
Running setup.py install for onedrived ... done
Successfully installed dbus-python-1.2.4 onedrived-2.0.0
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

今度は成功!!

Install from source manually

git clone https://github.com/xybu/onedrived-dev.git
cd onedrived-dev

python3 ./setup.py test

snip

Traceback (most recent call last):
File "./setup.py", line 63, in
zip_safe=False
File "/usr/lib64/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/site-packages/setuptools/command/test.py", line 148, in run
self.distribution.install_requires)
File "/usr/lib/python3.4/site-packages/setuptools/dist.py", line 312, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 846, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1084, in best_match
dist = working_set.find(req)
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 721, in find
raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (setuptools 19.2 (/usr/lib/python3.4/site-packages), Requirement.parse('setuptools>=30.0.0'))

setuptoolのバージョンが古いという旨のエラーが出力されるので、setuptoolのバージョンを更新する

wget https://pypi.python.org/packages/6c/54/f7e9cea6897636a04e74c3954f0d8335cc38f7d01e27eec98026b049a300/setuptools-38.5.1.zip
sudo pip3 install ./setuptools-33.1.1.zip

再度テストを実行。

python3 ./setup.py test

snip

No package 'libffi' found
c/_cffi_backend.c:15:17: 致命的エラー: ffi.h: そのようなファイルやディレクトリはありません
#include
^
コンパイルを停止しました。
error: Setup script exited with error: command 'gcc' failed with exit status 1

libffiが見つからないのでインストール。

sudo yum -y install libffi-devel

再度、テストを実行

python3 ./setup.py test

snip

Running requests-mock-1.4.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-peaamvum/requests-mock-1.4.0/egg-dist-tmp-xtmm2215
Download error on https://pypi.python.org/simple/pbr/: [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't find index page for 'pbr' (maybe misspelled?)
No local packages or working download links found for pbr
error: Could not find suitable distribution for Requirement.parse('pbr')

pbrが見つからないのでインストール。

sudo pip3 install pbr

再度、テストを実行

python3 ./setup.py test

snip

test_handle_update (tests.test_tasks.TestUpdateSubscriptionTask) ... ok
test_lifecycle (tests.test_threads.TestTaskWorkerThread) ... ok
test_recognize_event_patterns (tests.test_watcher.TestLocalRepositoryWatcher) ... ok
test_execution (tests.test_webhook_worker.TestWebhookWorker) ... ERROR:root:Unknown subscription ID "233".
ok

                                                                                                                                          • -

Ran 86 tests in 2.858s

OK

テストに合格しました!!長かった・・・

途中ですが

マニュアルに従ってインストールを行いましたが、
ngrokのインストールとアカウント登録が必要らしいので、
面倒になって絶賛放置中です。

Free Client for OneDrive on Linuxをサービス化する

はじめに

Free Client for OneDrive on LinuxをCentOS7でサービス化する方法です。
GitHub - skilion/onedrive: Free Client for OneDrive on Linux

OneDriveをインストールする

yum install onedrive - とりあえず日記

コマンドを作る

/opt/onedrive.sh というスクリプトを用意します。

onedriveをhogeという一般ユーザーで実行しています。

/opt/onedrive.sh

#!/bin/bash
sudo -u hoge onedrive --monitor --syncdir /home/OneDrive --confdir /home/hoge/.config/onedrive

実行権限を与えます。

sudo chmod 0755 /opt/onedrive.sh

/etc/systemd/system/ の下にUnit定義ファイルを作る

/etc/systemd/system/onedrive.service

[Unit]
Description = onedrive daemon

[Service]
ExecStart = /opt/onedrive.sh
Restart = always
Type = simple

[Install]
WantedBy = multi-user.target

UnitがServiceとして認識されたか確認する

$ sudo systemctl list-unit-files --type=service | grep onedrive
onedrive.service disabled

systemctlコマンドでUnitを起動する

# 自動起動on
$ sudo systemctl enable onedrive
# 起動
$ sudo systemctl start onedrive

状態の確認。

$ systemctl status onedrive

● onedrive.service - onedrive daemon
Loaded: loaded (/etc/systemd/system/onedrive.service; enabled; vendor preset: disabled)
Active: active (running) since 土 2018-02-10 14:28:04 JST; 4s ago
Main PID: 1287 (onedrive.sh)
CGroup: /system.slice/onedrive.service
├─1287 /bin/bash /opt/onedrive.sh
├─1288 sudo -u hoge onedrive --monitor --syncdir /home/OneDrive --confdir /home/hoge/.config/onedrive
└─1289 onedrive --monitor --syncdir /home/OneDrive --confdir /home/hoge/.config/onedrive

2月 10 14:28:04 localhost.localdomain systemd[1]: Started onedrive daemon.
2月 10 14:28:04 localhost.localdomain systemd[1]: Starting onedrive daemon...
2月 10 14:28:05 localhost.localdomain sudo[1288]: root : TTY=unknown ; PWD=/ ; USER=hoge ; COMMAND=/bin/onedr...drive
Hint: Some lines were ellipsized, use -l to show in full.