-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint
executable file
·135 lines (126 loc) · 4.21 KB
/
entrypoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash -e
# functions & common bits
HAS_DB_CREDS=
DB_HOST=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
setup_db_creds () {
if [ -f ./app/etc/env.php ]; then
DB_HOST=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["host"].PHP_EOL;');
DB_DATABASE=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["dbname"].PHP_EOL;');
DB_USERNAME=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["username"].PHP_EOL;');
DB_PASSWORD=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["password"].PHP_EOL;');
else
echo "[error] './app/etc/env.php' not found, please ensure you are running from Magento root."
exit 2
fi
}
# reduce/remove captcha threshold
CAPTCHA_THRESHOLD="0.0"
# will only work on MDOQ
CAPTCHA_PUBLIC_KEY=6Lf3dMwgAAAAADj1nNGMR8232JBU-0z8NQYLdSBa
CAPTCHA_PRIVATE_KEY=6Lf3dMwgAAAAAHwqAbn7nrR5jbbbaEZ1A-_X6F_5
captcha () {
if [ -z "${SKIP_CAPTCHA}" ]; then
echo "[info] reducing captcha threshold (${CAPTCHA_THRESHOLD})"
mysql -h ${DB_HOST} -u ${DB_USERNAME} -p${DB_PASSWORD} ${DB_DATABASE} -e "delete from core_config_data where path = 'recaptcha_frontend/type_recaptcha_v3/score_threshold';"
php bin/magento config:set -- recaptcha_frontend/type_recaptcha_v3/score_threshold 0
else
echo "[info] skiping captcha"
fi
}
captchaHelp () {
echo "--skip-captcha skips captcha functionality
--captcha-threshold= change the captcha threshold (default 0.0)
--captcha-public-key= change the public key used for captcha (default will work on MDOQ)
--captcha-private-key= change the private key used for captcha (default will work on MDOQ)"
}
# Admin security bits
# # Allows some GI tests using URLs to run without issue
# php bin/magento config:set admin/security/use_form_key 0
adminSecurityAccountSharing () {
if [ -z "${SKIP_ADMIN_ACCOUNT_SHARING}" ]; then
echo "[info] enabling admin account sharing"
php bin/magento config:set admin/security/admin_account_sharing 1
else
echo "[info] skiping enabling admin account sharing"
fi
}
adminSecurityDisableFormKey () {
if [ -z "${SKIP_ADMIN_FORM_KEY}" ]; then
echo "[info] disabling admin form key"
php bin/magento config:set admin/security/use_form_key 0
else
echo "[info] skiping disabling admin form key"
fi
}
adminSecurityHelp () {
echo "--skip-account-sharing skips enabling admin account sharing
--skip-disable-form-key skips disabling admin form key"
}
help () {
echo "ZERO1 Common PRA's for use on MDOQ"
echo "----------------------------------"
captchaHelp
adminSecurityHelp
echo "----------------------------------"
echo "see repo for more info: https://github.com/zero1limited/mdoq-pras"
}
################################################################
# SCRIPT ENTRY #
################################################################
# Parse Arguments
SKIP_CAPTCHA=
SKIP_ADMIN_ACCOUNT_SHARING=
SKIP_ADMIN_FORM_KEY=
for i in "$@"; do
case $i in
--skip-captcha)
SKIP_CAPTCHA="1"
;;
--captcha-threshold=*)
CAPTCHA_THRESHOLD="${i#*=}"
shift
;;
--captcha-public-key=*)
CAPTCHA_PUBLIC_KEY="${i#*=}"
shift
;;
--captcha-threshold=*)
CAPTCHA_PRIVATE_KEY="${i#*=}"
shift
;;
--skip-account-sharing)
SKIP_ADMIN_ACCOUNT_SHARING="1"
;;
--skip-disable-form-key)
SKIP_ADMIN_FORM_KEY="1"
;;
--help|-h|"?")
help
exit 0
;;
-v|--verbose)
set -x
;;
-*|--*)
echo "unexpected argument: '${i}'"
echo "run '${0} --help' for more information"
exit 1;
;;
*)
echo "unexpected value: '${i}'"
echo "run '${0} --help' for more information"
exit 1;
;;
esac
done
# Setup common bits
setup_db_creds
# run what we want
captcha
adminSecurityAccountSharing
adminSecurityDisableFormKey
# finally flush cache
php bin/magento cache:flush