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

Clean scripts

This commit is contained in:
Maniack Crudelis 2019-01-19 13:34:47 +01:00
parent b0a9db465b
commit 14373bc73c
7 changed files with 18 additions and 112 deletions

View file

@ -17,7 +17,7 @@
multi_instance=1
incorrect_path=1
port_already_use=0
change_url=0
change_url=1
;;; Levels
Level 1=auto
Level 2=auto

View file

@ -8,7 +8,7 @@
},
"version": "1.0",
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
"license": "GPL-3.0-only",
"license": "free",
"maintainer": {
"name": "YunoHost Contributors",
"email": "apps@yunohost.org"
@ -42,15 +42,6 @@
"example": "/site",
"default": "/site"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public website?",
"fr": "Est-ce un site public ?"
},
"default": true
},
{
"name": "password",
"type": "password",
@ -60,6 +51,15 @@
},
"example": "myreallystrengthpassword"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public website?",
"fr": "Est-ce un site public ?"
},
"default": true
},
{
"name": "with_mysql",
"type": "boolean",

View file

@ -13,10 +13,6 @@ 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

View file

@ -13,10 +13,6 @@ 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
@ -26,21 +22,11 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
with_mysql=$YNH_APP_ARG_WITH_MYSQL
### If it's a multi-instance app, meaning it can be installed several times independently
### The id of the app as stated in the manifest is available as $YNH_APP_ID
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
### The app instance name is available as $YNH_APP_INSTANCE_NAME
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
### The app instance name is probably what interests you most, since this is
### guaranteed to be unique. This is a good unique identifier to define installation path,
### db names, ...
app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER
@ -48,8 +34,6 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -84,15 +68,6 @@ ynh_app_setting_set $app final_path $final_path
# CREATE A MYSQL DATABASE
#=================================================
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
### The password will be stored as 'mysqlpwd' into the app settings,
### and will be available as $db_pwd
### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
if [ $with_mysql -eq 1 ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
@ -103,8 +78,6 @@ fi
# NGINX CONFIGURATION
#=================================================
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config
ynh_add_nginx_config
@ -122,17 +95,6 @@ chpasswd <<< "${user}:${password}"
# PHP-FPM CONFIGURATION
#=================================================
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
### With the reload at the end of the script.
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
ynh_add_fpm_config
@ -160,9 +122,6 @@ systemctl reload ssh
# MODIFY A CONFIG FILE
#=================================================
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
ynh_replace_string "{USER}" "$user" ../sources/www/index.html
@ -181,28 +140,10 @@ cp -r ../sources "$final_path"
# SECURE FILES AND DIRECTORIES
#=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set permissions to app files
chown -R root: $final_path
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
### You'll find the service in the 'services' section of YunoHost admin panel.
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
yunohost service add $app --log "/var/log/$app/APP.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/APP.log"
chown -R $user: "$final_path"
# Home directory of the user needs to be owned by root to allow
# SFTP connections
chown root: "$final_path"
#=================================================
# SETUP SSOWAT

View file

@ -16,40 +16,15 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
with_mysql=$(ynh_app_setting_get $app with_mysql)
user=$(ynh_app_setting_get $app user)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
with_mysql=$(ynh_app_setting_get $app with_mysql)
user=$(ynh_app_setting_get $app user)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
then
echo "Remove $app service"
yunohost service remove $app
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================

View file

@ -13,10 +13,6 @@ 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

View file

@ -17,10 +17,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
with_mysql=$(ynh_app_setting_get $app with_mysql)
password=$(ynh_app_setting_get $app password)