diff --git a/README.md b/README.md index fb6c89c..73dbf63 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,60 @@ -# Usage of this package (REMOVE THIS SECTION BEFORE RELEASE) -- Copy this app before working on it. -- Edit the `conf/nginx.conf` file to match app prerequisites. -- Edit the `manifest.json` with app specific info. -- Edit the `install`, `upgrade`, `remove`, `backup`, and `restore` scripts. - - Using the [script helpers documentation.](https://yunohost.org/#/packaging_apps_helpers) -- Add a `LICENSE` file for the package. -- Edit `README.md` and `README_fr.md`. +# PHP Server Monitor for YunoHost -# Example app for YunoHost - -[![Integration level](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP) ![](https://ci-apps.yunohost.org/ci/badges/REPLACEBYYOURAPP.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/REPLACEBYYOURAPP.maintain.svg) -[![Install REPLACEBYYOURAPP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP) +[![Integration level](https://dash.yunohost.org/integration/phpservermon.svg)](https://dash.yunohost.org/appci/app/phpservermon) ![](https://ci-apps.yunohost.org/ci/badges/phpservermon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/phpservermon.maintain.svg) +[![Install PHP Server Monitor with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=phpservermon) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install REPLACEBYYOURAPP quickly and simply on a YunoHost server. +> *This package allows you to install PHP Server Monitor quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Quick description of this app. -**Shipped version:** 1.0 +PHP Server Monitor is a script that checks whether your websites and servers are up and running. + +**Shipped version:** 3.5.2 ## Screenshots -![](Link to a screenshot of this app.) +![](images/screenshot.png) -## Demo - -* [Official demo](Link to a demo site for this app.) - -## Configuration - -How to configure this app: From an admin panel, a plain file with SSH, or any other way. ## Documentation - * Official documentation: Link to the official documentation of this app + * Official documentation: http://www.phpservermonitor.org/ * YunoHost documentation: If specific documentation is needed, feel free to contribute. ## YunoHost specific features #### Multi-user support -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? + LDAP and HTTP auth are not supported. +The app can be used by multiple users. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/phpservermon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/phpservermon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/phpservermon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/phpservermon/) ## Limitations -* Any known limitations. - -## Additional information - -* Other info you would like to add about this app. - -**More info on the documentation page:** -https://yunohost.org/packaging_apps - +* SSO are not supported. ## Links - * Report a bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues - * App website: Link to the official website of this app. - * Upstream app repository: Link to the official repository of the upstream app. + * Report a bug: https://github.com/YunoHost-Apps/phpservermon_ynh/issues + * App website: http://www.phpservermonitor.org/. + * Upstream app repository: https://github.com/phpservermon/phpservermon/. * YunoHost website: https://yunohost.org/ --- ## Developer info -**Only if you want to use a testing branch for coding, instead of merging directly into master.** -Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/phpservermon_ynh/tree/testing). To try the testing branch, please proceed like that. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app install https://github.com/YunoHost-Apps/phpservermon_ynh/tree/testing --debug or -sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app upgrade phpservermon -u https://github.com/YunoHost-Apps/phpservermon_ynh/tree/testing --debug ``` diff --git a/README_fr.md b/README_fr.md index afe7706..5c5ec1e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,19 +1,3 @@ -Todo - -php depend -PHP Extensions (modules) - - ext-curl - ext-ctype - ext-filter - ext-hash - ext-json - ext-libxml - ext-openssl - ext-pdo - ext-pcre - ext-sockets - ext-xml Readme readme.fr @@ -22,26 +6,26 @@ backup, restore, upgrade , change url +# PHP Server Monitor pour YunoHost - -# App exemple pour YunoHost - -[![Niveau d'intégration](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP) ![](https://ci-apps.yunohost.org/ci/badges/REPLACEBYYOURAPP.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/REPLACEBYYOURAPP.maintain.svg) -[![Installer REPLACEBYYOURAPP avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP) +[![Niveau d'intégration](https://dash.yunohost.org/integration/phpservermon.svg)](https://dash.yunohost.org/appci/app/phpservermon) ![](https://ci-apps.yunohost.org/ci/badges/phpservermon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/phpservermon.maintain.svg) +[![Installer phpservermon avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=phpservermon) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer REPLACEBYYOURAPP rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d'installer PHP Server Monitor rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble -Description rapide de cette application. -**Version incluse :** 1.0 +PHP Server Monitor est une application qui contrôle que vos serveurs et site web soient fonctionnels. + +**Version incluse :** 3.5.2 ## Captures d'écran -![](Lien vers une capture d'écran de cette application.) +![](images/screenshot.png) + ## Démo diff --git a/check_process b/check_process new file mode 100644 index 0000000..ce4e89e --- /dev/null +++ b/check_process @@ -0,0 +1,20 @@ + +;; Test complet + ; Manifest + domain="domain.tld" (DOMAIN) + path="/path" (PATH) + is_public=1 (PUBLIC|public=1|private=0) + password="pass" + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=1 + port_already_use=0 + change_url=1 + diff --git a/check_process.default b/check_process.default deleted file mode 100644 index 41888cb..0000000 --- a/check_process.default +++ /dev/null @@ -1,35 +0,0 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - -;; Test complet - ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) - language="fr" - is_public=1 (PUBLIC|public=1|private=0) - password="pass" - port="666" (PORT) - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& - diff --git a/images/screenshot.png b/images/screenshot.png new file mode 100644 index 0000000..423382c Binary files /dev/null and b/images/screenshot.png differ diff --git a/manifest.json b/manifest.json index d7383ae..0807a27 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "packaging_format": 1, "description": { "en": "PHP Server Monitor is a script that checks whether your websites and servers are up and running", - "fr": "PHP Sever Monitor est un application pour vérifier que vos sites web et serveurs fonctionnent " + "fr": "PHP Server Monitor est un application pour vérifier que vos sites web et serveurs fonctionnent" }, "version": "3.5.2~ynh1", "url": "www.phpservermonitor.org", diff --git a/scripts/_common.sh b/scripts/_common.sh index 6c95253..c45026f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,11 @@ # dependencies used by the app #pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" -pkg_dependencies="" +pkg_dependencies="php$YNH_DEFAULT_PHP_VERSION-curl +php$YNH_DEFAULT_PHP_VERSION-common +php$YNH_DEFAULT_PHP_VERSION-json +php$YNH_DEFAULT_PHP_VERSION-xml" + #================================================= diff --git a/scripts/backup b/scripts/backup index 6ea8892..c72abab 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,5 +1,8 @@ #!/bin/bash +#gerer config file au backup cf install cf ynh_backup_if_checksum_is_different + + #================================================= # GENERIC START #================================================= diff --git a/scripts/change_url b/scripts/change_url index 126010e..c74124f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,9 +30,9 @@ ynh_script_progression --message="Loading installation settings..." --time --wei final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -70,11 +70,6 @@ fi #================================================= # STANDARD MODIFICATIONS #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -105,20 +100,10 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index cc1ef3e..e972a15 100755 --- a/scripts/install +++ b/scripts/install @@ -153,12 +153,15 @@ ynh_add_fpm_config #================================================= # MODIFY A CONFIG FILE #================================================= +cp -a $final_path/config.php.sample $final_path/config.php ### `ynh_replace_string` is used to replace a string in a file. ### (It's compatible with sed regular expressions syntax) -#ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" - +ynh_replace_string --match_string="db_user" --replace_string=$db_user --target_file="$final_path/config.php" +ynh_replace_string --match_string="db_pass" --replace_string=$db_pwd --target_file="$final_path/config.php" +ynh_replace_string --match_string="db_name" --replace_string=$db_name --target_file="$final_path/config.php" +ynh_replace_string --match_string='PSM_BASE_URL', '' --replace_string='PSM_BASE_URL',$path_url --target_file="$final_path/config.php" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= @@ -168,7 +171,11 @@ ynh_add_fpm_config ### you can make a backup of this file before modifying it again if the admin had modified it. # Calculate and store the config file checksum into the app settings -#ynh_store_file_checksum --file="$final_path/CONFIG_FILE" +ynh_store_file_checksum --file="$final_path/config.php" + +#configure owner of file + +chown -R $app:$app $final_path #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index c334a77..9760b4c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -73,7 +73,7 @@ ynh_system_user_create --username=$app #================================================= # Restore permissions on app files -chown -R root: $final_path +chown -R $app:$app $final_path #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -81,15 +81,6 @@ chown -R root: $final_path ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# RESTORE FAIL2BAN CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the Fail2Ban configuration..." --time --weight=1 - -ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban - #================================================= # SPECIFIC RESTORATION #================================================= @@ -109,41 +100,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 SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 - -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 - -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RESTORE VARIOUS FILES -#================================================= - -ynh_restore_file --origin_path="/etc/cron.d/$app" - -ynh_restore_file --origin_path="/etc/$app/" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index fff0363..6e18737 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,4 @@ #!/bin/bash - #================================================= # GENERIC START #================================================= @@ -18,9 +17,7 @@ app=$YNH_APP_INSTANCE_NAME 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) -language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= @@ -40,44 +37,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# - -# 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 -#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 -#fi - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - 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 -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" -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -95,11 +54,6 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -144,29 +98,13 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --time --w # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # MODIFY A CONFIG FILE #================================================= ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" - -ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different --file="$final_path/config.php" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/CONFIG_FILE" @@ -178,37 +116,7 @@ ynh_store_file_checksum --file="$final_path/CONFIG_FILE" #================================================= # Set permissions on app files -chown -R root: $final_path - -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 - -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# UPGRADE FAIL2BAN -#================================================= -ynh_script_progression --message="Reconfiguring Fail2Ban..." --time --weight=1 - -# Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +chown -R $app:$app $final_path #================================================= # RELOAD NGINX