ページ

ラベル RaspberryPi の投稿を表示しています。 すべての投稿を表示
ラベル RaspberryPi の投稿を表示しています。 すべての投稿を表示

2014年8月31日日曜日

RaspberryPiと戯れてみる 11 - 外部から室内の温度を表示 -

ブラウザ上で温度計の内容を見れる様にする。

phpで作成したシェルスクリプトを実行。
↓ここらへんを参考にhtmlを作成。
http://logic.moo.jp/data/archives/443.html

いざ、ブラウザからアクセスしてみても、うまくいかない ><

ブラウザから実行する際はwww-dataユーザで実行する事になるが、
sudo が使えない事が原因でしたorz。

以下サイトを参考に修正。
http://www.maruko2.com/mw/一般ユーザーを_sudo_できるようにする

<?php
$temp = shell_exec('/home/pi/tmp102.sh');
?>
<html>
<body>
<?php
echo "<pre>$temp</pre>";
?>
</body>
</html>
~                 

実行!!








無事温度が見れました^^
次はもう少し見た目を。。。

以前もやったBootstrapを使ってみる。
以下参考サイト
http://www.atmarkit.co.jp/ait/articles/1403/19/news034_4.html














最終的に温度計やmotion起動/停止を盛り込んだ画面

2014年8月30日土曜日

RaspberryPiと戯れてみる 10 - 温度測定 -

以前Arduinoでやった温度測定をRaspberry pi でやって外から温度を見れるようにする。

まずはRaspberry Pi がI2C接続できるようにする。
以下サイトを参考に設定
http://www.gvc-on.net/?p=288

pi@raspberrypi ~ $ sudo diff /etc/modules /etc/modules.org 
8d7
< i2c-dev
pi@raspberrypi ~ $ sudo diff /etc/modprobe.d/raspi-blacklist.conf /etc/modprobe.d/raspi-blacklist.conf.org 
4c4
< #blacklist i2c-bcm2708
---
> blacklist i2c-bcm2708

再起動。

ちゃんとI2Cデバイスモジュールが読み込まれているか確認。
pi@raspberrypi ~ $ dmesg | grep i2c
[    4.899135] bcm2708_i2c_init_pinmode(0,0)
[    4.906241] bcm2708_i2c_init_pinmode(0,1)
[    5.086692] bcm2708_i2c bcm2708_i2c.0: BSC0 Controller at 0x20205000 (irq 79) (baudrate 100000)
[    5.277198] bcm2708_i2c_init_pinmode(1,2)
[    5.368575] bcm2708_i2c_init_pinmode(1,3)
[    5.374680] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[   11.249426] i2c /dev entries driver

I2C用ツールをインストール。
pi@raspberrypi ~ $ sudo apt-get install i2c-tools
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  libnet-daemon-perl libplrpc-perl
これを削除するには 'apt-get autoremove' を利用してください。
提案パッケージ:
  libi2c-dev python-smbus
以下のパッケージが新たにインストールされます:
  i2c-tools
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 1 個。
59.5 kB のアーカイブを取得する必要があります。
この操作後に追加で 223 kB のディスク容量が消費されます。
取得:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main i2c-tools armhf 3.1.0-2 [59.5 kB]
59.5 kB を 1秒 で取得しました (47.1 kB/s)
以前に未選択のパッケージ i2c-tools を選択しています。
(データベースを読み込んでいます ... 現在 71037 個のファイルとディレクトリがインストールされています。)
(.../i2c-tools_3.1.0-2_armhf.deb から) i2c-tools を展開しています...
man-db のトリガを処理しています ...
i2c-tools (3.1.0-2) を設定しています ...

配線。


















Raspberry Piのピン配置
http://elinux.org/RPi_Low-level_peripherals

pi@raspberrypi ~ $ sudo i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

bcのインストール
pi@raspberrypi ~ $ sudo apt-get install bc
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  libnet-daemon-perl libplrpc-perl
これを削除するには 'apt-get autoremove' を利用してください。
以下のパッケージが新たにインストールされます:
  bc
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 1 個。
106 kB のアーカイブを取得する必要があります。
この操作後に追加で 257 kB のディスク容量が消費されます。
取得:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main bc armhf 1.06.95-2 [106 kB]
106 kB を 1秒 で取得しました (79.4 kB/s)
以前に未選択のパッケージ bc を選択しています。
(データベースを読み込んでいます ... 現在 71054 個のファイルとディレクトリがインストールされています。)
(.../bc_1.06.95-2_armhf.deb から) bc を展開しています...
menu のトリガを処理しています ...
install-info のトリガを処理しています ...
man-db のトリガを処理しています ...
bc (1.06.95-2) を設定しています ...
menu のトリガを処理しています ...

シェルスクリプト作成
#!/bin/bash

hexraw=$(sudo i2cget -y 1 0x48 0x00 w)
while [ "$hexraw" == "" ]; do
    hexraw=$(sudo i2cget -y 1 0x48 0x00 w)
done

msb=$(echo ${hexraw:4:2})
lsb=$(echo ${hexraw:2:1})
dec=$(printf "%d\n" "0x$msb$lsb")

echo "scale=4; $dec*0.0625" | bc
~                                                                                         
~                                                                                         
~         


無事温度測定できました^^
pi@raspberrypi ~ $ ./tmp102.sh 
29.1250
pi@raspberrypi ~ $ ./tmp102.sh 
31.5000
pi@raspberrypi ~ $ ./tmp102.sh 
31.6875
pi@raspberrypi ~ $ ./tmp102.sh 
31.8125
pi@raspberrypi ~ $ ./tmp102.sh 
31.8750
pi@raspberrypi ~ $ ./tmp102.sh 
31.9375
pi@raspberrypi ~ $ ./tmp102.sh 
31.9375
pi@raspberrypi ~ $ ./tmp102.sh 
32.0000
pi@raspberrypi ~ $ ./tmp102.sh 
32.0625
pi@raspberrypi ~ $ ./tmp102.sh 
30.5000
pi@raspberrypi ~ $ ./tmp102.sh 
30.3750
pi@raspberrypi ~ $ ./tmp102.sh 
30.3750
pi@raspberrypi ~ $ ./tmp102.sh 
30.3125
pi@raspberrypi ~ $ ./tmp102.sh 
30.3125
pi@raspberrypi ~ $ ./tmp102.sh 
30.2500
pi@raspberrypi ~ $ ./tmp102.sh 
30.2500
pi@raspberrypi ~ $ ./tmp102.sh 
30.1875
pi@raspberrypi ~ $ ./tmp102.sh 
30.1875
pi@raspberrypi ~ $ ./tmp102.sh 
30.1875

次はVPN接続して外からブラウザ上で温度が見れるようにする。

2014年8月23日土曜日

RaspberryPiと戯れてみる 9 - WEBカメラ連携 -

久しぶりにRaspberry Piを触ってみる。

WEBカメラを使用してプチ監視カメラを作成。

購入したWEBカメラ Logicool WebCamera c270




















Raspberry Piに接続し認識しているか確認。
pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 005: ID 046d:0825 Logitech, Inc. Webcam C270

pi@raspberrypi ~ $ 

ちゃんと認識してくれている模様。
まずは更新作業。
sudo apt-get update
sudo apt-get upgrade

次に扱い易いと噂のmotionをインストールしてみる。
pi@raspberrypi ~ $ sudo apt-get install motion
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  libnet-daemon-perl libplrpc-perl
これを削除するには 'apt-get autoremove' を利用してください。
以下の特別パッケージがインストールされます:
  ffmpeg libav-tools libavcodec53 libavdevice53 libavfilter2 libavformat53 libavutil51
  libdc1394-22 libdirac-encoder0 libgsm1 libjack-jackd2-0 libmp3lame0 libopencv-core2.3
  libopencv-imgproc2.3 libpostproc52 libpq5 libraw1394-11 libschroedinger-1.0-0
  libspeex1 libswscale2 libtheora0 libva1 libvpx1 libx264-123 libxvidcore4
提案パッケージ:
  jackd2 libraw1394-doc speex postgresql-client
以下のパッケージが新たにインストールされます:
  ffmpeg libav-tools libavcodec53 libavdevice53 libavfilter2 libavformat53 libavutil51
  libdc1394-22 libdirac-encoder0 libgsm1 libjack-jackd2-0 libmp3lame0 libopencv-core2.3
  libopencv-imgproc2.3 libpostproc52 libpq5 libraw1394-11 libschroedinger-1.0-0
  libspeex1 libswscale2 libtheora0 libva1 libvpx1 libx264-123 libxvidcore4 motion
アップグレード: 0 個、新規インストール: 26 個、削除: 0 個、保留: 1 個。
8,297 kB 中 106 kB のアーカイブを取得する必要があります。
この操作後に追加で 20.5 MB のディスク容量が消費されます。
続行しますか [Y/n]? y
取得:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libswscale2 armhf 6:0.8.13-1+rpi1 [106 kB]
106 kB を 1秒 で取得しました (104 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ libavutil51:armhf を選択しています。
(データベースを読み込んでいます ... 現在 70747 個のファイルとディレクトリがインストールされています。)
(.../libavutil51_6%3a0.8.13-1+rpi1_armhf.deb から) libavutil51:armhf を展開しています...
以前に未選択のパッケージ libdirac-encoder0:armhf を選択しています。
(.../libdirac-encoder0_1.0.2-6_armhf.deb から) libdirac-encoder0:armhf を展開しています...
以前に未選択のパッケージ libgsm1:armhf を選択しています。
(.../libgsm1_1.0.13-4_armhf.deb から) libgsm1:armhf を展開しています...
以前に未選択のパッケージ libmp3lame0:armhf を選択しています。
(.../libmp3lame0_3.99.5+repack1-3_armhf.deb から) libmp3lame0:armhf を展開しています...
以前に未選択のパッケージ libschroedinger-1.0-0:armhf を選択しています。
(.../libschroedinger-1.0-0_1.0.11-2_armhf.deb から) libschroedinger-1.0-0:armhf を展開しています...
以前に未選択のパッケージ libspeex1:armhf を選択しています。
(.../libspeex1_1.2~rc1-7_armhf.deb から) libspeex1:armhf を展開しています...
以前に未選択のパッケージ libtheora0:armhf を選択しています。
(.../libtheora0_1.1.1+dfsg.1-3.1_armhf.deb から) libtheora0:armhf を展開しています...
以前に未選択のパッケージ libva1:armhf を選択しています。
(.../libva1_1.0.15-4_armhf.deb から) libva1:armhf を展開しています...
以前に未選択のパッケージ libvpx1:armhf を選択しています。
(.../libvpx1_1.1.0-1+rpi1_armhf.deb から) libvpx1:armhf を展開しています...
以前に未選択のパッケージ libx264-123:armhf を選択しています。
(.../libx264-123_2%3a0.123.2189+git35cf912-1+rpi1_armhf.deb から) libx264-123:armhf を展開しています...
以前に未選択のパッケージ libxvidcore4:armhf を選択しています。
(.../libxvidcore4_2%3a1.3.2-9_armhf.deb から) libxvidcore4:armhf を展開しています...
以前に未選択のパッケージ libavcodec53:armhf を選択しています。
(.../libavcodec53_6%3a0.8.13-1+rpi1_armhf.deb から) libavcodec53:armhf を展開しています...
以前に未選択のパッケージ libavformat53:armhf を選択しています。
(.../libavformat53_6%3a0.8.13-1+rpi1_armhf.deb から) libavformat53:armhf を展開しています...
以前に未選択のパッケージ libraw1394-11:armhf を選択しています。
(.../libraw1394-11_2.0.9-1_armhf.deb から) libraw1394-11:armhf を展開しています...
以前に未選択のパッケージ libdc1394-22:armhf を選択しています。
(.../libdc1394-22_2.2.0-2_armhf.deb から) libdc1394-22:armhf を展開しています...
以前に未選択のパッケージ libjack-jackd2-0:armhf を選択しています。
(.../libjack-jackd2-0_1.9.8~dfsg.4+20120529git007cdc37-5+rpi2_armhf.deb から) libjack-jackd2-0:armhf を展開しています...
以前に未選択のパッケージ libavdevice53:armhf を選択しています。
(.../libavdevice53_6%3a0.8.13-1+rpi1_armhf.deb から) libavdevice53:armhf を展開しています...
以前に未選択のパッケージ libopencv-core2.3 を選択しています。
(.../libopencv-core2.3_2.3.1-11_armhf.deb から) libopencv-core2.3 を展開しています...
以前に未選択のパッケージ libopencv-imgproc2.3 を選択しています。
(.../libopencv-imgproc2.3_2.3.1-11_armhf.deb から) libopencv-imgproc2.3 を展開しています...
以前に未選択のパッケージ libswscale2:armhf を選択しています。
(.../libswscale2_6%3a0.8.13-1+rpi1_armhf.deb から) libswscale2:armhf を展開しています...
以前に未選択のパッケージ libavfilter2:armhf を選択しています。
(.../libavfilter2_6%3a0.8.13-1+rpi1_armhf.deb から) libavfilter2:armhf を展開しています...
以前に未選択のパッケージ libpostproc52:armhf を選択しています。
(.../libpostproc52_6%3a0.8.13-1+rpi1_armhf.deb から) libpostproc52:armhf を展開しています...
以前に未選択のパッケージ libav-tools を選択しています。
(.../libav-tools_6%3a0.8.13-1+rpi1_armhf.deb から) libav-tools を展開しています...
以前に未選択のパッケージ libpq5 を選択しています。
(.../libpq5_9.1.13-0wheezy1_armhf.deb から) libpq5 を展開しています...
以前に未選択のパッケージ motion を選択しています。
(.../motion_3.2.12-3.4_armhf.deb から) motion を展開しています...
以前に未選択のパッケージ ffmpeg を選択しています。
(.../ffmpeg_6%3a0.8.13-1+rpi1_armhf.deb から) ffmpeg を展開しています...
man-db のトリガを処理しています ...
libavutil51:armhf (6:0.8.13-1+rpi1) を設定しています ...
libdirac-encoder0:armhf (1.0.2-6) を設定しています ...
libgsm1:armhf (1.0.13-4) を設定しています ...
libmp3lame0:armhf (3.99.5+repack1-3) を設定しています ...
libschroedinger-1.0-0:armhf (1.0.11-2) を設定しています ...
libspeex1:armhf (1.2~rc1-7) を設定しています ...
libtheora0:armhf (1.1.1+dfsg.1-3.1) を設定しています ...
libva1:armhf (1.0.15-4) を設定しています ...
libvpx1:armhf (1.1.0-1+rpi1) を設定しています ...
libx264-123:armhf (2:0.123.2189+git35cf912-1+rpi1) を設定しています ...
libxvidcore4:armhf (2:1.3.2-9) を設定しています ...
libavcodec53:armhf (6:0.8.13-1+rpi1) を設定しています ...
libavformat53:armhf (6:0.8.13-1+rpi1) を設定しています ...
libraw1394-11:armhf (2.0.9-1) を設定しています ...
Creating device node /dev/raw1394... /run/udev or .udevdb or .udev presence implies active udev.  Aborting MAKEDEV invocation.
done.
libdc1394-22:armhf (2.2.0-2) を設定しています ...
libjack-jackd2-0:armhf (1.9.8~dfsg.4+20120529git007cdc37-5+rpi2) を設定しています ...
libavdevice53:armhf (6:0.8.13-1+rpi1) を設定しています ...
libopencv-core2.3 (2.3.1-11) を設定しています ...
libopencv-imgproc2.3 (2.3.1-11) を設定しています ...
libswscale2:armhf (6:0.8.13-1+rpi1) を設定しています ...
libavfilter2:armhf (6:0.8.13-1+rpi1) を設定しています ...
libpostproc52:armhf (6:0.8.13-1+rpi1) を設定しています ...
libav-tools (6:0.8.13-1+rpi1) を設定しています ...
libpq5 (9.1.13-0wheezy1) を設定しています ...
motion (3.2.12-3.4) を設定しています ...
グループ `motion' (グループ ID 114) を追加しています...
完了。
システムユーザ `motion' (UID 109) を追加しています...
新しいユーザ `motion' (UID 109) をグループ `motion' に追加しています...
ホームディレクトリ `/home/motion' は作成しません。
ユーザ `motion' をグループ `video' に追加しています...
ユーザ motion をグループ video に追加
完了。
[warn] Not starting motion daemon, disabled via /etc/default/motion ... (warning).

ffmpeg (6:0.8.13-1+rpi1) を設定しています ...

motion.confの設定
pi@raspberrypi /tmp/motion $ sudo diff /etc/motion/motion.conf /etc/motion/motion.conf.org 
11c11
< daemon on
---
> daemon off
153c153
< threshold 3000
---
> threshold 1500
247c247
< ffmpeg_cap_new off
---
> ffmpeg_cap_new on
413c413
< webcam_localhost off
---
> webcam_localhost on

早速実行して確認しようとしたら。。灰色で写ってない!!!
原因はraspberrypiの設定でカメラを有効にしないといけないみたいでした。
参考サイト
http://katsumi-and-pi.blogspot.jp/2014/05/raspberry-pi.html
























いざ、実行!!























無事映りました〜^^


2013年12月23日月曜日

RaspberryPiと戯れてみる 8 - マウント -

ルータのプチNASディレクトリをRasppbery Pi上からマウント


https://sites.google.com/site/iroironeuromag/linuxgarami/-linuxkarawindows-nas-ni-jie-xusuru
ここら辺を参考にコマンド実行

mount.cifs: bad UNC
 
とかで怒られるorz
 
パスの指定が¥になっていたので、/に直して再度実行。
 
sudo mount -t cifs //192.168.0.1/baffalo-1 /nas/baffalo
 
今度はうまく行きました^_^
 

2013年11月30日土曜日

RaspberryPiと戯れてみる 7 - VPN再チャレンジ -

VPN再チャレンジ!!


有識者の方のありがたい助言をいただき、どうもdocomoの回線からVPN接続した場合
PPTPをサポートしていなさげらしいorz。

なので、「L2PTを使用するべし」というお言葉を頂きました。

・L2PT  http://e-words.jp/w/L2TP.html
・PPP http://e-words.jp/w/PPP.html

先生に聞いてみると以下参考サイトを発見
http://www.majishini.net/wp/?p=394

まずは、IPアドレスを固定で使用する様に設定。
参考サイト
http://www.hiramine.com/physicalcomputing/raspberrypi/setup_staticip.html

pi@raspberrypi /etc/network $ diff interfaces interfaces.org
4,7c4
< iface eth0 inet static
< address 192.168.0.4
< netmask 255.255.255.0
< gateway 192.168.0.1
---

> iface eth0 inet dhcp

sysctl.congの編集と反映

pi@raspberrypi /etc $ sudo vi sysctl.conf
pi@raspberrypi /etc $ sudo sysctl -p
kernel.printk = 3 4 1 3
vm.swappiness = 1
vm.min_free_kbytes = 8192
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.lo.send_redirects = 0

net.ipv4.conf.lo.accept_redirects = 0

/etc/ipsec.confの編集

pi@raspberrypi /etc $ sudo cp -p ipsec.conf ipsec.conf.org
pi@raspberrypi /etc $ sudo vi ipsec.conf
pi@raspberrypi /etc $ diff ipsec.conf ipsec.conf.org 
43,61d42
< conn L2TP
<        keyingtries=0
<        type=transport
<        compress=yes
<        authby=secret
<        forceencaps=yes
<        pfs=no
<        auto=add
<        ike=aes-sha1;modp3072
<        phase2=esp
<        phase2alg=aes-sha1;modp3072
<        rekey=no
<        salifetime=3h
<        ikelifetime=1h
<        left=192.168.0.4 # Raspberry PiのIPアドレスにする
<        leftprotoport=17/1701
<        right=%any
<        rightprotoport=17/%any
pi@raspberrypi /etc $ 

/etc/ipsec.secretsの編集

pi@raspberrypi /etc $ sudo diff ipsec.secrets ipsec.secrets.org
11,12d10
< 192.168.0.4 %any: PSK "XXXXXX"
pi@raspberrypi /etc $ 

openswan再起動とベリファイチェック

pi@raspberrypi /etc $ sudo service ipsec restart
ipsec_setup: Stopping Openswan IPsec...
ipsec_setup: Starting Openswan IPsec 2.6.37...
ipsec_setup: No KLIPS support found while requested, desperately falling back to netkey
ipsec_setup: NETKEY support found. Use protostack=netkey in /etc/ipsec.conf to avoid attempts to use KLIPS. Attempting to continue with NETKEY
pi@raspberrypi /etc $ sudo ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path                             [OK]
Linux Openswan U2.6.37/K3.6.11+ (netkey)
Checking for IPsec support in kernel                        [OK]
 SAref kernel support                                       [N/A]
 NETKEY:  Testing XFRM related proc values                  [OK]
[OK]
[OK]
Checking that pluto is running                              [OK]
 Pluto listening for IKE on udp 500                         [OK]
 Pluto listening for NAT-T on udp 4500                      [OK]
Checking for 'ip' command                                   [OK]
Checking /bin/sh is not /bin/dash                           [WARNING]
Checking for 'iptables' command                             [OK]
Opportunistic Encryption Support                            [DISABLED]

xl2tpdの設定

pi@raspberrypi /etc/xl2tpd $ sudo vi xl2tpd.conf
pi@raspberrypi /etc/xl2tpd $ sudo diff xl2tpd.conf xl2tpd.conf.org 
77,86d76
< [global]
< port = 1701
< [lns default]
< ip range = 192.168.0.201 - 192.168.0.210
< local ip = 192.168.0.4
< length bit = yes
< refuse chap = yes
< require authentication = yes
< pppoptfile = /etc/ppp/l2tpd.pppopt
pi@raspberrypi /etc/xl2tpd $ 

pppoptfileの作成

pi@raspberrypi /etc/xl2tpd $ sudo vi /etc/ppp/l2tpd.pppopt
pi@raspberrypi /etc/xl2tpd $ sudo cat /etc/ppp/l2tpd.pppopt
asyncmap 0
auth
crtscts
lock
modem
debug
proxyarp
lcp-echo-interval 180
lcp-echo-failure 3

refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2

ms-dns 192.168.0.1

pppd認証の設定

pi@raspberrypi /etc/ppp $ sudo diff chap-secrets chap-secrets.org 
3c3
< XXXXXX * XXXXXX *
---
pi@raspberrypi /etc/ppp $ 

自宅ルータの設定









あとはAndroid端末から接続・・・

うまく繋がりました!!

























☝️自宅Raspberry Piのredmineへ接続している様子
ここまで長かった〜orz

ついでにファイルサーバもインストール

sambaを導入。

参考サイト
http://assimane.blog.so-net.ne.jp/2013-03-30

pi@raspberrypi ~ $ sudo apt-get install samba
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の特別パッケージがインストールされます:
  tdb-tools
提案パッケージ:
  openbsd-inetd inet-superserver smbldap-tools ldb-tools ctdb
以下のパッケージが新たにインストールされます:
  samba tdb-tools
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
3,332 kB のアーカイブを取得する必要があります。
この操作後に追加で 20.1 MB のディスク容量が消費されます。
続行しますか [Y/n]? y
取得:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main samba armhf 2:3.6.6-6+deb7u1 [3,307 kB]
取得:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main tdb-tools armhf 1.2.10-2 [25.9 kB]
3,332 kB を 5秒 で取得しました (601 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ samba を選択しています。
(データベースを読み込んでいます ... 現在 70009 個のファイルとディレクトリがインストールされています。)
(.../samba_2%3a3.6.6-6+deb7u1_armhf.deb から) samba を展開しています...
以前に未選択のパッケージ tdb-tools を選択しています。
(.../tdb-tools_1.2.10-2_armhf.deb から) tdb-tools を展開しています...
man-db のトリガを処理しています ...
samba (2:3.6.6-6+deb7u1) を設定しています ...
Generating /etc/default/samba...
グループ `sambashare' (グループ ID 113) を追加しています...
完了。
update-alternatives: /usr/bin/smbstatus (smbstatus) を提供するために 自動モード で /usr/bin/smbstatus.samba3 を使います
[ ok ] Starting Samba daemons: nmbd smbd.
tdb-tools (1.2.10-2) を設定しています ...
update-alternatives: /usr/bin/tdbbackup (tdbbackup) を提供するために 自動モード で /usr/bin/tdbbackup.tdbtools を使います

pi@raspberrypi ~ $ 
pi@raspberrypi ~ $ sudo apt-get install samba-common-bin
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  samba-common-bin
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
2,690 kB のアーカイブを取得する必要があります。
この操作後に追加で 15.9 MB のディスク容量が消費されます。
取得:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main samba-common-bin armhf 2:3.6.6-6+deb7u1 [2,690 kB]
2,690 kB を 3秒 で取得しました (866 kB/s)     
以前に未選択のパッケージ samba-common-bin を選択しています。
(データベースを読み込んでいます ... 現在 70100 個のファイルとディレクトリがインストールされています。)
(.../samba-common-bin_2%3a3.6.6-6+deb7u1_armhf.deb から) samba-common-bin を展開しています...
man-db のトリガを処理しています ...
samba-common-bin (2:3.6.6-6+deb7u1) を設定しています ...
update-alternatives: /usr/bin/nmblookup (nmblookup) を提供するために 自動モード で /usr/bin/nmblookup.samba3 を使います
update-alternatives: /usr/bin/net (net) を提供するために 自動モード で /usr/bin/net.samba3 を使います
update-alternatives: /usr/bin/testparm (testparm) を提供するために 自動モード で /usr/bin/testparm.samba3 を使います
pi@raspberrypi ~ $ 

設定ファイルの更新

pi@raspberrypi ~ $ sudo cp -p /etc/samba/smb.conf /etc/samba/smb.conf.org
pi@raspberrypi ~ $ sudo vi /etc/samba/smb.conf
pi@raspberrypi ~ $ sudo diff /etc/samba/smb.conf /etc/samba/smb.conf.org
334,341d333
< [share]
< comment = share drive
< read only = no
< locking = no
< path = /home/pi/share
< guest ok = yes
< force user = pi
pi@raspberrypi ~ $ 


パスワードの設定と再起動

pi@raspberrypi ~ $ sudo smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.
pi@raspberrypi ~ $ sudo service samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.

パスワード : sanji

ドヤから確認し、無事アクセスできました。


2013年11月24日日曜日

RaspberryPiと戯れてみる 6 - Redmine自動バックアップ -

redmineの自動バックアップ

redmineのバックアップには
・redmine/files
・database
のバックアップが必要
http://t2wonderland.blogspot.jp/2013/02/redmine-redmine.html

1. files配下のバックアップ

redmine/filesはどこにあるか探した所、
/var/lib/redmine/default/files
にありました。

pi@raspberrypi /usr/backup/redmine $ sudo tar -cvzf /usr/backup/redmine/files_`date +%Y%m%d`.tgz /var/lib/redmine/default/files
tar: メンバ名から先頭の `/' を取り除きます
/var/lib/redmine/default/files/
/var/lib/redmine/default/files/131124140554_Puzzle.xlsx
files配下をtarファイルに圧縮するコマンドを実行。
tarファイルが作成されています。

2. databaseのバックアップ

参考サイトを元にダンプファイルを作成するコマンドを実行してみた所、
pi@raspberrypi /usr/backup/redmine $ sudo mysqldump -uredmine -pspice redmine > ./db_`date +%Y%m%d`.dump
mysqldump: Got error: 1045: ユーザー 'redmine'@'localhost' を拒否します.uUsing password: YES) when trying to connect

怒られてしまいましたorz。
はて?な感じなので普通にログインしてみる
pi@raspberrypi /usr/backup/redmine $ mysql -uredmine -pXXXX
ERROR 1045 (28000): ユーザー 'redmine'@'localhost' を拒否します.uUsing password: YES)

