Skip to content

Instantly share code, notes, and snippets.

@mattbloomfield
Created April 2, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbloomfield/08ae5d8bda27672b3205b2ad3df5d085 to your computer and use it in GitHub Desktop.
Save mattbloomfield/08ae5d8bda27672b3205b2ad3df5d085 to your computer and use it in GitHub Desktop.
To be run once - upon first install
# This is dependent on other jobs. Please download them from gist.github.com/mattbloomfield
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## To be run once - upon first install
## Usage: fin setup
# Forces whole job to error on failure
set -e
# Get user token
PSH_TOKEN=$(fin config get --env=local SECRET_PLATFORMSH_CLI_TOKEN)
if [ -z "$PSH_TOKEN" ]
then
echo "${BLUE}Please enter your Platform.sh API Token and press [ENTER]: \n If you do not have a token, visit https://docs.platform.sh/development/cli/api-tokens.html and create one${RESET}"
read PSH_TOKEN
fin config set --env=local SECRET_PLATFORMSH_CLI_TOKEN=${PSH_TOKEN}
fi
# Build local .env file
fin refresh_env
# fin init to create db
echo "${YELLOW} INITIALIZING DOCKSAL PROJECT...${RESET}"
fin init
# print out connection details
divider===============================
divider=$divider$divider
header="\n %-5s %-9s %12s %-16s %-6s\n"
format=" %-5s %-9s %12s %-16s %-6s\n"
width=55
echo "${YELLOW}Database Connection Details${RED}"
printf "$header" "User" "Password" "Database" "Host" "Port"
printf "%$width.${width}s\n" "$divider"
printf "$format" \
root root ${MYSQL_DATABASE} 192.168.64.100 33061
# fin sync to sync db
echo "${YELLOW} SYNCING DATABASE...${RESET}"
fin sync
# set the git hooks directory to the version controlled one
fin git_hooks
# fin watch to start dev server
echo "${YELLOW} STARTING DEVELOPMENT SERVER...${RESET}"
fin watch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment