mirror of
https://github.com/YunoHost-Apps/libreto_ynh.git
synced 2024-09-03 19:36:14 +02:00
Cleanup manifestv2, better hanldling of config file
This commit is contained in:
parent
7160c031dd
commit
52c650d52c
8 changed files with 77 additions and 107 deletions
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
|
||||
|
||||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
|
Loading…
Reference in a new issue