Skip to content

Instantly share code, notes, and snippets.

View mattbloomfield's full-sized avatar

Matt Bloomfield mattbloomfield

View GitHub Profile
@mattbloomfield
mattbloomfield / sync_local.sh
Last active April 2, 2021 15:34
Custom `pull` command to sync your local db with a remote env
#!/bin/sh
# This command is used for when assets are stored locally. For AWS syncing, see sync_aws.sh
## Custom `pull` command to sync your local db with a remote env.
## NOTE THAT THIS WILL REPLACE YOUR EXISTING DATABASE
## Usage: fin sync
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
@mattbloomfield
mattbloomfield / ssh.sh
Created April 2, 2021 14:56
Easy way to SSH into a psh env
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Easy way to SSH into a psh env
## Usage: fin ssh <environment>
@mattbloomfield
mattbloomfield / setup.sh
Created April 2, 2021 14:55
To be run once - upon first install
# This is dependent on other jobs. Please download them from gist.github.com/mattbloomfield
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
@mattbloomfield
mattbloomfield / replicate_deploy.sh
Created April 2, 2021 14:53
Replicates a deploy in a platform.sh environment
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Replicates a deploy in a platform.sh environment
## Usage: fin replicate_deploy
@mattbloomfield
mattbloomfield / handler.js
Created April 2, 2021 14:53
Lambda Function to retrieve the .env file for a site based on sitename
"use strict";
module.exports.endpoint = async (event, context, callback) => {
const queryParams = event.queryStringParameters;
if (!queryParams) callback("No query params");
const devUser = queryParams.user;
const site = queryParams.site;
const key = queryParams.key;
@mattbloomfield
mattbloomfield / refresh_env
Created April 2, 2021 14:48
Useful to refresh your local .env file
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Useful to refresh your local .env file
## Usage: fin refresh_env
@mattbloomfield
mattbloomfield / push_files.sh
Created April 2, 2021 14:43
Custom `push` command to sync your local files to a remote env.
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Custom `pull` command to sync your local files with a remote env.
## Usage: fin sync_files
@mattbloomfield
mattbloomfield / logs.sh
Created April 2, 2021 14:42
Tails the logs output by CraftCMS
#!/usr/bin/env bash
## Tails the logs output by CraftCMS
## Usage: fin logs
# Forces whole job to error on failure
set -e
fin exec "tail -f storage/logs/*"
@mattbloomfield
mattbloomfield / init.sh
Created April 2, 2021 14:40
Removes any previous containers this project may have created, then starts and executes npm install/composer install
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Removes any previous containers this project may have created, then starts and executes npm install/composer install
## Usage: fin init
@mattbloomfield
mattbloomfield / db_dump.sh
Created April 2, 2021 14:39
Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
#!/bin/bash
## Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
## Usage: fin db_dump [path]
# Forces whole job to error on failure
set -e
TRANSACTION_ID=$(date +"%Y-%m-%d_%H-%M-%S")
SAVE_PATH=$1