Workaround for LXC root priv for mysql

This commit is contained in:
Disassembler 2019-12-13 21:28:55 +01:00
parent 19b62a4370
commit 0e465b0820
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
5 changed files with 14 additions and 14 deletions

@ -1 +1 @@
Subproject commit 119636f94ee6ca1c17bb9e9ffb6e924e79f8d476 Subproject commit e05ffc194f95e9078d0bf8e9a1d2494b4a1ba3ca

View File

@ -6,16 +6,16 @@ mkdir -p /srv/mifosx/mariadb_conf /srv/mifosx/mariadb_data
chown 103306:103306 /srv/mifosx/mariadb_data chown 103306:103306 /srv/mifosx/mariadb_data
cp mariadb_conf/my.cnf /srv/mifosx/mariadb_conf/my.cnf cp mariadb_conf/my.cnf /srv/mifosx/mariadb_conf/my.cnf
chown -R 100000:100000 /srv/mifosx/mariadb_conf chown -R 100000:100000 /srv/mifosx/mariadb_conf
lxc-execute mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db lxc-execute mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --auth-root-socket-user=mysql --skip-test-db
# Create databases # Create databases
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-mifosx-mariadb start service lxc-mifosx-mariadb start
envsubst <createdb.sql | lxc-attach mifosx-mariadb -- mysql envsubst <createdb.sql | lxc-attach mifosx-mariadb -- mysql -u mysql
# Populate database # Populate database
lxc-execute mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mifosx-mariadb -- mysql mifosplatform-tenants lxc-execute mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
envsubst <schemapwd.sql | lxc-attach mifosx-mariadb -- mysql mifosplatform-tenants envsubst <schemapwd.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
# Configure Mifos X # Configure Mifos X
mkdir -p /srv/mifosx_conf mkdir -p /srv/mifosx_conf
@ -30,14 +30,14 @@ done
service stop mifosx service stop mifosx
# Fix missing previous_run_status column # Fix missing previous_run_status column
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mifosx-mariadb -- mysql mifostenant-default echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mifosx-mariadb -- mysql -u mysql mifostenant-default
# Update admin account # Update admin account
export MIFOSX_ADMIN_USER=admin export MIFOSX_ADMIN_USER=admin
export MIFOSX_ADMIN_EMAIL=admin@example.com export MIFOSX_ADMIN_EMAIL=admin@example.com
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}') export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
envsubst <adminpwd.sql | lxc-attach mifosx-mariadb -- mysql mifostenant-default envsubst <adminpwd.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifostenant-default
# Install config update script # Install config update script
cp update-conf.sh /srv/mifosx/update-conf.sh cp update-conf.sh /srv/mifosx/update-conf.sh

View File

@ -4,4 +4,4 @@ sed -i "s|\(^\s\+proxyName=\).*|\1\"mifosx.${DOMAIN}\"|" /srv/mifosx/mifosx_conf
sed -i "s|\(^\s\+proxyPort=\).*|\1\"${PORT}\"|" /srv/mifosx/mifosx_conf/server.xml sed -i "s|\(^\s\+proxyPort=\).*|\1\"${PORT}\"|" /srv/mifosx/mifosx_conf/server.xml
QUERY="UPDATE \`c_external_service_properties\` SET \`value\` = '${EMAIL}' WHERE \`external_service_id\` = 2 and \`name\` LIKE 'username'" QUERY="UPDATE \`c_external_service_properties\` SET \`value\` = '${EMAIL}' WHERE \`external_service_id\` = 2 and \`name\` LIKE 'username'"
lxc-attach mifosx-mariadb -- mysql -e "${QUERY}" mifostenant-default lxc-attach mifosx-mariadb -- mysql -u mysql -e "${QUERY}" mifostenant-default

View File

@ -6,12 +6,12 @@ mkdir -p /srv/ushahidi/mariadb_conf /srv/ushahidi/mariadb_data
chown 103306:103306 /srv/ushahidi/mariadb_data chown 103306:103306 /srv/ushahidi/mariadb_data
cp mariadb_conf/my.cnf /srv/ushahidi/mariadb_conf/my.cnf cp mariadb_conf/my.cnf /srv/ushahidi/mariadb_conf/my.cnf
chown -R 100000:100000 /srv/ushahidi/mariadb_conf chown -R 100000:100000 /srv/ushahidi/mariadb_conf
lxc-execute ushahidi-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db lxc-execute ushahidi-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --auth-root-socket-user=mysql --skip-test-db
# Create database # Create database
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-ushahidi-mariadb start service lxc-ushahidi-mariadb start
envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- mysql envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql
# Configure Ushahidi # Configure Ushahidi
mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data
@ -27,7 +27,7 @@ lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahid
export USHAHIDI_ADMIN_USER=admin@example.com export USHAHIDI_ADMIN_USER=admin@example.com
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))") export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql ushahidi envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql ushahidi
# Install config update script # Install config update script
cp update-conf.sh /srv/ushahidi/update-conf.sh cp update-conf.sh /srv/ushahidi/update-conf.sh

