diff --git a/patches/00-installto-opts.patch b/patches/00-installto-opts.patch index 5c66498..8c54bd6 100644 --- a/patches/00-installto-opts.patch +++ b/patches/00-installto-opts.patch @@ -1,21 +1,11 @@ ---- a/bin/installto.sh 2016-03-30 15:46:11.686447589 +0200 -+++ b/bin/installto.sh 2016-03-30 15:49:27.184064426 +0200 -@@ -23,6 +23,9 @@ - - require_once INSTALL_PATH . 'program/include/clisetup.php'; - -+// get arguments -+$opts = rcube_utils::get_opt(array('f' => 'force', 'y' => 'accept')); -+ - $target_dir = unslashify($_SERVER['argv'][1]); - - if (empty($target_dir) || !is_dir(realpath($target_dir))) -@@ -35,13 +38,15 @@ +--- a/bin/installto.sh ++++ b/bin/installto.sh +@@ -38,13 +38,15 @@ if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m)) $oldversion = $m[1]; -if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>=')) -+if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>=') && !opts['force']) ++if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>=') && !opts['force']) rcube::raise_error("Installation at target location is up-to-date!", false, true); -echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; @@ -27,19 +17,19 @@ -if (strtolower($input) == 'y') { +if ($opts['accept'] || strtolower($input) == 'y') { - $err = false; echo "Copying files to target location..."; - $dirs = array('program','installer','bin','SQL','plugins','skins'); -@@ -77,7 +82,11 @@ - if (!$err) { - echo "Running update script at target...\n"; -- system("cd $target_dir && php bin/update.sh --version=$oldversion"); -+ $command = "cd $target_dir && php bin/update.sh --version=$oldversion"; -+ if ($opts['accept']) { -+ $command .= " --accept"; -+ } -+ system($command); - echo "All done.\n"; + // Save a copy of original .htaccess file (#1490623) +@@ -99,7 +101,11 @@ if (strtolower($input) == 'y') { } + + echo "Running update script at target...\n"; +- system("cd $target_dir && php bin/update.sh --version=$oldversion"); ++ $command = "cd $target_dir && php bin/update.sh --version=$oldversion"; ++ if ($opts['accept']) { ++ $command .= " --accept"; ++ } ++ system($command); + echo "All done.\n"; } + else { diff --git a/scripts/_common.sh b/scripts/_common.sh index 2bea361..fd56e57 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,6 +17,14 @@ ROUNDCUBE_SOURCE_URL="https://github.com/roundcube/roundcubemail/releases/downlo # App package root directory should be the parent folder PKGDIR=$(cd ../; pwd) +QUIET () { # Redirect standard out into /dev/null + $@ > /dev/null +} + +WARNING () { # Writes on the error channel to go into warning. + eval "$@" >&2 +} + # # Common helpers # @@ -37,9 +45,9 @@ extract_roundcube() { sudo rm "$rc_tarball" # apply patches - # (cd "$DESTDIR" \ - # && for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \ - # || ynh_die "Unable to apply patches to Roundcube" + (cd "$DESTDIR" \ + && for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \ + || ynh_die "Unable to apply patches to Roundcube" # copy composer.json-dist for Roundcube with complete dependencies sudo cp "${PKGDIR}/sources/composer.json-dist" "${DESTDIR}/composer.json-dist" diff --git a/scripts/install b/scripts/install index e4d11b1..99659cc 100644 --- a/scripts/install +++ b/scripts/install @@ -7,15 +7,16 @@ set -eu source ./_common.sh source /usr/share/yunohost/helpers +app=$YNH_APP_INSTANCE_NAME + # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH) with_carddav=$YNH_APP_ARG_WITH_CARDDAV -app=$YNH_APP_INSTANCE_NAME - # Check domain/path availability -sudo yunohost app checkurl "${domain}${path}" -a "$app" +sudo yunohost app checkurl "${domain}${path}" -a "$app" \ + || ynh_die "Path not available: ${domain}${path}" # Set app specific variables dbname=$app @@ -24,9 +25,6 @@ dbuser=$app deskey=$(ynh_string_random 24) dbpass=$(ynh_string_random) -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path}" -a "$app" - # Save app settings ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path diff --git a/scripts/upgrade b/scripts/upgrade index 91b93a6..0b9a8c4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,10 +68,9 @@ ynh_substitute_char "#DBNAME#" "$dbname" "$rc_conf" # Install files and set permissions sudo mkdir -p "${final_path}/logs" "${final_path}/temp" -sudo chown -R $app: "${final_path}" # Check if dependencies need to be updated with composer -if [[ -f ${DESTDIR}/composer.json ]]; then +if [[ -f ${final_path}/composer.json ]]; then exec_composer admin "${final_path}" update --no-dev --prefer-dist else init_composer "${final_path}" admin @@ -80,7 +79,7 @@ fi # Install some plugins manually sudo rm -rf "${final_path}/plugins/ldapAliasSync" sudo cp -r ../sources/plugins/ldapAliasSync "${final_path}/plugins" -sudo chown -R $app: "${final_path}/plugins/ldapAliasSync" +# sudo chown -R $app: "${final_path}/plugins/ldapAliasSync" installed_plugins=" 'ldapAliasSync'," # Update or install additional plugins @@ -108,6 +107,9 @@ fi sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \ "$rc_conf" +# Owner user app +sudo chown -R $app: "${final_path}" + # Modify Nginx configuration file and copy it to Nginx conf directory ynh_nginx_config @@ -115,5 +117,4 @@ ynh_nginx_config ynh_fpm_config # Reload services -sudo systemctl restart php5-fpm sudo systemctl reload nginx