1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/moncycle_ynh.git synced 2024-09-03 19:46:16 +02:00

Merge pull request #13 from YunoHost-Apps/testing

Testing
This commit is contained in:
Alexandre Aubin 2023-12-02 19:02:54 +01:00 committed by GitHub
commit 06356df070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 174 additions and 820 deletions

View file

@ -1,137 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
exit 1
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"admin"*)
src="app"
;;
*"update"*)
src="app-upgrade"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -16,9 +16,26 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
Menstrual cycle follow-up for natural family planning
Make it easy to monitor menstrual cycles and apply natural methods. Billings. Symptothermy. FertilityCare
**Shipped version:** 7.0~ynh4
### Features:
- a menstrual cycle tracking chart
- dedicated to natural methods
- monitoring the evolution of cervical mucus
- body temperature tracking (optional)
- FertilityCare rating (optional)
- simple on phone as on PC
- aesthetic visual with dark mode
- open source code
- no pseudo predictive intelligence
- PDF/CSV export for your instructors
- finished Excel or Google Sheets
- the same account on several devices
- automatic sending of cycles by email
- no data sales/no advertising
**Shipped version:** 7.0~ynh5
**Demo:** https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo
@ -26,13 +43,6 @@ Menstrual cycle follow-up for natural family planning
![Screenshot of Moncycle](./doc/screenshots/moncycle_app.png)
## Disclaimers / important information
* No LDAP integration
* After installing, you can create your own user using the form
* Once done, you can (if you want) set the account creation to false in `/var/www/moncycle_app/config.php`
* If you want to use the app in PWA mode, be sure to be connected to your account first
## Documentation and resources
* Official app website: <https://moncycle.app>

View file

@ -16,48 +16,27 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble
Rendre facile le suivi des cycles menstruels et lapplication des méthodes naturelles.
Billings . Symptothermie . FertilityCare
Rendre facile le suivi des cycles menstruels et lapplication des méthodes naturelles. Billings . Symptothermie . FertilityCare
### Caractéristiques
### Caractéristiques :
👩 un tableau de suivi du cycle menstruel
🌳 dédiée aux méthodes naturelles
🤏 suivi de l'évolution de la glaire cervicale
🌡️ suivi de la température corporelle (optionnel)
🔠 notation FertilityCare (optionnel)
📱 simple sur téléphone comme sur PC
✨ visuel esthétique avec mode sombre
📖 code open source
🤪 pas de pseudo intelligence prédictive
📊 export PDF/CSV pour vos moniteurs/instructrices
🔢 fini Excel ou Google Sheets
💑 un même compte sur plusieurs appareils
✉️ envoi par mail automatique des cycles
🔒 pas de vente de données / pas de publicité
🇫🇷 hébergée et développée en France
- un tableau de suivi du cycle menstruel
- dédiée aux méthodes naturelles
- suivi de l'évolution de la glaire cervicale
- suivi de la température corporelle (optionnel)
- notation FertilityCare (optionnel)
- simple sur téléphone comme sur PC
- visuel esthétique avec mode sombre
- code open source
- pas de pseudo intelligence prédictive
- export PDF/CSV pour vos moniteurs/instructrices
- fini Excel ou Google Sheets
- un même compte sur plusieurs appareils
- envoi par mail automatique des cycles
- pas de vente de données/pas de publicité
### Les méthodes naturelles
Les méthodes naturelles ? «Ce sont des méthodes basées sur la connaissance des signes de fertilité du cycle féminin. Le couple peut ainsi connaitre avec précision les périodes fertiles ou infertiles qu'il traverse, et en fonction de son projet d'enfant, connaitre le meilleur moment pour transmettre la vie, ou les périodes infertiles lorsqu'il souhaite espacer ou limiter les naissances.» Source: methodes-naturelles.fr
Il existe plusieurs méthodes proposées par différentes associations. Voici une liste non exhaustive:
[Méthode Billings](https://www.methode-billings.com/)
👉 méthode compatible avec moncycle.app
[Symptothermie (Cyclamen)](http://www.methodes-naturelles.fr/les_methodes_naturelles/la-methode-dauto-observation)
👉 méthode compatible avec moncycle.app
[Symptothermie (SensiPlan)](https://symptothermie.info/)
👉 méthode compatible avec moncycle.app
[FertilityCare (NaProTechnologie)](https://www.fertilitycare.fr/)
👉 méthode compatible avec moncycle.app
🧠 moncycle.app n'a pas pour objectif de prédire ou de contrôler la bonne application des méthodes (ni de remplacer vos moniteurs) mais seulement de proposer un support numérique. Vous restez le cerveau derrière votre tableau. Si vous ne connaissez pas les méthodes naturelles ou si vous avez des questions sur les règles de celles-ci, rapprochez-vous d'un moniteur de l'une des associations ci-dessus.
**Version incluse :** 7.0~ynh4
**Version incluse :** 7.0~ynh5
**Démo :** https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo
@ -65,13 +44,6 @@ Il existe plusieurs méthodes proposées par différentes associations. Voici un
![Capture décran de Moncycle](./doc/screenshots/moncycle_app.png)
## Avertissements / informations importantes
* No LDAP integration
* After installing, you can create your own user using the form
* Once done, you can (if you want) set the account creation to false in `/var/www/moncycle_app/config.php`
* If you want to use the app in PWA mode, be sure to be connected to your account first
## Documentations et ressources
* Site officiel de lapp : <https://moncycle.app>

View file

@ -1,30 +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"
path="/path"
is_public=1
; 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&is_public=1&language=fr&admin=USER&password=pass&port=666&

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/jean-io/moncycle.app/archive/9c15d501269f5873091b5914fd2a7f155d22ba04.zip
SOURCE_SUM=bd5c5e0b6d1b9ed7206aeef08f6b371319d349fe17c15305623740333a33da54
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1 +1 @@
0 1 * * * __APP__ /usr/bin/php__PHPVERSION__ --define apc.enable_cli=1 -f __FINAL_PATH__/script/cron.php
0 1 * * * __APP__ /usr/bin/php__PHPVERSION__ --define apc.enable_cli=1 -f __INSTALL_DIR__/script/cron.php

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
alias __INSTALL_DIR__/;
# Deny access to hidden files and directories
location ~ ^/(.+/|)\.(?!well-known\/) {

18
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,18 @@
Make it easy to monitor menstrual cycles and apply natural methods. Billings. Symptothermy. FertilityCare
### Features:
- a menstrual cycle tracking chart
- dedicated to natural methods
- monitoring the evolution of cervical mucus
- body temperature tracking (optional)
- FertilityCare rating (optional)
- simple on phone as on PC
- aesthetic visual with dark mode
- open source code
- no pseudo predictive intelligence
- PDF/CSV export for your instructors
- finished Excel or Google Sheets
- the same account on several devices
- automatic sending of cycles by email
- no data sales/no advertising

View file

@ -1,40 +1,18 @@
Rendre facile le suivi des cycles menstruels et lapplication des méthodes naturelles.
Billings . Symptothermie . FertilityCare
Rendre facile le suivi des cycles menstruels et lapplication des méthodes naturelles. Billings . Symptothermie . FertilityCare
### Caractéristiques
### Caractéristiques :
👩 un tableau de suivi du cycle menstruel
🌳 dédiée aux méthodes naturelles
🤏 suivi de l'évolution de la glaire cervicale
🌡️ suivi de la température corporelle (optionnel)
🔠 notation FertilityCare (optionnel)
📱 simple sur téléphone comme sur PC
✨ visuel esthétique avec mode sombre
📖 code open source
🤪 pas de pseudo intelligence prédictive
📊 export PDF/CSV pour vos moniteurs/instructrices
🔢 fini Excel ou Google Sheets
💑 un même compte sur plusieurs appareils
✉️ envoi par mail automatique des cycles
🔒 pas de vente de données / pas de publicité
🇫🇷 hébergée et développée en France
### Les méthodes naturelles
Les méthodes naturelles ? «Ce sont des méthodes basées sur la connaissance des signes de fertilité du cycle féminin. Le couple peut ainsi connaitre avec précision les périodes fertiles ou infertiles qu'il traverse, et en fonction de son projet d'enfant, connaitre le meilleur moment pour transmettre la vie, ou les périodes infertiles lorsqu'il souhaite espacer ou limiter les naissances.» Source: methodes-naturelles.fr
Il existe plusieurs méthodes proposées par différentes associations. Voici une liste non exhaustive:
[Méthode Billings](https://www.methode-billings.com/)
👉 méthode compatible avec moncycle.app
[Symptothermie (Cyclamen)](http://www.methodes-naturelles.fr/les_methodes_naturelles/la-methode-dauto-observation)
👉 méthode compatible avec moncycle.app
[Symptothermie (SensiPlan)](https://symptothermie.info/)
👉 méthode compatible avec moncycle.app
[FertilityCare (NaProTechnologie)](https://www.fertilitycare.fr/)
👉 méthode compatible avec moncycle.app
🧠 moncycle.app n'a pas pour objectif de prédire ou de contrôler la bonne application des méthodes (ni de remplacer vos moniteurs) mais seulement de proposer un support numérique. Vous restez le cerveau derrière votre tableau. Si vous ne connaissez pas les méthodes naturelles ou si vous avez des questions sur les règles de celles-ci, rapprochez-vous d'un moniteur de l'une des associations ci-dessus.
- un tableau de suivi du cycle menstruel
- dédiée aux méthodes naturelles
- suivi de l'évolution de la glaire cervicale
- suivi de la température corporelle (optionnel)
- notation FertilityCare (optionnel)
- simple sur téléphone comme sur PC
- visuel esthétique avec mode sombre
- code open source
- pas de pseudo intelligence prédictive
- export PDF/CSV pour vos moniteurs/instructrices
- fini Excel ou Google Sheets
- un même compte sur plusieurs appareils
- envoi par mail automatique des cycles
- pas de vente de données/pas de publicité

View file

@ -1,4 +1,3 @@
* No LDAP integration
* After installing, you can create your own user using the form
* Once done, you can (if you want) set the account creation to false in `/var/www/moncycle_app/config.php`
* Once done, you can (if you want) set the account creation to false in `__INSTALL_DIR__/config.php`
* If you want to use the app in PWA mode, be sure to be connected to your account first

View file

@ -1,49 +0,0 @@
{
"name": "Moncycle",
"id": "moncycle",
"packaging_format": 1,
"description": {
"en": "Menstrual cycle follow-up for natural family planning",
"fr": "Suivi de cycle pour les méthodes naturelles de régulation de naissance"
},
"version": "7.0~ynh4",
"url": "https://moncycle.app",
"upstream": {
"license": "CC-BY-NC-SA-4.0",
"website": "https://moncycle.app",
"demo": "https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo",
"code": "https://github.com/jean-io/moncycle.app"
},
"license": "CC-BY-NC-SA-4.0",
"maintainer": {
"name": "Raoul de Limezy"
},
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": true,
"services": [
"nginx",
"php8.0-fpm",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/moncycle",
"default": "/moncycle"
},
{
"name": "is_public",
"type": "boolean",
"default": false
}
]
}
}

56
manifest.toml Normal file
View file

@ -0,0 +1,56 @@
packaging_format = 2
id = "moncycle"
name = "Moncycle"
description.en = "Menstrual cycle follow-up for natural family planning"
description.fr = "Suivi de cycle pour les méthodes naturelles de régulation de naissance"
version = "7.0~ynh5"
maintainers = ["Raoul de Limezy"]
[upstream]
license = "CC-BY-NC-SA-4.0"
website = "https://moncycle.app"
demo = "https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo"
code = "https://github.com/jean-io/moncycle.app"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "100M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/moncycle"
[install.init_main_permission]
type = "group"
default = false
[resources]
[resources.sources.main]
url = "https://github.com/jean-io/moncycle.app/archive/v7.tar.gz"
sha256 = "25f435a55304a5692f55a681971ac41a034c527a87198612e3bfadb7a3b92028"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "mariadb-server, php8.2-gd, php8.2-mysql"
[resources.database]
type = "mysql"

View file

@ -6,13 +6,6 @@
# PHP APP SPECIFIC
#=================================================
YNH_PHP_VERSION="8.0"
php_dependencies="php$YNH_PHP_VERSION-fpm php$YNH_PHP_VERSION-cli php$YNH_PHP_VERSION-gd php$YNH_PHP_VERSION-mysql"
# dependencies used by the app (must be on a single line)
pkg_dependencies="libfreetype6-dev libjpeg62-turbo-dev libpng-dev $php_dependencies"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -10,29 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
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)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -42,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -56,13 +33,6 @@ 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 FAIL2BAN CONFIGURATION
#=================================================
# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================

View file

@ -9,63 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
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)
# 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)
#=================================================
# 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
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
@ -74,38 +17,7 @@ fi
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_change_url_nginx_config
#=================================================
# END OF SCRIPT

View file

@ -9,88 +9,21 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
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"
ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path"
ynh_exec_warn_less mkdir "$final_path/sessions"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
ynh_exec_warn_less mkdir "$install_dir/sessions"
pushd "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
pushd "$install_dir"
ynh_exec_warn_less mv ./www_data/* .
ynh_exec_warn_less ./module/install.sh
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < db/table.sql
@ -103,64 +36,24 @@ popd
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# 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=1
ynh_add_fpm_config
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_config --template="../conf/moncycleapp.cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.php" --destination="$final_path/config.php"
ynh_add_config --template="../conf/config.php" --destination="$install_dir/config.php"
chmod 400 "$final_path/config.php"
chown $app:$app "$final_path/config.php"
#=================================================
# GENERIC FINALIZATION
#=================================================
# ADD A CRON JOB
#=================================================
cron_path="/etc/cron.d/$app"
ynh_add_config --template="../conf/moncycleapp.cron" --destination="$cron_path"
chown root: "$cron_path"
chmod 644 "$cron_path"
#=================================================
# SETUP FAIL2BAN
#=================================================
#ynh_script_progression --message="Configuring Fail2Ban..." --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"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
chmod 400 "$install_dir/config.php"
chown $app:$app "$install_dir/config.php"
#=================================================
# END OF SCRIPT

View file

@ -9,36 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
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
#=================================================
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 APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -47,50 +17,12 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# 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
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config
#ynh_remove_fail2ban_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,78 +10,22 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
# RESTORE THE MYSQL DATABASE
#=================================================
#ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
# ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
# ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
# ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -93,21 +37,9 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config
ynh_add_fpm_config --usage="low" --footprint="low" --phpversion=$phpversion
#=================================================
# 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
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
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
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
@ -119,13 +51,6 @@ ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --w
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_script_progression --message="Restoring cron job..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,141 +9,52 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
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
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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
# Move config.php to temp folder
# Can't use the --keep="config.php" option
pushd "$final_path"
pushd "$install_dir"
ynh_exec_warn_less mv ./config.php /tmp/
popd
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --full_replace=1
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
chmod 750 "$final_path"
ynh_exec_warn_less mkdir "$final_path/sessions"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
ynh_exec_warn_less mkdir "$install_dir/sessions"
pushd "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
pushd "$install_dir"
ynh_exec_warn_less mv ./www_data/* .
ynh_exec_warn_less mv /tmp/config.php .
ynh_exec_warn_less ./module/install.sh
popd
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage="low" --footprint="low"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
ynh_add_fpm_config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# UPDATE THE CRON JOB
#=================================================
cron_path="/etc/cron.d/$app"
ynh_add_config --template="../conf/moncycleapp.cron" --destination="$cron_path"
chown root: "$cron_path"
chmod 644 "$cron_path"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
#ynh_script_progression --message="Reconfiguring Fail2Ban..." --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"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_add_config --template="../conf/moncycleapp.cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# END OF SCRIPT

8
tests.toml Normal file
View file

@ -0,0 +1,8 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------