パスワードが違うとの事ですが、パスワードは合っています。

pi@raspberrypi /usr/backup/redmine $ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.31-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user, host, password from user;
ERROR 1046 (3D000): データベースが選択されていません.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| redmine_default    |
| test               |
+--------------------+
5 rows in set (0.01 sec)

mysql> use redmine_default;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user, host, password from user;
ERROR 1146 (42S02): Table 'redmine_default.user' doesn't exist
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user, host, password from user;
+------------------+-------------+-------------------------------------------+
| user             | host        | password                                  |
+------------------+-------------+-------------------------------------------+
| root             | localhost   | *7E4342FF084A70DD409EAB26EC7F6360D80F12BC |
| root             | raspberrypi | *7E4342FF084A70DD409EAB26EC7F6360D80F12BC |
| root             | 127.0.0.1   | *7E4342FF084A70DD409EAB26EC7F6360D80F12BC |
| root             | ::1         | *7E4342FF084A70DD409EAB26EC7F6360D80F12BC |
|                  | localhost   |                                           |
|                  | raspberrypi |                                           |
| debian-sys-maint | localhost   | *24EC3DF32614F55A010429412599E3D93437737E |
| redmine_default  | localhost   | *3BA1B4133A1E16B59311B1B379C2E78F19627CFE |
+------------------+-------------+-------------------------------------------+
8 rows in set (0.00 sec)

