라즈베리 클라우드로 변신

date: 2017-10-04 19:48:35 +0900
categories:   라즈베리, btsync, rsiliosync, owncloud

프롤로그

Dropbox를 활용해서 토렌트 파일을 공유하고 텔레그램 봇에게 명령을 내리지 않아도,
스스로 다운로드를 받게 하려고(미완료) Dropbox 라즈베리 설치를 검새하는 도중 bittorrented sync 라는 제목의 TechG 기사 보고 사진을 공유해서 바로 바로 티브이에서 확인하면 좋겠다는 생각으로 시작

유리병 라즈베리 백업장비


(올 멋있다. 이렇게 함 만들어 보자 ... 2017이 다가기 전에)

이 유리병 백업 장치는 라즈베리 파이 모듈에 PC와 모바일 장치의 파일 동기화 프로그램인 비트토렌드 싱크(BitTorrent Sync)를 조합해 만들었다. 라즈베리 파이 버전의 비트토렌트 싱크, Node.js, 그 외 필요한 패키지 등 묶은 소프트웨어로 이뤄졌고, 데이터 전송 상태를 확인하기 위해 LED를 붙인 것이 전부다. 라즈베리 파이에 프로그램으로 올린 비트토렌트 싱크는 p2p(peer-to-peer) 서비스로 알려진 비트토렌트 그룹에서 만든 프로그램으로 PC와 스마트폰, 태블릿 같은 장치의 저장공간을 연결하는 재주를 갖고 있다. 여기에 쓰레기통에 버려질 운명의 유리병과 나무 받침대를 활용, 기판뿐인 라즈베리 파이 백업 장치를 멋진 장식품으로 꾸몄다.
원문 Back Up And Sync Your Files Inside A Mason Jar With Raspberry Preserve

Resilio Sync 설치(10/3)

블로그를 보고 설치하려고 했으나 다운로드 파일이 없어서  검새 후
Resilio Sync on Raspberry Pi 를 참조 설치 성공
(그동안 변해 있어음. 완존 상용 드랍박스외 또다른 류 ???)

sudo mkdir -p /opt/resilio/bin
sudo mkdir /opt/resilio/app_files
cd /opt/resilio/bin
sudo wget https://download-cdn.resilio.com/stable/linux-arm/resilio-sync_arm.tar.gz
sudo tar -xvf resilio-sync_arm.tar.gz
sudo rm -f resilio-sync_arm.tar.gz
sudo ./rslsync --webui.listen 0.0.0.0:8888

부팅시 자동으로 시작되도록 서비스 등록 --> 실패, 이유 해당 서비스를 찾지 못함???

sudo systemctl enable resilio-sync
sudo systemctl (command) resilio-sync

==> 패키지 형태로 재 설치 그러나 minidlna가 지원하는 이미지 포멧에 제한이 있음 아이폰의 포멧 HEIC는 지원하지 않음. 1.1.2 에서는 JPG만 지원함

  • 설치순서
  • For arm64 architecture For Raspberry Pi 1
sudo dpkg --add-architecture armhf
sudo apt-get update
  • In /etc/apt/sources.list change the line as follows:
    deb [arch=armhf] http://linux-packages.resilio.com/resilio-sync/deb resilio-sync non-free
참고 : armhf is
an architecture used mostly in mobile devices and netbooks. Its more common name is ARM, or the Acorn RISC (reduced instruction set computing) Machine (see here for more information). Some packages that are not multi-arch will not install properly, whether they are i386 or not.
  • 설치
sudo apt-get update
sudo apt-get install resilio-sync
  • Enable sync service automatic startup as user rslsync:
sudo systemctl enable resilio-sync    

USB 외장하드 ntfs mount  이슈

문제점 :  외장하드 파티션에서 chmod, chown 명령 적용이 안됨
예) sudo chmod -R 777 ./dlna 에러가 나지는 않지만 권한변경이 기존대로 유지됨

  • As-IS /etc/fstab의 외장하드 mount 명려여
    /dev/sda1       /media/usbhdd1         ntfs    defaults,noatime  0       0

원인(추정) : ntfs는 윈도우 파일 포멧으로 파일 형식에 실행권한이 주는게 아니라 확장자로 구분 즉 리눅스와 다른 파일 포멧으로 외장하드를 마운트 했기때문에 리눅스에서 쓰이는 파일권한 적용이 되지 않는 것임

해결 : ntfs-3g 재설치(sudo apt-get updates && apt-get upgrade -y && sudo apt-get install ntfs-3g) 후 외장하드 UUID를 사용하고 마운트 옵션에 permissions 추가

출처- How do I use 'chmod' on an NTFS (or FAT32) partition?
========================
Contrary to what most people believe, NTFS is a POSIX-compatible¹ filesystem, and it is possible to use permissions on NTFS.
To enable this, you need a "User Mapping File" or just give the permissions option when mounting (when no compatibility with Windows is needed). This maps linux users on your system with the user IDs like NTFS/Windows use them internally.
See the ntfs-3g manpage for some info and some examples. If you need more information, see the ntfs-3g advanced documentation about ownership and permissions.
======================
For NTFS partitions, use the permissions option in fstab.
First unmount the ntfs partition.
  • Identify your partition UUID with blkid
sudo blkid
  • Then edit /etc/fstab
sudo -e /etc/fstab
  • And add or edit a line for the ntfs partition, change the "UUID" to your partition UUID
UUID=12102C02102CEB83 /media/windows ntfs-3g auto,users,permissions 0 0
The options I gave you, auto, will automatically mount the partition when you boot and users allows users >to mount and umount .
You can then use chown and chmod on the ntfs partition.

기타  --> Kernal까지는 아니더라도 Disk mount 대한 이해 필요

ntfs-3g unknown Filesystem error,  터입을 ntfs로 할경우 permissions unknown option error --> 정상 부팅 되지않고 Emergency Mode로 들어감

UUID로 변경후  udev mtp-probe를 시도하다가 에러발생 -->  libmtp-runtime 인스톨로 해결

출처 - "failed to execute /lib/udev/mtp-probe" at boot
Got the "failed to execute /lib/udev/mtp-probe" message at boot recently.  Is there anything wrong with >my system?
Do you have a file /lib/udev/mtp-probe and is it executable?
It comes with package 'libmtp-runtime'. Install libmtp-runtime
  • 이후 정상 부팅이 되었으나 권한이 변경됨 777 -> 7000,

Owncloud 설치(10/8)

Setting up Owncloud on linux is a mess of various terminal commands. Thankfully, Github user Petrockblog has made it very simple. He created a shell script for installing and updating Owncloud. Simply do the following:
Install Github:
sudo apt-get update
sudo apt-get install -y git dialog
Download the latest setup script:
cd
git clone git://github.com/petrockblog/OwncloudPie.git
And execute the script:
cd OwncloudPie
chmod +x owncloudpie_setup.sh
sudo ./owncloudpie_setup.sh
  • 저장 디렉토리 변경 :
  • 원래 /var/www/html/owncloud/config/config.php datadirectory => /var/www/html/owncloud/data
  • 변경 /media/usbhdd1/shares/owncloud-data
  • 설치 후 바로 제거 resilio-sync와 중복되고, 폰앱 유료이고 평도 좋지 않음

미제

  1. minidlna를 설치 하여 사진을 라즈베리에 저장하고 티브이의 쉐어기능(dlna)를 활용하여 사진을 보도록 이미 구성해 놓았음(5/29/2017)

라즈베리 : minidlna 설치, 외장하드에 비디오, 사진 디렉토리 생성

사진 디렉토리에 볼맘 폰디렉토리(아이폰 6s), 내폰(아이폰 7plus) 생성하고 사진을 복사해 놓았음

근데 문제는 어떤 App를 사용하여 해당 디렉토리에 복사를 했는지 모르겟음.

왜 디렉토리 이름이 내가 생성한 이름이 아님
--> 해결
사진을 TV에서 바로 볼 수 있게 하기 위해서 기 설치된 samba를 활용할 수 있도록, 아이폰에서 samba 지원 앱 FileExplorer 설치했고 TV에서 자동으로 인식 사진을 볼 수 있도록 dlna를 라즈베리에서 지원할 수 있도록 minidlna 설치했던 것임
내 아이디어는 아니고 누군가의 아이디어 있었던 거 같은데 .... 정리 해 두지 않아서 모르겠음

minidlna : dlna 지원, TV 스마트쉐어에서 자동 인식 사진 보기 가능
samba : imac, windows, iphone  파일 공유
FileExplorer : 아이폰에서 samba 서버 접근 기능 제공

nfts 파티션(외장하드/삼바공유) chmod/chown 작동하지 않음

minidlna 실시간 업데이트되지 않음

  • 1.1.2 버전을 1.2.1 업그레이드 실패 패키지 형태로 제공되지 않고 소스 설치해야함, 오류가 많아 포기
  • 실시간 업데이트가 안되기보다는 지원하는 사진포멧이 JPG 뿐임(버전 1.1.2)