Skip to content

Commit b09bc12

Browse files
committed
Outline export_env_var as function
1 parent bee5536 commit b09bc12

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bootstrap/docker_and_authorized_git.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ YELLOW='\033[0;33m'
1010
GREEN='\033[0;32m'
1111
NC='\033[0m' # No Color
1212

13+
# Exports an environment variable to ~/.bashrc
14+
# $1 is the name of the env var
15+
# $2 is the value to be exported
16+
export_env_var () {
17+
echo "export $1=$2" >> ~/.bashrc
18+
}
19+
1320
# assuming the system is Debian
1421
printf "${GREEN}Installing vim, tmux, git, make, unzip, and htop${NC}\n"
1522
sudo apt-get update
@@ -31,7 +38,8 @@ printf "${GREEN}Configuring git authorization${NC}\n"
3138
printf "${YELLOW}Please, generate a 'repo-read' access token for git.\n"
3239
printf "(See https://github.com/settings/tokens):${NC} "
3340
read gitkey
34-
echo "export GIT_KEY=$gitkey" >> ~/.bashrc
41+
export_env_var "GIT_KEY" "$gitkey"
42+
3543

3644
# then, allow the instance to access github
3745
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
@@ -57,7 +65,7 @@ echo \
5765

5866
sudo apt-get update
5967
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
60-
echo "export DOCKER_BUILDKIT=1" >> ~/.bashrc
68+
export_env_var "DOCKER_BUILDKIT" "1"
6169

6270

6371
printf "${GREEN}Installing docker-compose${NC}\n"
@@ -66,7 +74,7 @@ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-
6674
sudo chmod +x /usr/local/bin/docker-compose
6775

6876
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
69-
echo "export COMPOSE_DOCKER_CLI_BUILD=1" >> ~/.bashrc
77+
export_env_var "COMPOSE_DOCKER_CLI_BUILD" "1"
7078

7179

7280
printf "${GREEN}Removing self${NC}\n"

0 commit comments

Comments
 (0)