mysql> quit;
Bye
rootでmysqlへログインし、設定されているユーザ名とパスワード一覧を表示してみる事に
すると「redmine」ではなく「redmine_default」らしい。

これをふまえてmysqlのダンプ出力コマンドは、
pi@raspberrypi /usr/backup/redmine $ sudo mysqldump -uredmine_default -pXXXX redmine_default > ./db_`date +%Y%m%d`.dump
でダンプ出力ができました。

cronでバックアップしようと思ったのですが、今は未だ24時間起動しっぱなしでは無い為、
手動で行う事にしました。
ログイン時に自動でバックアップしてくれるように ~/.profileを編集
sudo /usr/backup/redmine/backup_redmine.sh
上記を一番下に追加しました。
これでpiユーザでログインする度に自動でバックアップが行われます。

2013年11月9日土曜日

RaspberryPiと戯れてみる 5 - Redmine SCM Repository Creation Plugin -

Redmine関連調査


前回、SCM Repository Creation pluginをインストールしてみたが、
リポジトリが作成できない。

そこでログを見てみる事に。
/var/log/redmine/default/production.log

Processing RepositoriesController#create (for 192.168.0.4 at 2013-11-09 10:25:32) [POST]
  Parameters: {"authenticity_token"=>"MKNJS+kSPag72DRzkCOd1c8JqoZO/jO07K7cWl3mgPw=", "repository_scm"=>"Git", "repository"=>{"is_default"=>"1", "identifier"=>"bibo", "url"=>"/var/www/repos/git/bibo-rock.git.0", "path_encoding"=>"", "extra_report_last_commit"=>"0"}, "commit"=>"リポジトリの作成", "operation"=>"add", "controller"=>"repositories", "action"=>"create", "project_id"=>"bibo-rock"}
