Last active
August 29, 2023 07:09
-
-
Save razius/1c09c60b25b2aafc5bf13a8666b744ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECT_PATH="$HOME/Desktop/unisport" | |
GIT_REPO="git@github.com:unisport/unisport.git" | |
git-remote-url-reachable() { | |
git ls-remote $GIT_REPO HEAD > /dev/null 2>&1 | |
} | |
aws-configured() { | |
aws sts get-caller-identity > /dev/null 2>&1 | |
} | |
if ! command -v git >/dev/null 2>&1; then | |
sudo apt-get install -y git | |
fi | |
GIT_NAME=$(git config --get user.name) | |
if [ -z "$GIT_NAME" ]; then | |
while [ -z "$FULL_NAME" ] | |
do | |
tput clear | |
read -p $'\e[31m\nType in your full name: \e[0m' FULL_NAME | |
git config --global --replace-all user.name "$FULL_NAME" | |
done | |
fi | |
GIT_EMAIL=$(git config --get user.email) | |
if [ -z "$GIT_EMAIL" ]; then | |
while [ -z "$EMAIL" ] | |
do | |
tput clear | |
read -p $'\e[31m\nType in your email address that you used for github (https://github.com/settings/emails): \e[0m' EMAIL | |
git config --global --replace-all user.email "$EMAIL" | |
done | |
fi | |
SSH_KEYFILE="$HOME/.ssh/id_rsa" | |
if [ ! -f $SSH_KEYFILE ]; then | |
ssh-keygen -f $SSH_KEYFILE -t rsa -N '' > /dev/null | |
fi | |
# Non-interactive git clone | |
# https://serverfault.com/questions/447028/non-interactive-git-clone-ssh-fingerprint-prompt | |
if [ ! -n "$(grep -s "^github.com " ~/.ssh/known_hosts)" ]; then ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null; fi | |
while ! git-remote-url-reachable; do | |
tput clear | |
printf "\e[31m\nGo to https://github.com/settings/ssh/new and paste in the following key (use something like 'work' for Title):\n\n\e[0m" | |
cat $SSH_KEYFILE.pub | |
read -p $'\n\e[31mPress enter when done. \e[0m' | |
done | |
if [ ! -d "$PROJECT_PATH" ]; then | |
git clone "git@github.com:unisport/unisport.git" $PROJECT_PATH | |
fi | |
echo "Your project folder is located at: $PROJECT_PATH" | |
if ! command -v pipenv >/dev/null 2>&1; then | |
sudo apt-get install -y -U python3.11 python3-pip python3-virtualenv python3-virtualenvwrapper | |
fi | |
pushd $PROJECT_PATH > /dev/null | |
VIRTUALENV_PATH=$(pipenv --venv) | |
if [ ! -d "$VIRTUALENV_PATH" ]; then | |
pipenv --python 3.11 | |
pipenv install | |
fi | |
if ! command -v docker >/dev/null 2>&1; then | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
# https://docs.docker.com/engine/install/linux-postinstall/ | |
sudo groupadd docker | |
sudo usermod -aG docker ${USER} | |
sudo systemctl enable docker | |
fi | |
if ! command -v docker-compose >/dev/null 2>&1; then | |
# https://docs.docker.com/compose/install/ | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
fi | |
pipenv shell | |
while ! aws-configured; do | |
AWS_ACCESS_KEY="" | |
AWS_SECRET_ACCESS_KEY="" | |
aws configure set region eu-west-1 | |
while [ -z "$AWS_ACCESS_KEY" ] | |
do | |
tput clear | |
read -p $'\e[31m\nPaste your AWS_ACCESS_KEY: \e[0m' AWS_ACCESS_KEY | |
aws configure set aws_access_key_id "$AWS_ACCESS_KEY" | |
done | |
while [ -z "$AWS_SECRET_ACCESS_KEY" ] | |
do | |
tput clear | |
read -p $'\e[31m\nPaste your AWS_SECRET_ACCESS_KEY: \e[0m' AWS_SECRET_ACCESS_KEY | |
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" | |
done | |
done | |
ARC_VERSION=$(arc version) | |
if [ -z "$ARC_VERSION" ]; then | |
sudo apt-get install -y php php-curl | |
git clone https://github.com/phacility/arcanist.git "$HOME/.local/lib/arcanist/" | |
ln -s "$HOME/.local/lib/arcanist/bin/arc" "$HOME/.local/bin/arc" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment