mirror of
https://github.com/YunoHost-Apps/phpmyadmin_ynh.git
synced 2024-09-03 19:56:46 +02:00
Merge pull request #92 from YunoHost-Apps/testing
Normalization from example_ynh
This commit is contained in:
commit
477f16bdd5
11 changed files with 215 additions and 129 deletions
|
@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
|
|||
|
||||
phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.
|
||||
|
||||
**Shipped version:** 4.8.5
|
||||
**Shipped version:** 4.9.0.1
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
@ -34,9 +34,9 @@ phpMyAdmin is a free software tool written in PHP, intended to handle the admini
|
|||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/phpmyadmin%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/phpmyadmin/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/phpmyadmin%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/phpmyadmin/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/phpmyadmin%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/phpmyadmin/)
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/phpmyadmin/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/phpmyadmin/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/phpmyadmin/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
@ -46,6 +46,7 @@ phpMyAdmin is a free software tool written in PHP, intended to handle the admini
|
|||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues
|
||||
* Phpmyadmin website: https://www.phpmyadmin.net/
|
||||
* Phpmyadmin repository: https://github.com/phpmyadmin/phpmyadmin
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
|
|
@ -16,19 +16,9 @@
|
|||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=na
|
||||
# Level 5: https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues/62
|
||||
Level 5=1
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_8_5.tar.gz
|
||||
SOURCE_SUM=dd7a7eebeae2fc003c7d5870965baf827b63cffee55dd799a42b465247313c1e
|
||||
SOURCE_URL=https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_9_0_1.tar.gz
|
||||
SOURCE_SUM=974080cdd3577da098b8f1e1cc117079425973a0592cb0d737a0e95c0980ae45
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Manage MySQL databases over the web",
|
||||
"fr": "Application web de gestion des bases de données MySQL"
|
||||
},
|
||||
"version": "4.8.5~ynh2",
|
||||
"version": "4.9.0.1~ynh1",
|
||||
"url": "http://www.phpmyadmin.net",
|
||||
"license": "GPL-2.0-only",
|
||||
"maintainer": {
|
||||
|
|
|
@ -19,43 +19,47 @@ exec_as() {
|
|||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands"
|
||||
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
ynh_composer_exec () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=wc
|
||||
declare -Ar args_array=( [w]=workdir= [c]=commands= )
|
||||
local legacy_args=vwc
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||
local phpversion
|
||||
local workdir
|
||||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
COMPOSER_HOME="$workdir/.composer" \
|
||||
php "$workdir/composer.phar" $commands \
|
||||
php${phpversion} "$workdir/composer.phar" $commands \
|
||||
-d "$workdir" --quiet --no-interaction
|
||||
}
|
||||
|
||||
# Install and initialize Composer in the given directory
|
||||
#
|
||||
# usage: ynh_install_composer [--workdir=$final_path]
|
||||
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
ynh_install_composer () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=w
|
||||
declare -Ar args_array=( [w]=workdir= )
|
||||
local legacy_args=vw
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
|
||||
local phpversion
|
||||
local workdir
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| COMPOSER_HOME="$workdir/.composer" \
|
||||
php -- --quiet --install-dir="$workdir" \
|
||||
php${phpversion} -- --quiet --install-dir="$workdir" \
|
||||
|| ynh_die "Unable to install Composer."
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \
|
||||
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
||||
|| ynh_die "Unable to update core dependencies with Composer."
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_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)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -34,28 +34,28 @@ db_name=$(ynh_app_setting_get $app db_name)
|
|||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up php-fpm configuration..."
|
||||
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
92
scripts/change_url
Normal file
92
scripts/change_url
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
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..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
|
||||
|
||||
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..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
|
@ -32,22 +32,19 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
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)
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app admin $admin
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -56,21 +53,21 @@ ynh_app_setting_set $app admin $admin
|
|||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..."
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
|
||||
|
||||
# Setup a privileged user for phpmyadmin (to prevent using MySQL root user)
|
||||
db_admin_user="${app}_root"
|
||||
ynh_app_setting_set $app db_admin_user $db_admin_user
|
||||
ynh_app_setting_set --app=$app --key=db_admin_user --value=$db_admin_user
|
||||
db_admin_pwd="$(ynh_string_random)"
|
||||
ynh_app_setting_set $app db_admin_pwd $db_admin_pwd
|
||||
ynh_app_setting_set --app=$app --key=db_admin_pwd --value=$db_admin_pwd
|
||||
|
||||
if ! ynh_mysql_user_exists "$db_admin_user"
|
||||
if ! ynh_mysql_user_exists --user=$db_admin_user
|
||||
then
|
||||
ynh_mysql_create_user "$db_admin_user" "$db_admin_pwd"
|
||||
ynh_mysql_execute_as_root "GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" mysql
|
||||
ynh_mysql_create_user $db_admin_user "$db_admin_pwd"
|
||||
ynh_mysql_execute_as_root --sql="GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" --database=mysql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -78,9 +75,9 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=6
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
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 "$final_path"
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -96,7 +93,7 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -113,11 +110,11 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Filling database..." --weight=3
|
||||
|
||||
ynh_replace_string "__YNH_PMA_USER__" "$db_name" ../conf/create_db.sql
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/create_db.sql
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< ../conf/create_db.sql
|
||||
ynh_replace_string "phpmyadmin" "$db_name" $final_path/sql/create_tables.sql
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/create_tables.sql
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< $final_path/sql/create_tables.sql
|
||||
|
||||
#=================================================
|
||||
|
@ -125,15 +122,15 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring phpmyadmin..."
|
||||
|
||||
ynh_replace_string "__YNH_PMA_ADMIN_USER__" "$db_admin_user" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_ADMIN_PASSWORD__" "$db_admin_pwd" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_USER__" "$db_name" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_PASSWORD__" "$db_pwd" ../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_ADMIN_USER__" --replace_string="$db_admin_user" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_ADMIN_PASSWORD__" --replace_string="$db_admin_pwd" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_PASSWORD__" --replace_string="$db_pwd" --target_file=../conf/config.inc.php
|
||||
|
||||
cp ../conf/config.inc.php $final_path
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$final_path/config.inc.php"
|
||||
ynh_store_file_checksum --file="$final_path/config.inc.php"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES WITH COMPOSER
|
||||
|
|
|
@ -16,10 +16,10 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_admin_user=$(ynh_app_setting_get $app db_admin_user)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_admin_user=$(ynh_app_setting_get --app=$app --key=db_admin_user)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -29,7 +29,7 @@ db_admin_user=$(ynh_app_setting_get $app db_admin_user)
|
|||
ynh_script_progression --message="Removing the MySQL database" --weight=2
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db $db_name $db_name
|
||||
ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
|
||||
|
||||
# Remove phpmyadmin MySQL admin user
|
||||
ynh_mysql_drop_user $db_admin_user
|
||||
|
@ -40,7 +40,7 @@ ynh_mysql_drop_user $db_admin_user
|
|||
ynh_script_progression --message="Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -66,7 +66,7 @@ ynh_remove_fpm_config
|
|||
ynh_script_progression --message="Removing the dedicated system user"
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -23,21 +23,21 @@ ynh_script_progression --message="Loading settings..." --weight=3
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -45,32 +45,33 @@ test ! -d $final_path \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=4
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
# Setup a privileged user for phpmyadmin (to prevent using MySQL root user)
|
||||
db_admin_user=$(ynh_app_setting_get $app db_admin_user)
|
||||
db_admin_pwd=$(ynh_app_setting_get $app db_admin_pwd)
|
||||
db_admin_user=$(ynh_app_setting_get --app=$app --key=db_admin_user)
|
||||
db_admin_pwd=$(ynh_app_setting_get --app=$app --key=db_admin_pwd)
|
||||
|
||||
if ! ynh_mysql_user_exists "$db_admin_user" ; then
|
||||
if ! ynh_mysql_user_exists --user=$db_admin_user
|
||||
then
|
||||
ynh_mysql_create_user "$db_admin_user" "$db_admin_pwd"
|
||||
ynh_mysql_execute_as_root "GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" mysql
|
||||
ynh_mysql_execute_as_root --sql="GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" --database=mysql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -79,7 +80,7 @@ fi
|
|||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
|
@ -94,7 +95,7 @@ chown $app: $final_path/tmp
|
|||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -16,13 +16,13 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_admin_user=$(ynh_app_setting_get $app db_admin_user)
|
||||
db_admin_pwd=$(ynh_app_setting_get $app db_admin_pwd)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_admin_user=$(ynh_app_setting_get --app=$app --key=db_admin_user)
|
||||
db_admin_pwd=$(ynh_app_setting_get --app=$app --key=db_admin_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -36,37 +36,38 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
if [ -z "$db_name" ]; then
|
||||
# In older version, db_name was always phpmyadmin
|
||||
db_name=phpmyadmin
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
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
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path="/var/www/$app"
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# In older version, the admin setting was admin_user
|
||||
if [ -z $admin ]; then
|
||||
admin=$(ynh_app_setting_get $app admin_user)
|
||||
ynh_app_setting_set "$app" admin "$admin"
|
||||
ynh_app_setting_delete $app admin_user
|
||||
if [ -z "$admin" ]; then
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin_user)
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_delete --app=$app --key=admin_user
|
||||
fi
|
||||
|
||||
# If db_admin_user doesn't exist, create it
|
||||
if [ -z $db_admin_user ]; then
|
||||
if [ -z "$db_admin_user" ]; then
|
||||
# Setup a privileged user for phpmyadmin (to prevent using MySQL root user)
|
||||
db_admin_user="${app}_root"
|
||||
ynh_app_setting_set $app db_admin_user $db_admin_user
|
||||
ynh_app_setting_set --app=$app --key=db_admin_user --value=$db_admin_user
|
||||
db_admin_pwd="$(ynh_string_random)"
|
||||
ynh_app_setting_set $app db_admin_pwd $db_admin_pwd
|
||||
ynh_app_setting_set --app=$app --key=db_admin_pwd --value=$db_admin_pwd
|
||||
|
||||
if ! ynh_mysql_user_exists "$db_admin_user" ; then
|
||||
ynh_mysql_create_user "$db_admin_user" "$db_admin_pwd"
|
||||
ynh_mysql_execute_as_root "GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" mysql
|
||||
if ! ynh_mysql_user_exists --user=$db_admin_user
|
||||
then
|
||||
ynh_mysql_create_user $db_admin_user "$db_admin_pwd"
|
||||
ynh_mysql_execute_as_root --sql="GRANT ALL PRIVILEGES ON *.* TO '$db_admin_user'@'localhost' IDENTIFIED BY '$db_admin_pwd' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;" --database=mysql
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -89,7 +90,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -102,7 +103,7 @@ then
|
|||
ynh_script_progression --message="Upgrading source files..." --weight=5
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -119,7 +120,7 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -135,7 +136,7 @@ ynh_add_fpm_config
|
|||
# UPGRADE THE DATABASE
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
|
@ -143,17 +144,17 @@ then
|
|||
|
||||
# Handle upgrade from a version before latest version
|
||||
# Ignore warnings and failures that will occur if already on latest version
|
||||
ynh_replace_string "phpmyadmin" "$db_name" $final_path/sql/upgrade_column_info_4_3_0+.sql
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/upgrade_column_info_4_3_0+.sql
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< $final_path/sql/upgrade_column_info_4_3_0+.sql > /dev/null 2>&1 || true
|
||||
|
||||
# Upgrade from last version (don't ignore failures)
|
||||
ynh_replace_string "phpmyadmin" "$db_name" $final_path/sql/upgrade_tables_4_7_0+.sql
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/upgrade_tables_4_7_0+.sql
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< $final_path/sql/upgrade_tables_4_7_0+.sql
|
||||
|
||||
ynh_replace_string "phpmyadmin" "$db_name" $final_path/sql/create_tables.sql
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/create_tables.sql
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< $final_path/sql/create_tables.sql
|
||||
fi
|
||||
|
||||
|
@ -163,17 +164,17 @@ fi
|
|||
ynh_script_progression --message="Reconfiguring phpmyadmin..."
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$final_path/config.inc.php"
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/config.inc.php"
|
||||
|
||||
ynh_replace_string "__YNH_PMA_ADMIN_USER__" "$db_admin_user" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_ADMIN_PASSWORD__" "$db_admin_pwd" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_USER__" "$db_name" ../conf/config.inc.php
|
||||
ynh_replace_string "__YNH_PMA_PASSWORD__" "$db_pwd" ../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_ADMIN_USER__" --replace_string="$db_admin_user" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_ADMIN_PASSWORD__" --replace_string="$db_admin_pwd" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/config.inc.php
|
||||
ynh_replace_string --match_string="__YNH_PMA_PASSWORD__" --replace_string="$db_pwd" --target_file=../conf/config.inc.php
|
||||
|
||||
cp ../conf/config.inc.php $final_path
|
||||
|
||||
# Recalculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$final_path/config.inc.php"
|
||||
ynh_store_file_checksum --file="$final_path/config.inc.php"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
|
Loading…
Reference in a new issue