diff --git a/setup/jenkins-plugins/install-newversion.sh b/setup/jenkins-plugins/install-newversion.sh new file mode 100644 index 0000000..c808386 --- /dev/null +++ b/setup/jenkins-plugins/install-newversion.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail + +JENKINS_URL="http://localhost:8080" +JENKINS_USER="admin" +JENKINS_TOKEN="YOUR_API_TOKEN_HERE" #GET the token from Manage Jenkins → Users → admin → API Token + +echo "Checking Jenkins availability..." + +HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ + -u ${JENKINS_USER}:${JENKINS_TOKEN} \ + ${JENKINS_URL}/login) + +if [ "$HTTP_CODE" != "200" ]; then + echo "❌ Cannot authenticate to Jenkins. HTTP code: $HTTP_CODE" + exit 1 +fi + +echo "✔ Jenkins reachable and authenticated" + +echo "Getting CSRF crumb..." + +CRUMB_RESPONSE=$(curl -s \ + -u ${JENKINS_USER}:${JENKINS_TOKEN} \ + ${JENKINS_URL}/crumbIssuer/api/json) + +if ! echo "$CRUMB_RESPONSE" | jq . >/dev/null 2>&1; then + echo "❌ Failed to retrieve crumb. Response:" + echo "$CRUMB_RESPONSE" + exit 1 +fi + +JENKINS_CRUMB=$(echo "$CRUMB_RESPONSE" | jq -r .crumb) + +echo "✔ Crumb obtained" + +echo "Installing plugins from plugins.txt..." + +while read -r plugin; do + [ -z "$plugin" ] && continue + + echo "Installing ${plugin}..." + + curl -s -X POST \ + -u "${JENKINS_USER}:${JENKINS_TOKEN}" \ + -H "Jenkins-Crumb:${JENKINS_CRUMB}" \ + -H "Content-Type: text/xml" \ + --data "" \ + "${JENKINS_URL}/pluginManager/installNecessaryPlugins" + +done < plugins.txt + +echo "✔ Plugin installation requests sent" + +echo "Triggering safe restart..." + +curl -s -X POST \ + -u "${JENKINS_USER}:${JENKINS_TOKEN}" \ + -H "Jenkins-Crumb:${JENKINS_CRUMB}" \ + "${JENKINS_URL}/safeRestart" + +echo "🎉 Done." \ No newline at end of file diff --git a/setup/vm-install-script/install-script-nversion.sh b/setup/vm-install-script/install-script-nversion.sh new file mode 100644 index 0000000..95f1c6c --- /dev/null +++ b/setup/vm-install-script/install-script-nversion.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +echo ".........----------------#################._.-.-INSTALL-.-._.#################----------------........." +PS1='\[\e[01;36m\]\u\[\e[01;37m\]@\[\e[01;33m\]\H\[\e[01;37m\]:\[\e[01;32m\]\w\[\e[01;37m\]\$\[\033[0;37m\] ' +echo "PS1='\[\e[01;36m\]\u\[\e[01;37m\]@\[\e[01;33m\]\H\[\e[01;37m\]:\[\e[01;32m\]\w\[\e[01;37m\]\$\[\033[0;37m\] '" >> ~/.bashrc +sed -i '1s/^/force_color_prompt=yes\n/' ~/.bashrc +source ~/.bashrc + +# Don't ask to restart services after apt update, just do it. +[ -f /etc/needrestart/needrestart.conf ] && sed -i 's/#\$nrconf{restart} = \x27i\x27/$nrconf{restart} = \x27a\x27/' /etc/needrestart/needrestart.conf + +apt-get autoremove -y #removes the packages that are no longer needed +apt-get update +systemctl daemon-reload + +KUBE_LATEST=$(curl -L -s https://dl.k8s.io/release/stable.txt | awk 'BEGIN { FS="." } { printf "%s.%s", $1, $2 }') +mkdir -p /etc/apt/keyrings +curl -fsSL https://pkgs.k8s.io/core:/stable:/${KUBE_LATEST}/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${KUBE_LATEST}/deb/ /" >> /etc/apt/sources.list.d/kubernetes.list + +apt-get update +KUBE_VERSION=$(apt-cache madison kubeadm | head -1 | awk '{print $3}') +apt-get install -y docker.io vim build-essential jq python3-pip kubelet kubectl kubernetes-cni kubeadm containerd +pip3 install jc + +### UUID of VM +### comment below line if this Script is not executed on Cloud based VMs +jc dmidecode | jq .[1].values.uuid -r + +systemctl enable kubelet + +echo ".........----------------#################._.-.-KUBERNETES-.-._.#################----------------........." +rm -f /root/.kube/config +kubeadm reset -f + +mkdir -p /etc/containerd +containerd config default | sed 's/SystemdCgroup = false/SystemdCgroup = true/' > /etc/containerd/config.toml +systemctl restart containerd + +# uncomment below line if your host doesnt have minimum requirement of 2 CPU +# kubeadm init --pod-network-cidr '10.244.0.0/16' --service-cidr '10.96.0.0/16' --ignore-preflight-errors=NumCPU --skip-token-print +kubeadm init --pod-network-cidr '10.244.0.0/16' --service-cidr '10.96.0.0/16' --skip-token-print + +mkdir -p ~/.kube +cp -i /etc/kubernetes/admin.conf ~/.kube/config + +kubectl apply -f "https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s-1.11.yaml" +kubectl rollout status daemonset weave-net -n kube-system --timeout=90s +sleep 5 + +echo "untaint controlplane node" +node=$(kubectl get nodes -o=jsonpath='{.items[0].metadata.name}') +for taint in $(kubectl get node $node -o jsonpath='{range .spec.taints[*]}{.key}{":"}{.effect}{"-"}{end}') +do + kubectl taint node $node $taint +done +kubectl get nodes -o wide + +echo ".........----------------#################._.-.-Docker-.-._.#################----------------........." + +cat > /etc/docker/daemon.json < /etc/apt/sources.list.d/jenkins.list +apt update +apt install -y jenkins +systemctl daemon-reload +systemctl enable jenkins +systemctl start jenkins +usermod -a -G docker jenkins +echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +echo ".........----------------#################._.-.-COMPLETED-.-._.#################----------------........." \ No newline at end of file