Skip to content

Commit

Permalink
rename "browsertrix" to "browsertrix cloud" in init shell script (and…
Browse files Browse the repository at this point in the history
… format with shfmt)
  • Loading branch information
emma-sg committed Mar 7, 2024
1 parent 7722436 commit fc914d1
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions btrix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# ./btrix: Browsertrix Cloud dev environment utility
# ./btrix: Browsertrix dev environment utility
#
# Test commands require installing pytest first, e.g.:
# python3 -m pip install pytest
Expand Down Expand Up @@ -34,8 +34,7 @@
# $ ./btrix nightly
# Run nightly backend tests


bootstrap(){
bootstrap() {
echo "Building backend..."
./scripts/build-backend.sh

Expand All @@ -46,7 +45,7 @@ bootstrap(){
helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
}

bootstrapMicrok8s(){
bootstrapMicrok8s() {
echo "Building backend..."
./scripts/build-backend.sh

Expand All @@ -57,17 +56,17 @@ bootstrapMicrok8s(){
microk8s helm3 upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
}

waitUntilReady(){
waitUntilReady() {
echo "Waiting until ready..."
kubectl wait --for=condition=ready pod --all --timeout=300s
}

waitUntilReadyMicrok8s(){
waitUntilReadyMicrok8s() {
echo "Waiting until ready..."
microk8s kubectl wait --for=condition=ready pod --all --timeout=300s
}

reset(){
reset() {
echo "Stopping all crawls & profile browsers"
kubectl delete cjs -n crawlers --all
kubectl delete pjs -n crawlers --all
Expand All @@ -81,7 +80,7 @@ reset(){
kubectl delete configmap -n crawlers -l btrix.crawlconfig
}

resetMicrok8s(){
resetMicrok8s() {
echo "Stopping all crawls & profile browsers"
microk8s kubectl delete cjs -n crawlers --all
microk8s kubectl delete pjs -n crawlers --all
Expand Down Expand Up @@ -134,22 +133,24 @@ if [[ $1 = "bootstrap" ]]; then

echo "Current context: $CONTEXT"
echo "Are you sure you want to update this context?"
if [[ "$(read -e -p '[y/N] > '; echo $REPLY)" == [Yy]* ]] ; then
if [[ "$(
read -e -p '[y/N] > '
echo $REPLY
)" == [Yy]* ]]; then
echo Continuing
else
echo Stopping
exit 1
fi

if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]]; then
bootstrapMicrok8s
else
bootstrap
fi


if [[ $2 = "$WAIT" || $3 = "$WAIT" ]]; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]]; then
waitUntilReadyMicrok8s
else
waitUntilReady
Expand All @@ -159,26 +160,29 @@ fi

# reset: uninstall, delete data, then bootstrap
if [[ $1 = "reset" ]]; then

echo "Current context: $CONTEXT"
echo "Resetting k8s cluster will delete the database. All running crawls will first be canceled. Are you sure you want to do this?"
if [[ "$(read -e -p '[y/N] > '; echo $REPLY)" == [Yy]* ]] ; then
if [[ "$(
read -e -p '[y/N] > '
echo $REPLY
)" == [Yy]* ]]; then
echo Continuing
else
echo Stopping
exit 1
fi

if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]]; then
resetMicrok8s
bootstrapMicrok8s
else
reset
bootstrap
fi

if [[ $2 = "$WAIT" || $3 = "$WAIT" ]] ; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
if [[ $2 = "$WAIT" || $3 = "$WAIT" ]]; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]]; then
waitUntilReadyMicrok8s
else
waitUntilReady
Expand All @@ -196,9 +200,9 @@ if [[ $1 = "nightly" ]]; then
runNightlyTests
fi

# down: stop and uninstall browsertrix cloud
# down: stop and uninstall browsertrix
if [[ $1 = "down" ]]; then
if [[ $2 = "$MICROK8S" ]] ; then
if [[ $2 = "$MICROK8S" ]]; then
resetMicrok8s
else
reset
Expand Down

0 comments on commit fc914d1

Please sign in to comment.