2017年2月9日木曜日

Raspberry Pi Zero WiFiドングル差した時にNASのディレクトリをmount

※2018/8/28 update
OSをGNU/Linux 9 (stretch)に上げたら、エラーでmount出来なくなったので、
ms="mount -t cifs //192.168.128.237/iTunes /home/shin/nas237_music -o iocharset=utf8,vers=1.0,username=root,password=xxxx"
とver.指定を追加しました。

mpd用に、WiFiドングル差した時にNASのディレクトリをmountする
python script書いてみた。

#!/usr/bin/env python
from time import sleep
import sys
import os

import os.path
wifi='/sys/class/net/wlan0'
mc="mountpoint -q /home/xxx/nas123_music"
ms="mount -t cifs //192.168.1.123/iTunes /home/xxx/nas123_music -o iocharset=utf8,username=root,password=xxxx"

while True :
    if  os.path.exists(wifi):
        rc=os.system(mc)
        if rc!=0:
           os.system(ms)
        sleep(10.0)

0 件のコメント: