diff --git a/conf/app.src.default b/conf/app.src.default deleted file mode 100644 index 1347e37..0000000 --- a/conf/app.src.default +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-__VERSION__.tar.bz2 -SOURCE_SUM=__SHA256_SUM__ -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.bz2 -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/nextcloud.cron b/conf/nextcloud.cron index e04f227..e040d0c 100644 --- a/conf/nextcloud.cron +++ b/conf/nextcloud.cron @@ -1 +1 @@ -*/15 * * * * __USER__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/cron.php +*/15 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINAL_PATH__/cron.php diff --git a/hooks/post_user_create b/hooks/post_user_create index da6bb53..c6717ef 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -1,5 +1,6 @@ #!/bin/bash -user=$1 +user="$1" +app="$(basename $0 | cut -d- -f 2-)" # Extract the app name from the script name, which is supposed to be something like "50-app_id" -sudo setfacl --modify g:__GROUP__:rwx /home/$user +setfacl --modify g:$app:rwx /home/$user diff --git a/manifest.json b/manifest.json index 063d098..ccc8955 100644 --- a/manifest.json +++ b/manifest.json @@ -22,7 +22,7 @@ "email": "pierre@kayou.io" }, "requirements": { - "yunohost": ">= 4.1.6" + "yunohost": ">= 4.2" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index adf5f21..ca742ee 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -102,42 +102,3 @@ ynh_smart_mktemp () { #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -#================================================= -# YUNOHOST MULTIMEDIA INTEGRATION -#================================================= - -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.2" - local checksum="806a827ba1902d6911095602a9221181" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1 - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Check if the package acl is installed. Or install it. - ynh_package_is_installed 'acl' \ - || ynh_package_install acl - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Grant write access to multimedia directories to a specified user -# -# usage: ynh_multimedia_addaccess user_name -# -# | arg: user_name - User to be granted write access -ynh_multimedia_addaccess () { - local user_name=$1 - groupadd -f multimedia - usermod -a -G multimedia $user_name -} diff --git a/scripts/change_url b/scripts/change_url index e9f4ba7..f89e12e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -111,7 +111,7 @@ then exec_occ config:system:set trusted_domains 1 --value=$new_domain # Change hostname for activity notifications - ynh_replace_string --match_string="'overwrite.cli.url' => 'http://${old_domain}'," --replace_string="'overwrite.cli.url' => 'https://${new_domain}'," --target_file="${final_path}/config/config.php" + exec_occ config:system:set overwrite.cli.url --value="https://${new_domain}" fi if [ $change_domain -eq 1 ] diff --git a/scripts/install b/scripts/install index 6b49c74..614c496 100755 --- a/scripts/install +++ b/scripts/install @@ -73,10 +73,15 @@ ynh_script_progression --message="Setting up source files..." # Load the last available version source upgrade.d/upgrade.last.sh + # Create an app.src for the last version of nextcloud -cp ../conf/app.src.default ../conf/app.src -ynh_replace_string --match_string="__VERSION__" --replace_string="$next_version" --target_file="../conf/app.src" -ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$nextcloud_source_sha256" --target_file="../conf/app.src" +cat > ../conf/app.src << EOF +SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-$next_version.tar.bz2 +SOURCE_SUM=$nextcloud_source_sha256 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.bz2 +SOURCE_IN_SUBDIR=true +EOF ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Enable YunoHost patches on Nextcloud sources @@ -171,10 +176,8 @@ exec_occ ldap:create-empty-config # Load the installation config file in Nextcloud nc_conf="$final_path/config_install.json" -cp ../conf/config_install.json "$nc_conf" +ynh_add_config --template="../conf/config_install.json" --destination="$nc_conf" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$nc_conf" -ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$nc_conf" exec_occ config:import "$nc_conf" # Then remove the config file @@ -182,9 +185,8 @@ ynh_secure_remove --file="$nc_conf" # Load the additional config file (used also for upgrade) nc_conf="$final_path/config.json" -cp ../conf/config.json "$nc_conf" +ynh_add_config --template="../conf/config.json" --destination="$nc_conf" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$nc_conf" exec_occ config:import "$nc_conf" # Then remove the config file @@ -243,7 +245,7 @@ exec_occ config:system:get logout_url >/dev/null 2>&1 \ # CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS #================================================= -ynh_replace_string --match_string="'overwrite.cli.url' => 'http://localhost'," --replace_string="'overwrite.cli.url' => 'https://${domain}'," --target_file="${final_path}/config/config.php" +exec_occ config:system:set overwrite.cli.url --value="https://${domain}" #================================================= # REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE @@ -267,14 +269,10 @@ ynh_store_file_checksum --file="$final_path/config/config.php" #================================================= cron_path="/etc/cron.d/$app" -cp -a ../conf/nextcloud.cron "$cron_path" +ynh_add_config --template="../conf/nextcloud.cron" --destination="$cron_path" chown root: "$cron_path" chmod 644 "$cron_path" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$cron_path" -ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$cron_path" - exec_occ background:cron #================================================= @@ -285,13 +283,6 @@ exec_occ db:add-missing-indices exec_occ db:add-missing-columns exec_occ db:convert-filecache-bigint -n -#================================================= -# CONFIGURE THE HOOK FILE FOR USER CREATE -#================================================= - -# Set system group in hooks -ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create - #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index eea4379..a9ed1c6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -267,9 +267,13 @@ then ynh_print_info --message="Upgrade to nextcloud $next_version" # Create an app.src for this version of Nextcloud - cp ../conf/app.src.default ../conf/app.src - ynh_replace_string --match_string="__VERSION__" --replace_string="$next_version" --target_file="../conf/app.src" - ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$nextcloud_source_sha256" --target_file="../conf/app.src" + cat > ../conf/app.src << EOF +SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-$next_version.tar.bz2 +SOURCE_SUM=$nextcloud_source_sha256 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.bz2 +SOURCE_IN_SUBDIR=true +EOF # Create a temporary directory tmpdir="$(ynh_smart_mktemp min_size=300)" @@ -332,9 +336,7 @@ then ynh_backup_if_checksum_is_different --file="$final_path/config/config.php" nc_conf="${final_path}/config.json" - cp ../conf/config.json "$nc_conf" - - ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$nc_conf" + ynh_add_config --template="../conf/config.json" --destination="$nc_conf" # Reneable the mail app if [ $mail_app_must_be_reactived -eq 1 ]; then @@ -371,7 +373,7 @@ then # CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS #================================================= - ynh_replace_string --match_string="'overwrite.cli.url' => 'http://localhost'," --replace_string="'overwrite.cli.url' => 'https://${domain}'," --target_file="${final_path}/config/config.php" + exec_occ config:system:set overwrite.cli.url --value="https://${domain}" #================================================= # MOUNT HOME FOLDERS AS EXTERNAL STORAGE @@ -402,23 +404,12 @@ fi #================================================= cron_path="/etc/cron.d/$app" -cp -a ../conf/nextcloud.cron "$cron_path" +ynh_add_config --template="../conf/nextcloud.cron" --destination="$cron_path" chown root: "$cron_path" chmod 644 "$cron_path" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$cron_path" -ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$cron_path" - exec_occ background:cron -#================================================= -# UPDATE THE HOOK FILE FOR USER CREATE -#================================================= - -# Set system group in hooks -ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create - #================================================= # GENERIC FINALIZATION #=================================================