Skip to content

Instantly share code, notes, and snippets.

@mkllnk
mkllnk / post-receive
Created April 19, 2019 04:38
Generic Git post-receive hook to trigger a deployment script
#!/bin/sh
set -e
# GIT_DIR is usually set to `.` and we need to change into the work tree.
cd "$GIT_DIR/.." || exit 1
unset GIT_DIR
# The just uploaded commit to deploy:
NEWREF="$(cat /dev/stdin | cut -d ' ' -f 2)"
@mkllnk
mkllnk / post-receive
Created July 11, 2018 08:49
OFN Aus deployment script
#!/bin/sh
set -e
APP_PATH="$HOME/apps/openfoodnetwork"
CURRENT_PATH="/home/openfoodnetwork/apps/openfoodnetwork/current"
SHARED_PATH="/home/openfoodnetwork/apps/openfoodnetwork/shared"
CONFIG_PATH="/home/openfoodnetwork/apps/openfoodnetwork/shared/config"
BUNDLE="$HOME/.rbenv/shims/bundle"
GEM_PATH="/home/openfoodnetwork/.gem"
cd /var/discourse/
./launcher enter app
# vi config/discourse_defaults.conf
## sidekiq_workers = 1
# sv reload unicorn
# ps fax | grep sidek
# kill -STOP 10641
# for i in `seq 5`; do kill -CONT 10641; sleep 5; kill -STOP 10641; sleep 5; done
# kill -CONT 10641
#!/bin/sh
# This executes `git push` and then calls Shopify's theme command to update the associated theme.
# You can easily replace the theme command with another deploy command you like to be executed.
if ! test -e config.yml; then
echo "Error: not in theme directory"
exit 1
fi
@mkllnk
mkllnk / github-pull
Last active June 29, 2023 04:40
Checkout pull requests from other repositories in Github
#!/bin/bash
#set -ex
usage=" Usage: $0 <repo> <branch>
or: $0 user:branch
Example: $0 Em-AK/openfoodnetwork.git i18n-tests
$0 Em-AK:i18n-tests"
#!/bin/sh
#
# Pre-conditions:
# - You have SFTP access.
# - You have sshfs installed.
# - You have certbot installed.
domain='example.org'
mkdir -p "/tmp/$domain"
@mkllnk
mkllnk / certbot-ssl-renewal
Created April 9, 2017 03:07
Certbot SSL renew script for cron
#!/bin/sh
# This script is to be placed in /etc/cron.daily/. Make it executable:
#
# chmod +x /etc/cron.daily/certbot-ssl-renewal
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH
@mkllnk
mkllnk / fairfood-deploy-prod
Created March 23, 2017 04:10
Fairfood deploy sripts
#!/bin/sh
set -xe
git status | grep -F '# On branch master'
last_tag="$(git tag | grep -E '^[0-9]{4}\.' | tail -1)"
next_tag="$1"
# Check that a tag is given
@mkllnk
mkllnk / watch-html-php.sh
Created January 22, 2017 06:46
Watch PHP files and convert them to HTML when they change
#!/bin/bash
dir="${1-.}"
inotifywait -r -m -e CLOSE_WRITE "$dir" |
grep '\.html\.php$' --line-buffered |
while read path _ file; do
dstfile="$path${file%.php}"
echo "Processing $path$file $dstfile"
php "$path$file" > "$dstfile"
@mkllnk
mkllnk / post-receive
Created December 7, 2016 23:50
Git post-receive hook example for push deploy
#!/bin/sh
# GIT_DIR='.'
#
# on stdin:
# oldrev: old commit id like 0000000000000000000000000000000000000000
# newrev: new commit id like d26d82b03fbe38646941b6efb89827c88efa81e5
# refname: branch reference like refs/heads/master
# Deploy only the master branch and ignore the rest