Skip to content

Instantly share code, notes, and snippets.

@rachelwhitton
rachelwhitton / .lando.yml
Created September 17, 2021 16:25
lando inst fixes
name: inst
recipe: pantheon
config:
framework: drupal8
site: inst
id: a68cc9c7-e79f-4689-a3d8-6105d8a80fbf
services:
myservice:
type: redis
portforward: true
@rachelwhitton
rachelwhitton / settings.php
Created April 29, 2020 16:09
Example Drupal 7 cache conditional for Pantheon environments
<?php
// All Pantheon Environments.
if (defined('PANTHEON_ENVIRONMENT')) {
// Drupal caching in development environments.
if (!in_array(PANTHEON_ENVIRONMENT, array('test', 'live'))) {
// Anonymous caching.
$conf['cache'] = 0;
// Block caching - disabled.
$conf['block_cache'] = 0;
@rachelwhitton
rachelwhitton / logs.sh
Last active February 12, 2020 16:11
Gather all logs across all application containers for Live environment on Pantheon
#!/bin/bash
# Exit on error
set -e
# This tool will:
# * Create a Directory to store the site environment logs
# * Download all the logs of a given site environment
# NOTE: You need to be a member of the site for this process to work
@rachelwhitton
rachelwhitton / audit-cname-values.sh
Created December 9, 2019 23:18
Given a txt file of CNAME values, audit for values that resolve to Pantheon
#!/bin/bash
PANTHEON_GLOBAL_CDN=(23.185.0.1 23.185.0.2 23.185.0.3 23.185.0.4)
while IFS='' read -r l || [ -n "$l" ]; do
IP=`dig +short $l | grep '^[.0-9]*$'`
if [[ "${PANTHEON_GLOBAL_CDN[@]}" =~ $IP ]];
then
echo "yes '$l'" >> CNAMEpointsToPantheon.txt ;
else
echo "no";
fi
@rachelwhitton
rachelwhitton / ipblock.settings.php
Created November 26, 2019 19:51
PHP example that forbids requests from IPs not allowed
<?php
//Redirect /user and /admin pages for non-department IPs
function ip_in_list($ips) {
foreach(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']) as $check_ip) {
foreach($ips as $ip) {
if(FALSE !== strpos($check_ip, $ip)) {
@rachelwhitton
rachelwhitton / sobole.zsh-theme
Created November 22, 2019 19:10
Slightly customized Sobole theme /Users/rachel/.oh-my-zsh/custom/themes/
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@rachelwhitton
rachelwhitton / logs.sh
Last active December 12, 2019 15:57
Gather logs from all containers on Live environment
# Prompt for the desired site UUID
echo Provide the desired site UUID, then press [ENTER]:
read SITE_UUID
for app_server in `dig +short appserver.live.$SITE_UUID.drush.in`;
do
mkdir $app_server
sftp -o Port=2222 live.$SITE_UUID@$app_server << !
cd logs
lcd $app_server
@rachelwhitton
rachelwhitton / renewal-report.sh
Last active March 21, 2019 21:16
Audit sustained traffic patterns, custom domain usage, and compare legacy to new site plans.
#!/bin/bash
# Prompt for the desired org UUID or name
echo Provide the desired org UUID or name, then press [ENTER]:
read PANTHEON_ORG
# Get a list of all sites in the org
PANTHEON_SITES="$(terminus org:site:list -n ${PANTHEON_ORG} --format=list --field=Name)"
# Name the CSV output file
@rachelwhitton
rachelwhitton / find_module.sh
Last active March 21, 2019 21:30
Search org for module or plugin
echo ORG:
read ORG
echo ENV:
read ENV
echo MODULE:
read MODULE
SITES=`terminus site:list --org=$ORG --format=list --field=name | sort`
for SITE in $SITES; do
echo "$SITE "
terminus drush $SITE.$ENV -- pml | grep $MODULE
#!/bin/bash
terminus site:list --org="Org Name" --format=list > ./org_sites.txt
while IFS= read -r site;
do
terminus site:info "$site" --field name && terminus env:info "$site".live --field php_version
done < ./org_sites.txt