#!/bin/bash #./setup.sh 3000 192.168.195.195:30000/nginx:latest cicd/Jenkinsfile folderName=${PWD##*/} folderName=${folderName:-/} echo "Hello, lets get your project set up. Please follow the prompts attentively." read -p "Do you want to run this project locally? [Yn] " localProject if [ $localProject == 'Y' ] || [ $localProject == 'y' ] then echo "Configuring local settings" read -p " Local port to expose DB on? [eg 5432] " localPort read -p " Postgres container to use? [eg postgis/postgis:latest] " localContainer read -p " Superuser password? " postgresPassword echo " Creating start script" cp template/start.sh start.sh sed -ie "s|{{localPort}}|$localPort|g" start.sh sed -ie "s|{{localContainer}}|$localContainer|g" start.sh sed -ie "s|{{postgresPassword}}|$postgresPassword|g" start.sh chmod +x start.sh rm start.she fi read -p "Are you deploying this with the Sciocatti Jenkins pipeline? [Yn] " useJenkins if [ $useJenkins == 'Y' ] || [ $useJenkins == 'y' ] then echo "Configuring deployment settings. See the Readme for info on deployable branches." read -p " K3S App name: " k3sApp read -p " K3S namespace: [eg utility] " k3sNamespace read -p " K3S container: [eg postgis/postgis:latest] " k3sContainerBase read -p " K3S NodePort: " k3sport read -p " Superuser Password Secret ID: " deploySecret k3sportMain=$((k3sport+1)) echo "Creating Folders" echo " Creating cicd/" mkdir cicd echo " Creating cicd/main" mkdir cicd/main echo "Loading files" echo " Loading cicd/Jenkinsfile" cp template/Jenkinsfile cicd/Jenkinsfile sed -ie "s|{{k3sApp}}|$k3sApp|g" cicd/Jenkinsfile sed -ie "s|{{deploySecret}}|$deploySecret|g" cicd/Jenkinsfile rm cicd/Jenkinsfilee echo " Loading main" k3sEnv=main echo " Loading cicd/main/Dockerfile" cp template/Dockerfile cicd/main/Dockerfile sed -ie "s|{{k3sApp}}|$k3sApp|g" cicd/main/Dockerfile sed -ie "s|{{k3sNamespace}}|$k3sNamespace|g" cicd/main/Dockerfile sed -ie "s|{{k3sContainerBase}}|$k3sContainerBase|g" cicd/main/Dockerfile sed -ie "s|{{k3sport}}|$k3sport|g" cicd/main/Dockerfile rm cicd/main/Dockerfilee echo " Loading cicd/main/deployment.yaml" cp template/deployment.yaml cicd/main/deployment.yaml sed -ie "s|{{k3sApp}}|$k3sApp|g" cicd/main/deployment.yaml sed -ie "s|{{k3sport}}|$k3sport|g" cicd/main/deployment.yaml sed -ie "s|{{k3sNamespace}}|$k3sNamespace|g" cicd/main/deployment.yaml sed -ie "s|{{k3sContainerBase}}|$k3sContainerBase|g" cicd/main/deployment.yaml rm cicd/main/deployment.yamle fi echo "Removing template folder" rm -rf template echo "Thank you! Happy building..."