diff --git a/check_process b/check_process index 8ece525..1f73ffc 100644 --- a/check_process +++ b/check_process @@ -2,10 +2,10 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" - language="fr" is_public=1 - password="super_password" + language="fr" + admin="john" + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -14,14 +14,15 @@ setup_private=1 setup_public=1 upgrade=1 + # 3.3.4~ynh3 upgrade=1 from_commit=28f03211e7354cd7a1e34ec379e06e4bda25fbeb backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= Notification=none ;;; Upgrade options ; commit=28f03211e7354cd7a1e34ec379e06e4bda25fbeb - name=Merge pull request #7 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + name=3.3.4~ynh3 diff --git a/conf/app.src b/conf/app.src index e2552f9..0ae83db 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,5 @@ SOURCE_SUM=983d60881fab3139bbcbe9182dcaaa1d2e9c6fb80fef682a0b28785ee22d05dd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 4bf80c3..5d89fa2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -35,5 +35,5 @@ location __PATH__/ { } location @rewriteapp { - rewrite ^(.*)$ /app.php/$1 last; - } + rewrite ^(.*)$ /app.php/$1 last; +} diff --git a/manifest.json b/manifest.json index a944284..9610e7f 100644 --- a/manifest.json +++ b/manifest.json @@ -50,8 +50,8 @@ "name": "language", "type": "string", "ask": { - "en": "Choose the board language", - "fr": "Choisissez la langue du forum" + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" }, "choices": ["fr", "en"], "default": "fr" diff --git a/scripts/_common.sh b/scripts/_common.sh index 76661c2..4b1e250 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,6 +6,7 @@ YNH_PHP_VERSION="7.3" +# dependencies used by the app pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-common php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xmlrpc php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath" #================================================= diff --git a/scripts/backup b/scripts/backup index b6cad37..236d57f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -53,7 +53,9 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= -# BACKUP THE CRON FILE +# SPECIFIC BACKUP +#================================================= +# BACKUP VARIOUS FILES #================================================= ynh_backup --src_path="/etc/cron.d/$app" diff --git a/scripts/change_url b/scripts/change_url index 80cf020..b43a8d5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -26,14 +26,13 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 +# Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -95,7 +94,7 @@ then fi #================================================= -# GENERIC FINALIZATION +# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 78127be..a932501 100644 --- a/scripts/install +++ b/scripts/install @@ -21,12 +21,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE +admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD email=$(ynh_user_get_info --username=$admin --key=mail) -language=$YNH_APP_ARG_LANGUAGE -phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -48,16 +47,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=phpversion --value=$phpversion - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies +ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # STANDARD MODIFICATIONS @@ -70,6 +61,13 @@ ynh_script_progression --message="Finding an available port..." --weight=1 port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= @@ -97,14 +95,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# DOWNLOAD, CHECK AND UNPACK LANGUAGE PACK -#================================================= - tmpdir="$(mktemp -d)" # Download, check integrity, uncompress and patch the source from app.src @@ -114,6 +104,10 @@ cp -a "$tmpdir/styles/prosilver/theme/fr" "$final_path/styles/prosilver/theme/fr # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -129,7 +123,10 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=4 # Create a dedicated PHP-FPM config ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# SPECIFIC SETUP #================================================= # SETUP APPLICATION WITH CLI #================================================= diff --git a/scripts/remove b/scripts/remove index 6294a38..9d81b4c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,8 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# STANDARD REMOVE #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -30,14 +32,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -63,8 +57,19 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 ynh_remove_fpm_config #================================================= -# REMOVE THE CRON FILE +# REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index a05472c..cce93e5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -36,14 +36,15 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -53,7 +54,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -91,8 +92,9 @@ 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 CRON FILE +# RESTORE VARIOUS FILES #================================================= +ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 1e14acf..d77cb7f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,15 +18,16 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +language=$(ynh_app_setting_get --app=$app --key=language) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -language=$(ynh_app_setting_get --app=$app --key=language) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -77,30 +78,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=5 - # new_phpbb_dir=$(mktemp -d) - # # Download, check integrity, uncompress and patch the source from app.src - # ynh_setup_source --dest_dir="$new_phpbb_dir" - # ynh_secure_remove --file="$new_phpbb_dir/config.php" - # ynh_secure_remove --file="$new_phpbb_dir/images" - # ynh_secure_remove --file="$new_phpbb_dir/files" - # ynh_secure_remove --file="$new_phpbb_dir/store" - - # old_phpbb_dir=$(mktemp -d) - - # mv $final_path/* $old_phpbb_dir - # mv $old_phpbb_dir/config.php $final_path/ - # mv $old_phpbb_dir/images/ $final_path/ - # mv $old_phpbb_dir/files/ $final_path/ - # mv $old_phpbb_dir/store/ $final_path/ - - # mv $new_phpbb_dir/* $final_path - - # ynh_secure_remove --file="$old_phpbb_dir" - # ynh_secure_remove --file="$new_phpbb_dir" - - ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.php $final_path/images $final_path/files $final_path/store" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" --keep="config.php images/ files/ store/" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -126,20 +110,18 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 ynh_add_fpm_config #================================================= -# PHP-FPM CONFIGURATION +# SPECIFIC UPGRADE +#================================================= +# UPGRADE APP #================================================= ynh_script_progression --message="Upgrading the $app..." --weight=1 -ynh_exec_as "$app" php${phpversion} "$final_path/bin/phpbbcli.php" --no-interaction db:migrate --safe-mode +ynh_exec_as $app php${phpversion} "$final_path/bin/phpbbcli.php" --no-interaction db:migrate --safe-mode if [ -e "$final_path/install" ]; then - mv "$final_path/install" "$final_path/install_old" + ynh_exec_as $app mv "$final_path/install" "$final_path/install_old" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # SETUP A CRON #=================================================