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

Normalization from example_ynh

This commit is contained in:
Maniack Crudelis 2019-02-17 15:42:09 +01:00
parent 84577ca941
commit 4d8b2a45c8
10 changed files with 149 additions and 96 deletions

View file

@ -1,4 +1,63 @@
# phpmyadmin for yunohost
# Phpmyadmin for YunoHost
* https://www.phpmyadmin.net/
[![Integration level](https://dash.yunohost.org/integration/phpmyadmin.svg)](https://dash.yunohost.org/appci/app/phpmyadmin)
[![Install Phpmyadmin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=phpmyadmin)
> *This package allow you to install Phpmyadmin quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
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
## Screenshots
![](https://www.phpmyadmin.net/static/images/screenshots/structure.png)
## Demo
* [YunoHost demo](https://demo.yunohost.org/phpmyadmin/)
* [Official demo](https://demo.phpmyadmin.net/master-config/)
## Configuration
## Documentation
* Official documentation: https://www.phpmyadmin.net/docs/
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-users support
#### 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/)
## Limitations
## Additionnal informations
## Links
* Report a bug: https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues
* Phpmyadmin website: https://www.phpmyadmin.net/
* YunoHost website: https://yunohost.org/
---
Developers infos
----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing --debug
or
sudo yunohost app upgrade phpmyadmin -u https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing --debug
```

View file

@ -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'] = '__YNH_PMA_ADMIN_USER__';
$cfg['Servers'][$i]['password'] = '__YNH_PMA_ADMIN_PASSWORD__';
/* 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'] = '__YNH_PMA_USER__';
$cfg['Servers'][$i]['controlpass'] = '__YNH_PMA_PASSWORD__';
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'YNH_PMA_USER';
$cfg['Servers'][$i]['pmadb'] = '__YNH_PMA_USER__';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';

View file

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

View file

@ -1,7 +1,10 @@
location __PATH__ {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}

View file

@ -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~ynh1",
"version": "4.8.5~ynh2",
"url": "http://www.phpmyadmin.net",
"license": "GPL-2.0-only",
"maintainer": {

View file

@ -1,35 +1,18 @@
#!/bin/bash
# =============================================================================
# COMPOSER
# =============================================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Execute a composer command from a given directory
# usage: composer_exec workdir COMMAND [ARG ...]
exec_composer() {
local workdir=$1
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
COMPOSER_HOME="${workdir}/.composer" \
php "${workdir}/composer.phar" $@ \
-d "${workdir}" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer destdir
init_composer() {
local destdir=$1
# install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="${destdir}/.composer" \
php -- --quiet --install-dir="$destdir" \
|| ynh_die "Unable to install Composer"
# Force the dependence to PHP 5.6
exec_composer "$destdir" config -g platform.php 5.6
exec_composer "$destdir" update --no-dev
# update dependencies to create composer.lock
exec_composer "$destdir" install --no-dev \
|| ynh_die "Unable to update PhpMyAdmin core dependencies"
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}

View file

@ -2,23 +2,11 @@
#=================================================
# GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat access to unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# if [ ! -e _common.sh ]; then
# # Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
# fi
# source _common.sh
# source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================

View file

@ -36,8 +36,6 @@ 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)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register $app $domain $path_url
@ -65,11 +63,13 @@ ynh_app_setting_set $app db_admin_user $db_admin_user
db_admin_pwd="$(ynh_string_random)"
ynh_app_setting_set $app db_admin_pwd $db_admin_pwd
if ! ynh_mysql_user_exists "$db_admin_user" ; then
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
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -105,7 +105,7 @@ ynh_add_fpm_config
# POPULATE THE DATABASE
#=================================================
ynh_replace_string "YNH_PMA_USER" "$db_name" ../conf/create_db.sql
ynh_replace_string "__YNH_PMA_USER__" "$db_name" ../conf/create_db.sql
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
< ../conf/create_db.sql
ynh_replace_string "phpmyadmin" "$db_name" $final_path/sql/create_tables.sql
@ -116,26 +116,39 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
# CONFIGURE PHPMYADMIN
#=================================================
ynh_replace_string "YNH_DOMAIN" "$domain" ../conf/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 "YNH_MYSQL_ROOT_PASSWORD" "$(cat $MYSQL_ROOT_PWD_FILE)" ../conf/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
cp ../conf/config.inc.php $final_path
# Recalculate and store the config file checksum into the app settings
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/config.inc.php"
#=================================================
# INSTALL DEPENDENCIES
# INSTALL DEPENDENCIES WITH COMPOSER
#=================================================
# Set permissions for initialization
chown -R $app: "$final_path"
# Install composer
init_composer "$final_path"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$final_path/.composer" \
php -- --quiet --install-dir="$final_path" \
|| ynh_die "Unable to install Composer"
# Update dependencies to create composer.lock
exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" install --no-dev \
-d "$final_path" --quiet --no-interaction \
|| ynh_die "Unable to update core dependencies with Composer"
# Install dependencies
exec_composer "$final_path" update --no-dev
ynh_exec_warn_less exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" update --no-dev \
-d "$final_path" --quiet --no-interaction
#=================================================
# GENERIC FINALIZATION

View file

@ -2,23 +2,11 @@
#=================================================
# GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat access to unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# if [ ! -e _common.sh ]; then
# # Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
# fi
# source _common.sh
# source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
@ -80,6 +68,7 @@ if ! ynh_mysql_user_exists "$db_admin_user" ; then
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
fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -94,6 +83,8 @@ ynh_system_user_create $app
# config.inc.php contains sensitive data, restrict its access
chown root:$app $final_path/config.inc.php
chown $app: $final_path/tmp
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================

View file

@ -66,11 +66,14 @@ fi
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_backup_before_upgrade # Backup the current version of the app
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_restore_upgradebackup # restore it if the upgrade fails
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
ynh_abort_if_errors # 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
#=================================================
# CHECK THE PATH
@ -99,7 +102,7 @@ ynh_add_nginx_config
# CREATE DEDICATED USER
#=================================================
# Create a system user
# Create a dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
@ -138,12 +141,11 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/config.inc.php"
ynh_replace_string "YNH_DOMAIN" "$domain" ../conf/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 "YNH_MYSQL_ROOT_PASSWORD" "$(cat $MYSQL_ROOT_PWD_FILE)" ../conf/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
cp ../conf/config.inc.php $final_path
# Recalculate and store the config file checksum into the app settings
@ -153,11 +155,25 @@ ynh_store_file_checksum "$final_path/config.inc.php"
# INSTALL DEPENDENCIES
#=================================================
# Set permissions for initialization
chown -R $app: "$final_path"
# Install composer
init_composer "$final_path"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$final_path/.composer" \
php -- --quiet --install-dir="$final_path" \
|| ynh_die "Unable to install Composer"
# Update dependencies to create composer.lock
exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" install --no-dev \
-d "$final_path" --quiet --no-interaction \
|| ynh_die "Unable to update core dependencies with Composer"
# Install dependencies
exec_composer "$final_path" update --no-dev
ynh_exec_warn_less exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" update --no-dev \
-d "$final_path" --quiet --no-interaction
#=================================================
# GENERIC FINALIZATION