====== grive2 ====== * Linux용 [[linux:googledrive|Google Drive for Linux]] Client 2015 신규 Google Drive API에 맞춰 개발된 버전. * https://github.com/vitalif/grive2 * [[https://www.linuxuprising.com/2018/08/cli-google-drive-client-grive2-how-to.html|Cli Google Drive Client Grive2: How To Enable Automatic Synchronization - Linux Uprising Blog]] * [[http://dothisbest.com/how-to/install-google-drive-grive2-on-ubuntu/|How to install Google Drive Grive2 on Ubuntu]] * [[http://www.webupd8.org/2015/05/grive2-grive-fork-with-google-drive.html|Grive2: Grive Fork With Google Drive REST API And Partial Sync Support [PPA] ~ Web Upd8: Ubuntu / Linux blog]] ===== pacstall 설치 ===== pacstall -I grive2-git ===== Debian Build Package ===== * https://github.com/vitalif/grive2/releases 에서 소스 다운로드 sudo apt-get install git cmake build-essential libgcrypt20-dev \ libyajl-dev libboost-all-dev libcurl4-openssl-dev libexpat1-dev \ libcppunit-dev binutils-dev debhelper zlib1g-dev dpkg-dev \ pkg-config libstdc++-9-dev # 특히 libstdc++-9-dev 주의! 문서에는 안나오는 의존성임. 또한 Ubuntu 22.04 이전 버전에서는 ''libstdc++-7-dev'' 이었음. cd /tmp git clone https://github.com/vitalif/grive2.git # 소스 압축푼 디렉토리로 이동(ext 파티션이어야 한다) cd grive2 dpkg-buildpackage -j4 # 상위디렉토리에 deb 패키지 생성됨 sudo dpkg -i # 마지막에 오류 발생하는 것은 무시 dpkg-buildpackage: info: full upload; Debian-native package (full source is included) signfile grive2_0.5.2+git20210315.dsc gpg: skipped "Vitaliy Filippov ": No secret key gpg: dpkg-sign.v7YLDLyX/grive2_0.5.2+git20210315.dsc: clear-sign failed: No secret key dpkg-buildpackage: error: failed to sign .dsc file ===== API 인증 ===== * 2019년 11월 부터 Google Drive API 를 사용자가 작접 id와 secret 을 받아서 지정해줘야만 하게 되었다.(추후 바뀔 수 있음) * https://github.com/vitalif/grive2/issues/287#issuecomment-557704687 - Go to https://console.developers.google.com/apis/library. Login with your Google account and create a new project on Google Cloud Platform. You can also use an existing one. - Search for Google Drive API and enable it. - Go to API Credentials page (https://console.developers.google.com/apis/credentials) - Create a new OAuth Client credential. You will be provided with a id and a secret. Save both because you gonna need it for grive2. - Then you need to follow this repo README, download grive2, build and install. Then run grive -a --id [client id] --secret [client secret] # id 는 긴코드값.apps.googleusercontent.com 형태이다. ===== 사용 ===== * 신규 동기화 mkdir SyncDir # 신규 동기화 디렉토리 생성 cd SyncDir grive -a # 신규 동기화 시작 * 일단 디렉토리 동기화를 한 번 지정하면 해당 디렉토리에 인증 정보가 저장되어 ''grive'' 명령만으로 동기화를 수행한다. * 동기화 # 동기화 대상 디렉토리에서 cd SyncDir grive # 혹은 grive -p /path/to/SyncDir * Options * ''-V'' : verbose * ''-l [/path/to/logfile.log]'' : 로깅 * ''-a'' : 신규 동기화 인증 * ''-p [/path/to/sync]'' : 동기화할 디렉토리 지정. * **NTFS 파티션**에서 오류가 발생했다. [[linux:partition|Linux Partition]]을 참조하여 ''/etc/fstab/''의 해당 파티션 옵션에 ''fmask=111,uid=1000''을 추가했더니 잘 작동했다. ===== 동기화 ===== * [[linux:systemd|systemd]] 서비스를 제공해주는데, 시간 기반과 파일 변경기반 두가지를 제공해준다. * 하나의 구글 드라이브에 대해서 둘 중의 하나만 적용해야 한다. * 아래 예에서 ''google-drive'' 는 ''$HOME'' 에 있는 구글 드라이브 디렉토리이다. ==== time based ==== systemctl --user enable grive-timer@$(systemd-escape google-drive).timer systemctl --user start grive-timer@$(systemd-escape google-drive).timer ==== change based ==== * ''inotify-tools'', ''inotifywait'' 명령으로 변경 감지 동기화 systemctl --user enable grive-changes@$(systemd-escape google-drive).service systemctl --user start grive-changes@$(systemd-escape google-drive).service ==== log ==== journalctl -f --user-unit=grive-timer@$(systemd-escape google-drive).timer journalctl -f --user-unit=grive-changes@$(systemd-escape google-drive).service * 만약 systemd 서비스가 작동하지 않는다면 ''grive-sync.sh'' 파일의 경로가 잘못됐을 수 있다. * ''/usr/[local/]lib/systemd/user/grive-timer@.service'' 혹은 ''/usr/[local/]lib/systemd/user/grive-changes@.service'' 파일에서 ''grive-sync.sh'' 파일 경로 확인. * 현재 해당 파일이 ''/lib/x86_64-linux-gnu/grive/grive-sync.sh''로 설치 됐는데, ''/usr/libexec/grive''에서 찾는 현상 발생 * pacstall로 설치시에는 ''/usr/local/libexec/grive/grive-sync.sh'' cd /usr/libexec sudo mkdir -p /usr/libexec/grive cd /usr/libexec/grive sudo ln -s /lib/x86_64-linux-gnu/grive/grive-sync.sh