Add Magento 2 init scripts
This commit is contained in:
parent
3c7309f95d
commit
c7e0473bbf
3 changed files with 75 additions and 2 deletions
15
bin/findroot
Executable file
15
bin/findroot
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from mbutils import find_root
|
||||||
|
|
||||||
|
try:
|
||||||
|
print(find_root(*sys.argv[1:]))
|
||||||
|
sys.exit(0)
|
||||||
|
except IOError:
|
||||||
|
print("File not found in any directory", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
except TypeError:
|
||||||
|
print("No filename specified", file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
|
@ -6,6 +6,11 @@ from collections import OrderedDict
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
|
|
||||||
def find_in_parent(filename, starting_dir=None):
|
def find_in_parent(filename, starting_dir=None):
|
||||||
|
'''Look up the directory tree until you find a file.'''
|
||||||
|
root = find_root(filename, starting_dir)
|
||||||
|
return path.join(root, filename)
|
||||||
|
|
||||||
|
def find_root(filename, starting_dir=None):
|
||||||
'''Look up the directory tree until you find a file.'''
|
'''Look up the directory tree until you find a file.'''
|
||||||
if starting_dir is None:
|
if starting_dir is None:
|
||||||
starting_dir = os.getcwd()
|
starting_dir = os.getcwd()
|
||||||
|
@ -13,11 +18,11 @@ def find_in_parent(filename, starting_dir=None):
|
||||||
candidate_file = path.join(starting_dir, filename)
|
candidate_file = path.join(starting_dir, filename)
|
||||||
|
|
||||||
if (path.isfile(candidate_file)):
|
if (path.isfile(candidate_file)):
|
||||||
return candidate_file
|
return starting_dir
|
||||||
elif starting_dir == '/':
|
elif starting_dir == '/':
|
||||||
raise IOError('File not found in any directory')
|
raise IOError('File not found in any directory')
|
||||||
else:
|
else:
|
||||||
return find_in_parent(filename, path.dirname(starting_dir))
|
return find_root(filename, path.dirname(starting_dir))
|
||||||
|
|
||||||
def _parse_composer_manifest(path):
|
def _parse_composer_manifest(path):
|
||||||
'''Parse composer.json into dict'''
|
'''Parse composer.json into dict'''
|
||||||
|
|
|
@ -136,4 +136,57 @@ setopt extended_history
|
||||||
# to do things correctly and see if it's slow.
|
# to do things correctly and see if it's slow.
|
||||||
setopt hist_lex_words
|
setopt hist_lex_words
|
||||||
|
|
||||||
|
# Liquid Prompt!
|
||||||
source "$HOME/.zsh/liquidprompt/liquidprompt"
|
source "$HOME/.zsh/liquidprompt/liquidprompt"
|
||||||
|
|
||||||
|
# Create MySQL Docker container
|
||||||
|
function provision_mysql {
|
||||||
|
mkdir -p "$HOME/Data/5.6/data" && docker run -d\
|
||||||
|
--name="mysql-5.6" \
|
||||||
|
-e "MYSQL_ROOT_PASSWORD=root" \
|
||||||
|
-p 33306:3306 \
|
||||||
|
-v "$HOME/Data/5.6/data:/tmp/data" \
|
||||||
|
-v "/var/lib/mysql" \
|
||||||
|
"mysql:5.6"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Access MySQL Docker container
|
||||||
|
alias mysql='docker exec -it "mysql-5.6" mysql -uroot -proot'
|
||||||
|
|
||||||
|
# Install Magento 2
|
||||||
|
function install_magento {
|
||||||
|
local host="$1"
|
||||||
|
local db_name="$2"
|
||||||
|
|
||||||
|
n98-magerun2 setup:install \
|
||||||
|
--admin-firstname="Max" \
|
||||||
|
--admin-lastname="Bucknell" \
|
||||||
|
--admin-email="me@maxbucknell.com" \
|
||||||
|
--admin-user="max.bucknell" \
|
||||||
|
--admin-password="password123" \
|
||||||
|
--base-url="http://$host:15013/index.php/" \
|
||||||
|
--backend-frontname="admin" \
|
||||||
|
--db-host="127.0.0.1:33306" \
|
||||||
|
--db-name="$db_name" \
|
||||||
|
--db-user="root" \
|
||||||
|
--db-password="root" \
|
||||||
|
--language="en_US" \
|
||||||
|
--currency="EUR" \
|
||||||
|
--timezone="UTC" \
|
||||||
|
--use-rewrites="1" \
|
||||||
|
--use-secure="0" \
|
||||||
|
--use-secure-admin="0" \
|
||||||
|
--admin-use-security-key="0" \
|
||||||
|
--session-save="files"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find root of Magetno 2 installation
|
||||||
|
alias find_magento_root='findroot "app/etc/config.php"'
|
||||||
|
|
||||||
|
# Start M2 server
|
||||||
|
function serve_m2 {
|
||||||
|
local root="$(find_magento_root)"
|
||||||
|
pushd "$root/pub"
|
||||||
|
php -S "0.0.0.0:15013" "../phpserver/router.php" "../pub"
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue