From 4a1ab6052cfb90f2d48bb387e79a32b7d1e2d0c4 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 31 Dec 2019 16:06:25 +0100 Subject: [PATCH] v6.27 + DietPi-Software | phpMyAdmin: Switch to non APT install to be compatible with custom PHP versions (Stretch) and Debian Buster (no APT package available): https://github.com/MichaIng/DietPi/issues/3284 --- dietpi/dietpi-software | 138 ++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 71 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 0fa3cb9b70..f5997d5376 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -1640,56 +1640,51 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='SQLite' aSOFTWARE_DESC[$software_id]='database' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=-1 + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1335#p1335' #------------------ software_id=88 aSOFTWARE_NAME[$software_id]='MariaDB' aSOFTWARE_DESC[$software_id]='database' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=-1 + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1335#p1335' #------------------ software_id=89 aSOFTWARE_NAME[$software_id]='PHP' aSOFTWARE_DESC[$software_id]='Hypertext Preprocessor for dynamic web content' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=-1 + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1335#p1335' #------------------ software_id=90 aSOFTWARE_NAME[$software_id]='phpMyAdmin' aSOFTWARE_DESC[$software_id]='optional mysql admin tools' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=54#p54' aSOFTWARE_REQUIRES_WEBSERVER[$software_id]=1 aSOFTWARE_REQUIRES_MYSQL[$software_id]=1 aSOFTWARE_REQUIRES_PHP[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=54#p54' - # - non-RPi Buster: https://packages.debian.org/phpmyadmin - (( $G_HW_MODEL > 9 )) && aSOFTWARE_AVAIL_G_DISTRO[$software_id,5]=0 && aSOFTWARE_AVAIL_G_DISTRO[$software_id,6]=0 - # Since the APT package depends on PHP meta packages, PHP7.2 cannot be installed - # Since ownCloud + phpBB require PHP7.2 currently, phpMyAdmin is not compatible with those - [[ -f '/var/www/owncloud/occ' || -f '/var/www/phpBB3/config.php' ]] && aSOFTWARE_AVAIL_G_DISTRO[$software_id,$G_DISTRO]=0 #------------------ software_id=91 aSOFTWARE_NAME[$software_id]='Redis' aSOFTWARE_DESC[$software_id]='optional non-sql database store' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 #------------------ software_id=92 aSOFTWARE_NAME[$software_id]='CertBot' aSOFTWARE_DESC[$software_id]='free, ssl cert install allowing https://' - aSOFTWARE_CATEGORY_INDEX[$software_id]=13 aSOFTWARE_TYPE[$software_id]=0 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1061#p1062' + aSOFTWARE_CATEGORY_INDEX[$software_id]=13 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1062#p1062' #------------------ software_id=125 @@ -3277,33 +3272,21 @@ Package: openssl libssl*\nPin: origin packages.sury.org\nPin-Priority: -1' > /et Banner_Installing - # MariaDB must be running during install to allow debconf setup. - G_RUN_CMD systemctl start mariadb - - # Set password parameters before installing - debconf-set-selections <<< 'phpmyadmin phpmyadmin/dbconfig-install boolean true' - debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $GLOBAL_PW" - debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $GLOBAL_PW" - - if (( ${aSOFTWARE_INSTALL_STATE[83]} == 1 )); then - - debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' - - elif (( ${aSOFTWARE_INSTALL_STATE[84]} == 1 )); then - - debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect lighttpd' - # Workaround an APT error, when installing lighttpd and phpmyadmin in the same session: https://github.com/MichaIng/DietPi/issues/316 - G_ERROR_HANDLER_NO_FAIL=1 G_AGI phpmyadmin - G_WHIP_MSG 'Working around Lighttpd + phpMyAdmin APT errors:\n\nYou may have seen an error during the phpMyAdmin APT installation. This occurs, when Lighttpd webserver was installed within the same session.\n -We work around this error by running APT a second time. Please do not worry and ignore any error or failure message within these install steps. After DietPi-Software finished, Lighttpd should start up and phpMyAdmin web UI should be available as expected.' + # Install required PHP modules: https://docs.phpmyadmin.net/en/latest/require.html#php + G_AGI $PHP_NAME-{curl,gd,json,mbstring,xml,zip} - else - - debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect none' - - fi - - G_AGI phpmyadmin + # Quick install: https://docs.phpmyadmin.net/en/latest/setup.html#quick-install + # - Get latest version name + INSTALL_URL_ADDRESS='https://api.github.com/repos/phpmyadmin/phpmyadmin/releases/latest' + G_CHECK_URL "$INSTALL_URL_ADDRESS" + local version=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 '^[[:blank:]]*"name":' | cut -d \" -f 4) + local fallback_url='https://files.phpmyadmin.net/phpMyAdmin/5.0.0/phpMyAdmin-5.0.0-english.tar.gz' + Download_Install "https://files.phpmyadmin.net/phpMyAdmin/$version/phpMyAdmin-$version-english.tar.gz" + # - Reinstall: Clean install but preserve existing config file + [[ -f '/var/www/phpmyadmin/config.inc.php' ]] && G_RUN_CMD mv /var/www/phpmyadmin/config.inc.php phpMyAdmin-*-english/ + [[ -d '/var/www/phpmyadmin' ]] && G_RUN_CMD rm -R /var/www/phpmyadmin + # - Move new instance in place + G_RUN_CMD mv phpMyAdmin-*-english /var/www/phpmyadmin fi @@ -7126,20 +7109,35 @@ _EOF_ Banner_Configuration - # Nginx/Lighttpd symlink to /var/www - if (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 || - ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then + # Create MariaDB database and user + if [[ -d $G_FP_DIETPI_USERDATA/mysql/phpmyadmin ]]; then - ln -sf /usr/share/phpmyadmin /var/www + G_DIETPI-NOTIFY 2 'phpMyAdmin MariaDB database found, will NOT overwrite.' + G_RUN_CMD systemctl restart mariadb + + else + + /DietPi/dietpi/func/create_mysql_db phpmyadmin phpmyadmin "$GLOBAL_PW" + mysql phpmyadmin < /var/www/phpmyadmin/sql/create_tables.sql fi - # Due to MariaDB unix_socket authentication, "root" cannot be used to login the web ui. - # Thus default "phpmyadmin" user need to be used, who on Jessie does not have all privileges: - # https://dietpi.com/phpbb/viewtopic.php?p=54#p54 - systemctl start mariadb + # Since "root" user cannot be used for login (unix_socket authentication), grant full admin privileges to "phpmyadmin" mysql -e 'grant all privileges on *.* to phpmyadmin@localhost with grant option' + # Copy default config in place and adjust, if not already existent + if [[ ! -f '/var/www/phpmyadmin/config.inc.php' ]]; then + + cp -a /var/www/phpmyadmin/config.sample.inc.php /var/www/phpmyadmin/config.inc.php + GCI_PASSWORD=1 G_CONFIG_INJECT "\$cfg\['blowfish_secret'\][[:blank:]]*=" "\$cfg['blowfish_secret'] = '$(openssl rand -base64 32)';" /var/www/phpmyadmin/config.inc.php + + fi + + # Pre-create TempDir: https://docs.phpmyadmin.net/en/latest/config.html#cfg_TempDir + mkdir /var/www/phpmyadmin/tmp + chown www-data:www-data /var/www/phpmyadmin/tmp + chmod 700 /var/www/phpmyadmin/tmp + fi software_id=91 # Redis @@ -14120,37 +14118,35 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - G_WHIP_MSG "Creating MariaDB database backup before uninstallation:\n\nIn case of accident, we create a database backup for you. You can remove it manually, if you are sure, that you don't need it any more.\n\n$G_FP_DIETPI_USERDATA/mariadb-database-backup.sql" - G_RUN_CMD systemctl start mariadb - mysqldump --all-databases > $G_FP_DIETPI_USERDATA/mariadb-database-backup.sql - systemctl stop mariadb - G_AGP mariadb-server php*-mysql + # Do a full database backup, if mariadb binary is still available: https://github.com/MichaIng/DietPi/issues/3257#issuecomment-568764107 + if command -v mysql &> /dev/null; then - # - config folder - rm -R /etc/mysql 2> /dev/null - rm -R /root/.mysql_history 2> /dev/null + G_WHIP_MSG "Creating MariaDB database backup before uninstallation:\n\nIn case of accident, we create a database backup for you. You can remove it manually, if you are sure, that you don't need it any more.\n\n$G_FP_DIETPI_USERDATA/mariadb-database-backup.sql" + G_RUN_CMD systemctl start mariadb + mysqldump --all-databases > $G_FP_DIETPI_USERDATA/mariadb-database-backup.sql + systemctl stop mariadb - # - SQL store - rm -R /var/lib/mysql 2> /dev/null - rm -R $G_FP_DIETPI_USERDATA/mysql 2> /dev/null + fi + + G_AGP mariadb-server php*-mysql + rm -Rf {$G_FP_DIETPI_USERDATA,/var/lib,/var/log,/etc}/mysql + [[ -d '/root/.mysql_history' ]] && rm -R /root/.mysql_history fi - software_id=74 + software_id=74 # InfluxDB if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - G_AGP influxdb - if [[ -f '/lib/systemd/system/influxdb.service' ]]; then systemctl unmask influxdb systemctl disable --now influxdb - rm /lib/systemd/system/influxdb.service + rm -R /lib/systemd/system/influxdb.service* fi - + G_AGP influxdb [[ -f '/etc/apt/sources.list.d/influxdb.list' ]] && rm /etc/apt/sources.list.d/influxdb.list rm -Rf /var/lib/influxdb # Symlink [[ -d $G_FP_DIETPI_USERDATA/influxdb ]] && rm -R $G_FP_DIETPI_USERDATA/influxdb @@ -14169,7 +14165,7 @@ _EOF_ fi - software_id=80 + software_id=80 # Ubooquity if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling @@ -14177,10 +14173,10 @@ _EOF_ if [[ -f '/etc/systemd/system/ubooquity.service' ]]; then systemctl disable --now ubooquity - rm /etc/systemd/system/ubooquity.service + rm -R /etc/systemd/system/ubooquity.service* fi - userdel -rf ubooquity + getent passwd ubooquity &> /dev/null && userdel -rf ubooquity [[ -d $G_FP_DIETPI_USERDATA/ubooquity ]] && rm -R $G_FP_DIETPI_USERDATA/ubooquity fi @@ -15339,11 +15335,11 @@ Once DietPi has completed your software installations, and rebooted, please foll fi - # phpMyAdmin is currently not compatible with ownCloud and phpBB: https://github.com/MichaIng/DietPi/issues/2808#issuecomment-493220292 - if (( ${aSOFTWARE_INSTALL_STATE[90]} == 1 && ( ${aSOFTWARE_INSTALL_STATE[47]} > 0 || ${aSOFTWARE_INSTALL_STATE[54]} > 0 ) )); then + # phpMyAdmin is currently not compatible with phpBB: https://github.com/MichaIng/DietPi/issues/2808#issuecomment-493220292 + if (( ${aSOFTWARE_INSTALL_STATE[90]} == 1 && ${aSOFTWARE_INSTALL_STATE[54]} > 0 )); then G_WHIP_MSG '[WARNING] Incompatible selection\n -phpMyAdmin is currently not compatible with ownCloud and phpBB. This will be possible with ownCloud 10.3 and phpBB 3.3. Check out the changelogs of future DietPi updates to get informed.\n +phpMyAdmin is currently not compatible with phpBB. This will be possible with phpBB 3.3. Check out the changelogs of future DietPi updates to get informed.\n phpMyAdmin will be deselected!' aSOFTWARE_INSTALL_STATE[90]=0 @@ -15441,7 +15437,7 @@ This will allow you to choose which program loads automatically, after the syste elif [[ $user_data_location_current == $G_FP_DIETPI_USERDATA ]]; then - user_data_location_description="SD/EMMC | $user_data_location_current" + user_data_location_description="SD/eMMC | $user_data_location_current" else @@ -15449,7 +15445,7 @@ This will allow you to choose which program loads automatically, after the syste fi - # - Webserver preference system + # Webserver preference system local index_webserver_text='Apache2' if (( $INDEX_WEBSERVER_TARGET == -1 )); then