Skip to content

Instantly share code, notes, and snippets.

View onnimonni's full-sized avatar

Onni Hakala onnimonni

View GitHub Profile
@onnimonni
onnimonni / multisite-readme.md
Last active December 12, 2016 17:48
Ohjeet Multisiten asentaminen ja käyttämisestä

Steps for multisite

Tehdään alusta alkaen multisite eikä muuteta kesken singlesiteä multisiteksi.

Multisiten yläsivusto on syytä jättää tyhjäksi vain hallintatoimenpiteitä varten

Domain aliasten tekemiseen käytetään mercatoria

https://github.com/humanmade/Mercator

Tee lisäksi mu-plugari mikä disabloi SSO:n jotta ei saada redirect looppeja

@onnimonni
onnimonni / flynn-login.sh
Last active November 28, 2016 10:13
Flynn cluster login helper
#!/bin/bash
##
# Login into any Flynn node without checking strict host key checking and run given command
# $1 - address for the cluster
# $2...n - command to run in server
##
function flynn_ssh_helper() {
cluster_domain=$1
ssh -oStrictHostKeyChecking=no $(dig +short $cluster_domain | head -n1) "${@:2}" 2>/dev/null
@onnimonni
onnimonni / mercator-https-domain-alias.php
Created November 8, 2016 07:07
Redirects alias site wp-admin to original site admin when using mercator plugin https://github.com/humanmade/Mercator.
<?php
/**
* Plugin Name: Mercator https domain alias
* Description: Redirects mercator aliases into main site when wp-admin is accessed
* Version: 0.1
* Author: Onni Hakala / Geniem Oy
* Author URI: https://github.com/onnimonni
* License: MIT
*/
@onnimonni
onnimonni / wpai-run-imports.sh
Created September 19, 2016 06:58
Helper bash script which you can use to run wp all import synchronously. This also outputs problems which you may have with wpai.
#!/bin/bash
##
# Script to run WP All Import scripts sychronously with cron
##
# This is default wp core directory for us
ABSPATH="/var/www/project/wp"
function usage()
{
@onnimonni
onnimonni / disable-updates-and-external-connections.php
Last active August 26, 2016 07:21
Instead of using this small hack consider using this plugin https://github.com/devgeniem/wp-core-blocker. It takes care of much more edge cases and core functionality.
<?php
/**
* Plugin Name: Disable All Updates and External Connections
* Description: Plugin which disables core, plugin and theme updates and connections to wordpress.org This is quite useful in local development
* Version: 1.0.0
* Author: Onni Hakala
* Author URI: https://github.com/onnimonni
* License: MIT License
*/
@onnimonni
onnimonni / init-envs.sh
Created August 22, 2016 11:01
Docker startup script to setup all ENVs to PHP-FPM ENVs
#!/bin/bash
##
# This startup script adds all docker container ENVs to php-fpm ENVs by adding them into static config file
##
php_config_file=/etc/php-fpm.d/env.conf
# Don't recreate the php-fpm file if it exists ( the container was restarted )
if [ ! -f $php_config_file ];
then
@onnimonni
onnimonni / validate_sha256sum
Last active May 8, 2024 11:53
Shell script to validate file sha256 hashes. I use this to check if downloaded binaries are correct in Dockerfiles. This might make updating harder but at least it you see which parts have been updated since the last run.
#!/bin/sh
##
# This script contains helper for sha256 validating your downloads
#
# Source: https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
# Author: Onni Hakala
# License: MIT
##
# Stop program and give error message
@onnimonni
onnimonni / env-susbst.sh
Last active August 3, 2016 20:28 — forked from pebo/env-susbst.sh
envsubst like substitution; only replacing $VAR or ${VAR} if they have a value in in env
#!/bin/bash
# envsubst like substitution; only replacing ${VAR} if they exists
# based on http://mywiki.wooledge.org/TemplateFiles
# source: https://gist.github.com/pebo/c30d9b4819e908a305244874c916a4dc
while read -r; do
while [[ $REPLY =~ \$(\{([a-zA-Z_][a-zA-Z_0-9]*)\})(.*) ]]; do
if [[ -n ${!BASH_REMATCH[2]} ]]; then
printf %s "${REPLY%"$BASH_REMATCH"}${!BASH_REMATCH[2]}"
else
printf %s "${REPLY%"$BASH_REMATCH"}\$${BASH_REMATCH[2]}"
@onnimonni
onnimonni / run-wp-cron.sh
Created July 7, 2016 12:49 — forked from bjornjohansen/run-wp-cron.sh
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
#!/bin/bash
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
# Source: https://bjornjohansen.no/wordpress-cron-wp-cli
# Github: https://gist.github.com/bjornjohansen/a00a9fee5475c4dadb56#file-run-wp-cron-sh
# This is modified for our container. In this container you don't need to use --path
# because it's automatically included
@onnimonni
onnimonni / synchronized-wpallimport.sh
Created June 2, 2016 09:09
Synchronized wpallimport with php-cli. This is really a big hack and I think that wpallimport should be avoided. But if you have to stick with it and need to do multiple imports after each other this works.
#!/bin/bash
set -ex
# This is a hack to use wpallimport without http request.
# We need this to be synchronized so that importers don't overlap and cause too much strain
# Import Asunnot with wpallimport
php -e -r 'parse_str("import_key=XXXXXXXXX&import_id=16&action=trigger", $_GET); include "/data/code/web/wp/wp-cron.php";'
# Wait until importer is ready