Skip to content

Commit

Permalink
use a flag file to track mkcert CA install status
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbentrup committed Sep 14, 2020
1 parent 9b611fb commit f54c8a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 4 additions & 12 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ handler_log_file="$mdm_path/handler.log"
dockerize_log_file="$mdm_path/dockerize.log"
docker_settings_file="$HOME/Library/Group Containers/group.com.docker/settings.json"
advanced_mode_flag_file="$mdm_path/advanced-mode-on"
mkcert_installed_flag_file="$mdm_path/.mkcert-installed"
rel_app_config_file="app/.mdm_app_config"
mdm_ver_file="$mdm_path/latest-sem-ver"
magento_cloud_cmd="$HOME/.magento-cloud/bin/magento-cloud"
Expand Down Expand Up @@ -396,18 +397,9 @@ is_running_as_sudo() {
}

is_mkcert_CA_installed() {
local warning_count status=0
is_mkcert_installed || return 1
if is_mac; then
security dump-trust-settings -d | grep -q mkcert || status="$?"
return "$status"
elif is_CI; then
warning_count="$(mkcert 2>&1 | grep -c "Warning:")"
# no chrome or firefox installed on CI so a warning remains
[[ "$warning_count" -eq 1 ]]
else
[[ "$warning_count" -eq 0 ]]
fi
# if user install mkcert CA out of band, this will be inaccurate
# but using the menu item to install/uninstall again will bring it back in sync
[[ -f "$mkcert_installed_flag_file" ]]
}

is_string_valid_composer_credentials() {
Expand Down
2 changes: 2 additions & 0 deletions bin/menu-items-handlers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ toggle_mkcert_CA_install() {
if is_mkcert_CA_installed; then
warning_w_newlines "Removing your local certificate authority. Your password is required to make these changes."
mkcert -uninstall
rm "$mkcert_installed_flag_file"
! is_mkcert_CA_installed && msg_w_newlines "Successfully removed." || msg_w_newlines "Please try again."
else
warning_w_newlines "Please be careful when installing a local certificate authority and only continue if you understand the risks.
This will require your password.
"
mkcert -install
touch "$mkcert_installed_flag_file"
is_mkcert_CA_installed && msg_w_newlines "Successfully installed." || msg_w_newlines "Please try again."
fi
}
Expand Down

0 comments on commit f54c8a8

Please sign in to comment.