1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minio_ynh.git synced 2024-09-03 19:46:18 +02:00

Merge pull request #38 from Limezy/fix-migration

Fix broken migration
This commit is contained in:
Limezy 2023-02-02 00:17:47 +07:00 committed by GitHub
commit 0c776b05f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2022-12-24T15-21-38Z
SOURCE_SUM=8274f56d3ca69b2538fd818ff53a793c2fe1fc568489d97ee74d463123536aa6
SOURCE_URL=https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2023-01-28T20-29-38Z
SOURCE_SUM=ecd7b92a7a5c6e74db16fcd19950a28fa8ccb1fcc343ff37050787da346f7d4e
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mc

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://dl.min.io/client/mc/release/linux-arm64/archive/mc.RELEASE.2022-12-24T15-21-38Z
SOURCE_SUM=5a29fb81e9a7d75b0afca9fbccfca6eba6c54e7dcefbe8b0ac662bc7a70e089a
SOURCE_URL=https://dl.min.io/client/mc/release/linux-arm64/archive/mc.RELEASE.2023-01-28T20-29-38Z
SOURCE_SUM=319fb47eb7f48e3e6efff1151bb82d44463d5c23f94495146c813f9ed2531a4b
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mc

View file

@ -128,6 +128,23 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A High Performance, Kubernetes Native Object Storage" --log="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
if ynh_compare_current_package_version --comparison lt --version 2022.12.12~ynh1
then
ynh_script_progression --message="Moving old Filesystem to secure MinIO start"
tmp="/tmp/minio"
ynh_exec_warn_less cp -Ra "$datadir" "$tmp"
ynh_secure_remove --file="$datadir"
ynh_exec_warn_less mkdir "$datadir"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
@ -159,21 +176,20 @@ ynh_script_progression --message="Ensuring downward compatibility..."
if ynh_compare_current_package_version --comparison lt --version 2022.12.12~ynh1
then
ynh_script_progression --message="Migration from Filesystem to Single-Node Single-Drive mode"
pushd $datadir
pushd "$tmp/"
for d in * ; do
if [ "$d" == "*" ]
then
ynh_script_progression --message="No buckets to migrate"
else
ynh_script_progression --message="Migrating bucket $d"
mv "$d" "DATA_$d"
pushd $mc_path
ynh_exec_warn_less sudo -u $app ./mc mb minio/"$d"
ynh_exec_warn_less sudo -u $app ./mc mirror --preserve "$datadir/DATA_$d" minio/"$d"
ynh_exec_warn_less sudo -u $app ./mc mirror --preserve "$tmp/$d" "minio/$d"
# This is a hack, but it will make outline_ynh users' lifes much easier !
if [ "$d" == "outlinestorage" ]
then
ynh_exec_warn_less sudo -u $app ./mc policy set public minio/outlinestorage
ynh_exec_warn_less sudo -u $app ./mc anonymous set public minio/outlinestorage
else
ynh_script_progression --message="Bucket is migrated and objects are now mirrored. However, make sure to set properly access policy of bucket $d. That part of the migration can't be automated, sorry ! You can log into the minio console to perform your changes."
fi
@ -182,6 +198,7 @@ then
fi
done
popd
ynh_secure_remove --file="$tmp"
else
ynh_script_progression --message="No migration required"
fi