Add new configuration files and scripts
parent
587355a1bf
commit
a322eb2199
|
@ -0,0 +1,4 @@
|
|||
globals:
|
||||
version_lscache: 6.2.0.1
|
||||
version_wordpress: 6.5
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
jpsType: install
|
||||
jpsVersion: '0.1'
|
||||
id: wordpress
|
||||
name: MightyBox WordPress Kit
|
||||
categories:
|
||||
- apps/blogs
|
||||
- apps/content-management
|
||||
- apps/wordpress
|
||||
logo: https://raw.githubusercontent.com/jelastic-jps/wordpress/master/images/wp-standalone.png
|
||||
homepage: http://wordpress.org/
|
||||
description:
|
||||
text: MightyBox standalone WordPress kit with built-in tools for optimizing application servers and advanced features for running websites efficiently. The lightweight WordPress CMS is deployed in its own container with minimal resources to keep costs low.
|
||||
short: MightyBox WordPress Standalone with built-in kit for choosing optimal application servers and a set of advanced features for running websites and blogs
|
||||
|
||||
baseUrl: https://deploy.mightybox.io/kits/wp-mb-kit/raw/branch/main
|
||||
|
||||
onBeforeInit: /scripts/beforeInit.js?_r=${fn.random}
|
||||
onBeforeInstall: /scripts/beforeInstall.js?_r=${fn.random}
|
||||
nodes: definedInOnBeforeInstall
|
||||
|
||||
skipNodeEmails: true
|
||||
|
||||
mixins:
|
||||
- https://deploy.mightybox.io/kits/wp-mb-kit/raw/branch/main/configs/vers.yaml
|
||||
- /scripts/common.yml
|
||||
|
||||
globals:
|
||||
isSingleDeploy: ${settings.isSingleDeploy:true}
|
||||
BASE_URL: https://deploy.mightybox.io/kits/wp-mb-kit/raw/branch/main
|
||||
DB_USER: ${settings.DB_USER:user-[fn.random]}
|
||||
DB_PASS: ${settings.DB_PASS:[fn.password(10)]}
|
||||
DB_HOST: 127.0.0.1
|
||||
PROTOCOL: http
|
||||
WP_ADMIN_PASS: ${settings.WP_ADMIN_PASS:[fn.password(10)]}
|
||||
SUCCESS: default
|
||||
|
||||
onInstall:
|
||||
- addLimits
|
||||
- addMetadata
|
||||
- initLEsettings
|
||||
- setupNode:
|
||||
nodeId: cp
|
||||
- if (${globals.isSingleDeploy}):
|
||||
- setProtocol
|
||||
- setDomain
|
||||
- createUserDB
|
||||
- installWordpress
|
||||
- if (${settings.mu-addon:false}): installMultisite
|
||||
- if (${settings.le-addon:false}):
|
||||
- installLEaddon
|
||||
- setupLEdomain
|
||||
- install:
|
||||
- jps: /scripts/events.jps?_r=${fn.random}
|
||||
- jps: ${globals.BASE_URL}/scripts/addons.jps?_r=${fn.random}
|
||||
- if ('${settings.success_email}' != 'false'):
|
||||
- return:
|
||||
type: success
|
||||
message: /success/text/success-${globals.SUCCESS}.md?_r=${fn.random}
|
||||
email: /success/email/success-${nodes.cp.master.nodeType}-${globals.SUCCESS}.md?_r=${fn.random}
|
||||
|
||||
actions:
|
||||
addLimits:
|
||||
- env.control.ApplyNodeGroupData[cp]:
|
||||
data:
|
||||
validation :
|
||||
maxCount: 1
|
||||
|
||||
addMetadata:
|
||||
script: |
|
||||
var metadata = { project: "${settings.project:default}", projectScope: "${settings.projectScope:production}" };
|
||||
return api.env.control.ApplyEnvProperty ?
|
||||
api.env.control.ApplyEnvProperty('${env.name}', session, metadata) :
|
||||
api.env.control.ApplyNodeGroupData('${env.name}', session, 'cp', metadata);
|
||||
|
||||
setProtocol:
|
||||
- script: |
|
||||
return {
|
||||
result:0,
|
||||
ssl: jelastic.billing.account.GetQuotas('environment.jelasticssl.enabled').array[0].value
|
||||
}
|
||||
- if (${response.ssl} || ${settings.le-addon:false}):
|
||||
setGlobals:
|
||||
PROTOCOL: https
|
||||
|
||||
setDomain:
|
||||
- script: ${globals.BASE_URL}/scripts/idna.js
|
||||
domains: ${env.domain}
|
||||
- setGlobals:
|
||||
DOMAIN: ${response.domains}
|
||||
|
||||
installLEaddon:
|
||||
- install: https://github.com/jelastic-jps/lets-encrypt/blob/master/manifest.jps?_r=${fn.random}
|
||||
nodeGroup: cp
|
||||
skipEmail: true
|
||||
settings:
|
||||
test: false
|
||||
skipEmail: true
|
||||
fallbackToX1: true
|
||||
withExtIp: ${globals.isExtIP}
|
||||
|
||||
initLEsettings:
|
||||
- script: |
|
||||
return {
|
||||
result:0,
|
||||
extIP: Boolean(jelastic.billing.account.GetQuotas('environment.externalip.enabled').array[0].value)
|
||||
}
|
||||
- setGlobals:
|
||||
isExtIP: ${response.extIP}
|
||||
|
||||
- cmd[cp]: |-
|
||||
[ ! -d /var/lib/jelastic/keys/letsencrypt ] && mkdir -p /var/lib/jelastic/keys/letsencrypt;
|
||||
echo "webroot=true" > /var/lib/jelastic/keys/letsencrypt/settings-custom;
|
||||
echo "webrootPath=/var/www/webroot/ROOT" >> /var/lib/jelastic/keys/letsencrypt/settings-custom;
|
||||
echo "test=false" >> /var/lib/jelastic/keys/letsencrypt/settings-custom;
|
||||
echo "withExtIp=${globals.isExtIP}" >> /var/lib/jelastic/keys/letsencrypt/settings-custom;
|
||||
user: root
|
||||
|
||||
setupLEdomain:
|
||||
- cmd[cp]: |-
|
||||
source /opt/letsencrypt/settings;
|
||||
bash ~/bin/setupWP.sh --url https://${domain};
|
||||
|
||||
installWordpress:
|
||||
- install: ${globals.BASE_URL}/scripts/installWP.jps
|
||||
settings:
|
||||
db_host: ${globals.DB_HOST}
|
||||
db_user: ${globals.DB_USER}
|
||||
db_pass: ${globals.DB_PASS}
|
||||
redis_host: /var/run/redis/redis.sock
|
||||
redis_port: 0
|
||||
wp_admin_pass: ${globals.WP_ADMIN_PASS}
|
||||
wp_title: "Hello World"
|
||||
wp_url: ${globals.PROTOCOL}://${globals.DOMAIN}/
|
||||
cluster: false
|
||||
|
||||
setupNode:
|
||||
- log: OPTIMIZATION
|
||||
- install: https://raw.githubusercontent.com/jelastic/templates/master/config_v2.jps?_r=${fn.random}
|
||||
settings:
|
||||
targetGroup: cp
|
||||
targetNodes: ${this.nodeId}
|
||||
optimization: wordpress
|
||||
|
||||
createUserDB:
|
||||
- log: Create user for DataBase
|
||||
- cmd [cp]: |-
|
||||
wget ${baseUrl}/configs/sqldb/wordpress.cnf -O /etc/mysql/conf.d/wordpress.cnf &>> /var/log/run.log;
|
||||
wget https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/master/scripts/setupUser.sh -O ~/setupUser.sh &>> /var/log/run.log;
|
||||
bash ~/setupUser.sh ${globals.DB_USER} ${globals.DB_PASS} &>> /var/log/run.log;
|
||||
jem passwd set -p ${globals.DB_PASS} &>> /var/log/run.log;
|
||||
user: root
|
||||
|
||||
installWoocommerce:
|
||||
cmd[${nodes.cp.master.id}]: |-
|
||||
wp plugin install woocommerce --version=${globals.version_woocommerce} --activate --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
|
||||
startPage: ${env.url}
|
|
@ -0,0 +1,78 @@
|
|||
type: update
|
||||
id: wordpress-addons
|
||||
name: Addons for WordPress
|
||||
description: Addons for WordPress
|
||||
|
||||
onAfterClone:
|
||||
- script: delete MANIFEST.id; return {result:0, jps:MANIFEST};
|
||||
- install [cp]: ${response.jps}
|
||||
envName: ${event.response.env.envName}
|
||||
|
||||
onInstall:
|
||||
installAddon:
|
||||
- id: setup-site-url-addon
|
||||
nodeGroup: cp
|
||||
- id: cache-purge-addon
|
||||
nodeGroup: cp
|
||||
|
||||
addons:
|
||||
- id: setup-site-url-addon
|
||||
type: update
|
||||
name: WordPress Site Address (URL)
|
||||
description: The Site Address(URL) setting is the address you want people to type in their browser to reach your WordPress blog.
|
||||
logo: https://github.com/jelastic-jps/wordpress/blob/master/wordpress-edition/images/logo/cluster.svg
|
||||
settings:
|
||||
fields:
|
||||
- type: string
|
||||
name: siteURL
|
||||
caption: Site Address (URL)
|
||||
default: ''
|
||||
required: true
|
||||
regex: "^https?:\\/\\/.+$"
|
||||
regexText: Incorrect Site URL.
|
||||
|
||||
buttons:
|
||||
- caption: Site URL
|
||||
settings: main
|
||||
action: setup_site_url
|
||||
loadingText: Applying...
|
||||
confirmText: Do you want to change Site URL?
|
||||
successText: Site URL for WordPress has been successfully applyed!
|
||||
|
||||
- id: cache-purge-addon
|
||||
type: update
|
||||
name: Cache Manager
|
||||
description: Clean all caches at once. Object Cache, Static Cache...
|
||||
logo: https://github.com/jelastic-jps/wordpress/blob/master/wordpress-edition/images/logo/cluster.svg
|
||||
|
||||
buttons:
|
||||
- caption: Clean all caches
|
||||
action: cache_purge
|
||||
loadingText: Cleaning...
|
||||
confirmText: Do you want to clean all caches?
|
||||
successText: Caches have been successfully cleaned!
|
||||
|
||||
actions:
|
||||
litespeed-cache-clean:
|
||||
- if (nodes.bl):
|
||||
cmd[bl]: |-
|
||||
[ -d /tmp/lscache/vhosts/Jelastic/ ] && rm -rf /tmp/lscache/vhosts/Jelastic/* &>> /var/log/run.log;
|
||||
- cmd[cp]: |-
|
||||
[ -d /var/www/webroot/.cache/vhosts/Jelastic/ ] && rm -rf /var/www/webroot/.cache/vhosts/Jelastic/* &>> /var/log/run.log;
|
||||
|
||||
nginx-cache-clean:
|
||||
- cmd[cp]: |-
|
||||
[ -d /var/www/webroot/ROOT/.cache/ ] && rm -rf /var/www/webroot/ROOT/.cache/* &>> /var/log/run.log;
|
||||
|
||||
wordpress-cache-clean:
|
||||
- cmd[cp]: |-
|
||||
wp cache flush --path=/var/www/webroot/ROOT/ &>> /var/log/run.log;
|
||||
|
||||
cache_purge:
|
||||
- if (/llsmp/.test("${nodes.cp.nodeType}") || /litespeed/.test("${nodes.cp.nodeType}")): litespeed-cache-clean
|
||||
- if (/lemp/.test("${nodes.cp.nodeType}") || /nginx/.test("${nodes.cp.nodeType}")): nginx-cache-clean
|
||||
- wordpress-cache-clean
|
||||
|
||||
setup_site_url:
|
||||
- cmd[${nodes.cp.master.id}]: bash ~/bin/setupWP.sh --url ${settings.siteURL}
|
||||
- cache_purge
|
|
@ -0,0 +1,27 @@
|
|||
import com.hivext.api.Response;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import com.hivext.api.core.utils.Transport;
|
||||
|
||||
var cdnAppid = "c05ffa5b45628a2a0c95467ebca8a0b4";
|
||||
var lsAppid = "9e6afcf310004ac84060f90ff41a5aba";
|
||||
var isCDN = jelastic.dev.apps.GetApp(cdnAppid);
|
||||
var isLS = jelastic.dev.apps.GetApp(lsAppid);
|
||||
|
||||
var settings = jps.settings;
|
||||
var fields = {};
|
||||
for (var i = 0, field; field = jps.settings.fields[i]; i++)
|
||||
fields[field.name] = field;
|
||||
|
||||
if (isLS.result == 0 || isLS.result == Response.PERMISSION_DENIED) {
|
||||
fields["ls-addon"].hidden = false;
|
||||
fields["ls-addon"].value = true;
|
||||
} else {
|
||||
fields["ls-addon"].hidden = true;
|
||||
fields["ls-addon"].value = false;
|
||||
fields["ls-addon"].showIf = null;
|
||||
}
|
||||
|
||||
return {
|
||||
result: 0,
|
||||
settings: settings
|
||||
};
|
|
@ -0,0 +1,27 @@
|
|||
var wpbfp = '${settings.wp_protect}' == 'true' ? "THROTTLE" : "OFF";
|
||||
|
||||
var resp = {
|
||||
result: 0,
|
||||
ssl: !!jelastic.billing.account.GetQuotas('environment.jelasticssl.enabled').array[0].value,
|
||||
nodes: []
|
||||
}
|
||||
|
||||
resp.nodes.push({
|
||||
nodeType: "llsmp",
|
||||
engine: "${settings.php_engine:php8.3}",
|
||||
count: 1,
|
||||
cloudlets: "${settings.cloudlets:16}",
|
||||
diskLimit: "${settings.diskspace:[quota.disk.limitation]}",
|
||||
nodeGroup: "cp",
|
||||
skipNodeEmails: "true",
|
||||
displayName: "AppServer",
|
||||
env: {
|
||||
SERVER_WEBROOT: "/var/www/webroot/ROOT",
|
||||
REDIS_ENABLED: "true",
|
||||
WAF: "${settings.waf}",
|
||||
WP_PROTECT: wpbfp,
|
||||
WP_PROTECT_LIMIT: 100
|
||||
}
|
||||
})
|
||||
|
||||
return resp;
|
|
@ -0,0 +1,38 @@
|
|||
type: update
|
||||
id: wordpress-standalone-events
|
||||
name: WordPress Standalone Events
|
||||
|
||||
globals:
|
||||
BASE_URL: https://deploy.mightybox.io/kits/wp-mb-kit/raw/branch/main
|
||||
|
||||
onAfterInstallAddon [nodeGroup:cp, id:cdn]:
|
||||
install: ${globals.BASE_URL}/scripts/setupCDN.jps
|
||||
|
||||
onAfterInstallAddon [nodeGroup:bl, id:letsencrypt-ssl-addon]:
|
||||
- cmd[cp]: |-
|
||||
source /opt/letsencrypt/settings;
|
||||
bash ~/bin/setupWP.sh --url https://${domain};
|
||||
|
||||
onAfterClone:
|
||||
- install: ${globals.BASE_URL}/scripts/setupDomain.jps?_r=${fn.random}
|
||||
envName: ${event.response.env.envName}
|
||||
settings:
|
||||
domain: ${event.response.env.domain}
|
||||
|
||||
- script: delete MANIFEST.id; return {result:0, jps:MANIFEST};
|
||||
- install: ${response.jps}
|
||||
envName: ${event.response.env.envName}
|
||||
|
||||
onBeforeMigrate:
|
||||
- cmd[${nodes.cp.master.id}]: wp option get siteurl --path=/var/www/webroot/ROOT | cut -d'/' -f3;
|
||||
- if (/${response.out}/.test(env.domain)):
|
||||
cmd[${nodes.cp.master.id}]: echo true > ~/migrate
|
||||
- else:
|
||||
cmd[${nodes.cp.master.id}]: echo false > ~/migrate
|
||||
|
||||
onAfterMigrate:
|
||||
- cmd[${nodes.cp.master.id}]: if test -f ~/migrate; then cat ~/migrate; fi
|
||||
- if (/${response.out}/.test(true)):
|
||||
- install: ${globals.BASE_URL}/scripts/setupDomain.jps?_r=${fn.random}
|
||||
settings:
|
||||
domain: ${env.domain}
|
|
@ -0,0 +1,338 @@
|
|||
// http://stackoverflow.com/questions/183485/can-anyone-recommend-a-good-free-javascript-for-punycode-to-unicode-conversion
|
||||
//Javascript Punycode converter derived from example in RFC3492.
|
||||
//This implementation is created by some@domain.name and released into public domain
|
||||
var punycode = new function Punycode() {
|
||||
// This object converts to and from puny-code used in IDN
|
||||
//
|
||||
// punycode.ToASCII ( domain )
|
||||
//
|
||||
// Returns a puny coded representation of "domain".
|
||||
// It only converts the part of the domain name that
|
||||
// has non ASCII characters. I.e. it dosent matter if
|
||||
// you call it with a domain that already is in ASCII.
|
||||
//
|
||||
// punycode.ToUnicode (domain)
|
||||
//
|
||||
// Converts a puny-coded domain name to unicode.
|
||||
// It only converts the puny-coded parts of the domain name.
|
||||
// I.e. it dosent matter if you call it on a string
|
||||
// that already has been converted to unicode.
|
||||
//
|
||||
//
|
||||
this.utf16 = {
|
||||
// The utf16-class is necessary to convert from javascripts internal character representation to unicode and back.
|
||||
decode:function(input){
|
||||
var output = [], i=0, len=input.length,value,extra;
|
||||
while (i < len) {
|
||||
value = input.charCodeAt(i++);
|
||||
if ((value & 0xF800) === 0xD800) {
|
||||
extra = input.charCodeAt(i++);
|
||||
if ( ((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00) ) {
|
||||
throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence");
|
||||
}
|
||||
value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
|
||||
}
|
||||
output.push(value);
|
||||
}
|
||||
return output;
|
||||
},
|
||||
encode:function(input){
|
||||
var output = [], i=0, len=input.length,value;
|
||||
while (i < len) {
|
||||
value = input[i++];
|
||||
if ( (value & 0xF800) === 0xD800 ) {
|
||||
throw new RangeError("UTF-16(encode): Illegal UTF-16 value");
|
||||
}
|
||||
if (value > 0xFFFF) {
|
||||
value -= 0x10000;
|
||||
output.push(String.fromCharCode(((value >>>10) & 0x3FF) | 0xD800));
|
||||
value = 0xDC00 | (value & 0x3FF);
|
||||
}
|
||||
output.push(String.fromCharCode(value));
|
||||
}
|
||||
return output.join("");
|
||||
}
|
||||
}
|
||||
|
||||
//Default parameters
|
||||
var initial_n = 0x80;
|
||||
var initial_bias = 72;
|
||||
var delimiter = "\x2D";
|
||||
var base = 36;
|
||||
var damp = 700;
|
||||
var tmin=1;
|
||||
var tmax=26;
|
||||
var skew=38;
|
||||
var maxint = 0x7FFFFFFF;
|
||||
|
||||
// decode_digit(cp) returns the numeric value of a basic code
|
||||
// point (for use in representing integers) in the range 0 to
|
||||
// base-1, or base if cp is does not represent a value.
|
||||
|
||||
function decode_digit(cp) {
|
||||
return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : cp - 97 < 26 ? cp - 97 : base;
|
||||
}
|
||||
|
||||
// encode_digit(d,flag) returns the basic code point whose value
|
||||
// (when used for representing integers) is d, which needs to be in
|
||||
// the range 0 to base-1. The lowercase form is used unless flag is
|
||||
// nonzero, in which case the uppercase form is used. The behavior
|
||||
// is undefined if flag is nonzero and digit d has no uppercase form.
|
||||
|
||||
function encode_digit(d, flag) {
|
||||
return d + 22 + 75 * (d < 26) - ((flag != 0) << 5);
|
||||
// 0..25 map to ASCII a..z or A..Z
|
||||
// 26..35 map to ASCII 0..9
|
||||
}
|
||||
//** Bias adaptation function **
|
||||
function adapt(delta, numpoints, firsttime ) {
|
||||
var k;
|
||||
delta = firsttime ? Math.floor(delta / damp) : (delta >> 1);
|
||||
delta += Math.floor(delta / numpoints);
|
||||
|
||||
for (k = 0; delta > (((base - tmin) * tmax) >> 1); k += base) {
|
||||
delta = Math.floor(delta / ( base - tmin ));
|
||||
}
|
||||
return Math.floor(k + (base - tmin + 1) * delta / (delta + skew));
|
||||
}
|
||||
|
||||
// encode_basic(bcp,flag) forces a basic code point to lowercase if flag is zero,
|
||||
// uppercase if flag is nonzero, and returns the resulting code point.
|
||||
// The code point is unchanged if it is caseless.
|
||||
// The behavior is undefined if bcp is not a basic code point.
|
||||
|
||||
function encode_basic(bcp, flag) {
|
||||
bcp -= (bcp - 97 < 26) << 5;
|
||||
return bcp + ((!flag && (bcp - 65 < 26)) << 5);
|
||||
}
|
||||
|
||||
// Main decode
|
||||
this.decode=function(input,preserveCase) {
|
||||
// Dont use utf16
|
||||
var output=[];
|
||||
var case_flags=[];
|
||||
var input_length = input.length;
|
||||
|
||||
var n, out, i, bias, basic, j, ic, oldi, w, k, digit, t, len;
|
||||
|
||||
// Initialize the state:
|
||||
|
||||
n = initial_n;
|
||||
i = 0;
|
||||
bias = initial_bias;
|
||||
|
||||
// Handle the basic code points: Let basic be the number of input code
|
||||
// points before the last delimiter, or 0 if there is none, then
|
||||
// copy the first basic code points to the output.
|
||||
|
||||
basic = input.lastIndexOf(delimiter);
|
||||
if (basic < 0) basic = 0;
|
||||
|
||||
for (j = 0; j < basic; ++j) {
|
||||
if(preserveCase) case_flags[output.length] = ( input.charCodeAt(j) -65 < 26);
|
||||
if ( input.charCodeAt(j) >= 0x80) {
|
||||
throw new RangeError("Illegal input >= 0x80");
|
||||
}
|
||||
output.push( input.charCodeAt(j) );
|
||||
}
|
||||
|
||||
// Main decoding loop: Start just after the last delimiter if any
|
||||
// basic code points were copied; start at the beginning otherwise.
|
||||
|
||||
for (ic = basic > 0 ? basic + 1 : 0; ic < input_length; ) {
|
||||
|
||||
// ic is the index of the next character to be consumed,
|
||||
|
||||
// Decode a generalized variable-length integer into delta,
|
||||
// which gets added to i. The overflow checking is easier
|
||||
// if we increase i as we go, then subtract off its starting
|
||||
// value at the end to obtain delta.
|
||||
for (oldi = i, w = 1, k = base; ; k += base) {
|
||||
if (ic >= input_length) {
|
||||
throw RangeError ("punycode_bad_input(1)");
|
||||
}
|
||||
digit = decode_digit(input.charCodeAt(ic++));
|
||||
|
||||
if (digit >= base) {
|
||||
throw RangeError("punycode_bad_input(2)");
|
||||
}
|
||||
if (digit > Math.floor((maxint - i) / w)) {
|
||||
throw RangeError ("punycode_overflow(1)");
|
||||
}
|
||||
i += digit * w;
|
||||
t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
|
||||
if (digit < t) { break; }
|
||||
if (w > Math.floor(maxint / (base - t))) {
|
||||
throw RangeError("punycode_overflow(2)");
|
||||
}
|
||||
w *= (base - t);
|
||||
}
|
||||
|
||||
out = output.length + 1;
|
||||
bias = adapt(i - oldi, out, oldi === 0);
|
||||
|
||||
// i was supposed to wrap around from out to 0,
|
||||
// incrementing n each time, so we'll fix that now:
|
||||
if ( Math.floor(i / out) > maxint - n) {
|
||||
throw RangeError("punycode_overflow(3)");
|
||||
}
|
||||
n += Math.floor( i / out ) ;
|
||||
i %= out;
|
||||
|
||||
// Insert n at position i of the output:
|
||||
// Case of last character determines uppercase flag:
|
||||
if (preserveCase) { case_flags.splice(i, 0, input.charCodeAt(ic -1) -65 < 26);}
|
||||
|
||||
output.splice(i, 0, n);
|
||||
i++;
|
||||
}
|
||||
if (preserveCase) {
|
||||
for (i = 0, len = output.length; i < len; i++) {
|
||||
if (case_flags[i]) {
|
||||
output[i] = (String.fromCharCode(output[i]).toUpperCase()).charCodeAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.utf16.encode(output);
|
||||
};
|
||||
|
||||
//** Main encode function **
|
||||
|
||||
this.encode = function (input,preserveCase) {
|
||||
//** Bias adaptation function **
|
||||
|
||||
var n, delta, h, b, bias, j, m, q, k, t, ijv, case_flags;
|
||||
|
||||
if (preserveCase) {
|
||||
// Preserve case, step1 of 2: Get a list of the unaltered string
|
||||
case_flags = this.utf16.decode(input);
|
||||
}
|
||||
// Converts the input in UTF-16 to Unicode
|
||||
input = this.utf16.decode(input.toLowerCase());
|
||||
|
||||
var input_length = input.length; // Cache the length
|
||||
|
||||
if (preserveCase) {
|
||||
// Preserve case, step2 of 2: Modify the list to true/false
|
||||
for (j=0; j < input_length; j++) {
|
||||
case_flags[j] = input[j] != case_flags[j];
|
||||
}
|
||||
}
|
||||
|
||||
var output=[];
|
||||
|
||||
|
||||
// Initialize the state:
|
||||
n = initial_n;
|
||||
delta = 0;
|
||||
bias = initial_bias;
|
||||
|
||||
// Handle the basic code points:
|
||||
for (j = 0; j < input_length; ++j) {
|
||||
if ( input[j] < 0x80) {
|
||||
output.push(
|
||||
String.fromCharCode(
|
||||
case_flags ? encode_basic(input[j], case_flags[j]) : input[j]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
h = b = output.length;
|
||||
|
||||
// h is the number of code points that have been handled, b is the
|
||||
// number of basic code points
|
||||
|
||||
if (b > 0) output.push(delimiter);
|
||||
|
||||
// Main encoding loop:
|
||||
//
|
||||
while (h < input_length) {
|
||||
// All non-basic code points < n have been
|
||||
// handled already. Find the next larger one:
|
||||
|
||||
for (m = maxint, j = 0; j < input_length; ++j) {
|
||||
ijv = input[j];
|
||||
if (ijv >= n && ijv < m) m = ijv;
|
||||
}
|
||||
|
||||
// Increase delta enough to advance the decoder's
|
||||
// <n,i> state to <m,0>, but guard against overflow:
|
||||
|
||||
if (m - n > Math.floor((maxint - delta) / (h + 1))) {
|
||||
throw RangeError("punycode_overflow (1)");
|
||||
}
|
||||
delta += (m - n) * (h + 1);
|
||||
n = m;
|
||||
|
||||
for (j = 0; j < input_length; ++j) {
|
||||
ijv = input[j];
|
||||
|
||||
if (ijv < n ) {
|
||||
if (++delta > maxint) return Error("punycode_overflow(2)");
|
||||
}
|
||||
|
||||
if (ijv == n) {
|
||||
// Represent delta as a generalized variable-length integer:
|
||||
for (q = delta, k = base; ; k += base) {
|
||||
t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
|
||||
if (q < t) break;
|
||||
output.push( String.fromCharCode(encode_digit(t + (q - t) % (base - t), 0)) );
|
||||
q = Math.floor( (q - t) / (base - t) );
|
||||
}
|
||||
output.push( String.fromCharCode(encode_digit(q, preserveCase && case_flags[j] ? 1:0 )));
|
||||
bias = adapt(delta, h + 1, h == b);
|
||||
delta = 0;
|
||||
++h;
|
||||
}
|
||||
}
|
||||
|
||||
++delta, ++n;
|
||||
}
|
||||
return output.join("");
|
||||
}
|
||||
|
||||
this.ToASCII = function ( domain ) {
|
||||
var domain_array = domain.split(".");
|
||||
var out = [];
|
||||
for (var i=0; i < domain_array.length; ++i) {
|
||||
var s = domain_array[i];
|
||||
out.push(
|
||||
s.match(/[^A-Za-z0-9-]/) ?
|
||||
"xn--" + punycode.encode(s) :
|
||||
s
|
||||
);
|
||||
}
|
||||
return out.join(".");
|
||||
}
|
||||
this.ToUnicode = function ( domain ) {
|
||||
var domain_array = domain.split(".");
|
||||
var out = [];
|
||||
for (var i=0; i < domain_array.length; ++i) {
|
||||
var s = domain_array[i];
|
||||
out.push(
|
||||
s.match(/^xn--/) ?
|
||||
punycode.decode(s.slice(4)) :
|
||||
s
|
||||
);
|
||||
}
|
||||
return out.join(".");
|
||||
}
|
||||
}();
|
||||
|
||||
var sEnvUrl = "${env.url}",
|
||||
sConverted = sEnvUrl.split('.')[0],
|
||||
sDomain,
|
||||
sResp;
|
||||
|
||||
|
||||
if (sConverted) {
|
||||
if (/[а-яА-ЯЁё]/.test(sConverted)) {
|
||||
sDomain = sConverted.split('//')[1];
|
||||
sConverted = punycode.ToASCII(sDomain);
|
||||
}
|
||||
}
|
||||
|
||||
sResp = sEnvUrl.replace(sDomain, sConverted).split('/')[2];
|
||||
|
||||
return {result: 0, domain: sResp}
|
|
@ -0,0 +1,100 @@
|
|||
jpsType: update
|
||||
id: wordpress-core-installation
|
||||
name: WordPress Core Installation
|
||||
description: WordPress Core Installation
|
||||
|
||||
mixins:
|
||||
- https://raw.githubusercontent.com/jelastic-jps/wordpress/master/configs/vers.yaml
|
||||
|
||||
globals:
|
||||
WP_ADMIN_PASS: ${settings.wp_admin_pass}
|
||||
WP_TITLE: ${settings.wp_title}
|
||||
DB_HOST: ${settings.db_host}
|
||||
DB_NAME: wp_${fn.random}
|
||||
DB_USER: ${settings.db_user}
|
||||
DB_PASS: ${settings.db_pass}
|
||||
REDIS_HOST: ${settings.redis_host:}
|
||||
REDIS_PORT: ${settings.redis_port:}
|
||||
REDIS_USER: ${settings.redis_user:}
|
||||
REDIS_PSWD: ${settings.redis_pswd:}
|
||||
WP_URL: ${settings.wp_url}
|
||||
CLUSTER: ${settings.cluster:true}
|
||||
|
||||
onInstall:
|
||||
- deployWordPress
|
||||
- installScripts
|
||||
- installWordPress
|
||||
- setupWordPress
|
||||
- installPlugins
|
||||
- setupPlugins
|
||||
|
||||
actions:
|
||||
deployWordPress:
|
||||
- cmd[${nodes.cp.master.id}]: |-
|
||||
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/;
|
||||
rsync -a --checksum /tmp/wordpress/* /var/www/webroot/ROOT/;
|
||||
- addContext [cp]:
|
||||
name: ROOT
|
||||
fileName: WordPress
|
||||
type: ARCHIVE
|
||||
|
||||
installWordPress:
|
||||
- if ('${globals.CLUSTER}' == 'true'):
|
||||
cmd[${nodes.cp.master.id}]: |-
|
||||
mysql -u${globals.DB_USER} -p${globals.DB_PASS} -h ${nodes.sqldb.master.intIP} -e "CREATE DATABASE IF NOT EXISTS ${globals.DB_NAME};"
|
||||
cd /var/www/webroot/ROOT && wp core config --dbhost=${nodes.sqldb.master.intIP} --dbname=${globals.DB_NAME} --dbuser=${globals.DB_USER} --dbpass=${globals.DB_PASS} --path=/var/www/webroot/ROOT;
|
||||
cd /var/www/webroot/ROOT && wp core install --title="${globals.WP_TITLE}" --admin_user=${user.email} --admin_password=${globals.WP_ADMIN_PASS} --url=${globals.WP_URL} --admin_email=${user.email} --skip-email --path=/var/www/webroot/ROOT;
|
||||
mv /var/www/webroot/ROOT/wp-config.php /tmp; sed -i "s/${nodes.sqldb.master.intIP}/${globals.DB_HOST}/g" /tmp/wp-config.php; mv /tmp/wp-config.php /var/www/webroot/ROOT;
|
||||
wget ${baseUrl}../images/favicon.ico -O /var/www/webroot/ROOT/favicon.ico;
|
||||
- else:
|
||||
cmd[${nodes.cp.master.id}]: |-
|
||||
mysql -u${globals.DB_USER} -p${globals.DB_PASS} -h ${globals.DB_HOST} -e "CREATE DATABASE IF NOT EXISTS ${globals.DB_NAME};"
|
||||
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;
|
||||
cd /var/www/webroot/ROOT && wp core install --title="${globals.WP_TITLE}" --admin_user=${user.email} --admin_password=${globals.WP_ADMIN_PASS} --url=${globals.WP_URL} --admin_email=${user.email} --skip-email --path=/var/www/webroot/ROOT;
|
||||
wget ${baseUrl}../images/favicon.ico -O /var/www/webroot/ROOT/favicon.ico;
|
||||
|
||||
installScripts:
|
||||
- cmd[cp]: |-
|
||||
[ ! -d $HOME/bin ] && mkdir $HOME/bin;
|
||||
curl -o $HOME/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x $HOME/bin/wp;
|
||||
echo "apache_modules:" > ~/bin/wp-cli.yml;
|
||||
echo " - mod_rewrite" >> ~/bin/wp-cli.yml;
|
||||
echo "export PATH=$PATH:$HOME/bin/" >> $HOME/.bash_profile;
|
||||
wget ${baseUrl}/setupWP.sh?_r=${fn.random} -O ~/bin/setupWP.sh &>> /var/log/run.log;
|
||||
echo $HOME/bin;
|
||||
- cmd[cp]:
|
||||
echo ${response.out} >> /etc/jelastic/redeploy.conf;
|
||||
yum install jq -y &>> /var/log/run.log;
|
||||
user: root
|
||||
|
||||
setupWordPress:
|
||||
- cmd[${nodes.cp.master.id}]: |-
|
||||
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;
|
||||
cd ~/bin/ && wp option update permalink_structure '/%postname%/' --path=/var/www/webroot/ROOT;
|
||||
cd ~/bin/ && wp rewrite structure '/%postname%/' --hard --path=/var/www/webroot/ROOT;
|
||||
|
||||
installPlugins:
|
||||
- if (/lemp/.test("${nodes.cp.nodeType}") || /nginxphp/.test("${nodes.cp.nodeType}")):
|
||||
cmd[${nodes.cp.master.id}]: |-
|
||||
wget ${baseUrl}../configs/wordpress/wp-jelastic.php -O /var/www/webroot/ROOT/wp-jelastic.php
|
||||
mv /var/www/webroot/ROOT/wp-config.php /tmp; sed -i "s/.*'wp-settings.php';.*/require_once ABSPATH . 'wp-jelastic.php';\n&/" /tmp/wp-config.php; mv /tmp/wp-config.php /var/www/webroot/ROOT;
|
||||
wp plugin install w3-total-cache --version=${globals.version_w3total} --activate --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp cache flush --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp plugin install nginx-cache --activate --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp cache flush --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp db query "INSERT INTO wp_options(option_name,option_value,autoload) VALUES('nginx_cache_path','/var/www/webroot/ROOT/.cache','yes');" --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp db query "INSERT INTO wp_options(option_name,option_value,autoload) VALUES('nginx_auto_purge',1,'yes');" --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp cache flush --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
|
||||
- if (/llsmp/.test("${nodes.cp.nodeType}") || /litespeed/.test("${nodes.cp.nodeType}")):
|
||||
cmd[${nodes.cp.master.id}]: |-
|
||||
wp plugin install litespeed-cache --version=${globals.version_lscache} --activate --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
wp cache flush --path=/var/www/webroot/ROOT &>> /var/log/run.log;
|
||||
|
||||
setupPlugins:
|
||||
- cmd[${nodes.cp.master.id}]: |-
|
||||
bash ~/bin/setupWP.sh --pgcache true --objectcache true --REDIS_HOST ${globals.REDIS_HOST} --REDIS_PORT ${globals.REDIS_PORT} --REDIS_USER ${globals.REDIS_USER} --REDIS_PSWD ${globals.REDIS_PSWD};
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import com.hivext.api.Response;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import com.hivext.api.core.utils.Transport;
|
||||
|
||||
var cdnAppid = "c05ffa5b45628a2a0c95467ebca8a0b4";
|
||||
var lsAppid = "9e6afcf310004ac84060f90ff41a5aba";
|
||||
var group = jelastic.billing.account.GetAccount(appid, session);
|
||||
var isCDN = jelastic.dev.apps.GetApp(cdnAppid);
|
||||
var isLS = jelastic.dev.apps.GetApp(lsAppid);
|
||||
|
||||
var markup = "", cur = null, text = "used";
|
||||
|
||||
var settings = jps.settings;
|
||||
var fields = {};
|
||||
for (var i = 0, field; field = jps.settings.fields[i]; i++)
|
||||
fields[field.name] = field;
|
||||
|
||||
if (isLS.result == 0 || isLS.result == Response.PERMISSION_DENIED) {
|
||||
fields["ls-addon"].hidden = false;
|
||||
fields["ls-addon"].value = true;
|
||||
} else {
|
||||
fields["ls-addon"].hidden = true;
|
||||
fields["ls-addon"].value = false;
|
||||
fields["ls-addon"].showIf = null;
|
||||
}
|
||||
|
||||
if (isCDN.result == 0 || isCDN.result == Response.PERMISSION_DENIED) {
|
||||
fields["cdn-addon"].hidden = false;
|
||||
fields["cdn-addon"].value = true;
|
||||
} else {
|
||||
fields["cdn-addon"].hidden = true;
|
||||
fields["cdn-addon"].value = false;
|
||||
}
|
||||
|
||||
//checking quotas
|
||||
var extIP = "environment.externalip.enabled",
|
||||
extIPperEnv = "environment.externalip.maxcount",
|
||||
extIPperNode = "environment.externalip.maxcount.per.node",
|
||||
markup = "", cur = null, text = "used", LE = true;
|
||||
|
||||
var quotas = jelastic.billing.account.GetQuotas(extIP + ";"+extIPperEnv+";" + extIPperNode ).array;
|
||||
for (var i = 0; i < quotas.length; i++){
|
||||
var q = quotas[i], n = toNative(q.quota.name);
|
||||
|
||||
if (n == extIP && !q.value){
|
||||
err(q, "required", 1, true);
|
||||
LE = false;
|
||||
}
|
||||
|
||||
if (n == extIPperEnv && q.value < 1){
|
||||
if (!markup) err(q, "required", 1, true);
|
||||
LE = false;
|
||||
}
|
||||
|
||||
if (n == extIPperNode && q.value < 1){
|
||||
if (!markup) err(q, "required", 1, true);
|
||||
LE = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!LE) {
|
||||
fields["displayfield"].markup = "Some advanced features are not available. Please upgrade your account.";
|
||||
fields["displayfield"].cls = "warning";
|
||||
fields["displayfield"].hideLabel = true;
|
||||
fields["displayfield"].height = 25;
|
||||
fields["le-addon"].disabled = true;
|
||||
fields["le-addon"].value = false;
|
||||
fields["bl_count"].markup = "Let's Encrypt is not available. " + markup + "Please upgrade your account.";
|
||||
fields["bl_count"].cls = "warning";
|
||||
fields["bl_count"].hidden = false;
|
||||
fields["bl_count"].height = 30;
|
||||
}
|
||||
|
||||
return {
|
||||
result: 0,
|
||||
settings: settings
|
||||
};
|
||||
|
||||
function err(e, text, cur, override){
|
||||
var m = (e.quota.description || e.quota.name) + " - " + e.value + ", " + text + " - " + cur + ". ";
|
||||
if (override) markup = m; else markup += m;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
**WordPress environment**: [${globals.PROTOCOL}://${env.domain}/](${globals.PROTOCOL}://${env.domain}/)
|
||||
|
||||
Use the following credentials to access the admin panel:
|
||||
|
||||
**Admin Panel**: [${globals.PROTOCOL}://${env.domain}/wp-admin/](${globals.PROTOCOL}://${env.domain}/wp-admin/)
|
||||
**Login**: ${user.email}
|
||||
**Password**: ${globals.WP_ADMIN_PASS}
|
||||
|
||||
Please use the following data to access LiteSpeed WebAdmin Console:
|
||||
|
||||
**Admin Console**: [https://${env.domain}:4848/](https://${env.domain}:4848/)
|
||||
**Login**: admin
|
||||
**Password**: ${globals.DB_PASS}
|
||||
|
||||
Manage the database nodes using the next credentials:
|
||||
|
||||
**phpMyAdmin Panel**: [https://${env.domain}:8443/](https://${env.domain}:8443/)
|
||||
**Username**: ${globals.DB_USER}
|
||||
**Password**: ${globals.DB_PASS}
|
|
@ -0,0 +1,17 @@
|
|||
**WordPress environment**: [${globals.PROTOCOL}://${env.domain}/](${globals.PROTOCOL}://${env.domain}/)
|
||||
|
||||
Use the following credentials to access the admin panel:
|
||||
|
||||
**Admin Panel**: [${globals.PROTOCOL}://${env.domain}/wp-admin/](${globals.PROTOCOL}://${env.domain}/wp-admin/)
|
||||
**Login**: ${user.email}
|
||||
**Password**: ${globals.WP_ADMIN_PASS}
|
||||
|
||||
The instructions below can help you with further managing your WordPress:
|
||||
|
||||
* [Bind custom domain](https://docs.jelastic.com/custom-domain-via-cname)
|
||||
* [Share access to the environment](http://docs.jelastic.com/share-environment)
|
||||
* [Adjust automatic vertical scaling settings](http://docs.jelastic.com/automatic-vertical-scaling)
|
||||
* [Configure automatic horizontal scaling](http://docs.jelastic.com/automatic-horizontal-scaling)
|
||||
* [Monitor the statistics](http://docs.jelastic.com/view-app-statistics) & [view log files](https://docs.jelastic.com/view-log-files)
|
||||
* [Attach Public IP](https://docs.jelastic.com/public-ip)
|
||||
* [Access environment via SSH](https://docs.jelastic.com/ssh-access)
|
Loading…
Reference in New Issue