diff --git a/README.md b/README.md index 6644a62..cfc9213 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Forum software that is easy to use, powerful, and highly customisable 1. The app will require to complete the registration process after the instllation is complete by **visiting the domain** on which *phpBB* is installed. 1. The MySQL database credentials will be sent to the **admin mail**. -1. Please delete, move or rename the install directory (`sudo rm -R /var/www/phpbb/install`) before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible. +1. Please delete, move or rename the install directory (`mv /var/www/phpbb/install /var/www/phpbb/install_old`) before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible. ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index 93baaad..d80c121 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,7 +27,7 @@ Forum facile à utiliser, puissant et hautement personnalisable 1. L'application devra terminer le processus d'enregistrement une fois l'installation terminée en **visitant le domaine** sur lequel *phpBB* est installé. 1. Les informations d'identification de la base de données MySQL seront envoyées à la **messagerie admin**. -1. Veuillez supprimer, déplacer ou renommer le répertoire d'installation (`sudo rm -R /var/www/phpbb/install`) avant d'utiliser votre forum. Si ce répertoire est toujours présent, seul le panneau de configuration d'administration (ACP) sera accessible. +1. Veuillez supprimer, déplacer ou renommer le répertoire d'installation (`mv /var/www/phpbb/install /var/www/phpbb/install_old`) avant d'utiliser votre forum. Si ce répertoire est toujours présent, seul le panneau de configuration d'administration (ACP) sera accessible. ## Documentations et ressources * Site officiel de l'app : http://www.phpbb.com/ diff --git a/check_process b/check_process index 78f1741..8c4f6f9 100644 --- a/check_process +++ b/check_process @@ -4,7 +4,7 @@ path="/path" admin="john" is_public=1 - password="pass" + password="super_password" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/install-config.yml.default b/conf/install-config.yml.default new file mode 100644 index 0000000..5359d66 --- /dev/null +++ b/conf/install-config.yml.default @@ -0,0 +1,38 @@ +installer: + admin: + name: __ADMIN__ + password: __PASSWORD__ + email: __EMAIL__ + + board: + lang: en + name: My Board + description: My amazing new phpBB board + + database: + dbms: mysqli + dbhost: ~ + dbport: ~ + dbuser: __DB_USER__ + dbpasswd: __DB_PWD__ + dbname: __DB_NAME__ + table_prefix: phpbb_ + + email: + enabled: true + smtp_delivery : ~ + smtp_host: ~ + smtp_port: ~ + smtp_auth: PLAIN + smtp_user: ~ + smtp_pass: ~ + + server: + cookie_secure: true + server_protocol: https:// + force_server_vars: false + server_name: __DOMAIN__ + server_port: 80 + script_path: __PATH_URL__ + + extensions: ['phpbb/viglink'] \ No newline at end of file diff --git a/conf/phpbb.cron b/conf/phpbb.cron new file mode 100644 index 0000000..469dc1b --- /dev/null +++ b/conf/phpbb.cron @@ -0,0 +1 @@ +* * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINAL_PATH__/bin/phpbbcli.php cron:run \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index fc803a6..18ec27c 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -2,4 +2,4 @@ 1. The app will require to complete the registration process after the instllation is complete by **visiting the domain** on which *phpBB* is installed. 1. The MySQL database credentials will be sent to the **admin mail**. -1. Please delete, move or rename the install directory (`sudo rm -R /var/www/phpbb/install`) before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible. +1. Please delete, move or rename the install directory (`mv /var/www/phpbb/install /var/www/phpbb/install_old`) before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index 00c0d20..dfe8b30 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -2,4 +2,4 @@ 1. L'application devra terminer le processus d'enregistrement une fois l'installation terminée en **visitant le domaine** sur lequel *phpBB* est installé. 1. Les informations d'identification de la base de données MySQL seront envoyées à la **messagerie admin**. -1. Veuillez supprimer, déplacer ou renommer le répertoire d'installation (`sudo rm -R /var/www/phpbb/install`) avant d'utiliser votre forum. Si ce répertoire est toujours présent, seul le panneau de configuration d'administration (ACP) sera accessible. \ No newline at end of file +1. Veuillez supprimer, déplacer ou renommer le répertoire d'installation (`mv /var/www/phpbb/install /var/www/phpbb/install_old`) avant d'utiliser votre forum. Si ce répertoire est toujours présent, seul le panneau de configuration d'administration (ACP) sera accessible. \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index b93a5ca..b6cad37 100644 --- a/scripts/backup +++ b/scripts/backup @@ -52,6 +52,12 @@ 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 +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index f84cc19..ae8aeea 100644 --- a/scripts/install +++ b/scripts/install @@ -121,21 +121,28 @@ 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) + #================================================= -# SETUP APPLICATION WITH CURL +# SETUP APPLICATION WITH CLI #================================================= -# Set the app as temporarily public for curl call -ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Making the app public for curl -ynh_permission_update --permission="main" --add="visitors" +ynh_script_progression --message="Configuring the APP..." --weight=1 -# Installation with curl -ynh_script_progression --message="Finalizing installation..." --weight=1 -ynh_local_curl "/install/app.php" "admin_name=$admin" "board_email=$email" "admin_pass1=$password" "admin_pass2=$password" +ynh_add_config --template="$YNH_APP_BASEDIR/conf/install-config.yml.default" --destination="$final_path/install/install-config.yml" -# Remove the public access -ynh_permission_update --permission="main" --remove="visitors" +ynh_exec_as "$app" php${phpversion} "$final_path/install/phpbbcli.php" -q --no-interaction install "$final_path/install/install-config.yml" + +mv "$final_path/install" "$final_path/install_old" + +#================================================= +# ADD A CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +ynh_add_config --template="../conf/phpbb.cron" --destination="$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -156,7 +163,7 @@ then fi # Only the admin can access the admin panel of the app (if the app has an admin panel) -ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +ynh_permission_create --permission="admin" --url="/adm" --allowed=$admin #================================================= # RELOAD NGINX @@ -172,15 +179,6 @@ ynh_script_progression --message="Sending a readme for the admin..." message="phpBB was successfully installed :) -Please open your $app domain: https://$domain$path_url - -Complete the registration process from the setup page displayed. -Details for MySQL database to be enterted while registration process: - -Database login: $app -Database name: $app -Database password: $db_pwd - If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/phpbb_ynh/issues" ynh_send_readme_to_admin "$message" diff --git a/scripts/remove b/scripts/remove index 6c5e664..63b1d85 100644 --- a/scripts/remove +++ b/scripts/remove @@ -67,6 +67,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE THE CRON FILE +#================================================= + +ynh_secure_remove --file="/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 3feec35..cbf519f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -85,6 +85,12 @@ 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 CRON FILE +#================================================= + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 11c9833..4bc02a1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ 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) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION @@ -36,6 +37,12 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + if [ -n "$new_phpbb_dir" ]; then + ynh_secure_remove --file="$new_phpbb_dir" + fi + if [ -n "$old_phpbb_dir" ]; then + ynh_secure_remove --file="$old_phpbb_dir" + fi # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -56,7 +63,7 @@ fi if ! ynh_permission_exists --permission="admin"; then # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin + ynh_permission_create --permission="admin" --url="/adm" --allowed=$admin fi #================================================= @@ -75,8 +82,26 @@ 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="$final_path" + 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" fi chmod 750 "$final_path" @@ -99,6 +124,26 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading the APP..." --weight=1 + +ynh_exec_as "$app" php${phpversion} "$final_path/bin/phpbbcli.php" -q --no-interaction db:migrate + +if [ -e "$final_path/install" ]; then + mv "$final_path/install" "$final_path/install_old" +fi + +#================================================= +# ADD A CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +ynh_add_config --template="../conf/phpbb.cron" --destination="$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================