Giter Site home page Giter Site logo

vcao / craft-scripts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nystudio107/craft-scripts

0.0 2.0 0.0 14 KB

Shell scripts to manage permissions, asset syncing, and database syncing between Craft CMS environments

License: MIT License

Shell 100.00%

craft-scripts's Introduction

craft-scripts fork by vcao

The original set of shell scripts are designed to manage permissions, asset syncing, and database syncing between Craft CMS environments. The original code was developed by nystudio107

I've added the ability to ssh into virtualized environments or your staging server. The issue I experienced was that I couldn't run mysql commands on a host machine; I actually need to do it on the virtualized development environment. I need to run the commands from the host machine, since I'm not in the virtualized environment 24/7.

Overview

There are several scripts included in craft-scripts, each of which perform different functions. They all use a shared .env.sh to function. This .env.sh should be created on each environment where you wish to run the craft-scripts, and it should be excluded from your git repo via .gitignore.

set_perms.sh

The set_perms.sh script sets the Craft CMS install file permissions in a strict manner, to assist in hardening Craft CMS installs.

See Hardening Craft CMS Permissions for a detailed writeup.

pull_db.sh

The pull_db.sh script pulls down a database dump from a remote server, and then dumps it into your local database

See Database & Asset Syncing Between Environments in Craft CMS for a detailed writeup.

pull_assets.sh

The pull_assets.sh script pulls down an arbitrary number of asset directories from a remote server, since we keep client-uploadable assets out of the git repo

See Database & Asset Syncing Between Environments in Craft CMS for a detailed writeup.

Setting it up

  1. Download or clone the craft-scripts git repo
  2. Copy the scripts directory into the root directory of your Craft CMS project
  3. Duplicate the example.env.sh file, and rename it to .env.sh
  4. Add .env.sh to your .gitignore file
  5. Then open up the .env.sh file into your favorite editor, and replace REPLACE_ME with the appropriate settings.

All configuration is done in the .env.sh file, rather than in the scripts themselves. This is is so that the same scripts can be used in multiple environments such as local dev, staging, and live production without modification. Just create a .env.sh file in each environment, and keep it out of your git repo via .gitignore.

Local Settings

All settings that are prefaced with LOCAL_ refer to the local environment where the script will be run, not your local dev environment.

LOCAL_ROOT_PATH is the absolute path to the root of your local Craft install, with a trailing / after it.

LOCAL_ASSETS_PATH is the relative path to your local assets directories, with a trailing / after it.

LOCAL_CHOWN_USER is the user that is the owner of your entire Craft install.

LOCAL_CHOWN_GROUP is your webserver's group, usually either nginx or apache.

LOCAL_WRITEABLE_DIRS is a quoted list of directories relative to LOCAL_ROOT_PATH that should be writeable by your webserver.

LOCAL_ASSETS_DIRS is a quoted list of asset directories relative to LOCAL_ASSETS_PATH that you want to pull down from the remote server. It's done this way in case you wish to sync some asset directories, but not others. If you want to pull down all asset directories in LOCAL_ASSETS_PATH, just leave one blank quoted string in this array

LOCAL_SSH_LOGIN is your ssh login to your local development server (e.g. Vagrant). For a Vagrant setup it's often vagrant@IP_ADDRESS. FYI your development server should be able to connect to your production server via passwordless SSH.

LOCAL_SSH_PORTis the port to use for ssh on the development server. This is normally 22

LOCAL_DB_NAME is the name of the local mysql Craft CMS database

LOCAL_DB_PASSWORD is the password for the local mysql Craft CMS database

LOCAL_DB_USER is the user for the local mysql Craft CMS database

LOCAL_MYSQL_CMD is the command for the local mysql executable, normally just mysql. It is provided because some setups like MAMP require a full path to a copy of mysql inside of the application bundle.

LOCAL_MYSQLDUMP_CMD is the command for the local mysqldump executable, normally just mysqldump. It is provided because some setups like MAMP require a full path to a copy of mysqldump inside of the application bundle.

Remote Settings

All settings that are prefaced with REMOTE_ refer to the remote environment where assets and the database will be pulled from.

REMOTE_SSH_LOGIN is your ssh login to the remote server, e.g.: [email protected]

REMOTE_SSH_PORT is the port to use for ssh on the remote server. This is normally 22

REMOTE_ROOT_PATH is the absolute path to the root of your Craft install on the remote server, with a trailing / after it.

REMOTE_ASSETS_PATH is the relative path to the remote assets directories, with a trailing / after it.

REMOTE_DB_HOST is the host name of the remote mysql Craft CMS database. This is normally localhost

REMOTE_DB_PORT is the port number of the remote mysql Craft CMS database. This is normally 3306

REMOTE_DB_NAME is the name of the remote mysql Craft CMS database

REMOTE_DB_PASSWORD is the password for the remote mysql Craft CMS database

REMOTE_DB_USER is the user for the remote mysql Craft CMS database

Craft-Scripts Changelog

1.0.1 -- 2017.01.20

  • [Added] Forked release

Original code brought to you by nystudio107

Forked by Victor Cao

craft-scripts's People

Contributors

khalwat avatar dennisfrank avatar jackbewley avatar vcao avatar martinherweg avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.