mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
Merge pull request #7715 from vpeter4/mariadb-11
mariadb: include mariadb-upgrade and mariadb-check and update addon (1)
This commit is contained in:
commit
9bd74cef15
@ -1 +1,3 @@
|
|||||||
initial release
|
1
|
||||||
|
- include mariadb-upgrade and mariadb-check
|
||||||
|
copy mariadb* binaries and make symbolic links to mysql*
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
PKG_NAME="mariadb"
|
PKG_NAME="mariadb"
|
||||||
PKG_VERSION="10.11.2"
|
PKG_VERSION="10.11.2"
|
||||||
PKG_REV="0"
|
PKG_REV="1"
|
||||||
PKG_SHA256="1c89dee0caed0f68bc2a1d203eb98a123150e6a179f6ee0f1fc0ba3f08dc71dc"
|
PKG_SHA256="1c89dee0caed0f68bc2a1d203eb98a123150e6a179f6ee0f1fc0ba3f08dc71dc"
|
||||||
PKG_LICENSE="GPL2"
|
PKG_LICENSE="GPL2"
|
||||||
PKG_SITE="https://mariadb.org"
|
PKG_SITE="https://mariadb.org"
|
||||||
@ -89,13 +89,15 @@ addon() {
|
|||||||
mkdir -p ${ADDON}/config
|
mkdir -p ${ADDON}/config
|
||||||
|
|
||||||
cp ${MARIADB}/bin/mariadbd \
|
cp ${MARIADB}/bin/mariadbd \
|
||||||
${MARIADB}/bin/mysql \
|
${MARIADB}/bin/mariadb \
|
||||||
${MARIADB}/bin/mysqladmin \
|
${MARIADB}/bin/mariadb-admin \
|
||||||
${MARIADB}/bin/mysqldump \
|
${MARIADB}/bin/mariadb-check \
|
||||||
${MARIADB}/bin/mysql_secure_installation \
|
${MARIADB}/bin/mariadb-dump \
|
||||||
|
${MARIADB}/bin/mariadb-secure-installation \
|
||||||
|
${MARIADB}/bin/mariadb-upgrade \
|
||||||
${MARIADB}/bin/my_print_defaults \
|
${MARIADB}/bin/my_print_defaults \
|
||||||
${MARIADB}/bin/resolveip \
|
${MARIADB}/bin/resolveip \
|
||||||
${MARIADB}/scripts/mysql_install_db \
|
${MARIADB}/scripts/mariadb-install-db \
|
||||||
${ADDON}/bin
|
${ADDON}/bin
|
||||||
|
|
||||||
cp -PR ${MARIADB}/share ${ADDON}
|
cp -PR ${MARIADB}/share ${ADDON}
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
||||||
|
|
||||||
|
_create_bin_link() {
|
||||||
|
[ ! -L ${ADDON_DIR}/bin/${2} ] && ln -sfn ${1} ${ADDON_DIR}/bin/${2}
|
||||||
|
}
|
||||||
|
|
||||||
. /etc/profile
|
. /etc/profile
|
||||||
oe_setup_addon service.mariadb
|
oe_setup_addon service.mariadb
|
||||||
|
|
||||||
@ -11,49 +15,57 @@ mkdir -p /run/mysqld
|
|||||||
|
|
||||||
# exit if already running
|
# exit if already running
|
||||||
PID=$(ps aux | awk '/\/bin\/mariadbd/ {print $1; exit 0}')
|
PID=$(ps aux | awk '/\/bin\/mariadbd/ {print $1; exit 0}')
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "${PID}" ]; then
|
||||||
echo "MariaDB server is already running"
|
echo "MariaDB server is already running"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# create symbolic links
|
||||||
|
_create_bin_link mariadb mysql
|
||||||
|
_create_bin_link mariadb-admin mysqladmin
|
||||||
|
_create_bin_link mariadb-dump mysqldump
|
||||||
|
_create_bin_link mariadb-secure-installation mysql_secure_installation
|
||||||
|
_create_bin_link mariadb-upgrade mysql_upgrade
|
||||||
|
_create_bin_link mariadb-install-db mysql_install_db
|
||||||
|
|
||||||
# copy config file
|
# copy config file
|
||||||
if [ ! -f $ADDON_HOME/my.cnf ]; then
|
if [ ! -f ${ADDON_HOME}/my.cnf ]; then
|
||||||
cp $ADDON_DIR/config/my.cnf $ADDON_HOME
|
cp ${ADDON_DIR}/config/my.cnf ${ADDON_HOME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install database
|
# install database
|
||||||
if [ ! -d "$ADDON_HOME/data/mysql" ]; then
|
if [ ! -d "${ADDON_HOME}/data/mysql" ]; then
|
||||||
mkdir -p $ADDON_HOME/data
|
mkdir -p ${ADDON_HOME}/data
|
||||||
echo "Installing database"
|
echo "Installing database"
|
||||||
$ADDON_DIR/bin/mysql_install_db --basedir=$ADDON_DIR --datadir=$ADDON_HOME/data
|
${ADDON_DIR}/bin/mariadb-install-db --basedir=${ADDON_DIR} --datadir=${ADDON_HOME}/data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for first run and generate passwords
|
# check for first run and generate passwords
|
||||||
if grep -q "@MYSQL_ROOT_PASS@" $ADDON_HOME/settings.xml; then
|
if grep -q "@MYSQL_ROOT_PASS@" ${ADDON_HOME}/settings.xml; then
|
||||||
MYSQL_ROOT_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)"
|
MYSQL_ROOT_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)"
|
||||||
MYSQL_KODI_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)"
|
MYSQL_KODI_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)"
|
||||||
|
|
||||||
sed -e "s|@MYSQL_ROOT_PASS@|$MYSQL_ROOT_PASS|g" \
|
sed -e "s|@MYSQL_ROOT_PASS@|${MYSQL_ROOT_PASS}|g" \
|
||||||
-e "s|@MYSQL_KODI_PASS@|$MYSQL_KODI_PASS|g" \
|
-e "s|@MYSQL_KODI_PASS@|${MYSQL_KODI_PASS}|g" \
|
||||||
-i $ADDON_HOME/settings.xml
|
-i ${ADDON_HOME}/settings.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# init script to create user kodi and change passwords
|
# init script to create user kodi and change passwords
|
||||||
init_file=""
|
init_file=""
|
||||||
if [[ ! -f $ADDON_HOME/set_mysql_passwords.sql ]] || [[ $ADDON_HOME/settings.xml -nt $ADDON_HOME/set_mysql_passwords.sql ]]; then
|
if [[ ! -f ${ADDON_HOME}/set_mysql_passwords.sql ]] || [[ ${ADDON_HOME}/settings.xml -nt ${ADDON_HOME}/set_mysql_passwords.sql ]]; then
|
||||||
cat << SQL_DATA > $ADDON_HOME/set_mysql_passwords.sql
|
cat << SQL_DATA > ${ADDON_HOME}/set_mysql_passwords.sql
|
||||||
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('$MYSQL_ROOT_PASS');
|
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASS}');
|
||||||
CREATE USER IF NOT EXISTS 'kodi';
|
CREATE USER IF NOT EXISTS 'kodi';
|
||||||
CREATE USER IF NOT EXISTS 'kodi'@'localhost';
|
CREATE USER IF NOT EXISTS 'kodi'@'localhost';
|
||||||
SET PASSWORD FOR 'kodi'=PASSWORD('$MYSQL_KODI_PASS');
|
SET PASSWORD FOR 'kodi'=PASSWORD('${MYSQL_KODI_PASS}');
|
||||||
SET PASSWORD FOR 'kodi'@'localhost'=PASSWORD('$MYSQL_KODI_PASS');
|
SET PASSWORD FOR 'kodi'@'localhost'=PASSWORD('${MYSQL_KODI_PASS}');
|
||||||
GRANT ALL ON *.* TO 'kodi';
|
GRANT ALL ON *.* TO 'kodi';
|
||||||
GRANT ALL ON *.* TO 'kodi'@'localhost';
|
GRANT ALL ON *.* TO 'kodi'@'localhost';
|
||||||
flush privileges;
|
flush privileges;
|
||||||
SQL_DATA
|
SQL_DATA
|
||||||
|
|
||||||
init_file="--init-file=$ADDON_HOME/set_mysql_passwords.sql"
|
init_file="--init-file=${ADDON_HOME}/set_mysql_passwords.sql"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting mariadbd"
|
echo "Starting mariadbd"
|
||||||
MYSQL_HOME="$ADDON_HOME" exec $ADDON_DIR/bin/mariadbd $init_file &
|
MYSQL_HOME="${ADDON_HOME}" exec ${ADDON_DIR}/bin/mariadbd ${init_file} &
|
||||||
|
Loading…
x
Reference in New Issue
Block a user