前言
CentOS7中安装google-drive-ocamlfuse比较简单,不会有组件版本不够新的问题,CentOS6的难点在于需要手动更新几个组件.
本篇安装环境:CentOS release 6.8 (Final)
1 2 |
[root@centos6 ~]# rpm -q centos-release centos-release-6-8.el6.centos.12.3.x86_64 |
* 英文官方指导 : google-drive-ocamlfuse Installation (https://github.com/astrada/google-drive-ocamlfuse/wiki/Installation)
* 中文参考教程 :下安装Google-drive-ocamlfuse,并挂载Google Drive (https://zhujiwiki.com/11186.html Centos/Ubuntu)
* 中文参考教程(含开机脚本) :[Linux][Google] CentOS掛載Google雲端硬碟 (https://www.lchick.idv.tw/?p=58)
官方步骤概览
1 2 3 4 5 6 7 8 9 10 11 |
# Connect CentOS repository. It will work for Amazon-Linux. #这个链接已经失效# sudo wget http://download.opensuse.org/repositories/home:ocaml/CentOS_7/home:ocaml.repo -P /etc/yum.repos.d/ # Install Ocaml and required dependencies. sudo yum install opam ocaml gcc gcc-c++ m4 make ocamldoc ocaml-camlp4-devel ncurses-devel opam init opam update opam install depext opam depext google-drive-ocamlfuse opam install google-drive-ocamlfuse |
实际安装和排错过程
安装必要组件:
sudo yum install opam ocaml gcc gcc-c++ m4 make ocamldoc ocaml-camlp4-devel ncurses-devel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
依赖解决: Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ====================================================================================== Installing: gcc x86_64 4.4.7-18.el6 base 10 M gcc-c++ x86_64 4.4.7-18.el6 base 4.7 M ncurses-devel x86_64 5.7-4.20090207.el6 base 641 k ocaml x86_64 3.11.2-5.el6 base 5.2 M ocaml-camlp4-devel x86_64 3.11.2-5.el6 base 6.3 M ocaml-ocamldoc x86_64 3.11.2-5.el6 base 2.1 M Installing for dependencies: cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k cpp x86_64 4.4.7-18.el6 base 3.7 M elfutils x86_64 0.164-2.el6 base 240 k elfutils-libs x86_64 0.164-2.el6 base 230 k gdb x86_64 7.2-92.el6 base 2.3 M gdbm-devel x86_64 1.8.0-39.el6 base 26 k glibc-devel x86_64 2.12-1.209.el6_9.2 updates 991 k glibc-headers x86_64 2.12-1.209.el6_9.2 updates 620 k kernel-headers x86_64 2.6.32-696.16.1.el6 updates 4.5 M libX11 x86_64 1.6.4-3.el6 base 587 k libX11-common noarch 1.6.4-3.el6 base 171 k libXau x86_64 1.0.6-4.el6 base 24 k libgomp x86_64 4.4.7-18.el6 base 134 k libstdc++-devel x86_64 4.4.7-18.el6 base 1.6 M libxcb x86_64 1.12-4.el6 base 180 k mpfr x86_64 2.4.1-6.el6 base 157 k ocaml-camlp4 x86_64 3.11.2-5.el6 base 11 M ocaml-runtime x86_64 3.11.2-5.el6 base 1.3 M patch x86_64 2.6-6.el6 base 90 k perl x86_64 4:5.10.1-144.el6 base 10 M perl-Module-Pluggable x86_64 1:3.90-144.el6 base 41 k perl-Pod-Escapes x86_64 1:1.04-144.el6 base 33 k perl-Pod-Simple x86_64 1:3.13-144.el6 base 213 k perl-libs x86_64 4:5.10.1-144.el6 base 579 k perl-version x86_64 3:0.77-144.el6 base 52 k ppl x86_64 0.10.2-11.el6 base 1.3 M redhat-rpm-config noarch 9.0.3-51.el6.centos base 60 k rpm-build x86_64 4.8.0-55.el6 base 131 k unzip x86_64 6.0-5.el6 base 152 k xz x86_64 4.999.9-0.5.beta.20091007git.el6 base 137 k xz-lzma-compat x86_64 4.999.9-0.5.beta.20091007git.el6 base 16 k Updating for dependencies: glibc x86_64 2.12-1.209.el6_9.2 updates 3.8 M glibc-common x86_64 2.12-1.209.el6_9.2 updates 14 M libgcc x86_64 4.4.7-18.el6 base 103 k libstdc++ x86_64 4.4.7-18.el6 base 295 k Transaction Summary ====================================================================================== Install 37 Package(s) Upgrade 4 Package(s) Total download size: 88 M Is this ok [y/N]: y |
opam init //可忽略这一步试试行不行.
1 2 |
[root@centos6 ~]# opam init -bash: opam: command not found |
说明opam没有安装成功,寻找安装opam的脚本安装:
1 |
wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s /usr/local/bin/ |
安装成功
ocaml切换到最新版: (否则ocaml版本太老不满足google-drive-ocamlfuse的依赖条件)
/usr/local/bin//opam init --comp 4.05.0
1 2 3 4 5 |
/usr/local/bin//opam init --comp 4.05.0 <==虽然现在查看ocaml的默认版本还是3.11.2老版,不过已经没有问题,安装程序会自行调用新版. [root@centos6 ~]# ocaml -version The Objective Caml toplevel, version 3.11.2 |
安装opam的依赖分析器,depext可以尝试自动安装OPAM软件包所需的系统软件包
1 |
opam install depext |
安装google-drive-ocamlfuse的依赖包: opam depext google-drive-ocamlfuse
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# opam depext google-drive-ocamlfuse 将要安装的依赖信息 Dependencies Resolved ====================================================================== Package Arch Version Repository Size ====================================================================== Installing: fuse-devel x86_64 2.8.3-5.el6 base 32 k gmp-devel x86_64 4.3.1-12.el6 base 171 k libcurl-devel x86_64 7.19.7-53.el6_9 updates 247 k openssl-devel x86_64 1.0.1e-57.el6 base 1.2 M sqlite-devel x86_64 3.6.20-1.el6_7.2 base 81 k zlib-devel x86_64 1.2.3-29.el6 base 44 k Installing for dependencies: autoconf noarch 2.63-5.1.el6 base 781 k automake noarch 1.11.1-4.el6 base 550 k fuse-libs x86_64 2.8.3-5.el6 base 74 k keyutils-libs-devel x86_64 1.4-5.el6 base 29 k krb5-devel x86_64 1.10.3-65.el6 base 504 k libcom_err-devel x86_64 1.41.12-23.el6 base 33 k libidn-devel x86_64 1.18-2.el6 base 137 k libkadm5 x86_64 1.10.3-65.el6 base 143 k libselinux-devel x86_64 2.0.94-7.el6 base 137 k libsepol-devel x86_64 2.0.41-4.el6 base 64 k Updating for dependencies: curl x86_64 7.19.7-53.el6_9 updates 197 k e2fsprogs x86_64 1.41.12-23.el6 base 554 k e2fsprogs-libs x86_64 1.41.12-23.el6 base 121 k gmp x86_64 4.3.1-12.el6 base 207 k krb5-libs x86_64 1.10.3-65.el6 base 675 k libcom_err x86_64 1.41.12-23.el6 base 38 k libcurl x86_64 7.19.7-53.el6_9 updates 169 k libss x86_64 1.41.12-23.el6 base 42 k openssl x86_64 1.0.1e-57.el6 base 1.5 M Transaction Summary ====================================================================== Install 16 Package(s) Upgrade 9 Package(s) Total download size: 7.6 M Is this ok [y/N]: y |
安装opam install google-drive-ocamlfuse本体: opam install google-drive-ocamlfuse
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@centos6 ~]# opam install google-drive-ocamlfuse [WARNING] Running as root is not recommended The following actions will be performed: ∗ install conf-perl 1 [required by zarith] ∗ install conf-m4 1 [required by ocamlfind] ∗ install camlidl 1.05 [required by google-drive-ocamlfuse] ∗ install conf-pkg-config 1.0 [required by sqlite3] ∗ install conf-gmp 1 [required by conf-gmp-powm-sec, zarith] ∗ install ocamlbuild 0.12.0 [required by google-drive-ocamlfuse] ∗ install ocamlfind 1.7.3 [required by google-drive-ocamlfuse] ∗ install conf-zlib 1 [required by cryptokit] ∗ install conf-gmp-powm-sec 1 [required by cryptokit] ∗ install zarith 1.7 [required by cryptokit] ∗ install xmlm 1.2.0 [required by gapi-ocaml] ∗ install sqlite3 4.1.3 [required by google-drive-ocamlfuse] ∗ install ocurl 0.7.0 [required by gapi-ocaml] ∗ install ocamlfuse 2.7.1-cvs5 [required by google-drive-ocamlfuse] ∗ install jbuilder 1.0+beta16 [required by cppo] ∗ install base-bytes base [required by ounit] ∗ install cryptokit 1.12 [required by gapi-ocaml] ∗ install easy-format 1.3.0 [required by yojson] ∗ install ounit 2.0.6 [required by google-drive-ocamlfuse] ∗ install ocamlnet 4.1.4 [required by gapi-ocaml] ∗ install cppo 1.6.0 [required by extlib, yojson] ∗ install biniou 1.0.6 [required by yojson] ∗ install extlib 1.7.2 [required by gapi-ocaml] ∗ install yojson 1.3.3 [required by gapi-ocaml] ∗ install gapi-ocaml 0.3.5 [required by google-drive-ocamlfuse] ∗ install google-drive-ocamlfuse 0.6.22 ===== ∗ 26 ===== Do you want to continue ? [Y/n] |
同意以后出现conf-gmp-powm-sec的错误,原因是GMP版本太低(或者不存在),而我们需要>=5的版本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ∗ installed conf-m4.1 ∗ installed conf-gmp.1 ∗ installed conf-perl.1 ∗ installed conf-pkg-config.1.0 [ERROR] The compilation of conf-gmp-powm-sec failed at "sh -exc cc -c $CFLAGS -I/usr/local/include test.c". ∗ installed conf-zlib.1 ∗ installed camlidl.1.05 ∗ installed ocamlbuild.0.12.0 ∗ installed ocamlfind.1.7.3 ∗ installed base-bytes.base ∗ installed jbuilder.1.0+beta16 ∗ installed ocamlfuse.2.7.1-cvs5 ∗ installed cppo.1.6.0 ∗ installed easy-format.1.3.0 ∗ installed biniou.1.0.6 ∗ installed extlib.1.7.2 ∗ installed sqlite3.4.1.3 ∗ installed ocurl.0.7.0 ∗ installed xmlm.1.2.0 ∗ installed ounit.2.0.6 ∗ installed yojson.1.3.3 ∗ installed zarith.1.7 ∗ installed ocamlnet.4.1.4 #=== ERROR while installing conf-gmp-powm-sec.1 ===============================# # opam-version 1.2.2 # os linux # command sh -exc cc -c $CFLAGS -I/usr/local/include test.c # path /root/.opam/4.05.0/build/conf-gmp-powm-sec.1 # compiler 4.05.0 # exit-code 1 # env-file /root/.opam/4.05.0/build/conf-gmp-powm-sec.1/conf-gmp-powm-sec-8142-be72be.env # stdout-file /root/.opam/4.05.0/build/conf-gmp-powm-sec.1/conf-gmp-powm-sec-8142-be72be.out # stderr-file /root/.opam/4.05.0/build/conf-gmp-powm-sec.1/conf-gmp-powm-sec-8142-be72be.err ### stderr ### # + cc -c -I/usr/local/include test.c # test.c:6:2: error: #error "GMP >= 5 is required to support mpz_powm_sec" =-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The following actions were aborted ∗ install cryptokit 1.12 ∗ install gapi-ocaml 0.3.5 ∗ install google-drive-ocamlfuse 0.6.22 The following actions failed ∗ install conf-gmp-powm-sec 1 The following changes have been performed ∗ install base-bytes base ∗ install biniou 1.0.6 ∗ install camlidl 1.05 ∗ install conf-gmp 1 ∗ install conf-m4 1 ∗ install conf-perl 1 ∗ install conf-pkg-config 1.0 ∗ install conf-zlib 1 ∗ install cppo 1.6.0 ∗ install easy-format 1.3.0 ∗ install extlib 1.7.2 ∗ install jbuilder 1.0+beta16 ∗ install ocamlbuild 0.12.0 ∗ install ocamlfind 1.7.3 ∗ install ocamlfuse 2.7.1-cvs5 ∗ install ocamlnet 4.1.4 ∗ install ocurl 0.7.0 ∗ install ounit 2.0.6 ∗ install sqlite3 4.1.3 ∗ install xmlm 1.2.0 ∗ install yojson 1.3.3 ∗ install zarith 1.7 The former state can be restored with: opam switch import "~/.opam/4.05.0/backup/state-20171104174422.export" |
安装新版GMP
下载地址 https://gmplib.org/#DOWNLOAD
1 2 3 4 5 6 7 |
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2 tar -xjvf gmp-6.1.2.tar.bz2 cd gmp-6.1.2 ./configure make make check <=非常重要! ! make install |
最后完成安装opam install google-drive-ocamlfuse,如下信息表示安装完毕.
1 2 3 4 5 6 7 |
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ∗ installed conf-gmp-powm-sec.1 ∗ installed cryptokit.1.12 ∗ installed gapi-ocaml.0.3.5 ∗ installed google-drive-ocamlfuse.0.6.22 Done. [root@centos6 ]# |
让环境变量立即生效(否则需要重启系统?)
1 2 3 4 5 |
export DISPLAY=:0.0 //这句可以不执行 source ~/.bash_profile <=非常重要! ! //这是让前面那些安装修改的环境变量立即生效,否则会出现"-bash: google-drive-ocamlfuse: command not found"问题. [root@centos6 googledrive]# google-drive-ocamlfuse -version google-drive-ocamlfuse, version 0.6.22 |
获取授权
运行google-drive-ocamlfuse -id 12345678.apps.googleusercontent.com -secret abcde12345 无法获得URL,这是因为centos6没有安装xgd-open
可尝试 google-drive-ocamlfuse -headless -label me -id ##yourClientID##.apps.googleusercontent.com -secret ###yoursecret#####
1 2 3 4 5 |
[root@centos6 ]# google-drive-ocamlfuse -id xx7038332872-qsaps89rs0sur7t66at9h9n1ljahfqtr.apps.googleusercontent.com -secret 8cRHCyubYeJI4p9-eLGU22xx /bin/sh: xdg-open: command not found /bin/sh: firefox: command not found /bin/sh: google-chrome: command not found /bin/sh: chromium-browser: command not found |
检查发现没有安装xdg-open
1 2 |
[root@centos6 ]# yum list | grep xdg-open [root@centos6 ]# |
安装 xdg-utils : yum install xdg-utils
1 |
[root@centos6 ]# yum install xdg-utils |
生成API授权url:
生成方式1
google-drive-ocamlfuse -headless -label me -id ##yourClientID## -secret ##yoursecret##
1 2 3 |
[root@centos6 ~]# google-drive-ocamlfuse -headless -label me -id xx7038332872-qsaps89rs0sur7t66at9h9n1ljahfqtr.apps.googleusercontent.com -secret 8cRHCyubYeJI4p9-eLGU22xx Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=xx7038332872-qsaps89rs0sur7t66at9h9n1ljahfqtr.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force Please enter the verification code: |
生成方式2
google-drive-ocamlfuse -id ##yourClientID## -secret ##yoursecret##
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@centos6 ]# google-drive-ocamlfuse -id xx7038332872-qsaps89rs0sur7t66at9h9n1ljahfqtr.apps.googleusercontent.com -secret 8cRHCyubYeJI4p9-eLGU22xx /usr/bin/xdg-open: line 402: htmlview: command not found /usr/bin/xdg-open: line 402: firefox: command not found /usr/bin/xdg-open: line 402: mozilla: command not found /usr/bin/xdg-open: line 402: netscape: command not found /usr/bin/xdg-open: line 402: links: command not found /usr/bin/xdg-open: line 402: lynx: command not found xdg-open: no method available for opening 'https://accounts.google.com/o/oauth2/auth?client_id=xx7038332872-qsaps89rs0sur7t66at9h9n1ljahfqtr.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force' /bin/sh: firefox: command not found /bin/sh: google-chrome: command not found /bin/sh: chromium-browser: command not found Please enter the verification code: |
输入登录授权码
1 2 3 |
Please enter the verification code: 4/b83Lv1RQlZJn78dIkvAwyr8OUFcqt6BmVes2SEGgxxx Access token retrieved correctly. 授权成功 |
挂载Google Drive (完成)
创建目录并且挂载谷歌云磁盘成功,df -lh可看到可用空间
1 2 3 4 5 6 7 8 |
[root@centos6 ]# mkdir ~/googledrive [root@centos6 ]# google-drive-ocamlfuse ~/googledrive [root@centos6 ]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda1 985G 1.8G 973G 1% / tmpfs 499M 0 499M 0% /dev/shm google-drive-ocamlfuse 8.0E 1.3T 8.0E 1% /root/googledrive |
开机启动脚本
用 type google-drive-ocamlfuse 可找到真实路劲
1 2 |
[root@centos6 ~]# type google-drive-ocamlfuse google-drive-ocamlfuse is /root/.opam/4.05.0/bin/google-drive-ocamlfuse |
启动命令的主要语法
1 2 3 4 |
#!/bin/bash su root -l -c "google-drive-ocamlfuse ~/gdfuse" exit 0 |
修改执行权限: sudo chmod +x gdfuse #sh文件
创建挂载目录: mkdir ~/gdfuse #挂载目录
给权挂载目录: chown root:root ~/gdfuse
开机启动方式1:在/etc/init.d目录下添加开机初始化脚本
1 2 |
cd /etc/init.d vi gdfuse |
编写gdfuse启动脚本
1 2 3 4 5 6 7 8 |
#!/bin/sh #add for chkconfig #chkconfig: 2345 70 30 #description: zidingyi wenzi #processname: gdfuse su root -l -c "google-drive-ocamlfuse ~/gdfuse" exit O |
说明>
1 2 3 4 5 6 |
2345是指脚本的运行级别,即在2345这4种模式下都可以运行,234都是文本界面,5就是图形界面X 70是指脚本将来的启动顺序号,如果别的程序的启动顺序号比70小(比如44、45),则脚本需要等这些程序都启动以后才启动。 30是指系统关闭时,脚本的停止顺序号。 #description: the description of the shell #关于脚本的简短描述 #processname: servicename #进程名,后边设置自启动的时候会用到 |
利用chkconfig命令将脚本设置为自启动
1 |
chkconfig --add servicename |
这样你的脚本就可以在开机后自动运行,reboot重启观察应当生效.否则排查脚本的路径或者权限是否有问题.
开机启动方式2:把启动程序的命令添加到/etc/rc.d/rc.local文件中,reboot重启观察应当已经挂载成功.
vi /etc/rc.d/rc.local
1 2 3 4 5 6 7 8 9 |
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local su root -l -c "google-drive-ocamlfuse ~/gdfuse" |
这种方式的缺陷是在所有init方式启动之后才执行rc.local,如果有init启动的软件需要立即调用google drive,可能会崩溃出错.