mirror of
https://github.com/YunoHost-Apps/my_webapp_ynh.git
synced 2024-09-03 19:46:26 +02:00
Normalization from example_ynh
This commit is contained in:
parent
ae1791160a
commit
034e5fc83c
8 changed files with 93 additions and 70 deletions
76
README.md
76
README.md
|
@ -1,7 +1,10 @@
|
|||
Custom Webapp
|
||||
-------------
|
||||
# Custom Webapp for YunoHost
|
||||
|
||||
Empty application with SFTP access to the Web directory.
|
||||
[](https://dash.yunohost.org/appci/app/my_webapp)
|
||||
[](https://install-app.yunohost.org/?app=my_webapp)
|
||||
|
||||
> *This package allow you to install Custom Webapp quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
|
||||
|
@ -17,49 +20,54 @@ at the installation. Under the Web directory, you will see a `www` folder
|
|||
which is the public and served one. You can put all the files of your
|
||||
custom Web application inside.
|
||||
|
||||
## Upgrade
|
||||
**Shipped version:** 1.0
|
||||
|
||||
Due to the SFTP access change, the upgrade can not be done from the last
|
||||
`my_webapp` application - provided with YunoHost 2.2. You will have to remove
|
||||
it first and install this new one, taking care of migrating your data.
|
||||
## Screenshots
|
||||
|
||||
### Save your files and the database
|
||||
## Demo
|
||||
|
||||
You will have to save the content of the `/var/www/my_webapp/files`
|
||||
directory, either from the Web admin interface provided by the old app or
|
||||
connecting to your server using SSH - or SFTP as `admin`.
|
||||
## Configuration
|
||||
|
||||
If you've created a MySQL database, you can also migrate it since the new
|
||||
version allows to manage it for you. To create a dump, you could either use
|
||||
[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
|
||||
your server and execute:
|
||||
`mysqldump -u root -p$(cat /etc/yunohost/mysql --no-create-db "$dbname" > ./dump.sql`
|
||||
(do not forget to replace `$dbname` by your database name).
|
||||
## Documentation
|
||||
|
||||
### Restore your custom Webapp
|
||||
* YunoHost documentation: https://github.com/YunoHost/doc/blob/master/app_my_webapp.md
|
||||
|
||||
When you've taken care of saving your files - and optionally your database,
|
||||
you can remove the app and install this new one. You can set the same
|
||||
settings as the previous installation.
|
||||
## YunoHost specific features
|
||||
|
||||
To restore your files, connect to the Web directory using the SFTP account - as
|
||||
described at the installation path - and put everything into the `www` directory.
|
||||
#### Multi-users support
|
||||
|
||||
If you have chosen to migrate your database too, open the file `db_access.txt`
|
||||
to know the new database, user and password you will have to set in your app
|
||||
configuration. You can restore the dump you've created earlier either using
|
||||
[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
|
||||
your server and execute:
|
||||
`mysql -u "$dbuser" -p"$dbpass" "$dbname" < ./dump.sql`
|
||||
(do not forget to replace `$dbuser`, `$dbpass` and `$dbname` with the values
|
||||
given in the file).
|
||||
#### Supported architectures
|
||||
|
||||
### SFTP port ###
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/my_webapp/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/my_webapp/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/my_webapp/)
|
||||
|
||||
## Limitations
|
||||
|
||||
## Additional information
|
||||
|
||||
#### SFTP port
|
||||
|
||||
You may have change the SSH port as described
|
||||
[here (section "Modifier le port SSH"](https://yunohost.org/#/security_fr) ;
|
||||
then you should use this port to update your website with SFTP.
|
||||
|
||||
## Links
|
||||
## Links
|
||||
|
||||
**YunoHost**: https://yunohost.org/
|
||||
* Report a bug: https://github.com/YunoHost-Apps/my_webapp_ynh/issues
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade my_webapp -u https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
location __PATH__ {
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/www/;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
"en": "Custom Web app with SFTP access",
|
||||
"fr": "Application Web personnalisée avec accès SFTP"
|
||||
},
|
||||
"version": "1.0",
|
||||
"version": "1.0~ynh1",
|
||||
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
|
||||
"license": "GPLv3",
|
||||
"license": "GPL-3.0-only",
|
||||
"maintainer": {
|
||||
"name": "YunoHost Contributors",
|
||||
"email": "apps@yunohost.org"
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit on command errors and treat access to unset variables as an error
|
||||
set -eu
|
||||
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
|
|
@ -42,8 +42,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available $domain $path_url
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
|
@ -89,14 +87,6 @@ ynh_system_user_exists "$user" || \
|
|||
# Add the password to this user
|
||||
chpasswd <<< "${user}:${password}"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -120,8 +110,8 @@ systemctl reload ssh
|
|||
# FILL AND COPY SOURCE FILES
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
|
||||
ynh_replace_string "{USER}" "$user" ../sources/www/index.html
|
||||
ynh_replace_string "__DOMAIN__" "$domain" ../sources/www/index.html
|
||||
ynh_replace_string "__USER__" "$user" ../sources/www/index.html
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
# Store the database access
|
||||
|
@ -132,6 +122,15 @@ fi
|
|||
# Copy files to the right place
|
||||
cp -r ../sources "$final_path"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit on command errors and treat access to unset variables as an error
|
||||
set -eu
|
||||
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
|
|
@ -36,6 +36,15 @@ https://github.com/YunoHost-Apps/my_webapp_ynh#upgrade"
|
|||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
|
@ -52,11 +61,14 @@ fi
|
|||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
||||
ynh_backup_before_upgrade # Backup the current version of the app
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_restore_upgradebackup # restore it if the upgrade fails
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
ynh_abort_if_errors # Exit if an error occurs during the execution of the script
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
|
@ -130,7 +142,7 @@ fi
|
|||
#=================================================
|
||||
|
||||
# Remove the previous config for upgrading it
|
||||
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
# Harden SSH connection for the user
|
||||
echo "##-> ${app}
|
||||
# Hardening user connection
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
</p>
|
||||
<dl>
|
||||
<dt>Domain</dt>
|
||||
<dd>{DOMAIN}</dd>
|
||||
<dd>__DOMAIN__</dd>
|
||||
<dt>Port</dt>
|
||||
<dd>22 (or the port you defined <a href="https://yunohost.org/#/security_fr">if you change the ssh port</a>)</dd>
|
||||
<dt>User</dt>
|
||||
<dd>{USER}</dd>
|
||||
<dd>__USER__</dd>
|
||||
<dt>Password</dt>
|
||||
<dd><i>the one you set at installation</i></dd>
|
||||
</dl>
|
||||
|
|
Loading…
Add table
Reference in a new issue