chore(init): init funtions
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
parent
5e8111e5d4
commit
377ecc18e7
1 changed files with 65 additions and 40 deletions
|
|
@ -19,9 +19,7 @@ version="v1.9.0"
|
|||
usr=`whoami`
|
||||
|
||||
# Installing k3s
|
||||
[[ x$SKIP_K8S_INSTALL == "xtrue" ]] && {
|
||||
info "Skipping Kuberntes installation"
|
||||
} || {
|
||||
function install_k8s{
|
||||
curl -sL https://get.k3s.io | sudo K3S_KUBECONFIG_MODE="644" INSTALL_K3S_VERSION='v1.22.8+k3s1' INSTALL_K3S_EXEC="--no-deploy=traefik" sh -
|
||||
[[ -d ~/.kube ]] || mkdir ~/.kube
|
||||
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
||||
|
|
@ -29,42 +27,42 @@ usr=`whoami`
|
|||
sudo chown -R $usr ~/.kube/config
|
||||
}
|
||||
|
||||
[[ x$SKIP_K8S_TOOLS == "xtrue" ]] && {
|
||||
info "Skipping Kuberntes installation"
|
||||
} || {
|
||||
function install_tools(){
|
||||
## installing kubectl
|
||||
which kubectl &> /dev/null || {
|
||||
info "kubectl not installed. Installing it..."
|
||||
sudo curl -SsL https://dl.k8s.io/release/v1.20.0/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl ; sudo chmod +x /usr/local/bin/kubectl
|
||||
}
|
||||
|
||||
## Installing GH package manager
|
||||
which eget &> /dev/null || {
|
||||
local version="1.3.0"
|
||||
info "eget not installed. Installing it..."
|
||||
curl -SsL https://github.com/zyedidia/eget/releases/download/v$version/eget-1.3.0-linux_amd64.tar.gz -o /tmp/eget.tar.gz
|
||||
cd /tmp
|
||||
tar -xf eget.tar.gz
|
||||
sudo mv eget-$version-linux_amd64/eget /usr/local/bin/eget
|
||||
sudo chmod +x /usr/local/bin/eget
|
||||
cd -
|
||||
}
|
||||
|
||||
## installing stern
|
||||
which stern &> /dev/null || {
|
||||
info "stern not installed. installing..."
|
||||
sudo curl -SsL https://github.com/derdanne/stern/releases/download/2.1.16/stern_linux_amd64 -o /usr/local/bin/stern ; sudo chmod +x /usr/local/bin/stern
|
||||
sudo eget --to /usr/local/bin stern/stern
|
||||
}
|
||||
|
||||
## installing k9s
|
||||
which k9s &> /dev/null || {
|
||||
info "k9s not installed. Installing it..."
|
||||
sudo curl -SsL https://github.com/derailed/k9s/releases/download/v0.24.2/k9s_Linux_x86_64.tar.gz -o /tmp/k9s.tar.gz
|
||||
cd /tmp
|
||||
tar -xf k9s.tar.gz
|
||||
sudo mv k9s /usr/local/bin/k9s
|
||||
sudo chmod +x /usr/local/bin/k9s
|
||||
cd -
|
||||
sudo eget --to /usr/local/bin derailed/k9s
|
||||
}
|
||||
|
||||
## installing helm
|
||||
which helm &> /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
which helm &> /dev/null || {
|
||||
info "helm not installed. Installing it..."
|
||||
curl -ssl https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz -o /tmp/helm.tar.gz
|
||||
tar -xf /tmp/helm.tar.gz
|
||||
chmod +x linux-amd64/helm
|
||||
sudo cp linux-amd64/helm /usr/local/bin/helm
|
||||
rm -rf linux-amd64/helm /tmp/helm.tar.gz
|
||||
fi
|
||||
sudo eget --to /usr/local/bin https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz -f helm
|
||||
}
|
||||
}
|
||||
|
||||
sleep 10
|
||||
|
|
@ -79,10 +77,6 @@ randomPass() {
|
|||
|
||||
## Prepping the infra
|
||||
|
||||
[[ -z $DOMAIN_NAME ]] && {
|
||||
fatal 'DOMAIN_NAME variable is empty. Rerun the script `DOMAIN_NAME=openreplay.mycomp.org bash init.sh `'
|
||||
}
|
||||
|
||||
# Mac os doesn't have gnu sed, which will cause compatibility issues.
|
||||
# This wrapper will help to check the sed, and use the correct version="v1.9.0"
|
||||
# Ref: https://stackoverflow.com/questions/37639496/how-can-i-check-the-version="v1.9.0"
|
||||
|
|
@ -102,21 +96,52 @@ function sed_i_wrapper(){
|
|||
fi
|
||||
}
|
||||
|
||||
info "Creating dynamic passwords"
|
||||
sed_i_wrapper -i "s/postgresqlPassword: \"changeMePassword\"/postgresqlPassword: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/accessKey: \"changeMeMinioAccessKey\"/accessKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/secretKey: \"changeMeMinioPassword\"/secretKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/jwt_secret: \"SetARandomStringHere\"/jwt_secret: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/assistKey: \"SetARandomStringHere\"/assistKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/assistJWTSecret: \"SetARandomStringHere\"/assistJWTSecret: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/domainName: \"\"/domainName: \"${DOMAIN_NAME}\"/g" vars.yaml
|
||||
function create_passwords() {
|
||||
[[ -z $DOMAIN_NAME ]] && {
|
||||
fatal 'DOMAIN_NAME variable is empty. Rerun the script `DOMAIN_NAME=openreplay.mycomp.org bash init.sh `'
|
||||
}
|
||||
|
||||
info "Setting proper permission for shared folder"
|
||||
sudo mkdir -p /openreplay/storage/nfs
|
||||
sudo chown -R 1001:1001 /openreplay/storage/nfs
|
||||
info "Creating dynamic passwords"
|
||||
sed_i_wrapper -i "s/postgresqlPassword: \"changeMePassword\"/postgresqlPassword: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/accessKey: \"changeMeMinioAccessKey\"/accessKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/secretKey: \"changeMeMinioPassword\"/secretKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/jwt_secret: \"SetARandomStringHere\"/jwt_secret: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/assistKey: \"SetARandomStringHere\"/assistKey: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/assistJWTSecret: \"SetARandomStringHere\"/assistJWTSecret: \"$(randomPass)\"/g" vars.yaml
|
||||
sed_i_wrapper -i "s/domainName: \"\"/domainName: \"${DOMAIN_NAME}\"/g" vars.yaml
|
||||
}
|
||||
|
||||
|
||||
function set_permissions() {
|
||||
info "Setting proper permission for shared folder"
|
||||
sudo mkdir -p /openreplay/storage/nfs
|
||||
sudo chown -R 1001:1001 /openreplay/storage/nfs
|
||||
}
|
||||
|
||||
## Installing OpenReplay
|
||||
info "installing databases"
|
||||
helm upgrade --install databases ./databases -n db --create-namespace --wait -f ./vars.yaml --atomic
|
||||
info "installing application"
|
||||
helm upgrade --install openreplay ./openreplay -n app --create-namespace --wait -f ./vars.yaml --atomic
|
||||
function install_openreplay() {
|
||||
info "installing databases"
|
||||
helm upgrade --install databases ./databases -n db --create-namespace --wait -f ./vars.yaml --atomic
|
||||
info "installing application"
|
||||
helm upgrade --install openreplay ./openreplay -n app --create-namespace --wait -f ./vars.yaml --atomic
|
||||
}
|
||||
|
||||
function main(){
|
||||
[[ x$SKIP_K8S_INSTALL == "x1" ]] && {
|
||||
info "Skipping Kuberntes installation"
|
||||
} || {
|
||||
install_k8s
|
||||
}
|
||||
[[ x$SKIP_K8S_TOOLS == "x1" ]] && {
|
||||
info "Skipping Kuberntes tools installation"
|
||||
} || {
|
||||
install_tools
|
||||
}
|
||||
create_passwords
|
||||
set_permissions
|
||||
[[ x$SKIP_OR_INSTALL == "x1" ]] && {
|
||||
info "Skipping OpenReplay installation"
|
||||
} || {
|
||||
install_openreplay
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue