Merge pull request '`rclone`をインストールする。' (#62) from install-rclone into master

Reviewed-on: #62
This commit is contained in:
Kazuhiro MUSASHI 2020-11-14 16:40:49 +09:00
commit a89a554afd
6 changed files with 91 additions and 1 deletions

View File

@ -8,5 +8,12 @@ node.reverse_merge!({
'digdag' => {
'binary_url' => 'https://dl.digdag.io/digdag-latest',
'install_path' => '/opt/digdag'
}
},
'rclone' => {
'url' => 'https://github.com/rclone/rclone/releases/download/',
'prefix' => 'rclone-',
'postfix' => '-linux-amd64',
'storage' => '/opt/rclone/',
'location' => '/usr/local/bin/'
},
})

View File

@ -4,6 +4,9 @@ include_recipe './install.rb'
include_recipe './setup.rb'
include_recipe './rclone_install.rb'
include_recipe './rclone_setup.rb'
# AWS EC2 Swap Setting:
if !node['is_ec2']
include_recipe './shared_dir.rb'

View File

@ -0,0 +1,4 @@
[gp]
type = google photos
token = {"access_token":"ya29.A0AfH6SMAv55TYq299mIJKY0zz-p3SS7JDzgGJERacdy64ckRdiL4vgjQTwgokYd6b8gnJ5oLcGwmAxUUPF-eYwD9LhrlSYcSYM8HzHJIpUuV70eJtF-Gw2QBMmkYDm3j7GpvjqNllketPeL0_KMYM40liOlxn7mqDJjvu_gFV7qg","token_type":"Bearer","refresh_token":"1//0gQgQpQWIend5CgYIARAAGBASNwF-L9IrQhnEw_xvzBygu6Bfsorr7Nl0e3Uah3PKxM2Oe_v14zPcOwSV4bC4y8UaYRj61Y33K7g","expiry":"2020-11-14T02:07:28.57842896+09:00"}

View File

@ -0,0 +1,4 @@
[gp]
type = google photos
token = {"access_token":"ya29.A0AfH6SMAv55TYq299mIJKY0zz-p3SS7JDzgGJERacdy64ckRdiL4vgjQTwgokYd6b8gnJ5oLcGwmAxUUPF-eYwD9LhrlSYcSYM8HzHJIpUuV70eJtF-Gw2QBMmkYDm3j7GpvjqNllketPeL0_KMYM40liOlxn7mqDJjvu_gFV7qg","token_type":"Bearer","refresh_token":"1//0gQgQpQWIend5CgYIARAAGBASNwF-L9IrQhnEw_xvzBygu6Bfsorr7Nl0e3Uah3PKxM2Oe_v14zPcOwSV4bC4y8UaYRj61Y33K7g","expiry":"2020-11-14T02:07:28.57842896+09:00"}

View File

@ -0,0 +1,48 @@
rclone_url = ''
rclone_dir = ''
vtag = ''
# Calculate the Download URL:
begin
require 'net/http'
uri = URI.parse('https://github.com/rclone/rclone/releases/latest')
Timeout.timeout(3) do
response = Net::HTTP.get_response(uri)
vtag = $1 if response.body =~ %r{tag\/(v\d+\.\d+\.\d+)}
rclone_dir = "#{node['rclone']['prefix']}#{vtag}#{node['rclone']['postfix']}"
rclone_url = "#{node['rclone']['url']}/#{vtag}/#{rclone_dir}.zip"
end
rescue
# Abort the chef client process:
raise 'Cannot connect to http://github.com.'
end
# バージョン確認して、アップデート必要かどうか確認
result = run_command("rclone --version 2>&1 | grep #{vtag}", error: false)
if result.exit_status != 0
# Download:
TMP = "/tmp/#{rclone_dir}.zip"
execute "wget #{rclone_url} -O #{TMP}"
# Install:
execute "unzip -d /opt/ -o #{TMP}"
execute "mv /opt/#{rclone_dir} /opt/rclone"
# Change Owner and Permissions:
file "#{node['rclone']['storage']}rclone" do
owner 'root'
group 'root'
mode '755'
end
# Create Link
link "#{node['rclone']['location']}rclone" do
to "#{node['rclone']['storage']}rclone"
end
end

View File

@ -0,0 +1,24 @@
# Deploy the files:
directory '/home/kazu634/.config/rclone/' do
owner 'kazu634'
group 'kazu634'
mode '750'
end
remote_file "/home/kazu634/.config/rclone/rclone.conf" do
owner 'kazu634'
group 'kazu634'
mode '600'
end
directory '/root/.config/rclone/' do
owner 'root'
group 'root'
mode '750'
end
remote_file "/root/.config/rclone/rclone.conf" do
owner 'kazu634'
group 'kazu634'
mode '600'
end