Script to remount userbuckets as project buckets
This commit is contained in:
parent
812a56cf99
commit
932d91364e
|
@ -141,6 +141,14 @@ define sunetdrive::app_type (
|
||||||
content => template('sunetdrive/application/upgrade23-25.erb.sh'),
|
content => template('sunetdrive/application/upgrade23-25.erb.sh'),
|
||||||
mode => '0744',
|
mode => '0744',
|
||||||
}
|
}
|
||||||
|
file { '/usr/local/bin/remount_user_bucket_as_project.sh':
|
||||||
|
ensure => present,
|
||||||
|
force => true,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
content => template('sunetdrive/application/remount_user_bucket_as_project.sh'),
|
||||||
|
mode => '0744',
|
||||||
|
}
|
||||||
file { '/opt/rotate/conf.d/nextcloud.conf':
|
file { '/opt/rotate/conf.d/nextcloud.conf':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
force => true,
|
force => true,
|
||||||
|
|
72
templates/application/remount_user_bucket_as_project.sh
Executable file
72
templates/application/remount_user_bucket_as_project.sh
Executable file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mountid="${1}"
|
||||||
|
user="${2}"
|
||||||
|
container="${3}"
|
||||||
|
if [[ -z ${mountid} ]] || [[ -z ${user} ]]; then
|
||||||
|
echo "We need a valid mount id and user to proceed"
|
||||||
|
echo "Usage: ${0} <mountid> <user> [<container>]"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z ${container} ]]; then
|
||||||
|
container="nextcloud_app_1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
occ="/usr/local/bin/occ"
|
||||||
|
function get_config {
|
||||||
|
${occ} files_external:config ${mountid} ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
bucket="$(get_config bucket)"
|
||||||
|
hostname="$(get_config hostname)"
|
||||||
|
key="$(get_config key)"
|
||||||
|
port="$(get_config port)"
|
||||||
|
region="$(get_config region)"
|
||||||
|
secret="$(get_config secret)"
|
||||||
|
jsonfile="/tmp/${user}-user-bucket.json"
|
||||||
|
mount_point="${user/@/-}"
|
||||||
|
mount_point="${mount_point/./-}-user-bucket"
|
||||||
|
|
||||||
|
echo "This will remount the user bucket with mountid ${mountid} for ${user} as project bucket with mountpoint ${mount_point}."
|
||||||
|
read -r -p "Press enter to continue"
|
||||||
|
|
||||||
|
echo '
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"mount_point": "\/'${mount_point}'",
|
||||||
|
"storage": "\\OCA\\Files_External\\Lib\\Storage\\AmazonS3",
|
||||||
|
"authentication_type": "amazons3::accesskey",
|
||||||
|
"configuration": {
|
||||||
|
"bucket": "'${bucket}'",
|
||||||
|
"hostname": "'${hostname}'",
|
||||||
|
"key": "'${key}'",
|
||||||
|
"legacy_auth": false,
|
||||||
|
"port": "'${port}'",
|
||||||
|
"region": "'${region}'",
|
||||||
|
"secret": "'${secret}'",
|
||||||
|
"storageClass": "",
|
||||||
|
"useMultipartCopy": false,
|
||||||
|
"use_path_style": true,
|
||||||
|
"use_ssl": true
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"encrypt": true,
|
||||||
|
"previews": true,
|
||||||
|
"enable_sharing": true,
|
||||||
|
"filesystem_check_changes": 0,
|
||||||
|
"encoding_compatibility": false,
|
||||||
|
"readonly": false
|
||||||
|
},
|
||||||
|
"applicable_users": [
|
||||||
|
],
|
||||||
|
"applicable_groups": ["admin"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
' > "${jsonfile}"
|
||||||
|
|
||||||
|
|
||||||
|
docker cp ${jsonfile} ${container}:/${jsonfile}
|
||||||
|
${occ} files_external:import /${jsonfile}
|
||||||
|
docker exec ${container} rm /${jsonfile}
|
||||||
|
${occ} files_external:delete ${mountid}
|
Loading…
Reference in a new issue