Creating reporitory: /var/www/repos/git/bibo-rock.git.0.git

NoMethodError (undefined method `created_with_scm=' for #<Repository::Git:0x2544db0>):
  /usr/lib/ruby/vendor_ruby/active_record/attribute_methods.rb:270:in `method_missing'
  /usr/lib/ruby/vendor_ruby/action_controller/base.rb:1333:in `perform_action'
  /usr/lib/ruby/vendor_ruby/action_controller/filters.rb:617:in `call_filters'
  /usr/lib/ruby/vendor_ruby/action_controller/filters.rb:610:in `perform_action_with_filters'

NoMethodErrorが出ている?
google先生に聞いてみると、
rake redmine:plugins:migrate RAILS_ENV=production
このコマンドを実行してないのでは?というが前回実行したはず。
もう一度実行。するとabortしているorz
どうやらコマンドがredmineのバージョンによって異なるみたい。
http://stackoverflow.com/questions/13194653/rake-redminepluginsmigrate-is-not-executing

正しいコマンドで実行。
pi@raspberrypi /usr/share/redmine $ sudo rake db:migrate_plugins RAILS_ENV=production
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/share/redmine/vendor/rails/railties/lib/rails/gem_dependency.rb:21.
Migrating engines...
Migrating acts_as_activity_provider...
Migrating acts_as_attachable...
Migrating acts_as_customizable...
Migrating acts_as_event...
Migrating acts_as_list...
Migrating acts_as_searchable...
Migrating acts_as_tree...
Migrating acts_as_versioned...
Migrating acts_as_watchable...
Migrating awesome_nested_set...
Migrating classic_pagination...
Migrating gravatar...
Migrating open_id_authentication...
Migrating prepend_engine_views...
Migrating redmine_scm...
==  AddRepositoriesCreatedWithScm: migrating ==================================
-- add_column(:repositories, :created_with_scm, :boolean, {:default=>false, :null=>false})
   -> 0.1317s
==  AddRepositoriesCreatedWithScm: migrated (0.1355s) =========================

Migrating rfpdf...

どうやらうまくいったっぽい?
redmine上からgitリポジトリを作成。すると・・・見事作成できました!!













redmineとgitの連携
http://d.hatena.ne.jp/CortYuming/20120430/p1
上記のサイトを参考に実施