diff --git a/conf/mc.src b/conf/mc.src new file mode 100644 index 0000000..8f12cdd --- /dev/null +++ b/conf/mc.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2021-11-05T10-05-06Z +SOURCE_SUM=9f5ad72fd93678f9f756c6da34a8d4d1e61f7356a96ee327c652ad765975d2b2 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT= +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME=mc +SOURCE_EXTRACT=false diff --git a/scripts/backup b/scripts/backup index b5eae4f..b01124b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) datadir=$(ynh_app_setting_get --app=$app --key=datadir) +mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/install b/scripts/install index a7a39b8..ee0fd9c 100755 --- a/scripts/install +++ b/scripts/install @@ -62,6 +62,8 @@ ynh_script_progression --message="Validating installation parameters..." --time final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +mc_path=$final_path/mc + # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -78,6 +80,8 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=minio_id --value=$minio_id ynh_app_setting_set --app=$app --key=minio_key --value=$minio_key +ynh_app_setting_set --app=$app --key=mc_path --value=$mc_path + #================================================= # STANDARD MODIFICATIONS @@ -154,6 +158,30 @@ chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# DOWNLOAD, CHECK AND UNPACK MINIO CLIENT +#================================================= +ynh_script_progression --message="Setting up MinIO client..." --time --weight=1 + +ynh_setup_source --dest_dir="$mc_path" --source_id=mc + +# FIXME: this should be managed by the core in the future +# Here, as a packager, you may have to tweak the ownerhsip/permissions +# such that the appropriate users (e.g. maybe www-data) can access +# files in some cases. +# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - +# this will be treated as a security issue. +chmod -R 750 "$mc_path" +chmod -R o-rwx "$mc_path" +chown -R $app:www-data "$mc_path" + +#================================================= +# SETUP MINIO CLIENT +#================================================= +ynh_script_progression --message="Setting up MinIO bucket for Outline..." --time --weight=1 + +$mc_path/mc alias set minio "https://$domain" $minio_id $minio_key + #================================================= # NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index caa3d6b..d960d38 100755 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) +mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) + #================================================= # CHECK IF THE APP CAN BE RESTORED