View File

@ -5,11 +5,11 @@ HOST="${DOMAIN}"
sed -i "s|\(^\s\+\"backend_url\": \).*|\1\"https://ush.${HOST}/platform\",|" /srv/ushahidi/ushahidi_conf/config.json sed -i "s|\(^\s\+\"backend_url\": \).*|\1\"https://ush.${HOST}/platform\",|" /srv/ushahidi/ushahidi_conf/config.json
API_URL="\"https:\\\/\\\/ush.${HOST}\\\/platform\\\/api\\\/v3\\\/config\\\/data-provider\"" API_URL="\"https:\\\/\\\/ush.${HOST}\\\/platform\\\/api\\\/v3\\\/config\\\/data-provider\""
QUERY="UPDATE \`config\` SET \`config_value\` = '${API_URL}' WHERE \`group_name\` LIKE 'data-provider' AND \`config_key\` LIKE 'url'" QUERY="UPDATE \`config\` SET \`config_value\` = '${API_URL}' WHERE \`group_name\` LIKE 'data-provider' AND \`config_key\` LIKE 'url'"
lxc-attach ushahidi-mariadb -- mysql -e "${QUERY}" ushahidi lxc-attach ushahidi-mariadb -- mysql -u mysql -e "${QUERY}" ushahidi
JSON="{\"incoming_type\":\"IMAP\",\"incoming_server\":\"localhost\",\"incoming_port\":143,\"incoming_security\":\"None\",\"incoming_username\":\"${EMAIL}\",\"incoming_password\":\"password\",\"outgoing_type\":\"SMTP\",\"outgoing_server\":\"host\",\"outgoing_port\":25,\"outgoing_security\":\"None\",\"outgoing_username\":\"${EMAIL}\",\"outgoing_password\":\"password\",\"from\":\"${EMAIL}\",\"from_name\":\"Ushahidi\"}" JSON="{\"incoming_type\":\"IMAP\",\"incoming_server\":\"localhost\",\"incoming_port\":143,\"incoming_security\":\"None\",\"incoming_username\":\"${EMAIL}\",\"incoming_password\":\"password\",\"outgoing_type\":\"SMTP\",\"outgoing_server\":\"host\",\"outgoing_port\":25,\"outgoing_security\":\"None\",\"outgoing_username\":\"${EMAIL}\",\"outgoing_password\":\"password\",\"from\":\"${EMAIL}\",\"from_name\":\"Ushahidi\"}"
QUERY="UPDATE \`config\` SET \`config_value\` = '${JSON}' WHERE \`group_name\` LIKE 'data-provider' AND \`config_key\` LIKE 'email'" QUERY="UPDATE \`config\` SET \`config_value\` = '${JSON}' WHERE \`group_name\` LIKE 'data-provider' AND \`config_key\` LIKE 'email'"
lxc-attach ushahidi-mariadb -- mysql -e "${QUERY}" ushahidi lxc-attach ushahidi-mariadb -- mysql -u mysql -e "${QUERY}" ushahidi
QUERY="UPDATE \`config\` SET \`config_value\` = '\"${EMAIL}\"' WHERE \`group_name\` LIKE 'site' AND \`config_key\` LIKE 'email'" QUERY="UPDATE \`config\` SET \`config_value\` = '\"${EMAIL}\"' WHERE \`group_name\` LIKE 'site' AND \`config_key\` LIKE 'email'"
lxc-attach ushahidi-mariadb -- mysql -e "${QUERY}" ushahidi lxc-attach ushahidi-mariadb -- mysql -u mysql -e "${QUERY}" ushahidi
sed -i "s|\(^\s\+\"google_analytics_id\": \).*|\1\"${GMAPS_API_KEY}\"|" /srv/ushahidi/ushahidi_conf/config.json sed -i "s|\(^\s\+\"google_analytics_id\": \).*|\1\"${GMAPS_API_KEY}\"|" /srv/ushahidi/ushahidi_conf/config.json