Commit a0063d39 authored by Sandeep Kadam's avatar Sandeep Kadam

Updated groups microsite bootstrap scripts

parent ed193ff1
......@@ -48,28 +48,18 @@ if [ "${WP_NEED_BLANK_SITE}" = "Yes" ]; then
# Disable comments
wp option update default_comment_status closed
fi
echo "VF theme - Activating VF theme"
if ! $(wp theme is-active vf-wp-groups); then
wp theme activate "vf-wp-groups"
fi
# List of Array for default VF plugins
PLUGINS_LIST='
advanced-custom-fields-pro
embl-taxonomy
vf-wp
embl-taxonomy
vf-beta-container
vf-breadcrumbs-container
vf-data-resources-block
vf-embl-news-container
vf-ebi-global-footer-container
vf-ebi-global-header-container
vf-factoid-block
vf-global-footer-container
vf-global-header-container
vf-latest-posts-block
vf-publications-block
vf-gutenberg
......@@ -78,6 +68,7 @@ vf-jobs-block
vf-members-block
embl-group-site-roles
vf-publications-group-ebi-block
vf-embl-news-block
';
echo "VF Plugins - Activating VF Plugins"
......@@ -88,9 +79,63 @@ for PLUGIN in ${PLUGINS_LIST}; do
fi
done;
wp plugin install onelogin-saml-sso --activate
echo "Activating header/footer theme based plugins"
# Activate header/footer based on the theme given
if [ "$site_theme" = EBI* ]; then
wp plugin activate 'vf-ebi-global-header-container' 'vf-ebi-global-footer-container'
else
wp plugin activate 'vf-global-header-container' 'vf-global-footer-container'
fi
echo "VF theme - Activating VF theme"
if ! $(wp theme is-active vf-wp-groups); then
wp theme activate "vf-wp-groups"
fi
wp plugin install onelogin-saml-sso
wp plugin install user-role-editor --activate
# Define postcontent of vf_template.
case "$site_theme" in
EMBL)
vf_template_content="
<!-- wp:vf/container-global-header /-->
<!-- wp:vf/container-breadcrumbs /-->
<!-- wp:vf/container-wp-groups-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-embl-news /-->
<!-- wp:vf/container-global-footer /-->";
;;
EBI-SERVICE|EBI-CLUSTERS|EBI-RESEARCH)
vf_template_content="
<!-- wp:vf/container-ebi-global-header /-->
<!-- wp:vf/container-breadcrumbs /-->
<!-- wp:vf/container-wp-groups-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-embl-news /-->
<!-- wp:vf/container-ebi-global-footer /-->";
;;
*)
# Default content
vf_template_content="
<!-- wp:vf/container-global-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-global-footer /-->";
;;
esac;
echo "=== VF plugin config ==="
if [ $(wp option get show_on_front) != 'page' ] ; then
echo "VF plugin config - setting config"
......@@ -122,20 +167,9 @@ if [ $(wp option get show_on_front) != 'page' ] ; then
wp menu create "Secondary"
wp menu location assign secondary secondary
# VF Blocks
wp option update options_vf_containers 5
wp option update _options_vf_containers field_vf_containers
wp option update options_vf_containers_0_vf_container_name vf_ebi_global_header
wp option update _options_vf_containers_0_vf_container_name field_vf_container_name
wp option update options_vf_containers_1_vf_container_name vf_breadcrumbs
wp option update _options_vf_containers_1_vf_container_name field_vf_container_name
wp option update options_vf_containers_2_vf_container_name vf_page_template
wp option update _options_vf_containers_2_vf_container_name field_vf_container_name
wp option update options_vf_containers_3_vf_container_name vf_embl_news
wp option update _options_vf_containers_3_vf_container_name field_vf_container_name
wp option update options_vf_containers_4_vf_container_name vf_ebi_global_footer
wp option update _options_vf_containers_4_vf_container_name field_vf_container_name
# Updated vf_template post content.
vf_template_post_id="$(wp post list --name=default --post_type=vf_template --field=ID)";
wp post update $vf_template_post_id --post_content="$vf_template_content";
else
echo "VF plugin config - already configured"
fi
......@@ -210,7 +244,7 @@ fi
echo "=== Taxonomy ==="
if ! [[ `wp option list --search=_options_embl_taxonomy --fields=option_value --format=total_bytes` ]] ; then
echo "Taxonomy - configuring"
wp option update embl_taxonomy "https://dev.beta.embl.org/api/v1/pattern.json?pattern=embl-ontology&source=contenthub"
wp option update embl_taxonomy $VF_API_URL"pattern.json?pattern=embl-ontology&source=contenthub"
wp option update _options_embl_taxonomy field_embl_taxonomy
wp option update _options_embl_taxonomy_term_who field_embl_taxonomy_term_who
wp option update _options_embl_taxonomy_term_what field_embl_taxonomy_term_what
......@@ -246,10 +280,10 @@ TEAM_LONG_DESCRIPTION="<h1>${WP_GROUP_TEAM_SHORT_DESCRIPTION} <a href='about'>Re
# Set the Gutenberg HTML content for the homepage
IFS='' read -r home_page_content <<EOF
<!-- wp:vf/group-header {"ver":1} /-->
<!-- wp:vf/latest-posts {"ver":1} /-->
<!-- wp:vf/data-resources {"ver":1} /-->
<!-- wp:vf/jobs {"limit":1,"filter":"all","ver":1} /-->
<!-- wp:vf/group-header {"ver":1} /-->
<!-- wp:acf/vfwp-latest-posts {"id":"block_5ea826258cfbb","name":"acf/vfwp-latest-posts"} /-->
<!-- wp:vf/data-resources {"ver":1} /-->
<!-- wp:vf/jobs {"limit":1,"filter":"all","ver":1} /-->
EOF
# Find ID of homepage and update contents
......@@ -319,18 +353,13 @@ default_blog_post_content="<!-- wp:paragraph -->
<p>Don't worry, you can always add it again. Doing this doesn't delete the blog, or the blog posts, but just removes the link in the navigation.</p>
<!-- /wp:paragraph -->";
# Update blog post content
wp post update 1 --post_title="Welcome to your new group or team blog!" --post_content="$default_blog_post_content";
# Update blog post content
wp post update 1 --post_title="Welcome to your new group or team blog!" --post_content="$default_blog_post_content";
# Set the VF Theme Color if not set
#db_theme_color_value="$(wp option pluck theme_mods_vf-themes vf_theme_color)"
if ! [[ `wp option pluck theme_mods_vf-wp-groups vf_theme_color` ]] ; then
# if [ -n "$db_theme_color_value" ]; then
wp option patch insert theme_mods_vf-wp-groups vf_theme_color "$VF_THEME_COLOR";
else
wp option patch update theme_mods_vf-wp-groups vf_theme_color "$VF_THEME_COLOR";
fi
# Flush the rewrite cache from DB
wp rewrite flush
# Update DB if any.
wp core update-db
echo "Wordpress Group Visual framework local setup completed!!!"
......@@ -115,7 +115,7 @@ function on_script_exit() {
echo "Deployment of $MICROSITE_SITE_URL [$FILE_NAME] for Server [$SERVER_NAME] - $DEPLOY_STATUS" >> ${DEPLOYMENT_LOG_MAIN_FOLDER}/${DEPLOYMENT_STATUS_LOGFILE}
}
# Catch the errors which are generated by the current script.
trap 'on_script_exit "$LINENO" $?' ERR EXIT
trap 'on_script_exit "$LINENO" $?' EXIT
# Go to the deploy path i.e wordpress installation path to trigger 'wp' commands.
cd ${DEPLOY_PATH}/
......@@ -140,24 +140,15 @@ echo "VF default configuration setup started..."
echo ""
echo "=== VF theme & plugins ==="
echo "VF theme - Activating VF theme"
if ! $(wp theme is-active vf-wp-groups); then
wp theme activate "vf-wp-groups"
fi
# List of Array for default VF plugins
PLUGINS_LIST='
advanced-custom-fields-pro
embl-taxonomy
vf-wp
embl-taxonomy
vf-beta-container
vf-breadcrumbs-container
vf-embl-news-container
vf-ebi-global-footer-container
vf-ebi-global-header-container
vf-factoid-block
vf-global-footer-container
vf-global-header-container
vf-latest-posts-block
vf-publications-block
vf-gutenberg
......@@ -171,12 +162,25 @@ for PLUGIN in ${PLUGINS_LIST}; do
fi
done;
echo "Activating header/footer theme based plugins"
# Activate header/footer based on the theme given
if [ "$site_theme" = EBI* ]; then
wp plugin activate 'vf-ebi-global-header-container' 'vf-ebi-global-footer-container'
else
wp plugin activate 'vf-global-header-container' 'vf-global-footer-container'
fi
echo "VF theme - Activating VF theme"
if ! $(wp theme is-active vf-wp-groups); then
wp theme activate "vf-wp-groups"
fi
echo "=== Core pages & show_on_front config ==="
if [ $(wp option get show_on_front) != 'page' ] ; then
# # Create some core pages
# Create home page - Create only if it doesn't exists.
if ! $(wp post list --post_type=page --fields=post_title | grep -E "^Home"); then
if ! $(wp post list --post_type=page --fields=post_title --format=csv | grep -E "^Home"); then
home_page_id=$(wp post create --post_title='Home' --post_type=page --post_status=publish --porcelain);
wp post meta update $home_page_id vf_locked 1
wp post meta update $home_page_id _vf_locked field_vf_locked
......@@ -221,6 +225,50 @@ wp option update options_vf_api_url $VF_API_URL
# Add tagline desc to the site
wp option update blogdescription $SITE_TAGLINE
# Define postcontent of vf_template.
case "$site_theme" in
EMBL)
vf_template_content="
<!-- wp:vf/container-global-header /-->
<!-- wp:vf/container-breadcrumbs /-->
<!-- wp:vf/container-wp-groups-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-embl-news /-->
<!-- wp:vf/container-global-footer /-->";
;;
EBI-SERVICE|EBI-CLUSTERS|EBI-RESEARCH)
vf_template_content="
<!-- wp:vf/container-ebi-global-header /-->
<!-- wp:vf/container-breadcrumbs /-->
<!-- wp:vf/container-wp-groups-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-embl-news /-->
<!-- wp:vf/container-ebi-global-footer /-->";
;;
*)
# Default content
vf_template_content="
<!-- wp:vf/container-global-header /-->
<!-- wp:vf/container-page-template /-->
<!-- wp:vf/container-global-footer /-->";
;;
esac;
# get the command and run it
COMMAND="${1}"; shift;
case "${COMMAND}" in
......@@ -229,23 +277,12 @@ case "${COMMAND}" in
echo "Configuring basic standalone site related VF setup"
# Go to the deploy path i.e wordpress installation path to trigger 'wp' commands.
cd ${DEPLOY_PATH}/
# Code goes here...
# Updated vf_template post content.
vf_template_post_id="$(wp post list --name=default --post_type=vf_template --field=ID)";
wp post update $vf_template_post_id --post_content="$vf_template_content";
# VF Blocks
echo "Activating VF containers blocks"
if [ $(wp option get options_vf_containers) != '4' ] ; then
wp option update options_vf_containers 4
wp option update _options_vf_containers field_vf_containers
wp option update options_vf_containers_0_vf_container_name $THEME_HEADER
wp option update _options_vf_containers_0_vf_container_name field_vf_container_name
wp option update options_vf_containers_1_vf_container_name vf_breadcrumbs
wp option update _options_vf_containers_1_vf_container_name field_vf_container_name
wp option update options_vf_containers_2_vf_container_name vf_page_template
wp option update _options_vf_containers_2_vf_container_name field_vf_container_name
wp option update options_vf_containers_3_vf_container_name $THEME_FOOTER
wp option update _options_vf_containers_3_vf_container_name field_vf_container_name
fi
;;
;;
microsite_setup)
echo "Configuring microsite related VF setup"
......@@ -263,8 +300,13 @@ case "${COMMAND}" in
embl-group-site-roles
ga-google-analytics
vf-publications-group-ebi-block
vf-embl-news-block
';
# Updated vf_template post content.
vf_template_post_id="$(wp post list --name='default' --post_type='vf_template' --field=ID)"
wp post update $vf_template_post_id --post_content="$vf_template_content"
# Check if plugin is active, if not then activate plugins
for PLUGIN in ${MICROSITE_PLUGINS_LIST}; do
if ! $(wp plugin is-active ${PLUGIN}); then
......@@ -272,23 +314,6 @@ case "${COMMAND}" in
fi
done;
# VF Blocks
echo "Activating VF containers blocks"
if [[ $(wp option get options_vf_containers) != '5' ]] ; then
wp option update options_vf_containers 5
wp option update _options_vf_containers field_vf_containers
wp option update options_vf_containers_0_vf_container_name $THEME_HEADER
wp option update _options_vf_containers_0_vf_container_name field_vf_container_name
wp option update options_vf_containers_1_vf_container_name vf_breadcrumbs
wp option update _options_vf_containers_1_vf_container_name field_vf_container_name
wp option update options_vf_containers_2_vf_container_name vf_page_template
wp option update _options_vf_containers_2_vf_container_name field_vf_container_name
wp option update options_vf_containers_3_vf_container_name vf_embl_news
wp option update _options_vf_containers_3_vf_container_name field_vf_container_name
wp option update options_vf_containers_4_vf_container_name $THEME_FOOTER
wp option update _options_vf_containers_4_vf_container_name field_vf_container_name
fi
# Configure jobs plugin
echo "=== Jobs ==="
jobs_id="$(wp post list --name=vf_jobs --post_type=vf_block --field=ID)"
......@@ -330,16 +355,12 @@ case "${COMMAND}" in
# Configure taxonomy
echo "=== Taxonomy ==="
if ! [[ `wp option list --search=_options_embl_taxonomy --fields=option_value --format=total_bytes` ]] ; then
echo "Taxonomy - configuring"
wp option update embl_taxonomy $VF_API_URL"pattern.json?pattern=embl-ontology&source=contenthub"
wp option update _options_embl_taxonomy field_embl_taxonomy
wp option update _options_embl_taxonomy_term_who field_embl_taxonomy_term_who
wp option update _options_embl_taxonomy_term_what field_embl_taxonomy_term_what
wp option update _options_embl_taxonomy_term_where field_embl_taxonomy_term_where
else
echo "Taxonomy - already configured"
fi
echo "Taxonomy - configuring"
wp option update embl_taxonomy $VF_API_URL"pattern.json?pattern=embl-ontology&source=contenthub"
wp option update _options_embl_taxonomy field_embl_taxonomy
wp option update _options_embl_taxonomy_term_who field_embl_taxonomy_term_who
wp option update _options_embl_taxonomy_term_what field_embl_taxonomy_term_what
wp option update _options_embl_taxonomy_term_where field_embl_taxonomy_term_where
# Clear the cached API calls if any.
trash_ids="$(wp post list --post_type='vf_cache' --format=ids)"
......@@ -376,7 +397,7 @@ case "${COMMAND}" in
# Set the Gutenberg HTML content for the homepage of microsite
home_page_content=$(cat <<EOF
<!-- wp:vf/group-header {"ver":1} /-->
<!-- wp:vf/latest-posts {"ver":1} /-->
<!-- wp:acf/vfwp-latest-posts {"id":"block_5ea826258cfbb","name":"acf/vfwp-latest-posts"} /-->
<!-- wp:vf/data-resources {"ver":1} /-->
<!-- wp:vf/jobs {"limit":1,"filter":"all","ver":1} /-->
EOF);
......@@ -386,7 +407,7 @@ EOF);
wp post update $home_page_id --post_content="$home_page_content"
# Create About page - Create only if it doesn't exists.
if ! $(wp post list --post_type=page --fields=post_title | grep -qE "^About"); then
if ! $(wp post list --post_type=page --fields=post_title --format=csv | grep -qE "^About"); then
about_page_id="$(wp post create --post_title='About' --post_type=page --post_status=publish --porcelain)"
wp menu item add-post primary $about_page_id --title="About"
fi
......@@ -395,7 +416,7 @@ EOF);
echo "=== Members, about and blog ==="
# Create Members page - Create only if it doesn't exists.
if ! $(wp post list --post_type=page --fields=post_title | grep -qE "^Members"); then
if ! $(wp post list --post_type=page --fields=post_title --format=csv | grep -qE "^Members"); then
# Set the Gutenberg HTML content for the members page
IFS='' read -r members_page_content <<EOF
<!-- wp:vf/members {"ver":1} /-->
......@@ -410,7 +431,7 @@ EOF
fi
# Create Publications page - Create only if it doesn't exists.
if ! $(wp post list --post_type=page --fields=post_title | grep -qE "^Publications"); then
if ! $(wp post list --post_type=page --fields=post_title --format=csv | grep -qE "^Publications"); then
publications_page_id="$(wp post create --post_title='Publications' --post_type=page --post_status=publish --porcelain)"
wp menu item add-post primary $publications_page_id --title="Publications"
......@@ -422,13 +443,13 @@ EOF
fi
# Create blog page - Create only if it doesn't exists.
if ! $(wp post list --post_type=page --fields=post_title | grep -qE "^Blog"); then
if ! $(wp post list --post_type=page --fields=post_title --format=csv | grep -qE "^Blog"); then
blog_page_id="$(wp post create --post_title='Blog' --post_type=page --post_status=publish --porcelain)"
wp post meta update $blog_page_id vf_locked 1
wp post meta update $blog_page_id _vf_locked field_vf_locked
wp option update page_for_posts $blog_page_id
if ! $(wp menu item list primary --fields=title | grep -qE "^Blog"); then
if ! $(wp menu item list primary --fields=title --format=csv | grep -qE "^Blog"); then
wp menu item add-post primary $blog_page_id --title="Blog"
fi
fi
......@@ -471,16 +492,7 @@ EOF
# Update blog post content
wp post update 1 --post_title="Welcome to your new group or team blog!" --post_content="$default_blog_post_content";
# Set the VF Theme Color if not set
#db_theme_color_value="$(wp option pluck theme_mods_vf-themes vf_theme_color)"
if ! [[ `wp option pluck theme_mods_vf-wp-groups vf_theme_color` ]] ; then
# if [ -n "$db_theme_color_value" ]; then
wp option patch insert theme_mods_vf-wp-groups vf_theme_color "$VF_THEME_COLOR";
else
wp option patch update theme_mods_vf-wp-groups vf_theme_color "$VF_THEME_COLOR";
fi
wp post update 1 --post_title="Welcome to your new group or team blog!" --post_content="$default_blog_post_content" || true;
# Set the Google analytics settings
#db_ga_options_value="$(wp option pluck gap_options gap_id)"
......@@ -501,20 +513,38 @@ esac;
# Flush the rewrite cache from DB
wp rewrite flush
# Disable caching for testing downtime
#wp option set options_vf_cache_disabled 1
# Additional tasks only for microsites.
if [ "$MICROSITE_FLAG" -eq "1" ] ; then
# Apply SAML Unique entity config
wp option set onelogin_saml_advanced_settings_sp_entity_id "${ENVIRONMENT}.$MICROSITE_FOLDER_NAME"
# Install en_GB language
if ! $(wp language core list --status=installed --fields=language --format=csv | grep -qE "^en_GB"); then
wp language core install en_GB
wp site switch-language en_GB
fi
# Set default group_admin role (Generated by custom plugin) for any new register user
wp option set default_role "group_admin"
# Update capabilities for group_admin role.
wp cap add 'group_admin' 'edit_vf_blocks' 'publish_vf_blocks' 'edit_vf_containers' 'publish_vf_containers'
# Update DB if any.
wp core update-db
# Apply SAML config & other additional configs
PHP=`which php`;
$PHP -f ${MICROSITE_PATH}/bin/scripts/wp_vf_custom_code.php -- ${DEPLOY_PATH} ${ENVIRONMENT}
# Apply SAML Unique entity config -Don't apply for dummy sites
if [[ "$MICROSITE_FOLDER_NAME" != *dummy-* ]] ; then
wp option set onelogin_saml_advanced_settings_sp_entity_id "${ENVIRONMENT}.$MICROSITE_FOLDER_NAME"
$PHP -f ${MICROSITE_PATH}/bin/scripts/wp_vf_custom_code.php -- ${DEPLOY_PATH} ${ENVIRONMENT}
fi
# Close/delete comments & pingbacks
wp comment delete 1 --force || true
wp db query "DELETE FROM wp_comments WHERE comment_approved != 1;";
wp db query "DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM wp_comments);";
wp db query "UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed';";
wp db query "UPDATE wp_options SET option_value = 'closed' WHERE option_name = 'default_comment_status';";
wp db query "UPDATE wp_options SET option_value = 'closed' WHERE option_name = 'default_ping_status';";
# Set default group_admin role (Generated by custom plugin) for any new register user
wp option set default_role "group_editor"
# Clear the cached API calls if any.
trash_ids="$(wp post list --post_type='vf_cache' --format=ids)"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment