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

Merge pull request #122 from YunoHost-Apps/testing

Testing | Improving databases: password fix and type selection
This commit is contained in:
tituspijean 2023-09-15 16:13:13 +02:00 committed by GitHub
commit 1a1784d669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 135 additions and 50 deletions

View file

@ -25,7 +25,7 @@ PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`
**Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside.
**Shipped version:** 1.0~ynh14
**Shipped version:** 1.0~ynh15
## Documentation and resources
* Upstream app code repository: <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -25,7 +25,7 @@ La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1
**Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur.
**Version incluse :** 1.0~ynh14
**Version incluse :** 1.0~ynh15
## Documentations et ressources
* Dépôt de code officiel de lapp : <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -11,13 +11,20 @@ Once installed, go to the chosen URL to know the username, domain and port you w
To connect, you'll need an SFTP app such as [Filezilla](https://filezilla-project.org/) for Windows, Mac or Linux. You can also use your default file manager on [Mac](https://support.apple.com/guide/mac-help/connect-mac-shared-computers-servers-mchlp1140/mac) or Linux.
### Adding or editing files
Once logged in SFTP, under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside.
### Forgot your SFTP password?
#### Forgot your SFTP password?
If you forgot your SFTP password, you can change it in YunoHost's webadmin interface in `Apps > My webapp > My Webapp configuration`.
You can also check there that SFTP is enabled.
### Login using the command line
Starting YunoHost v11.1.21, you can run `sudo yunohost app shell __APP__` in the command line interface to log in as your app user.
The `php` command will point to the PHP version installed for the app.
### Adding or editing files
Once logged in, under the Web directory you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside.
### Customizing the nginx configuration

View file

@ -9,19 +9,22 @@ Une fois installée, rendez-vous sur l'URL choisie pour connaître le nom d'util
- Mot de passe: mot de passe défini lors de l'installation
- Port: 22 (à moins que vous ayez changé le port SSH)
Pour vous connectez, vous devrez utiliser une application SFTP tel que [Filezilla](https://filezilla-project.org/) pour Windows, Mac ou Linux. Vous pouvez aussi directement utiliser votre gestionnaire de fichiers sous Linux ou [Mac](https://support.apple.com/guide/mac-help/connect-mac-shared-computers-servers-mchlp1140/mac).
Pour vous connecter, vous devrez utiliser une application SFTP tel que [Filezilla](https://filezilla-project.org/) pour Windows, Mac ou Linux. Vous pouvez aussi directement utiliser votre gestionnaire de fichiers sous Linux ou [Mac](https://support.apple.com/guide/mac-help/connect-mac-shared-computers-servers-mchlp1140/mac).
#### Oubli du mot de passe SFTP
Si vous avez oublié votre mot de passe SFTP, vous pouvez le changer dans la webadmin de Yunohost dans `Applications > Votre webapp > My Webapp configuration`.
Vous pourrez aussi vérifier que SFTP est activé pour votre app.
### Connexion par le terminal
A partir de YunoHost v11.1.21, vous pouvez lancer `sudo yunohost app shell __APP__` dans un terminal pour vous connecter en tant que l'utilisateur gérant l'app.
La commande `php` pointera vers la version de PHP installée pour l'app.
### Ajouter ou modifier les fichiers
Après vous être connecté avec SFTP, sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur.
### Oubli du mot de passe SFTP
Si vous avez oublié votre mot de passe SFTP, vous pouvez le changer dans la webadmin de Yunohost dans `Applications > Votre webapp > My Webapp configuration`.
## Résolution de problèmes
Si vous n'arrivez pas à vous connecter et que vous avez vérifié que le nom d'utilisateur et le mot de passe sont bons, vérifiez si SFTP est activé pour votre app
Après vous être connecté, sous le répertoire Web vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur.
### Personnaliser la configuration nginx

View file

@ -1,7 +1,12 @@
If you have requested a MYSQL database, please find information about this SQL database:
{% if database != 'none' %}
Here are information to log into the database:
- Type: __DATABASE__
- Database user: __DB_USER__
- Database name: __DB_NAME__
- Password: __DB_PWD__
The admin documentation below also contain information on how to connect using SFTP to edit the website content.
{% endif %}
The admin documentation below contains information on how to connect using SFTP to edit the website content.

View file

@ -1,7 +1,12 @@
Si vous avez demandé une base de données MYSQL, voici les informations de cette base de données SQL :
{% if database != 'none' %}
Voici les informations pour se connecter à la base de donnée:
- Type : __DATABASE__
- Utilisateur de la base de données : __DB_USER__
- Nom de la base de données : __DB_NAME__
- Mot de passe : __DB_PWD__
La documentation ci-dessous contient également les informations pour se connecter en SSH et modifier le contenu du site web.
{% endif %}
La documentation ci-dessous contient les informations pour se connecter en SSH et modifier le contenu du site web.

View file

@ -0,0 +1,4 @@
If you experienced issues with the displayed database password before, sorry for the inconvenience!
- New installations of the app fix the bug.
- If you want to keep using your current instance, you can use PhpMyAdmin to change the __APP__ user's password.

View file

@ -5,7 +5,7 @@ name = "My Webapp"
description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files"
description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP"
version = "1.0~ynh14"
version = "1.0~ynh15"
maintainers = []
@ -14,7 +14,7 @@ license = "GPL-3.0-only"
code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
[integration]
yunohost = ">= 11.1.19"
yunohost = ">= 11.2.4"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
@ -48,15 +48,16 @@ ram.runtime = "50M"
[install.phpversion]
ask.en = "Choose a PHP version you want to use for your app"
ask.fr = "Choisissez une version PHP que vous souhaitez utiliser pour votre application"
type = "string"
type = "select"
choices = ["none", "7.4", "8.0", "8.1", "8.2"]
default = "8.0"
[install.with_mysql]
ask.en = "Do you need a MySQL database?"
ask.fr = "Avez-vous besoin d'une base de données MySQL ?"
type = "boolean"
default = false
[install.database]
ask.en = "Do you need a database?"
ask.fr = "Avez-vous besoin d'une base de données ?"
type = "select"
choices = [ "none", "mysql", "postgresql" ]
default = "none"
[resources]
[resources.system_user]
@ -69,13 +70,21 @@ ram.runtime = "50M"
[resources.apt]
packages = "nginx" # Kind of "dummy" value to be sure to have a non-empty dep list
packages_from_raw_bash = """
if [[ "$with_mysql" = 1 ]]
then
if [[ "$database" == "mysql" ]]; then
echo "mariadb-server"
if [[ "$phpversion" != none ]]; then
echo "php${phpversion}-mysql"
fi
elif [[ "$database" == "postgresql" ]]; then
echo "postgresql postgresql-contrib"
if [[ "$phpversion" != none ]]; then
echo "php${phpversion}-pgsql"
fi
fi
if [[ "$phpversion" != none ]]
then
echo "php${phpversion}-fpm php${phpversion}-mysql"
if [[ "$phpversion" != none ]]; then
echo "php${phpversion}-fpm"
fi
"""

View file

@ -40,10 +40,15 @@ fi
# BACKUP THE MYSQL DATABASE
#=================================================
if [ $with_mysql -eq 1 ]
if [ $database != "none" ]
then
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_print_info --message="Backing up the database..."
if [ $database == "mysql" ]; then
ynh_mysql_dump_db --database="$db_name" > db.sql*
elif [ $database == "postgresql" ]; then
ynh_psql_dump_db --database="$db_name" > db.sql
fi
fi
#=================================================

View file

@ -35,9 +35,8 @@ ynh_app_setting_set --app=$app --key=password --value=$password
# CREATE A MYSQL DATABASE
#=================================================
if [ $with_mysql -eq 1 ]
then
ynh_script_progression --message="Creating a MySQL database..." --weight=2
if [ $database != "none" ]; then
ynh_script_progression --message="Creating a database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
@ -45,7 +44,12 @@ then
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
if [ $database == "mysql" ]; then
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
elif [ $database == "postgresql" ]; then
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
fi
fi
#=================================================

View file

@ -15,14 +15,18 @@ source /usr/share/yunohost/helpers
# REMOVE THE MYSQL DATABASE
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_script_progression --message="Removing the MySQL database..." --weight=2
if [ $database != "none" ]; then
ynh_script_progression --message="Removing the database..." --weight=2
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
# Remove a database if it exists, along with the associated user
if [ $database == "mysql" ]; then
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database == "postgresql" ]; then
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi
fi
#=================================================

View file

@ -20,14 +20,20 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.d/"
# RESTORE THE MYSQL DATABASE
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_script_progression --message="Restoring the MySQL database..."
if [ $database != "none" ]; then
ynh_script_progression --message="Restoring the database..."
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)
if [ $database == "mysql" ]; then
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
elif [ $database == "postgresql" ]; then
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
fi
fi
#=================================================

View file

@ -20,6 +20,18 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If database doesn't exist, create it and remove with_mysql setting
if [ -z "${database:-}" ]; then
if [ $with_mysql -eq 1 ]; then
database="mysql"
else
database="none"
fi
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_delete --app=$app --key=with_mysql
fi
# If admin_mail_html doesn't exist, create it
if [ -z "${admin_mail_html:-}" ]; then
admin_mail_html=1

View file

@ -7,8 +7,14 @@ test_format = 1.0
# -------------------------------
args.with_sftp = "1"
args.with_mysql = "1"
args.password = "SuperDuper_StrongPassw0rd"
args.database = "none"
args.phpversion = "8.0"
test_upgrade_from.bf5d3ed.name = "1.0~ynh14"
test_upgrade_from.bf5d3ed.args.with_mysql = "0"
test_upgrade_from.bf5d3ed.args.domain = "sub.domain.tld"
test_upgrade_from.bf5d3ed.args.path = "/"
test_upgrade_from.bf5d3ed.args.password = "SuperDuper_StrongPassw0rd"
[80_test]
@ -19,3 +25,18 @@ test_format = 1.0
only = ["install.subdir", "backup_restore", "upgrade" ]
args.phpversion = "none"
[mysql_test]
only = ["install.subdir", "backup_restore", "upgrade", "upgrade.bf5d3ed" ]
args.database = "mysql"
test_upgrade_from.bf5d3ed.name = "1.0~ynh14"
test_upgrade_from.bf5d3ed.args.with_mysql = "1"
test_upgrade_from.bf5d3ed.args.domain = "sub.domain.tld"
test_upgrade_from.bf5d3ed.args.path = "/"
test_upgrade_from.bf5d3ed.args.password = "SuperDuper_StrongPassw0rd"
[postgresql_test]
only = ["install.subdir", "backup_restore", "upgrade" ]
args.database = "postgresql"