Merge branch 'main' into stable
This commit is contained in:
commit
8b216f6730
4 changed files with 83 additions and 8 deletions
|
@ -93,6 +93,35 @@ define sunetdrive::app_type (
|
|||
unless $is_multinode{
|
||||
user { 'www-data': ensure => present, system => true }
|
||||
|
||||
file { '/usr/local/bin/get_containers':
|
||||
ensure => present,
|
||||
force => true,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
content => template('sunetdrive/application/get_containers'),
|
||||
mode => '0744',
|
||||
}
|
||||
if ($environment == 'test' and ($nodenumber == 3)) {
|
||||
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',
|
||||
}
|
||||
sunet::scriptherder::cronjob { 'scriptherder_scan_external_mounts':
|
||||
cmd => '/usr/local/bin/scan_external_mounts',
|
||||
hour => '1',
|
||||
minute => '20',
|
||||
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||
}
|
||||
cron { 'scan_external_mounts':
|
||||
ensure => absent,
|
||||
command => 'true',
|
||||
}
|
||||
}
|
||||
file { '/opt/nextcloud/cron.sh':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
|
|
|
@ -38,6 +38,35 @@ class sunetdrive::multinode (
|
|||
user { 'www-data': ensure => present, system => true }
|
||||
sunet::system_user {'mysql': username => 'mysql', group => 'mysql' }
|
||||
ensure_resource('file', '/opt/nextcloud' , { ensure => directory, recurse => true } )
|
||||
file { '/usr/local/bin/get_containers':
|
||||
ensure => present,
|
||||
force => true,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
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',
|
||||
}
|
||||
sunet::scriptherder::cronjob { 'scriptherder_scan_external_mounts':
|
||||
cmd => '/usr/local/bin/scan_external_mounts',
|
||||
hour => '1',
|
||||
minute => '20',
|
||||
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||
}
|
||||
cron { 'scan_external_mounts':
|
||||
ensure => absent,
|
||||
command => 'true',
|
||||
}
|
||||
}
|
||||
file { '/usr/local/bin/nocc':
|
||||
ensure => present,
|
||||
force => true,
|
||||
|
@ -87,14 +116,6 @@ class sunetdrive::multinode (
|
|||
content => template('sunetdrive/multinode/get_non_paying_customers.erb.sh'),
|
||||
mode => '0744',
|
||||
}
|
||||
file { '/usr/local/bin/get_containers':
|
||||
ensure => present,
|
||||
force => true,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
content => template('sunetdrive/multinode/get_containers'),
|
||||
mode => '0744',
|
||||
}
|
||||
file { '/usr/local/bin/restart_and_prune':
|
||||
ensure => present,
|
||||
force => true,
|
||||
|
|
25
templates/application/scan_external_mounts.sh
Normal file
25
templates/application/scan_external_mounts.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
error_ids=""
|
||||
# Only run if this is the only instance of this script running
|
||||
# note: since this script forks to run pgrep, we need -eq 2 here
|
||||
if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
|
||||
# We sleep a deterministic amount of time, which will be between 0 an 128 m and allways the same within
|
||||
# a specific host, but will differ between hosts
|
||||
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
|
||||
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}" | grep Error
|
||||
# shellcheck disable=SC2181
|
||||
if [[ ${?} -eq 0 ]]; then
|
||||
error_ids="${error_ids} ${id}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -n "${error_ids}" ]]; then
|
||||
echo "Errors found in the following mounts: ${error_ids}"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
Loading…
Add table
Reference in a new issue