From: whitestar Date: Tue, 4 Jan 2022 08:11:16 +0000 (+0900) Subject: add backup cron configuration. X-Git-Tag: bubbleupnp-server-0.2.3^0 X-Git-Url: http://git.osdn.net/view?p=metasearch%2Fgrid-chef-repo.git;a=commitdiff_plain;h=dc380910284e7a055d73868a48da3d96ffa0e329 add backup cron configuration. --- diff --git a/cookbooks/bubbleupnp-server/CHANGELOG.md b/cookbooks/bubbleupnp-server/CHANGELOG.md index 9e61d84..e09da87 100644 --- a/cookbooks/bubbleupnp-server/CHANGELOG.md +++ b/cookbooks/bubbleupnp-server/CHANGELOG.md @@ -1,5 +1,9 @@ # bubbleupnp-server CHANGELOG +0.2.3 +----- +- add backup cron configuration. + 0.2.2 ----- - fix the restore script. diff --git a/cookbooks/bubbleupnp-server/README.md b/cookbooks/bubbleupnp-server/README.md index 7ea22e6..0f9b153 100644 --- a/cookbooks/bubbleupnp-server/README.md +++ b/cookbooks/bubbleupnp-server/README.md @@ -86,7 +86,7 @@ override_attributes( 'config' => { 'services' => { 'bubbleupnp-server' => { - 'restart' => 'no', + 'restart' => 'unless-stopped', }, }, }, diff --git a/cookbooks/bubbleupnp-server/attributes/default.rb b/cookbooks/bubbleupnp-server/attributes/default.rb index 31c98a9..fa56e97 100644 --- a/cookbooks/bubbleupnp-server/attributes/default.rb +++ b/cookbooks/bubbleupnp-server/attributes/default.rb @@ -65,7 +65,7 @@ version_2_config = { 'services' => { 'bubbleupnp-server' => { 'image' => '${REGISTRY}/${NAME}:${VER}', - 'restart' => 'always', + 'restart' => 'unless-stopped', 'network_mode' => 'host', 'volumes' => [ # These volumes will be set by the bubbleupnp-server::docker-compose recipe automatically. diff --git a/cookbooks/bubbleupnp-server/recipes/docker-compose.rb b/cookbooks/bubbleupnp-server/recipes/docker-compose.rb index 24a1c8c..b9879c5 100644 --- a/cookbooks/bubbleupnp-server/recipes/docker-compose.rb +++ b/cookbooks/bubbleupnp-server/recipes/docker-compose.rb @@ -26,8 +26,12 @@ app_dir = node['bubbleupnp-server']['docker-compose']['app_dir'] data_dir = node['bubbleupnp-server']['docker-compose']['data_dir'] dot_env = node['bubbleupnp-server']['docker-compose']['dot_env'] +file_owner = 'root' +file_group = 'root' workdir = '/usr/share/bubbleupnpserver' if dot_env['VER'] > '0.9-5' || dot_env['VER'] == 'latest' + file_owner = 'bubbleupnpserver' + file_group = 'users' workdir = '/opt/bubbleupnpserver' end @@ -92,6 +96,8 @@ end group 'root' mode '0755' variables( + file_owner: file_owner, + file_group: file_group, workdir: workdir ) end diff --git a/cookbooks/bubbleupnp-server/templates/default/etc/cron.d/bubbleupnp-server-local b/cookbooks/bubbleupnp-server/templates/default/etc/cron.d/bubbleupnp-server-local index 8615a8b..9a2e104 100644 --- a/cookbooks/bubbleupnp-server/templates/default/etc/cron.d/bubbleupnp-server-local +++ b/cookbooks/bubbleupnp-server/templates/default/etc/cron.d/bubbleupnp-server-local @@ -14,3 +14,4 @@ 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 stop >> $LOG 2>&1 && docker-compose $OPTS up -d >> $LOG 2>&1 && docker-compose ps >> $LOG 2>&1 +30 * * * * root date "$DATE_F" >> $LOG && cd $APP_HOME && ./backup.sh >> $LOG 2>&1 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 index a3b5439..74351c6 100755 --- 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 @@ -9,4 +9,4 @@ sudo docker cp ./${backup_dir}/cache ${container_id}:<%= @workdir %>/ sudo docker cp ./${backup_dir}/Playlists ${container_id}:<%= @workdir %>/ # fix file owner -sudo docker exec -u root ${container_id} chown -R bubbleupnpserver:users <%= @workdir %>/{configuration.xml,cache,Playlists} +sudo docker exec -u root ${container_id} chown -R <%= @file_owner %>:<%= @file_group %> <%= @workdir %>/{configuration.xml,cache,Playlists} diff --git a/cookbooks/bubbleupnp-server/version b/cookbooks/bubbleupnp-server/version index ee1372d..7179039 100644 --- a/cookbooks/bubbleupnp-server/version +++ b/cookbooks/bubbleupnp-server/version @@ -1 +1 @@ -0.2.2 +0.2.3