10 ファイルとプログラムの移植

ファイルとプログラムの移植

注意

  • Raspbianのプロンプトは、$
  • キー入力の文字は、緑色
  1. apache2のファイル(CSSとindex.htmlファイル)の移植
    tab1.ssとtab2.cssの2つのファイルを/var/www/html/cssディレクトリーにコピーします。
    cd /var/www
    $ sudo chmod 777 html
    $ cd html
    $ sudo mkdir css
    $ sudo chmod 777 css
    WinSCPを使い、tab1.cssとtab2.cssファイルを/var/www/html/cssディレクトリーにコピーし、パーミッションを644に設定します。
    WinSCP CSS
    $ sudo chmod 755 css
    index.htmlファイルをWinSCPで/var/www/htmlディレクトリ―に上書きコピーします。そしてパーミッションを変更します。
    $ sudo chmod 644 /var/www/html/index.html
    $ sudo chmod 755 /var/www/html
  2. apache2ファイル移植後の動作の確認
    Web browserで以下のURLにアクセスし、「This web site has been closed.」と表示されれはOK
    http://192.168.7.251
  3. プログラムの移植
    次のpythonのプログラムを/usr/lib/cgi-binディレクトリーにWinSCPでコピーし、パーミッションを設定します。
    $ sudo chmod 777 /usr/lib/cgi-bin
    averagetempetoday.py    644
    bootmail.py    644
    cameraposition7.py    644
    ClimateChart1month.py    755
    ClimateChart1week.py    755
    ClimateChart.py    755
    csvexport.py    644
    defaultgatewayping.py    644
    get_climate.py    644
    intruderdetect.py    644
    loadconfig.py    644
    log_info.py    644
    pir8.py    644
    previousip.txt    666
    sekisan.txt    666
    sekisanondograph.py    755
    sekisanondosetting.py    755
    SendGmail.py    644
    wanip.py    644
    whiteledon3.py    644
    wifirouterswitch.py    644
    WinSCPで/usr/lib/cgi-binにcsvディレクトリーを作成し、パーミッションを777にします。
    $ sudo chmod 755 /usr/lib/cgi-bin
  4. cronの設定
    $ crontab -e
    no crontab for root – using an empty oneSelect an editor. To change later, run ‘select-editor’.
    1. /bin/ed
    2. /bin/nano <—- easiest
    3. /usr/bin/vim.tinyChoose 1-3 [2]: 2
    一番下に次の5行を追加します。

    */10 * * * * python /usr/lib/cgi-bin/get_climate.py
    */10 * * * * python /usr/lib/cgi-bin/wanip.py
    00 10 1 * * python /usr/lib/cgi-bin/csvexport.py
    */20 * * * * sudo python /usr/lib/cgi-bin/defaultgatewayping.py
    55 * * * * python /usr/lib/cgi-bin/averagetempetoday.py

  5. rc.localにraspbain起動時に自動的に動かすプログラムを記述します
    $ cd /etc
    $ sudo nano rc.local
    exit 0の前に次の行を追加します。
    # Power switch ON WiFi router
    sudo python /usr/lib/cgi-bin/wifirouterswitch.py# Boot mail
    sudo python /usr/lib/cgi-bin/bootmail.py &# Intruder detect
    sudo python /usr/lib/cgi-bin/intruderdetect.py &

    exit 0

  6. raspbianを再起動します。
    $ sudo reboot