From a82b7f0de487ceab2a24e9a2ea340f5dd73d59be Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 15 Jun 2022 23:45:27 +0200 Subject: [PATCH 1/3] Apply last example_ynh --- .gitattributes | 19 ---------- .gitignore | 1 - check_process | 7 +++- conf/nginx.conf | 39 +++++++++----------- manifest.json | 18 ++++----- scripts/_common.sh | 1 + scripts/backup | 18 +++++---- scripts/change_url | 4 ++ scripts/install | 65 +++++++++++++++++++-------------- scripts/remove | 26 +++++++------ scripts/restore | 53 ++++++++++++++------------- scripts/upgrade | 91 +++++++++++++++++++++++++++------------------- 12 files changed, 180 insertions(+), 162 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .gitignore diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b50a94d..0000000 --- a/.gitattributes +++ /dev/null @@ -1,19 +0,0 @@ -# Set default behaviour, in case users don't have core.autocrlf set. -* text=auto - -# Declare files that will always have LF line endings on checkout. -*.php text eol=lf -*.css text eol=lf -*.js text eol=lf -*.pstpl text eol=lf -*.html text eol=lf -*.sql text eol=lf -*.txt text eol=lf -*.lss text eol=lf - -# Denote all files that are truly binary and should not be modified. -*.jpg binary -*.png binary -*.gif binary -*.ico binary -*.mo binary diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8b13789..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/check_process b/check_process index 7790b6d..003542a 100644 --- a/check_process +++ b/check_process @@ -2,8 +2,9 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" language="en" + admin="john" + password="1Strong-Password" is_admin_public=1 ; Checks pkg_linter=1 @@ -13,8 +14,10 @@ setup_private=0 setup_public=1 upgrade=1 - #3.17.1 + # 3.17.1~ynh1 upgrade=1 from_commit=da4959616e67f89ef907a223f7c84607dc4771e5 + # 5.2.6~ynh2 + upgrade=1 from_commit=58cac7dfc0d0b835898d56238e550c775be7255b backup_restore=1 multi_instance=1 port_already_use=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 101844d..aaaca33 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,37 +1,32 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Path to source - alias __FINALPATH__/ ; + # Path to source + alias __FINALPATH__/; - more_set_headers "X-Frame-Options : ALLOWALL"; + more_set_headers "X-Frame-Options : ALLOWALL"; - index index.php; + index index.php; - # if (!-e $request_filename) - #{ - # rewrite ^(.+)$ __PATH__/index.php?q=$1 last; - #} + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + client_max_body_size 50M; - client_max_body_size 50m; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - try_files $uri $uri/ index.php; - - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - } + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } location ~ ^__PATH__/(data|config|\.ht|db_structure\.xml|README) { - deny all; + deny all; } diff --git a/manifest.json b/manifest.json index 1b76dbf..5fd9c33 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Create and distribute surveys", "fr": "Outil de création et diffusion de sondage" }, - "version": "5.2.6~ynh2", + "version": "5.2.6~ynh3", "url": "https://www.limesurvey.org/", "upstream": { "license": "GPL-2.0+", @@ -42,10 +42,6 @@ "example": "/poll", "default": "/poll" }, - { - "name": "admin", - "type": "user" - }, { "name": "language", "type": "string", @@ -168,6 +164,14 @@ ], "default": "en" }, + { + "name": "admin", + "type": "user" + }, + { + "name": "password", + "type": "password" + }, { "name": "is_admin_public", "type": "boolean", @@ -176,10 +180,6 @@ "fr": "En mode privé, seuls les utilisateurs YunoHost autorisés peuvent créer un sondage. En mode public, il est possible de créer un sondage avec un compte Limesurvey mais sans compte YunoHost." }, "default": true - }, - { - "name": "password", - "type": "password" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index c87b3fd..82e561f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,7 @@ PKG_DIR=$(cd ../; pwd) YNH_PHP_VERSION="7.3" +# dependencies used by the app pkg_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-imap python3-pip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring" #================================================= diff --git a/scripts/backup b/scripts/backup index 55e5ea9..b86ddbf 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -25,10 +28,10 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -41,6 +44,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -60,13 +69,6 @@ ynh_print_info --message="Backing up the MySQL database..." ynh_mysql_dump_db --database="$db_name" > db.sql -#================================================= -# BACKUP THE DATA DIRECTORY -#================================================= -ynh_print_info --message="Backing up data directory..." - -ynh_backup --src_path="$datadir" --is_big - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index d51bc52..54dbd91 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,6 +67,8 @@ then change_path=1 fi +#================================================= +# STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -96,6 +98,8 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index b8743dc..ebc9ae3 100755 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -22,10 +25,10 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN -is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC language=$YNH_APP_ARG_LANGUAGE +admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD +is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -47,8 +50,8 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 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=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # STANDARD MODIFICATIONS @@ -93,6 +96,15 @@ chmod 750 "$final_path/tmp" chmod 750 "$final_path/upload" chmod 750 "$final_path/application/config/" +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + #================================================= # NGINX CONFIGURATION #================================================= @@ -101,23 +113,16 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config - #================================================= # SPECIFIC SETUP #================================================= -# CREATE THE DATA DIRECTORY +# CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 datadir=/home/yunohost.app/limesurvey/upload ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mkdir -p $datadir # Remove upload if empty rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true @@ -126,23 +131,27 @@ chmod -R o-rwx "$datadir" ln -s $datadir $final_path/upload 2> /dev/null || true #================================================= -# CONFIGURE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Limesurvey..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/config.php" --destination="$final_path/application/config/config.php" +chmod 400 "$final_path/application/config/config.php" +chown $app:$app "$final_path/application/config/config.php" + #================================================= -# INSTALL +# INSTALL APP #================================================= +ynh_script_progression --message="Installing app..." ls_cli=$final_path/application/commands/console.php -fullname=$(ynh_user_get_info "$admin" "fullname") -mail=$(ynh_user_get_info "$admin" "mail") +fullname=$(ynh_user_get_info --username="$admin" --key="fullname") +mail=$(ynh_user_get_info --username="$admin" --key="mail") # Permission should be correctly set before to do this -ynh_exec_as "$app" php $ls_cli install "$admin" "$password" "$fullname" "$mail" +ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$password" "$fullname" "$mail" # Permission should be correctly set before to do this #ynh_exec_as "$app" php $ls_cli install "$admin" "$(ynh_string_random 24)" "$fullname" "$mail" @@ -150,6 +159,8 @@ ynh_exec_as "$app" php $ls_cli install "$admin" "$password" "$fullname" "$mail" #================================================= # LOAD SQL SPECIFIC CONFIG #================================================= +ynh_script_progression --message="Loading SQL specific config..." + ynh_add_config --template="../conf/data.sql" --destination="./data.sql" ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./data.sql @@ -157,30 +168,30 @@ ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name ynh_secure_remove --file=./data.sql #================================================= -# Add nice themes +# ADD NICE THEMES #================================================= +#ynh_script_progression --message="Adding nice themes..." #ynh_setup_source "$datadir/upload/templates/libreform" libreform #ynh_setup_source "$final_path/upload/templates/librepoll" librepoll #================================================= -# SETUP FAIL2BAN -#================================================= -# No message in logs and the apps contains already a 10 minutes ban policy - +# GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 +# Everyone can access the app. +# The "main" permission is automatically created before the install script. +ynh_permission_update --permission="main" --add="visitors" + if [ $is_admin_public -eq 1 ] then - allowed_groups="visitors $admin" + allowed_groups="visitors $admin" else - allowed_groups="$admin" + allowed_groups="$admin" fi -ynh_permission_update --permission="main" --show_tile="false" --add="visitors" - ynh_permission_create --permission="admin" --url="/admin" --allowed=$allowed_groups --show_tile="true" diff --git a/scripts/remove b/scripts/remove index 85f6233..05283bb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -24,14 +24,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -41,7 +33,7 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1 ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= -# REMOVE THE MAIN DIR OF THE APP +# REMOVE APP MAIN DIR #================================================= ynh_script_progression --message="Removing app main directory..." --weight=1 @@ -56,11 +48,11 @@ ynh_secure_remove --file="$final_path" if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" + ynh_secure_remove --file="$datadir" fi #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 @@ -75,6 +67,16 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# SPECIFIC REMOVE #================================================= # REMOVE DEDICATED USER #================================================= diff --git a/scripts/restore b/scripts/restore index 947ba9a..fc97dc3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -27,11 +30,11 @@ app=$YNH_APP_INSTANCE_NAME 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) -admin=$(ynh_app_setting_get --app=$app --key=admin) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) +admin=$(ynh_app_setting_get --app=$app --key=admin) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -43,13 +46,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -72,11 +68,17 @@ chmod 755 "$final_path/tmp" chmod 755 "$final_path/application/config/" #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +# RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 +ynh_script_progression --message="Restoring data directory..." --weight=2 -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" +ln -s $datadir $final_path/upload 2> /dev/null || true #================================================= # SPECIFIC RESTORATION @@ -88,6 +90,20 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." --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" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= @@ -97,19 +113,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RESTORE THE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Restoring data directory..." --weight=2 - -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. -ynh_restore_file --origin_path="$datadir" --not_mandatory - -mkdir -p "$datadir" -chown -R $app:www-data "$datadir" -chmod -R o-rwx "$datadir" -ln -s $datadir $final_path/upload 2> /dev/null || true - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2a779ec..ba7dcc0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,16 +20,18 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -prefix=$(ynh_app_setting_get $app prefix) +prefix=$(ynh_app_setting_get --app=$app --key=prefix) +is_admin_public=$(ynh_app_setting_get --app=$app --key=is_admin_public) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -41,12 +43,14 @@ ynh_script_progression --message="Backing up $app before upgrading (may take a w # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup + # Restore it if the upgrade fails + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -54,43 +58,50 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If db_name doesn't exist, create it if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi # If datadir doesn't exist, create it if [ -z "$datadir" ]; then - datadir=/home/yunohost.app/$app/upload - ynh_app_setting_set --app=$app --key=datadir --value=$datadir - mkdir -p $datadir - # Remove upload if empty - rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true - chown -R $app:www-data "$datadir" - chmod -R o-rwx "$datadir" - ln -s $datadir $final_path/upload + datadir=/home/yunohost.app/$app/upload + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mkdir -p $datadir + # Remove upload if empty + rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true + chown -R $app:www-data "$datadir" + chmod -R o-rwx "$datadir" + ln -s $datadir $final_path/upload fi # Cleaning legacy permissions if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all + ynh_legacy_permissions_delete_all - ynh_app_setting_delete --app=$app --key=is_admin_public + ynh_app_setting_delete --app=$app --key=is_public fi if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin + # Create the required permissions + if [ $is_admin_public -eq 1 ] + then + allowed_groups="visitors $admin" + else + allowed_groups="$admin" + fi + ynh_permission_create --permission="admin" --url="/admin" --allowed=$allowed_groups --show_tile="true" + fi # Create a permission if needed if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" + ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" fi #================================================= @@ -101,18 +112,16 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." --weight=1 - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="$(echo $final_path/plugins/*) $final_path/application/config/config.php $final_path/upload" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" --keep="$(echo $final_path/plugins/*) $final_path/application/config/config.php $final_path/upload" fi chmod 750 "$final_path" @@ -124,14 +133,6 @@ chown -R $app:www-data "$datadir" chmod 750 $datadir ln -s $datadir $final_path/upload 2> /dev/null || true -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -148,19 +149,35 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 ynh_add_fpm_config #================================================= -# CONFIGURE +# NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Limesurvey..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="../conf/config.php" --destination="$final_path/application/config/config.php" +chmod 400 "$final_path/application/config/config.php" +chown $app:$app "$final_path/application/config/config.php" + #================================================= # UPGRADE DB #================================================= +ynh_script_progression --message="Upgrading DB..." # Migrate DB ynh_exec_as "$app" php $final_path/application/commands/console.php updatedb +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= From ebeacbc5f9fa51581a660a6e620e34418383550f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Jun 2022 00:33:32 +0200 Subject: [PATCH 2/3] More example_ynh --- conf/app.src | 5 +++-- conf/config.php | 6 +++--- conf/data.sql | 8 ++++---- scripts/install | 17 +++++++++-------- scripts/restore | 12 +++++------- scripts/upgrade | 12 +++++++++--- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/conf/app.src b/conf/app.src index 1d9f7c2..8c0569e 100644 --- a/conf/app.src +++ b/conf/app.src @@ -2,5 +2,6 @@ SOURCE_URL=https://github.com/LimeSurvey/LimeSurvey/archive/refs/tags/5.2.6+2112 SOURCE_SUM=d097af55794000d87ad8f88698597f6cba2e972499819d3f4bd55748f1de1765 SOURCE_SUM_PRG=sha256sum SOURCE_FILENAME=limesurvey.tar.gz - - +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/config.php b/conf/config.php index f369905..79996b1 100644 --- a/conf/config.php +++ b/conf/config.php @@ -28,10 +28,10 @@ return array( 'db' => array( 'connectionString' => 'mysql:host=localhost;port=3306;dbname=__DB_NAME__;', 'emulatePrepare' => true, - 'username' => '__DB_NAME__', + 'username' => '__DB_USER__', 'password' => '__DB_PWD__', 'charset' => 'utf8mb4', - 'tablePrefix' => 'lime_', + 'tablePrefix' => '__PREFIX__', ), 'emcache' => array('class' => 'CFileCache'), @@ -65,7 +65,7 @@ return array( // 'use_asset_manager'=>true, // Uncomment if you want to use debug mode and asset manager at the same time 'enableLdap' => true, 'force_ssl' => true, - 'uploaddir' => '__DATADIR__' + 'uploaddir' => '__DATADIR__/upload' ) ); /* End of file config.php */ diff --git a/conf/data.sql b/conf/data.sql index 65c3d25..4f079ca 100644 --- a/conf/data.sql +++ b/conf/data.sql @@ -1,12 +1,12 @@ -UPDATE lime_plugins SET active=1 WHERE name="AuthLDAP"; +UPDATE __PREFIX__plugins SET active=1 WHERE name="AuthLDAP"; -INSERT INTO `lime_permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES +INSERT INTO `__PREFIX__permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES (2,'global',0,2,'auth_ldap',0,1,0,0,0,0), (3,'global',0,2,'surveys',1,0,0,0,0,0); -INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key`, `value`) VALUES +INSERT INTO `__PREFIX__plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key`, `value`) VALUES (2, 5, NULL, NULL, 'server', '\"ldap:\\/\\/localhost\"'), (3, 5, NULL, NULL, 'ldapport', '\"\"'), (4, 5, NULL, NULL, 'ldapversion', '\"3\"'), @@ -35,6 +35,6 @@ INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key #(24, 7, NULL, NULL, 'serverkey', '"REMOTE_USER"'), #(25, 7,NULL,NULL,'is_default','\"1\"'); -INSERT INTO `lime_settings_global` VALUES +INSERT INTO `__PREFIX__settings_global` VALUES ('defaultlang','__LANGUAGE__'), ('AssetsVersion','30214'); diff --git a/scripts/install b/scripts/install index ebc9ae3..06434e2 100755 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,8 @@ is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC app=$YNH_APP_INSTANCE_NAME +prefix=lime_ + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -52,6 +54,7 @@ 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=language --value=$language ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=prefix --value=$prefix #================================================= # STANDARD MODIFICATIONS @@ -92,9 +95,6 @@ ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -chmod 750 "$final_path/tmp" -chmod 750 "$final_path/upload" -chmod 750 "$final_path/application/config/" #================================================= # PHP-FPM CONFIGURATION @@ -120,15 +120,16 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -datadir=/home/yunohost.app/limesurvey/upload +datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir -mkdir -p $datadir +mkdir -p $datadir/upload + # Remove upload if empty rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true -chown -R $app:www-data "$datadir" chmod -R o-rwx "$datadir" -ln -s $datadir $final_path/upload 2> /dev/null || true +chown -R $app:www-data "$datadir" +ln -s $datadir/upload $final_path/upload 2> /dev/null || true #================================================= # ADD A CONFIGURATION @@ -154,7 +155,7 @@ mail=$(ynh_user_get_info --username="$admin" --key="mail") ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$password" "$fullname" "$mail" # Permission should be correctly set before to do this -#ynh_exec_as "$app" php $ls_cli install "$admin" "$(ynh_string_random 24)" "$fullname" "$mail" +#ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$(ynh_string_random 24)" "$fullname" "$mail" #================================================= # LOAD SQL SPECIFIC CONFIG diff --git a/scripts/restore b/scripts/restore index fc97dc3..5416426 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,7 +34,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -admin=$(ynh_app_setting_get --app=$app --key=admin) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -64,21 +63,20 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -chmod 755 "$final_path/tmp" -chmod 755 "$final_path/application/config/" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring data directory..." --weight=2 +ynh_script_progression --message="Restoring the data directory..." --weight=2 -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$datadir" --not_mandatory -mkdir -p "$datadir" +mkdir -p "$datadir/upload" + +chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:www-data "$datadir" -ln -s $datadir $final_path/upload 2> /dev/null || true +ln -s $datadir/upload $final_path/upload 2> /dev/null || true #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index ba7dcc0..e2a3fe8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,6 +68,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If prefix doesn't exist, create it +if [ -z "$prefix" ]; then + prefix="lime_" + ynh_app_setting_set --app=$app --key=prefix --value=$prefix +fi + # If datadir doesn't exist, create it if [ -z "$datadir" ]; then datadir=/home/yunohost.app/$app/upload @@ -77,7 +83,7 @@ if [ -z "$datadir" ]; then rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true chown -R $app:www-data "$datadir" chmod -R o-rwx "$datadir" - ln -s $datadir $final_path/upload + ln -s $datadir/upload $final_path/upload fi # Cleaning legacy permissions @@ -131,7 +137,7 @@ chmod 750 "$final_path/tmp" chmod 750 "$final_path/application/config/" chown -R $app:www-data "$datadir" chmod 750 $datadir -ln -s $datadir $final_path/upload 2> /dev/null || true +ln -s $datadir/upload $final_path/upload 2> /dev/null || true #================================================= # UPGRADE DEPENDENCIES @@ -174,7 +180,7 @@ chown $app:$app "$final_path/application/config/config.php" ynh_script_progression --message="Upgrading DB..." # Migrate DB -ynh_exec_as "$app" php $final_path/application/commands/console.php updatedb +ynh_exec_as "$app" php$phpversion $final_path/application/commands/console.php updatedb #================================================= # GENERIC FINALIZATION From 0c474009b93120f33eb8ade2e5c45ea6d2633250 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 15 Jun 2022 22:33:42 +0000 Subject: [PATCH 3/3] Auto-update README --- README.md | 25 ++++++++++++------------- README_fr.md | 31 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 74de597..0c98572 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # LimeSurvey for YunoHost -[![Integration level](https://dash.yunohost.org/integration/limesurvey.svg)](https://dash.yunohost.org/appci/app/limesurvey) ![](https://ci-apps.yunohost.org/ci/badges/limesurvey.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/limesurvey.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/limesurvey.svg)](https://dash.yunohost.org/appci/app/limesurvey) ![Working status](https://ci-apps.yunohost.org/ci/badges/limesurvey.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/limesurvey.maintain.svg) [![Install LimeSurvey with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=limesurvey) *[Lire ce readme en français.](./README_fr.md)* @@ -17,13 +17,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Create and distribute surveys -**Shipped version:** 5.2.6~ynh2 - - +**Shipped version:** 5.2.6~ynh3 ## Screenshots -![](./doc/screenshots/create_html_statistic_screen.png) +![Screenshot of LimeSurvey](./doc/screenshots/create_html_statistic_screen.png) ## Disclaimers / important information @@ -32,22 +30,23 @@ Create and distribute surveys * The application is integrated with YunoHost accounts (LDAP database) ## Documentation and resources -* Official app website: https://www.limesurvey.org -* Official user documentation: https://help.limesurvey.org -* Official admin documentation: https://manual.limesurvey.org/LimeSurvey_Manual/fr -* Upstream app code repository: https://github.com/LimeSurvey/LimeSurvey -* YunoHost documentation for this app: https://yunohost.org/app_limesurvey -* Report a bug: https://github.com/YunoHost-Apps/limesurvey_ynh/issues +* Official app website: +* Official user documentation: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing --debug or sudo yunohost app upgrade limesurvey -u https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index bc1a632..0c6c90d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # LimeSurvey pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/limesurvey.svg)](https://dash.yunohost.org/appci/app/limesurvey) ![](https://ci-apps.yunohost.org/ci/badges/limesurvey.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/limesurvey.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/limesurvey.svg)](https://dash.yunohost.org/appci/app/limesurvey) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/limesurvey.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/limesurvey.maintain.svg) [![Installer LimeSurvey avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=limesurvey) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer LimeSurvey rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* @@ -13,13 +17,11 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Outil de création et diffusion de sondage -**Version incluse :** 5.2.6~ynh2 - - +**Version incluse :** 5.2.6~ynh3 ## Captures d'écran -![](./doc/screenshots/create_html_statistic_screen.png) +![Capture d'écran de LimeSurvey](./doc/screenshots/create_html_statistic_screen.png) ## Avertissements / informations importantes @@ -28,22 +30,23 @@ Outil de création et diffusion de sondage * The application is integrated with YunoHost accounts (LDAP database) ## Documentations et ressources -* Site officiel de l'app : https://www.limesurvey.org -* Documentation officielle utilisateur : https://help.limesurvey.org -* Documentation officielle de l'admin : https://manual.limesurvey.org/LimeSurvey_Manual/fr -* Dépôt de code officiel de l'app : https://github.com/LimeSurvey/LimeSurvey -* Documentation YunoHost pour cette app : https://yunohost.org/app_limesurvey -* Signaler un bug : https://github.com/YunoHost-Apps/limesurvey_ynh/issues +* Site officiel de l'app : +* Documentation officielle utilisateur : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing --debug ou sudo yunohost app upgrade limesurvey -u https://github.com/YunoHost-Apps/limesurvey_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :**