diff --git a/check_process b/check_process index 201bb2d..2ce4d50 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/app.src b/conf/app.src index 31705bb..c80e538 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz -SOURCE_SUM=fec6996440009b29af82e031ea2c085766752732771289975af7573652ed4798 +SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.tar.gz +SOURCE_SUM=8264b57aeaa1f91c6d859331777c71e80d26088bef7cdcd5f9431119747ed1c1 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/config.inc.php b/conf/config.inc.php index b42cffd..647750e 100644 --- a/conf/config.inc.php +++ b/conf/config.inc.php @@ -28,8 +28,8 @@ $i = 0; $i++; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'config'; -$cfg['Servers'][$i]['user'] = '__YNH_PMA_ADMIN_USER__'; -$cfg['Servers'][$i]['password'] = '__YNH_PMA_ADMIN_PASSWORD__'; +$cfg['Servers'][$i]['user'] = '__DB_ADMIN_USER__'; +$cfg['Servers'][$i]['password'] = '__DB_ADMIN_PWD__'; /* Server parameters */ /* $cfg['Servers'][$i]['host'] = 'localhost'; @@ -49,11 +49,11 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlport'] = ''; -$cfg['Servers'][$i]['controluser'] = '__YNH_PMA_USER__'; -$cfg['Servers'][$i]['controlpass'] = '__YNH_PMA_PASSWORD__'; +$cfg['Servers'][$i]['controluser'] = '__DB_USER__'; +$cfg['Servers'][$i]['controlpass'] = '__DB_PWD__'; /* 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]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; diff --git a/conf/create_db.sql b/conf/create_db.sql index d603e62..ed1ef72 100644 --- a/conf/create_db.sql +++ b/conf/create_db.sql @@ -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; -USE __YNH_PMA_USER__; +USE __DB_USER__; -GRANT SELECT, INSERT, DELETE, UPDATE ON `__YNH_PMA_USER__`.* TO - '__YNH_PMA_USER__'@localhost; +GRANT SELECT, INSERT, DELETE, UPDATE ON `__DB_USER__`.* TO + '__DB_USER__'@localhost; diff --git a/manifest.json b/manifest.json index 8a1637d..cb79282 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Manage MySQL databases over the web", "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", "license": "GPL-2.0-only", "maintainer": { @@ -14,7 +14,7 @@ "email": "julien.malik@paraiso.me" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.2.0" }, "multi_instance": false, "services": [ @@ -27,29 +27,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for phpMyAdmin", - "fr": "Choisissez un domaine pour phpMyAdmin" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for phpMyAdmin", - "fr": "Choisissez un chemin pour phpMyAdmin" - }, "example": "/phpmyadmin", "default": "/phpmyadmin" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose the only allowed admin user", - "fr": "Choisissez l'unique utilisateur autorisé" - }, "example": "johndoe" } ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 46ce7fb..45d51fa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,74 +5,19 @@ #================================================= 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" +YNH_COMPOSER_VERSION=2.0.14 + +#================================================= +# PERSONAL HELPERS +#================================================= #================================================= # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -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." -} \ No newline at end of file +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install index 60edeff..bab3d17 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,14 @@ then FLUSH PRIVILEGES;" --database=mysql 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 #================================================= @@ -87,14 +95,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3 # Create a dedicated 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 #================================================= @@ -110,7 +110,7 @@ ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= 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" \ < ../conf/create_db.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_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 +ynh_add_config --template="../conf/config.inc.php" --destination="$final_path/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 --file="$final_path/config.inc.php" +chmod 400 "$final_path/some_config_file" +chown $app:$app "$final_path/some_config_file" #================================================= # INSTALL DEPENDENCIES WITH COMPOSER diff --git a/scripts/restore b/scripts/restore index 9f85bc0..dc230f8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,6 +47,14 @@ test ! -d $final_path \ 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 #================================================= @@ -74,14 +82,6 @@ then FLUSH PRIVILEGES;" --database=mysql 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d255fb3..f3e4d95 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,6 +90,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script 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 #================================================= @@ -101,7 +109,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 --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.inc.php" fi #================================================= @@ -112,14 +120,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated 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 #================================================= @@ -156,24 +156,6 @@ then < $final_path/sql/create_tables.sql 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 #=================================================