OSDN Git Service

fix volume mounting for the official image. bubbleupnp-server-0.2.1
authorwhitestar <whitestar@users.osdn.me>
Mon, 3 Jan 2022 06:34:17 +0000 (15:34 +0900)
committerwhitestar <whitestar@users.osdn.me>
Mon, 3 Jan 2022 06:34:17 +0000 (15:34 +0900)
cookbooks/bubbleupnp-server/CHANGELOG.md
cookbooks/bubbleupnp-server/recipes/docker-compose.rb
cookbooks/bubbleupnp-server/templates/default/etc/cron.d/bubbleupnp-server-local
cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/backup.sh [new file with mode: 0755]
cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/restore.sh [new file with mode: 0755]
cookbooks/bubbleupnp-server/version

index 1f90ce1..9b2d038 100644 (file)
@@ -1,5 +1,10 @@
 # bubbleupnp-server CHANGELOG
 
+0.2.1
+-----
+- fix volume mounting for the official image.
+- add backup and restore scripts.
+
 0.2.0
 -----
 - add 0.9-6 and the official image support.
index 4f3745d..24a1c8c 100644 (file)
@@ -50,9 +50,13 @@ force_override_config_srvs = node.force_override['bubbleupnp-server']['docker-co
 envs = {}
 vols = config_srvs['bubbleupnp-server']['volumes'].to_a
 
-vols.push("#{data_dir}/configuration.xml:#{workdir}/configuration.xml:rw")
-vols.push("#{data_dir}/cache:#{workdir}/cache:rw")
-vols.push("#{data_dir}/Playlists:#{workdir}/Playlists:rw")
+# Note: the official image already contains the following volume definitions.
+if dot_env['REGISTRY'] != 'bubblesoftapps'
+  # bind mounting
+  vols.push("#{data_dir}/configuration.xml:#{workdir}/configuration.xml:rw")
+  vols.push("#{data_dir}/cache:#{workdir}/cache:rw")
+  vols.push("#{data_dir}/Playlists:#{workdir}/Playlists:rw")
+end
 
 # merge environment hash
 force_override_config_srvs['bubbleupnp-server']['environment'] = envs unless envs.empty?
@@ -78,6 +82,21 @@ end
   end
 }
 
+[
+  'backup.sh',
+  'restore.sh',
+].each {|conf_file|
+  template "#{app_dir}/#{conf_file}" do
+    source "opt/docker-compose/app/bubbleupnp-server/#{conf_file}"
+    owner 'root'
+    group 'root'
+    mode '0755'
+    variables(
+      workdir: workdir
+    )
+  end
+}
+
 dockerfile_tpl = 'Dockerfile'
 dockerfile_tpl = 'Dockerfile.armhf' if node['kernel']['machine'] == 'armv7l'
 template "#{app_dir}/Dockerfile" do
index 1c862f1..8615a8b 100644 (file)
@@ -13,4 +13,4 @@ LOG=<%= log %>
 APP_HOME=<%= node['bubbleupnp-server']['docker-compose']['app_dir'] %>
 OPTS='<%= opts %>'
 
-@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && cd $APP_HOME && docker-compose $OPTS down >> $LOG 2>&1 && docker-compose $OPTS up -d >> $LOG 2>&1 && docker-compose ps >> $LOG 2>&1
+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && cd $APP_HOME && docker-compose $OPTS stop >> $LOG 2>&1 && docker-compose $OPTS up -d >> $LOG 2>&1 && docker-compose ps >> $LOG 2>&1
diff --git a/cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/backup.sh b/cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/backup.sh
new file mode 100755 (executable)
index 0000000..44eee28
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+backup_dir=bak
+container_id=`sudo docker-compose ps -q bubbleupnp-server`
+
+sudo mkdir -p ./${backup_dir}
+sudo docker cp ${container_id}:<%= @workdir %>/configuration.xml ./${backup_dir}
+sudo docker cp ${container_id}:<%= @workdir %>/cache ./${backup_dir}
+sudo docker cp ${container_id}:<%= @workdir %>/Playlists ./${backup_dir}
diff --git a/cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/restore.sh b/cookbooks/bubbleupnp-server/templates/default/opt/docker-compose/app/bubbleupnp-server/restore.sh
new file mode 100755 (executable)
index 0000000..58051b2
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+backup_dir=bak
+container_id=`sudo docker-compose ps -q bubbleupnp-server`
+
+sudo docker cp ./${backup_dir}/configuration.xml ${container_id}:<%= @workdir %>/
+sudo docker cp ./${backup_dir}/cache ${container_id}:<%= @workdir %>/
+sudo docker cp ./${backup_dir}/Playlists ${container_id}:<%= @workdir %>/