diff --git a/conf/config.dist.php b/conf/config.dist.php index cdb7787..2101880 100644 --- a/conf/config.dist.php +++ b/conf/config.dist.php @@ -46,7 +46,7 @@ $providers = array( // CUSTOM_PROVIDER$providers += array( // CUSTOM_PROVIDER '__PROVIDER__' => array( // CUSTOM_PROVIDER 'name' => "__PROVIDER__", -// CUSTOM_PROVIDER 'url' => "__INSTANCE__", +// CUSTOM_PROVIDER 'url' => "__ETHERPAD_INSTANCE__", // CUSTOM_PROVIDER 'default_text' => "Get involved with Etherpad at http://etherpad.org", // CUSTOM_PROVIDER 'markdown' => true, // CUSTOM_PROVIDER 'html' => true, @@ -54,9 +54,9 @@ $providers = array( // CUSTOM_PROVIDER); $options = array( - 'name' => "Libreto", + 'name' => "Libreto", 'root' => '__PATH__', 'use_subdomain' => false, - 'default_provider' => "__PROVIDER__", + 'default_provider' => "__DEFAULT_PROVIDER__", 'providers' => $providers, ); diff --git a/conf/nginx.conf b/conf/nginx.conf index dadb362..4d7e371 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,21 +2,21 @@ location __PATH__/ { # Path to source - alias __INSTALL_DIR__/; + alias __INSTALL_DIR__/libreto/; index index.php; - + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file client_max_body_size 50M; location __PATH__/assets/ { - alias __INSTALL_DIR__/libreto/assets/; + alias __INSTALL_DIR__/libreto/libreto/assets/; } # IF YOU CHANGE SOMETHING IN THIS CONFIGURATION # PLEASE CHECK THAT LIBRETO IS WORKING AND NOT JUST THE FIRST PAGE try_files "" @libreto; - + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } @@ -27,5 +27,5 @@ location @libreto { fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; - fastcgi_param SCRIPT_FILENAME __INSTALL_DIR__/index.php; + fastcgi_param SCRIPT_FILENAME __INSTALL_DIR__/libreto/index.php; } diff --git a/manifest.toml b/manifest.toml index 351dcdb..95f71e1 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "libreto" @@ -52,6 +54,13 @@ ram.runtime = "50M" default = true [resources] + [resources.sources.main] + # This is not used as we are using git clone + submodules. It's only here for autoupdate. + url = "https://codeload.github.com/zamentur/libreto/zip/76408f5e98a68156afa47996e670d110a1c6106d" + sha256 = "4381428a38a0262b98b44b0de0d7cea35dae67049f0efe6dffff655f17d4fbda" + prefetch = false + autoupdate.strategy = "latest_github_commit" + [resources.system_user] [resources.install_dir] diff --git a/scripts/install b/scripts/install index 810608c..9975e71 100755 --- a/scripts/install +++ b/scripts/install @@ -17,49 +17,18 @@ source /usr/share/yunohost/helpers path="/" ynh_app_setting_set --app="$app" --key=path --value="$path" -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= - -ynh_app_setting_set --app=$app --key=etherpad_instance --value=$etherpad_instance -ynh_app_setting_set --app=$app --key=creation_open --value=$creation_open - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=4 -git config --system --add safe.directory $install_dir - # Note: We use git instead of ynh_setup_source, cause this repo use submodules -git clone https://github.com/zamentur/libreto.git "$install_dir" --quiet - -chown -R $app:www-data "$install_dir" - -pushd "$install_dir" - ynh_exec_as $app git checkout $COMMIT --quiet - ynh_exec_as $app git submodule update --init --recursive --quiet -popd +ynh_exec_as "$app" git clone https://github.com/zamentur/libreto.git "$install_dir/libreto" --quiet +ynh_exec_as "$app" git -C "$install_dir/libreto" checkout "$COMMIT" --quiet +ynh_exec_as "$app" git -C "$install_dir/libreto" submodule update --init --recursive --quiet chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 - -# Create a dedicated NGINX config -ynh_add_nginx_config -ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf" +chown -R "$app:www-data" "$install_dir" #================================================= # SPECIFIC SETUP @@ -68,19 +37,27 @@ ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_ins #================================================= ynh_script_progression --message="Adding a configuration file..." -cp "../conf/config.dist.php" "$install_dir/config.php" - -provider="${domain%%.*}" +default_provider="framapad" +commented_provider="// CUSTOM_PROVIDER" if [ "$etherpad_instance" != "https://annuel2.framapad.org" ]; then - ynh_replace_string --match_string="// CUSTOM_PROVIDER" --replace_string="" --target_file="$install_dir/config.php" - ynh_replace_string --match_string="__PROVIDER__" --replace_string="$provider" --target_file="$install_dir/config.php" - ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="$install_dir/config.php" -else - ynh_replace_string --match_string="__PROVIDER__" --replace_string="framapad" --target_file="$install_dir/config.php" + provider="${domain%%.*}" + default_provider="$provider" + commented_provider="" fi +ynh_add_config --template="config.dist.php" --destination="$install_dir/libreto/config.php" -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$install_dir/config.php" +chown "$app:www-data" "$install_dir/libreto/config.php" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --usage=low --footprint=low + +# Create a dedicated NGINX config +ynh_add_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 787cb2c..5b17c2d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,18 +10,13 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config diff --git a/scripts/restore b/scripts/restore index b080003..6fbe3e1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,20 +18,15 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= @@ -41,7 +36,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b07ed95..db5f6e0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,51 +9,23 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=5 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=5 - - chown -R $app:www-data "$install_dir" - - # Download, check integrity, uncompress and patch the source from app.src - pushd "$install_dir" - ynh_exec_as $app git checkout master - ynh_exec_as $app git pull --quiet - ynh_exec_as $app git checkout $COMMIT --quiet - ynh_exec_as $app git submodule update --init --recursive --quiet - popd -fi - -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +# Download, check integrity, uncompress and patch the source from app.src +ynh_exec_as "$app" git -C "$install_dir/libreto" checkout master +ynh_exec_as "$app" git -C "$install_dir/libreto" pull --quiet +ynh_exec_as "$app" git -C "$install_dir/libreto" checkout $COMMIT --quiet +ynh_exec_as "$app" git -C "$install_dir/libreto" submodule update --init --recursive --quiet -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 - -# Create a dedicated NGINX config -ynh_add_nginx_config +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # SPECIFIC UPGRADE @@ -63,8 +35,28 @@ ynh_add_nginx_config ynh_script_progression --message="Updating a configuration file..." ynh_backup_if_checksum_is_different --file="$install_dir/config.php" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$install_dir/config.php" + +default_provider="framapad" +commented_provider="// CUSTOM_PROVIDER" +if [ "$etherpad_instance" != "https://annuel2.framapad.org" ]; then + provider="${domain%%.*}" + default_provider="$provider" + commented_provider="" +fi +ynh_add_config --template="config.dist.php" --destination="$install_dir/libreto/config.php" + +chown "$app:www-data" "$install_dir/libreto/config.php" + +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --usage=low --footprint=low + +# Create a dedicated NGINX config +ynh_add_nginx_config #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index 97671ac..c35342e 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default]