Skip to content
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

#554 Adjusting setup process: provide owner email/name (stf-related) #228

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions owner/.env.owner
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
STF_ADMIN_EMAIL=admin_email
STF_ADMIN_NAME=admin_name
54 changes: 53 additions & 1 deletion zebrunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export SIMULATORS=${metaDataFolder}/simulators.txt
read -p "Master host port [$ZBR_MCLOUD_PORT]: " local_port
if [[ ! -z $local_port ]]; then
ZBR_MCLOUD_PORT=$local_port
fi
fi

confirm "MCloud STF URL: $ZBR_MCLOUD_PROTOCOL://$ZBR_MCLOUD_HOSTNAME:$ZBR_MCLOUD_PORT/stf" "Continue?" "y"
is_confirmed=$?
Expand Down Expand Up @@ -249,6 +249,58 @@ export SIMULATORS=${metaDataFolder}/simulators.txt
done
export ZBR_WDA_BUNDLE_ID=$ZBR_WDA_BUNDLE_ID

validate_email() {
local email=$1
local regex='^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$'
if [[ $email =~ $regex ]]; then
return 0 # email is valid
else
return 1 # email is invalid
fi
}

echo
local is_confirmed=0
while [[ $is_confirmed -eq 0 ]]; do
read -p "Admin email [$STF_ADMIN_EMAIL]: " admin_email
if [[ ! -z $admin_email ]]; then

if validate_email $admin_email; then
STF_ADMIN_EMAIL=$admin_email

else
echo_warning "Invalid email address"
continue
fi

fi

confirm "Admin email: $STF_ADMIN_EMAIL" "Continue?" "y"
is_confirmed=$?
done
export STF_ADMIN_EMAIL=$STF_ADMIN_EMAIL

echo
local is_confirmed=0
while [[ $is_confirmed -eq 0 ]]; do
read -p "Admin name [$STF_ADMIN_NAME]: " admin_name
if [[ ! -z $admin_name ]]; then
STF_ADMIN_NAME=$admin_name
fi

confirm "Admin name: $STF_ADMIN_NAME" "Continue?" "y"
is_confirmed=$?
done
export STF_ADMIN_NAME=$STF_ADMIN_NAME

touch owner/.env
cp owner/.env.owner owner/.env

replace owner/.env "admin_email" "$STF_ADMIN_EMAIL"
replace owner/.env "admin_name" "$STF_ADMIN_NAME"

mv owner/.env stf/.env

# export all ZBR* variables to save user input
export_settings

Expand Down