From b74690d4b58dcda2931194bba804e4ab71e44ac6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 11:25:17 +0100 Subject: [PATCH] cleanup --- scripts/backup | 4 --- scripts/install | 81 ++----------------------------------------------- scripts/remove | 48 ----------------------------- scripts/restore | 4 --- 4 files changed, 2 insertions(+), 135 deletions(-) diff --git a/scripts/backup b/scripts/backup index 847f863..2348d9e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,10 +14,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 diff --git a/scripts/install b/scripts/install index 4073862..bd62b5e 100644 --- a/scripts/install +++ b/scripts/install @@ -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 @@ -33,17 +29,6 @@ password=$YNH_APP_ARG_PASSWORD website_title=$YNH_APP_ARG_WEBSITE_TITLE admin_email=$(ynh_user_get_info $admin 'mail') - -### 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 #================================================= @@ -51,8 +36,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_print_info "Validating installation parameters..." -### 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" @@ -77,50 +60,11 @@ ynh_app_setting_set $app website_title $website_title #================================================= # STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_print_info "Configuring firewall..." - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script - -# Find a free port -#port=$(ynh_find_port 8095) -# Open this port -#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port -#ynh_app_setting_set $app port $port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -#ynh_install_app_dependencies deb1 deb2 - #================================================= # CREATE A MYSQL DATABASE #================================================= ynh_print_info "Creating 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 - db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name ynh_mysql_setup_db $db_name $db_name @@ -130,10 +74,6 @@ ynh_mysql_setup_db $db_name $db_name #================================================= ynh_print_info "Setting up source files..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -143,8 +83,6 @@ ynh_setup_source "$final_path" #================================================= ynh_print_info "Configuring nginx web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_add_nginx_config @@ -161,17 +99,6 @@ ynh_system_user_create $app #================================================= ynh_print_info "Configuring php-fpm..." -### `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_add_fpm_config @@ -207,13 +134,9 @@ popd # 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 -sudo chown -R www-data: $final_path -sudo chmod 777 $final_path -R +chown -R www-data: $final_path + #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index e2cf5ea..6da30a6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -24,25 +24,6 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL -#================================================= - -# Remove a service from the admin panel, added by `yunohost service add` -#if yunohost service status $app >/dev/null 2>&1 -#then -# ynh_print_info "Removing $app service" -# yunohost service remove $app -#fi - -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_print_info "Stopping and removing the systemd service" - -# Remove the dedicated systemd config -#ynh_remove_systemd_config - #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -51,14 +32,6 @@ ynh_print_info "Removing the MySQL database" # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_user $db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_print_info "Removing dependencies" - -# Remove metapackage and its dependencies -#ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -83,33 +56,12 @@ ynh_print_info "Removing php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_print_info "Removing logrotate configuration" - -# Remove the app-specific logrotate config -#ynh_remove_logrotate - -#================================================= -# CLOSE A PORT -#================================================= - -#if yunohost firewall list | grep -q "\- $port$" -#then -# ynh_print_info "Closing port $port" -# ynh_exec_warn_less yunohost firewall disallow TCP $port -#fi - #================================================= # SPECIFIC REMOVE #================================================= # REMOVE THE CRON FILE #================================================= -# Remove a cron file -#ynh_secure_remove "/etc/cron.d/$app" - # Remove a directory securely ynh_secure_remove "/etc/$app/" diff --git a/scripts/restore b/scripts/restore index 38d4839..a6c19cb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,10 +14,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