Updated installWP
parent
45ba39e3fe
commit
56c55439de
|
@ -2,53 +2,18 @@ actions:
|
|||
applyEnvSettings:
|
||||
script: |
|
||||
var envs = '${this.targetAppid}'.split(',');
|
||||
var desiredCloudlets = parseInt('${this.cloudlets}');
|
||||
var desiredDiskSpace = parseInt('${this.diskspace}');
|
||||
|
||||
for (var i = 0, n = envs.length; i < n; i++) {
|
||||
var targetAppid = envs[i];
|
||||
var resp = jelastic.env.control.GetEnvInfo(targetAppid, session);
|
||||
if (resp.result != 0) {
|
||||
return {
|
||||
result: resp.result,
|
||||
error: 'Failed to get environment info for ' + targetAppid + ': ' + resp.error,
|
||||
};
|
||||
for (var i=0, n = envs.length; i < n; i++) {
|
||||
let targetAppid = envs[i];
|
||||
let resp = jelastic.env.control.GetEnvInfo(targetAppid, session);
|
||||
if (resp.result != 0) return resp;
|
||||
let node = resp.nodes[0];
|
||||
if (String(node.flexibleCloudlets) != '${this.cloudlets}') {
|
||||
resp = jelastic.env.control.SetCloudletsCountByGroup({ appid: targetAppid, session: session, nodeGroup: node.nodeGroup, fixedCloudlets: node.fixedCloudlets, flexibleCloudlets: '${this.cloudlets}'});
|
||||
if (resp.result != 0) return resp;
|
||||
}
|
||||
if (!resp.nodes || resp.nodes.length === 0) {
|
||||
return {
|
||||
result: 1,
|
||||
error: 'No nodes found in environment ' + targetAppid,
|
||||
};
|
||||
}
|
||||
var node = resp.nodes[0];
|
||||
if (parseInt(node.flexibleCloudlets) !== desiredCloudlets) {
|
||||
resp = jelastic.env.control.SetCloudletsCountByGroup({
|
||||
envName: targetAppid,
|
||||
session: session,
|
||||
nodeGroup: node.nodeGroup,
|
||||
fixedCloudlets: parseInt(node.fixedCloudlets),
|
||||
flexibleCloudlets: desiredCloudlets,
|
||||
});
|
||||
if (resp.result != 0) {
|
||||
return {
|
||||
result: resp.result,
|
||||
error: 'Failed to set cloudlets for ' + targetAppid + ': ' + resp.error,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (parseInt(node.diskLimit) !== desiredDiskSpace) {
|
||||
resp = jelastic.env.control.SetDiskLimitByGroup({
|
||||
envName: targetAppid,
|
||||
session: session,
|
||||
nodeGroup: node.nodeGroup,
|
||||
limit: desiredDiskSpace,
|
||||
});
|
||||
if (resp.result != 0) {
|
||||
return {
|
||||
result: resp.result,
|
||||
error: 'Failed to set disk space for ' + targetAppid + ': ' + resp.error,
|
||||
};
|
||||
}
|
||||
if (String(node.diskLimit) != '${this.diskspace}') {
|
||||
resp = jelastic.env.control.SetDiskLimitByGroup({ appid: targetAppid, session: session, nodeGroup: node.nodeGroup, limit: '${this.diskspace}' });
|
||||
if (resp.result != 0) return resp;
|
||||
}
|
||||
}
|
||||
return { result: 0 };
|
||||
return { result: 0 };
|
|
@ -4,7 +4,8 @@ name: WordPress Core Installation
|
|||
description: WordPress Core Installation
|
||||
|
||||
mixins:
|
||||
- ${globals.BASE_URL}/configs/vers.yaml
|
||||
- /scripts/common.yml # Ensure this mixin does not introduce 'fields'
|
||||
# Removed vers.yaml to prevent overriding 'beforeInit.js' settings
|
||||
|
||||
globals:
|
||||
WP_ADMIN_PASS: "${settings.wp_admin_pass}"
|
||||
|
@ -24,6 +25,7 @@ globals:
|
|||
VERSION_WORDPRESS: "${settings.version_wordpress:6.3.1}"
|
||||
version_lscache: "${settings.version_lscache:5.6.4}"
|
||||
TARGET_NODE_ID: "${settings.targetNodeID}"
|
||||
SERVER_WEBROOT: "/var/www/webroot/ROOT" # Optional for consistency
|
||||
|
||||
onInstall:
|
||||
- deployWordPress
|
||||
|
@ -40,7 +42,7 @@ actions:
|
|||
wget -qO /tmp/wordpress.tar.gz 'https://wordpress.org/wordpress-${globals.VERSION_WORDPRESS}.tar.gz';
|
||||
[ -d /tmp/wordpress/ ] && rm -rf /tmp/wordpress;
|
||||
tar -xzf /tmp/wordpress.tar.gz -C /tmp/;
|
||||
rsync -a /tmp/wordpress/ /var/www/webroot/ROOT/ >> /var/log/deploy_wordpress.log 2>&1;
|
||||
rsync -a /tmp/wordpress/ ${globals.SERVER_WEBROOT}/ >> /var/log/deploy_wordpress.log 2>&1;
|
||||
- addContext [cp]:
|
||||
name: ROOT
|
||||
fileName: WordPress
|
||||
|
@ -51,11 +53,11 @@ actions:
|
|||
echo "Creating Database ${globals.DB_NAME}" >> /var/log/install_wordpress.log;
|
||||
mysql -u${globals.DB_USER} -p${globals.DB_PASS} -h ${globals.DB_HOST} -e "CREATE DATABASE IF NOT EXISTS ${globals.DB_NAME};" >> /var/log/install_wordpress.log 2>&1;
|
||||
echo "Configuring wp-config.php" >> /var/log/install_wordpress.log;
|
||||
cd /var/www/webroot/ROOT && wp core config --dbhost=${globals.DB_HOST} --dbname=${globals.DB_NAME} --dbuser=${globals.DB_USER} --dbpass=${globals.DB_PASS} --path=/var/www/webroot/ROOT >> /var/log/install_wordpress.log 2>&1;
|
||||
cd ${globals.SERVER_WEBROOT} && wp core config --dbhost=${globals.DB_HOST} --dbname=${globals.DB_NAME} --dbuser=${globals.DB_USER} --dbpass=${globals.DB_PASS} --path=${globals.SERVER_WEBROOT} >> /var/log/install_wordpress.log 2>&1;
|
||||
echo "Installing WordPress Core" >> /var/log/install_wordpress.log;
|
||||
cd /var/www/webroot/ROOT && wp core install --title="${globals.WP_TITLE}" --admin_user=${globals.WP_ADMIN_USER} --admin_password=${globals.WP_ADMIN_PASS} --url=${globals.WP_URL} --admin_email=${globals.WP_ADMIN_EMAIL} --skip-email --path=/var/www/webroot/ROOT >> /var/log/install_wordpress.log 2>&1;
|
||||
cd ${globals.SERVER_WEBROOT} && wp core install --title="${globals.WP_TITLE}" --admin_user=${globals.WP_ADMIN_USER} --admin_password=${globals.WP_ADMIN_PASS} --url=${globals.WP_URL} --admin_email=${globals.WP_ADMIN_EMAIL} --skip-email --path=${globals.SERVER_WEBROOT} >> /var/log/install_wordpress.log 2>&1;
|
||||
echo "Downloading favicon.ico" >> /var/www/webroot/ROOT/favicon.ico;
|
||||
wget ${globals.BASE_URL}/images/favicon.ico -O /var/www/webroot/ROOT/favicon.ico >> /var/log/install_wordpress.log 2>&1;
|
||||
wget ${globals.BASE_URL}/images/favicon.ico -O ${globals.SERVER_WEBROOT}/favicon.ico >> /var/log/install_wordpress.log 2>&1;
|
||||
|
||||
installScripts:
|
||||
- cmd[cp]: |-
|
||||
|
@ -77,18 +79,18 @@ actions:
|
|||
setupWordPress:
|
||||
- cmd[${globals.TARGET_NODE_ID}]: |-
|
||||
echo "Disabling WP Auto Update Core" >> /var/log/setup_wordpress.log;
|
||||
grep -qE "(WP_AUTO_UPDATE_CORE)" /var/www/webroot/ROOT/wp-config.php || sed -i "/^\$table_prefix.*/a define( 'WP_AUTO_UPDATE_CORE', false );" /var/www/webroot/ROOT/wp-config.php;
|
||||
grep -qE "(WP_AUTO_UPDATE_CORE)" ${globals.SERVER_WEBROOT}/wp-config.php || sed -i "/^\$table_prefix.*/a define( 'WP_AUTO_UPDATE_CORE', false );" ${globals.SERVER_WEBROOT}/wp-config.php;
|
||||
echo "Updating Permalink Structure" >> /var/log/setup_wordpress.log;
|
||||
wp option update permalink_structure '/%postname%/' --path=/var/www/webroot/ROOT >> /var/log/setup_wordpress.log 2>&1;
|
||||
echo "Setting Rewrite Structure" >> /var/www/webroot/ROOT/wp-config.php;
|
||||
wp rewrite structure '/%postname%/' --hard --path=/var/www/webroot/ROOT >> /var/log/setup_wordpress.log 2>&1;
|
||||
wp option update permalink_structure '/%postname%/' --path=${globals.SERVER_WEBROOT} >> /var/log/setup_wordpress.log 2>&1;
|
||||
echo "Setting Rewrite Structure" >> /var/log/setup_wordpress.log;
|
||||
wp rewrite structure '/%postname%/' --hard --path=${globals.SERVER_WEBROOT} >> /var/log/setup_wordpress.log 2>&1;
|
||||
|
||||
installPlugins:
|
||||
- cmd[${globals.TARGET_NODE_ID}]: |-
|
||||
echo "Installing LiteSpeed Cache Plugin Version ${globals.version_lscache}" >> /var/log/install_plugins.log;
|
||||
wp plugin install litespeed-cache --version=${globals.version_lscache} --activate --path=/var/www/webroot/ROOT &>> /var/log/install_plugins.log;
|
||||
wp plugin install litespeed-cache --version=${globals.version_lscache} --activate --path=${globals.SERVER_WEBROOT} &>> /var/log/install_plugins.log;
|
||||
echo "Flushing WordPress Cache" >> /var/log/install_plugins.log;
|
||||
wp cache flush --path=/var/www/webroot/ROOT &>> /var/log/install_plugins.log;
|
||||
wp cache flush --path=${globals.SERVER_WEBROOT} &>> /var/log/install_plugins.log;
|
||||
|
||||
setupPlugins:
|
||||
- cmd[${globals.TARGET_NODE_ID}]: |-
|
||||
|
|
Loading…
Reference in New Issue