diff --git a/manifests/app_type.pp b/manifests/app_type.pp index c279318..ebf4f90 100644 --- a/manifests/app_type.pp +++ b/manifests/app_type.pp @@ -97,6 +97,22 @@ define sunetdrive::app_type ( content => template('sunetdrive/application/get_containers'), mode => '0744', } + if ($environment == 'test') { + file { '/usr/local/bin/scan_external_mounts': + ensure => present, + force => true, + owner => 'root', + group => 'root', + content => template('sunetdrive/application/scan_external_mounts.sh'), + mode => '0744', + } + cron { 'scan_external_mounts': + command => '/usr/local/bin/scan_external_mounts', + user => 'root', + minute => '42', + hour => '9', + } + } unless $is_multinode{ user { 'www-data': ensure => present, system => true } diff --git a/templates/application/scan_external_mounts.sh b/templates/application/scan_external_mounts.sh new file mode 100644 index 0000000..cc18148 --- /dev/null +++ b/templates/application/scan_external_mounts.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Only run if this is the only instance of this script running +if [[ $(pgrep -f "${0}" | wc -l) -eq 1 ]]; then + for container in $(get_containers); do + for id in $(nocc "${container}" files_external:list --all --output json | jq '.[].mount_id' | jq .); do + nocc "${container}" files_external:scan "${id}" + done + done +fi