Archive abandoned project
This commit is contained in:
parent
bc8862d90b
commit
65be894048
501 changed files with 24305 additions and 0 deletions
104
esh_archivebox/recipes/compose.rb
Normal file
104
esh_archivebox/recipes/compose.rb
Normal file
|
@ -0,0 +1,104 @@
|
|||
#
|
||||
# Cookbook:: esh_photoprism
|
||||
# Recipe:: compose
|
||||
#
|
||||
# Copyright:: 2022, https://easyself.host
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
directory '/opt/archivebox' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0700'
|
||||
action :create
|
||||
end
|
||||
|
||||
template '/opt/archivebox/docker-compose.yml' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0400'
|
||||
variables volume_data: "/var/lib/#{node['hostname']}-data"
|
||||
action :create
|
||||
end
|
||||
|
||||
execute 'docker compose pull' do
|
||||
command 'docker compose pull'
|
||||
cwd '/opt/archivebox'
|
||||
live_stream true
|
||||
action :run
|
||||
end
|
||||
|
||||
apt_package 'expect'
|
||||
|
||||
file '/tmp/archivebox-init.expect' do
|
||||
content <<~EOT
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
set timeout -1
|
||||
|
||||
cd /opt/archivebox
|
||||
spawn /usr/bin/docker compose run archivebox init --setup
|
||||
|
||||
expect "Username"
|
||||
send -- "#{node['esh']['archivebox']['username']}\\r"
|
||||
|
||||
expect "Email address:"
|
||||
send -- "#{node['esh']['archivebox']['email']}\\r"
|
||||
|
||||
expect "Password:"
|
||||
send -- "#{node['esh']['archivebox']['password']}\\r"
|
||||
|
||||
expect "Password (again):"
|
||||
send -- "#{node['esh']['archivebox']['password']}\\r"
|
||||
|
||||
expect eof
|
||||
EOT
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0400'
|
||||
not_if { ::File.exist?("/var/lib/#{node['hostname']}-data/index.sqlite3")}
|
||||
notifies :run, 'execute[init archivebox configuration]', :immediately
|
||||
action :create
|
||||
end
|
||||
|
||||
execute 'init archivebox configuration' do
|
||||
command 'expect -f /tmp/archivebox-init.expect'
|
||||
live_stream true
|
||||
action :nothing
|
||||
end
|
||||
|
||||
systemd_unit 'archivebox.service' do
|
||||
content <<~EOU
|
||||
[Unit]
|
||||
Description=archivebox via docker compose
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
WorkingDirectory=/opt/archivebox
|
||||
ExecStart=/usr/bin/docker compose up -d
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOU
|
||||
action [:create, :enable]
|
||||
subscribes :restart, 'template[/opt/archivebox/docker-compose.yml]', :delayed
|
||||
end
|
||||
|
||||
service 'archivebox' do
|
||||
action :nothing
|
||||
subscribes :start, 'execute[docker compose pull]', :delayed
|
||||
end
|
17
esh_archivebox/recipes/default.rb
Normal file
17
esh_archivebox/recipes/default.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Cookbook:: esh_archivebox
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2022, https://easyself.host
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
61
esh_archivebox/recipes/init.rb
Normal file
61
esh_archivebox/recipes/init.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# Cookbook:: esh_archivebox
|
||||
# Recipe:: init
|
||||
#
|
||||
# Copyright:: 2022, https://easyself.host
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
apt_package %w(systemd-container expect)
|
||||
|
||||
service 'archivebox' do
|
||||
action :stop
|
||||
not_if { ::File.exist?("/var/lib/#{node['hostname']}-data/index.sqlite3")}
|
||||
end
|
||||
|
||||
file '/tmp/archivebox-init.expect' do
|
||||
content <<~EOT
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
set timeout -1
|
||||
|
||||
spawn systemd-nspawn --oci-bundle=/var/lib/machines/archivebox/ --machine archivebox --hostname archivebox --bind /var/lib/#{node['hostname']}-data:/data --capability=CAP_CHOWN -- /app/bin/docker_entrypoint.sh init --setup
|
||||
|
||||
expect "Username (leave blank to use 'root'):"
|
||||
send -- "#{node['esh']['archivebox']['username']}\\r"
|
||||
|
||||
expect "Email address:"
|
||||
send -- "#{node['esh']['archivebox']['email']}\\r"
|
||||
|
||||
expect "Password:"
|
||||
send -- "#{node['esh']['archivebox']['password']}\\r"
|
||||
|
||||
expect "Password (again):"
|
||||
send -- "#{node['esh']['archivebox']['password']}\\r"
|
||||
|
||||
expect eof
|
||||
EOT
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0400'
|
||||
not_if { ::File.exist?("/var/lib/#{node['hostname']}-data/index.sqlite3")}
|
||||
notifies :run, 'execute[init archivebox configuration]', :immediately
|
||||
action :create
|
||||
end
|
||||
|
||||
execute 'init archivebox configuration' do
|
||||
command 'expect -f /tmp/archivebox-init.expect'
|
||||
live_stream true
|
||||
action :nothing
|
||||
notifies :start, 'service[archivebox]', :immediately
|
||||
end
|
26
esh_archivebox/recipes/system.rb
Normal file
26
esh_archivebox/recipes/system.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# Cookbook:: esh_archivebox
|
||||
# Recipe:: system
|
||||
#
|
||||
# Copyright:: 2022, https://easyself.host
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# The app use 999:999
|
||||
directory "/var/lib/#{node['hostname']}-data" do
|
||||
owner 999
|
||||
group 999
|
||||
mode '0750'
|
||||
not_if { ::Dir.exist?("/var/lib/#{node['hostname']}-data") }
|
||||
action :create
|
||||
end
|
39
esh_archivebox/recipes/undocker.rb
Normal file
39
esh_archivebox/recipes/undocker.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# Cookbook:: esh_archivebox
|
||||
# Recipe:: undocker
|
||||
#
|
||||
# Copyright:: 2022, https://easyself.host
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
url = node['esh']['archivebox']['docker']['url']
|
||||
image = node['esh']['archivebox']['docker']['image']
|
||||
tag = node['esh']['archivebox']['docker']['tag']
|
||||
network = node['esh']['archivebox']['docker']['network']
|
||||
env = node['esh']['archivebox']['docker']['env']
|
||||
service = node['esh']['archivebox']['docker']['service']
|
||||
|
||||
esh_undocker_download url do
|
||||
image image
|
||||
tag tag
|
||||
end
|
||||
|
||||
esh_undocker_extract image do
|
||||
tag tag
|
||||
network network
|
||||
env env
|
||||
end
|
||||
|
||||
esh_undocker_service image do
|
||||
content service
|
||||
end
|
Reference in a new issue