-
-
Notifications
You must be signed in to change notification settings - Fork 449
Added DDEV command to install OM (incl. sample data) #3248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5556483
Added ddev install script
sreichel a5fb152
Added db-prefix option (prefix does not work!)
sreichel a343d70
Added flags
sreichel 6bc9311
Added quiet install flag
sreichel 4f8be64
@ADDISON74 suggestions
sreichel 68c2f3f
Updated flags, fix --help
sreichel 8d38d9d
Minor change
sreichel bbe56c5
Wording
sreichel decfcb6
Disallow table-prefix when sample data is used
sreichel 5e38ffe
Merge branch 'main' into ddev-reinstall
sreichel 8275b2b
Added default table prefix
sreichel 72d6004
Merge branch 'main' into ddev-reinstall
sreichel 196b709
Fixed table prefix
sreichel 7680f73
phrase-changes
addison74 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/bin/bash | ||
|
||
## ProjectTypes: magento | ||
## Description: Install OpenMage | ||
## Usage: openmage-install [-d|--default] [-s|--sampledata] [-k|--keep] [-q|--quiet] | ||
## Example: ddev openmage-install -d -s -k | ||
## Flags: [{"Name":"default","Shorthand":"d","Usage":"use default values"},{"Name":"sampledata","Shorthand":"s","Usage":"install sample data"},{"Name":"keep","Shorthand":"k","Usage":"keep sample data package"},{"Name":"quiet","Shorthand":"q","Usage":"silent install with sample data"}] | ||
|
||
ROOT="${PWD}" | ||
|
||
QUIET_INSTALL_FLAG='' | ||
SAMPLE_DATA_FLAG='' | ||
SAMPLE_DATA_KEEP_FLAG='' | ||
USE_DEFAULT_FLAG='' | ||
|
||
while :; do | ||
case ${1:-} in | ||
-d|--default) | ||
USE_DEFAULT_FLAG='true' ;; | ||
-s|--sampledata) | ||
SAMPLE_DATA_FLAG='true' ;; | ||
-k|--keep) | ||
SAMPLE_DATA_KEEP_FLAG='true' ;; | ||
-q|--quiet) | ||
QUIET_INSTALL_FLAG='true' | ||
USE_DEFAULT_FLAG='true' | ||
SAMPLE_DATA_FLAG='true' | ||
;; | ||
--) # End of all options. | ||
shift | ||
break | ||
;; | ||
-?*) | ||
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 | ||
;; | ||
*) # Default case: No more options, so break out of the loop. | ||
break | ||
esac | ||
|
||
shift | ||
done | ||
|
||
LOCALXML="${ROOT}/app/etc/local.xml" | ||
if [ -f "${LOCALXML}" ]; then | ||
if [[ "${QUIET_INSTALL_FLAG}" ]]; then | ||
DELETE='y' | ||
else | ||
read -r -p "OpenMage is already installed. Delete local.xml and drop the database? [y/N] " DELETE | ||
DELETE=${DELETE,,} # to lower | ||
fi | ||
|
||
if [[ "${DELETE}" =~ ^(yes|y) ]]; then | ||
mysql -u db -h db -e "DROP SCHEMA IF EXISTS db; CREATE SCHEMA db;"; | ||
rm "${LOCALXML}" | ||
else | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# install sample data | ||
if [[ "${SAMPLE_DATA_FLAG}" ]]; then | ||
INSTALL_SAMPLE_DATA='y' | ||
else | ||
read -r -p "Install Sample Data? [y/N] " INSTALL_SAMPLE_DATA | ||
INSTALL_SAMPLE_DATA=${INSTALL_SAMPLE_DATA,,} # to lower | ||
fi | ||
|
||
if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then | ||
SAMPLE_DATA_URL=https://github.com/Vinai/compressed-magento-sample-data/raw/master/compressed-magento-sample-data-1.9.2.4.tgz | ||
SAMPLE_DATA_DIRECTORY="${ROOT}/.sampleData" | ||
SAMPLE_DATA_FILE=sample_data.tgz | ||
|
||
if [[ ! -d "${SAMPLE_DATA_DIRECTORY}" ]]; then | ||
echo "Creating Sample Data directory..." | ||
mkdir -p "${SAMPLE_DATA_DIRECTORY}" | ||
fi | ||
|
||
cd "${SAMPLE_DATA_DIRECTORY}" || exit | ||
if [[ ! -f "${SAMPLE_DATA_DIRECTORY}/${SAMPLE_DATA_FILE}" ]]; then | ||
echo "Downloading Sample Data..." | ||
wget "${SAMPLE_DATA_URL}" -O "${SAMPLE_DATA_FILE}" | ||
fi | ||
|
||
echo "Uncompressing Sample Data..." | ||
tar xf "${SAMPLE_DATA_FILE}" | ||
|
||
echo "Copying Sample Data into the OpenMage directory..." | ||
cp -r magento-sample-data-1.9.2.4/* "${ROOT}/" | ||
|
||
echo "Importing Sample Data into the database..." | ||
mysql -u db -h db db < "${SAMPLE_DATA_DIRECTORY}/magento-sample-data-1.9.2.4/magento_sample_data_for_1.9.2.4.sql" | ||
|
||
# remove sample data | ||
if [[ "${SAMPLE_DATA_KEEP_FLAG}" ]]; then | ||
rm -rf $( | ||
find . -maxdepth 1 -type f -name "*" ! -name "${SAMPLE_DATA_FILE}") | ||
else | ||
cd "${ROOT}" || exit | ||
rm -rf "${SAMPLE_DATA_DIRECTORY}" | ||
fi | ||
fi | ||
|
||
cd "${ROOT}" || exit | ||
|
||
if [[ "${USE_DEFAULT_FLAG}" ]]; then | ||
ADMIN_USER='admin' | ||
ADMIN_FIRSTNAME='OpenMage' | ||
ADMIN_LASTNAME='Administrator' | ||
ADMIN_EMAIL='[email protected]' | ||
ADMIN_PASSWORD='veryl0ngpassw0rd' | ||
TABLE_PREFIX='om_' | ||
else | ||
read -r -p "Admin User [admin]: " ADMIN_USER | ||
ADMIN_USER=${ADMIN_USER:-admin} | ||
read -r -p "Admin Firstname [OpenMage]: " ADMIN_FIRSTNAME | ||
ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-OpenMage} | ||
read -r -p "Admin Lastname [Administrator]: " ADMIN_LASTNAME | ||
ADMIN_LASTNAME=${ADMIN_LASTNAME:-Administrator} | ||
read -r -p "Admin Email [[email protected]]: " ADMIN_EMAIL | ||
ADMIN_EMAIL=${ADMIN_EMAIL:[email protected]} | ||
read -r -p "Admin Password [veryl0ngpassw0rd]: " ADMIN_PASSWORD | ||
ADMIN_PASSWORD=${ADMIN_PASSWORD:-veryl0ngpassw0rd} | ||
if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then | ||
TABLE_PREFIX='' | ||
else | ||
read -r -e -i 'om_' -p "Table Prefix [om_]: " TABLE_PREFIX | ||
fi | ||
fi | ||
|
||
php -f install.php -- \ | ||
--license_agreement_accepted 'yes' \ | ||
--locale 'en_US' \ | ||
--timezone 'America/New_York' \ | ||
--db_host 'db' \ | ||
--db_name 'db' \ | ||
--db_user 'db' \ | ||
--db_pass 'db' \ | ||
--db_prefix "${TABLE_PREFIX}" \ | ||
--url "${DDEV_PRIMARY_URL}" \ | ||
--use_rewrites 'yes' \ | ||
--use_secure 'yes' \ | ||
--secure_base_url "${DDEV_PRIMARY_URL}" \ | ||
--use_secure_admin 'yes' \ | ||
--admin_username "${ADMIN_USER}" \ | ||
--admin_lastname "${ADMIN_LASTNAME}" \ | ||
--admin_firstname "${ADMIN_FIRSTNAME}" \ | ||
--admin_email "${ADMIN_EMAIL}" \ | ||
--admin_password "${ADMIN_PASSWORD}" \ | ||
--session_save 'files' \ | ||
--admin_frontname 'admin' \ | ||
--backend_frontname 'admin' \ | ||
--default_currency 'USD' \ | ||
--enable_charts 'yes' \ | ||
--skip_url_validation 'yes' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.