1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/phpmyadmin_ynh.git synced 2024-09-03 19:56:46 +02:00
This commit is contained in:
ericgaspar 2021-06-04 08:54:01 +02:00
parent 2fdb855df1
commit 0bc311a060
No known key found for this signature in database
GPG key ID: 574F281483054D44
9 changed files with 56 additions and 146 deletions

View file

@ -1,8 +1,8 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
admin="john" (USER) admin="john"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.tar.gz
SOURCE_SUM=fec6996440009b29af82e031ea2c085766752732771289975af7573652ed4798 SOURCE_SUM=8264b57aeaa1f91c6d859331777c71e80d26088bef7cdcd5f9431119747ed1c1
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -28,8 +28,8 @@ $i = 0;
$i++; $i++;
/* Authentication type */ /* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '__YNH_PMA_ADMIN_USER__'; $cfg['Servers'][$i]['user'] = '__DB_ADMIN_USER__';
$cfg['Servers'][$i]['password'] = '__YNH_PMA_ADMIN_PASSWORD__'; $cfg['Servers'][$i]['password'] = '__DB_ADMIN_PWD__';
/* Server parameters */ /* Server parameters */
/* /*
$cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['host'] = 'localhost';
@ -49,11 +49,11 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
/* User used to manipulate with storage */ /* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = ''; // $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = '__YNH_PMA_USER__'; $cfg['Servers'][$i]['controluser'] = '__DB_USER__';
$cfg['Servers'][$i]['controlpass'] = '__YNH_PMA_PASSWORD__'; $cfg['Servers'][$i]['controlpass'] = '__DB_PWD__';
/* Storage database and tables */ /* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = '__YNH_PMA_USER__'; $cfg['Servers'][$i]['pmadb'] = '__DB_USER__';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info';

View file

@ -14,14 +14,14 @@
-- -------------------------------------------------------- -- --------------------------------------------------------
DROP DATABASE `__YNH_PMA_USER__`; DROP DATABASE `__DB_USER__`;
-- --
-- Database : `__YNH_PMA_USER__` -- Database : `__DB_USER__`
-- --
CREATE DATABASE IF NOT EXISTS `__YNH_PMA_USER__` CREATE DATABASE IF NOT EXISTS `__DB_USER__`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE __YNH_PMA_USER__; USE __DB_USER__;
GRANT SELECT, INSERT, DELETE, UPDATE ON `__YNH_PMA_USER__`.* TO GRANT SELECT, INSERT, DELETE, UPDATE ON `__DB_USER__`.* TO
'__YNH_PMA_USER__'@localhost; '__DB_USER__'@localhost;

View file

@ -6,7 +6,7 @@
"en": "Manage MySQL databases over the web", "en": "Manage MySQL databases over the web",
"fr": "Application web de gestion des bases de données MySQL" "fr": "Application web de gestion des bases de données MySQL"
}, },
"version": "5.1.0~ynh1", "version": "5.1.1~ynh1",
"url": "http://www.phpmyadmin.net", "url": "http://www.phpmyadmin.net",
"license": "GPL-2.0-only", "license": "GPL-2.0-only",
"maintainer": { "maintainer": {
@ -14,7 +14,7 @@
"email": "julien.malik@paraiso.me" "email": "julien.malik@paraiso.me"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.8.1" "yunohost": ">= 4.2.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -27,29 +27,17 @@
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": {
"en": "Choose a domain for phpMyAdmin",
"fr": "Choisissez un domaine pour phpMyAdmin"
},
"example": "domain.org" "example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for phpMyAdmin",
"fr": "Choisissez un chemin pour phpMyAdmin"
},
"example": "/phpmyadmin", "example": "/phpmyadmin",
"default": "/phpmyadmin" "default": "/phpmyadmin"
}, },
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user",
"ask": {
"en": "Choose the only allowed admin user",
"fr": "Choisissez l'unique utilisateur autorisé"
},
"example": "johndoe" "example": "johndoe"
} }
] ]

View file

@ -5,74 +5,19 @@
#================================================= #=================================================
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring" extra_php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring"
YNH_COMPOSER_VERSION=2.0.14
#=================================================
# PERSONAL HELPERS
#=================================================
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
# Execute a command as another user #=================================================
# usage: exec_as USER COMMAND [ARG ...] # FUTURE OFFICIAL HELPERS
ynh_exec_as() { #=================================================
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}
# Execute a command with Composer
#
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -v, --phpversion - PHP version to use with composer
# | 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=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:-$YNH_PHP_VERSION}"
COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"]
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vwa
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=)
local phpversion
local workdir
local install_args
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
install_args="${install_args:-}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer."
}

View file

@ -70,6 +70,14 @@ then
FLUSH PRIVILEGES;" --database=mysql FLUSH PRIVILEGES;" --database=mysql
fi fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -87,14 +95,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -110,7 +110,7 @@ ynh_add_fpm_config --package="$extra_php_dependencies"
#================================================= #=================================================
ynh_script_progression --message="Filling database..." --weight=3 ynh_script_progression --message="Filling database..." --weight=3
ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/create_db.sql ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file=../conf/create_db.sql
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \ ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
< ../conf/create_db.sql < ../conf/create_db.sql
ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/create_tables.sql ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/create_tables.sql
@ -122,15 +122,10 @@ ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name
#================================================= #=================================================
ynh_script_progression --message="Configuring phpMyAdmin..." ynh_script_progression --message="Configuring phpMyAdmin..."
ynh_replace_string --match_string="__YNH_PMA_ADMIN_USER__" --replace_string="$db_admin_user" --target_file=../conf/config.inc.php ynh_add_config --template="../conf/config.inc.php" --destination="$final_path/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 chmod 400 "$final_path/some_config_file"
chown $app:$app "$final_path/some_config_file"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/config.inc.php"
#================================================= #=================================================
# INSTALL DEPENDENCIES WITH COMPOSER # INSTALL DEPENDENCIES WITH COMPOSER

View file

@ -47,6 +47,14 @@ test ! -d $final_path \
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -74,14 +82,6 @@ then
FLUSH PRIVILEGES;" --database=mysql FLUSH PRIVILEGES;" --database=mysql
fi fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================

View file

@ -90,6 +90,14 @@ ynh_clean_setup () {
# 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 ynh_abort_if_errors
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -101,7 +109,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=5 ynh_script_progression --message="Upgrading source files..." --weight=5
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.inc.php"
fi fi
#================================================= #=================================================
@ -112,14 +120,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -156,24 +156,6 @@ then
< $final_path/sql/create_tables.sql < $final_path/sql/create_tables.sql
fi fi
#=================================================
# CONFIGURE PHPMYADMIN
#=================================================
ynh_script_progression --message="Reconfiguring phpMyAdmin..."
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/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 --file="$final_path/config.inc.php"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================