From c59c970eec6e0bf6e4233e21647d5d6b64523c05 Mon Sep 17 00:00:00 2001 From: "Yuriy Georgiev (jeux)" Date: Wed, 1 Dec 2021 10:45:46 +0200 Subject: [PATCH] Removed the obsolete POC installer from the project (#270) --- poc-installer/install.sh | 72 ------ ...containerd-v1.4.4+vmware.3.linux-amd64.tar | 0 .../cri-tools_1.19.0+vmware.3-1_amd64.deb | 0 poc-installer/payload/debinstall.list | 5 - .../kubeadm_1.20.5+vmware.2-1_amd64.deb | 0 .../kubectl_1.20.5+vmware.2-1_amd64.deb | 0 .../kubelet_1.20.5+vmware.2-1_amd64.deb | 0 .../kubernetes-cni_0.8.7+vmware.7-1_amd64.deb | 0 poc-installer/tkgpkg_fsbackup.sh | 234 ------------------ poc-installer/uninstall.sh | 47 ---- 10 files changed, 358 deletions(-) delete mode 100644 poc-installer/install.sh delete mode 100644 poc-installer/payload/cri-containerd-v1.4.4+vmware.3.linux-amd64.tar delete mode 100644 poc-installer/payload/cri-tools_1.19.0+vmware.3-1_amd64.deb delete mode 100644 poc-installer/payload/debinstall.list delete mode 100644 poc-installer/payload/kubeadm_1.20.5+vmware.2-1_amd64.deb delete mode 100644 poc-installer/payload/kubectl_1.20.5+vmware.2-1_amd64.deb delete mode 100644 poc-installer/payload/kubelet_1.20.5+vmware.2-1_amd64.deb delete mode 100644 poc-installer/payload/kubernetes-cni_0.8.7+vmware.7-1_amd64.deb delete mode 100644 poc-installer/tkgpkg_fsbackup.sh delete mode 100644 poc-installer/uninstall.sh diff --git a/poc-installer/install.sh b/poc-installer/install.sh deleted file mode 100644 index dcc9497ab..000000000 --- a/poc-installer/install.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -####################################### -# DATA SECTION (global vars & consts) # -####################################### -readonly WORK_DIR="/tmp/byoh" -readonly PAYLOAD_DIR="./payload" -readonly INSTALL_TMP_DIR="$WORK_DIR/root" - -#################### -# HELPER FUNCTIONS # -#################### - -recursiveExtractLayers() -{ - if [ ! -d "$INSTALL_TMP_DIR" ] - then - mkdir -p "$INSTALL_TMP_DIR" - fi - - for layerTar in $(find $WORK_DIR -name "layer.tar") - do - echo "Extracting layer $layerTar..." - tar -C "$INSTALL_TMP_DIR" -xf "$layerTar" - done -} - -############### -# ENTRY POINT # -############### - -#prepare -if [ ! -d "$WORK_DIR" ] -then - echo "*** Directory $WORK_DIR does not exists, creating backup file structure..." - mkdir -p "$INSTALL_TMP_DIR" -fi - - -#extract all archives from the "payload" directory -#fsObj = file system object (file or dir, in our case just tarballs) -cd $PAYLOAD_DIR - -for fsObj in *.tar -do - echo "Processing: $fsObj" - ../tkgpkg_fsbackup.sh "$fsObj" - tar -C "$INSTALL_TMP_DIR" -xvf "$fsObj" -done - -recursiveExtractLayers -echo "All tarballs extracted." - -#install all debs -while IFS="" read -r packageFile || [ -n "$packageFile" ] -do - apt install -y "./$packageFile" -done < debinstall.list - -#install all the content extracted from the tarballs -echo "Installing tarballs contents..." -cp -R $INSTALL_TMP_DIR/* / - -#turn off firewall -ufw disable - -#turn off swap -swapoff -a - -#start containerd -systemctl daemon-reload -systemctl start containerd \ No newline at end of file diff --git a/poc-installer/payload/cri-containerd-v1.4.4+vmware.3.linux-amd64.tar b/poc-installer/payload/cri-containerd-v1.4.4+vmware.3.linux-amd64.tar deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/payload/cri-tools_1.19.0+vmware.3-1_amd64.deb b/poc-installer/payload/cri-tools_1.19.0+vmware.3-1_amd64.deb deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/payload/debinstall.list b/poc-installer/payload/debinstall.list deleted file mode 100644 index eb33b1c77..000000000 --- a/poc-installer/payload/debinstall.list +++ /dev/null @@ -1,5 +0,0 @@ -kubernetes-cni_0.8.7+vmware.7-1_amd64.deb -cri-tools_1.19.0+vmware.3-1_amd64.deb -kubectl_1.20.5+vmware.2-1_amd64.deb -kubelet_1.20.5+vmware.2-1_amd64.deb -kubeadm_1.20.5+vmware.2-1_amd64.deb \ No newline at end of file diff --git a/poc-installer/payload/kubeadm_1.20.5+vmware.2-1_amd64.deb b/poc-installer/payload/kubeadm_1.20.5+vmware.2-1_amd64.deb deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/payload/kubectl_1.20.5+vmware.2-1_amd64.deb b/poc-installer/payload/kubectl_1.20.5+vmware.2-1_amd64.deb deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/payload/kubelet_1.20.5+vmware.2-1_amd64.deb b/poc-installer/payload/kubelet_1.20.5+vmware.2-1_amd64.deb deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/payload/kubernetes-cni_0.8.7+vmware.7-1_amd64.deb b/poc-installer/payload/kubernetes-cni_0.8.7+vmware.7-1_amd64.deb deleted file mode 100644 index e69de29bb..000000000 diff --git a/poc-installer/tkgpkg_fsbackup.sh b/poc-installer/tkgpkg_fsbackup.sh deleted file mode 100644 index 0c7a2b76b..000000000 --- a/poc-installer/tkgpkg_fsbackup.sh +++ /dev/null @@ -1,234 +0,0 @@ -############################################################################## -# This is a simple backup script. # -# It accepts a .tar (not a .gz or .bz compressed) or .deb as a first argument# -# and creates a backup of the current HOST file system based on its content. # -# Its sole purpose is to create a backup prior to extracting the package. # -# NOTE: the package must be a file system structure # -############################################################################## - -#!/bin/bash - -#.DATA SECTION (as we say in assembler jargon) -#here we just set some global consts -################## -readonly ARG1="$1" -readonly BAK_DIR="/tmp/byoh/bak" -readonly RESTORE_DIR="fs" -readonly WORK_DIR="/tmp/byoh" -readonly PAYLOAD_DIR="./payload" - -#HELPER FUNCTIONS -################## - -# accepts: file or dir absolute path -# returns: 0 = does not exists; 1 = it's a file; 2 = it's a dir -fileOrDirExists() -{ - fsItem=$1 - if [ -d "$fsItem" ]; then - return 2 #dir exists - else - if [ -f "$fsItem" ]; then - return 1 #file exists - else - return 0 #fs object does not exists - fi - fi -} - -#create dir in the backup if required -backupMkdirIfNotExists() -{ - dir=$1 - fileOrDirExists "$BAK_DIR/$RESTORE_DIR/$dir" - if [ $? -eq 0 ]; then - mkdir "$BAK_DIR/$RESTORE_DIR/$dir" - fi -} - -#backup a file to the appropriate backup dir -backupFile() -{ - fileItem=$1 - cp "$fileItem" "$BAK_DIR/$RESTORE_DIR$fileItem" - - #update the restore.list only if needed - if grep -Fxq "$fileItem" $BAK_DIR/restore.list 2> /dev/null - then - : # don't add the entry if it already exists - else - echo "$fileItem" >> $BAK_DIR/restore.list - fi -} - -backupAddRemoveItemEntry() -{ - fileItem=$1 - #update the remove.list only if needed - if grep -Fxq "$fileItem" $BAK_DIR/remove.list 2> /dev/null - then - : # don't add it if found - else - echo "$fileItem" >> $BAK_DIR/remove.list - fi -} - -isDebOrTar() -{ - fileItem=$1 - filename=$(basename -- "$fileItem") - extension="${fileItem##*.}" - - if [ "$extension" = "tar" ]; then - return 1 - elif [ "$extension" = "deb" ]; then - return 2 - else - return 3 - fi -} - -recursiveExtractLayers() -{ - if [ ! -d "$WORK_DIR/out" ] - then - mkdir "$WORK_DIR/out" - fi - - echo "Extracting layer.tar archives to $WORK_DIR/out..." - - for layerTar in $(find $WORK_DIR -name "layer.tar") - do - tar -C "$WORK_DIR/out" -xf "$layerTar" - done - - echo "Done." -} - -recursiveListLayers() -{ - for layerTar in $(find $WORK_DIR -name "layer.tar") - do - tar -tf $layerTar >> $BAK_DIR/$archiveList.list - done -} - -isOciCompliantTar() -{ - fileObject=$1 - tarContent=$(tar -tf "$fileObject") - - if [ -z "${tarContent##*layer.tar*}" ] ;then - return 1 - fi - - return 0 -} - -extractOciCompliantTar() -{ - fileName=$(basename -- $1) - mkdir "$WORK_DIR/$fileName" && tar -C "$WORK_DIR/$fileName" -xvf "$1" - recursiveListLayers - rm -rf "$WORK_DIR/$fileName" -} - -bakTar() -{ - isOciCompliantTar $1 - - if [ $? -eq 1 ]; then #if OCI compliant archive (containing layer.tar archives) - extractOciCompliantTar $1 - else #else if just plain file structure containing archive - saveNewFsObjectsToList $1 - fi -} - -bakDeb() -{ - dpkg -c $1 > $BAK_DIR/$archiveList.list -} - -saveNewFsObjectsToList() -{ - fileContentList=$(tar -tf $1) - - echo "$fileContentList" | - while IFS=/ read -r junk line; - do - fileOrDirExists $line - - if [ $? -eq 0 ]; then - echo $line >> $BAK_DIR/$archiveList.list; - fi - done -} - -#ENTRY POINT -################## - -#check for the command line argument (must be a tar or deb file path) -if [ -z $ARG1 ]; then - echo "Pass the .tar or .deb path as fist argument" - exit 0 -else - echo "*** Processing: $ARG1" -fi - -#creating the backup dir -if [ -d "$BAK_DIR/$RESTORE_DIR" ]; then - : -else - mkdir -p $BAK_DIR/$RESTORE_DIR -fi - -#getting the content of the package -if [ -f "$ARG1" ]; then - archiveList="$(basename -- $ARG1)" - - isDebOrTar "$ARG1" - debOrTar=$? - - if [ $debOrTar -eq 1 ]; then #tar - bakTar $ARG1 - sed -i 's/.*\.\///' $BAK_DIR/$archiveList.list - elif [ $debOrTar -eq 2 ]; then #deb - # at this point do nothing, however keep it for a while - # if needed, use it for deb file structure backup - # also put the "sed -i" command above (see tar) - # outside the current if-then-else statement - - : #bakDeb $ARG1 - else - echo "The extension is not .deb nor .tar - exiting." - exit 0 - fi - - -else - echo "$ARG1 does not exist, exiting..." - exit 0 -fi - -#process the file structure of the package -#and create backup directories reflecting the file system -#as well as backing up any files that are also present in the package -#(meaning that they are about to be replaced after extraction) -while IFS= read -r line; do - fsItem=/$line - - fileOrDirExists "$fsItem" - dest_fileOrDirExists=$? - - if [ $dest_fileOrDirExists -eq 2 ]; then - backupMkdirIfNotExists "$fsItem" - else - if [ $dest_fileOrDirExists -eq 1 ]; then - backupFile "$fsItem" - else - backupAddRemoveItemEntry "$fsItem" - fi - fi -done < $BAK_DIR/$archiveList.list - -echo "Backup complete." \ No newline at end of file diff --git a/poc-installer/uninstall.sh b/poc-installer/uninstall.sh deleted file mode 100644 index 78bcff33e..000000000 --- a/poc-installer/uninstall.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -####################################### -# DATA SECTION (global vars & consts) # -####################################### -readonly BAK_DIR="/tmp/byoh/bak" - -############### -# ENTRY POINT # -############### - -#stop the containerd daemon and uninstall it -sudo systemctl stop containerd -sudo systemctl disable containerd -sudo systemctl daemon-reload - -#remove installed deb packages and their dependencies -apt remove -y kubeadm kubelet kubectl kubernetes-cni cri-tools -apt autoremove -y - -#remove fs objects that we've installed (if any) -if [ -f "$BAK_DIR/remove.list" ]; then - while IFS="" read -r line; do - echo "Removing: $line" - rm -rf "$line" 2>/dev/null - done < $BAK_DIR/remove.list -fi - -#restore fs objects that we've replaced (if any) -#TODO: add md5 hash check to verify the versions -# if the current ver. is different than the one we've installed -# do not remove it! -if [ -f "$BAK_DIR/restore.list" ]; then - while IFS="" read -r line; do - echo "Restoring: $line" - cp -r "$line" 2>/dev/null - done < $BAK_DIR/restore.list -fi - -#cleanup all leftovers (backups and uninstall info) -rm -rf /tmp/byoh 2>/dev/null - -#turn on swap -swapon -a - -#turn on firewall -ufw enable