From: Ashish Jain Date: Sun, 2 Nov 2025 18:34:02 +0000 (+0000) Subject: Add libs folder and install_libs.sh X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=24678efd308b75b376b8e086962a9ef913a49b64;p=aiml-fw%2Faimlfw-dep.git Add libs folder and install_libs.sh The following tasks are done: 1. Moving all the libraries (loblib.sh) to lib folder. 2. Adding a script "install_libs.sh" whose job is to move all the libs to linux internal folder (/usr/local/lib/aimlfw/libs) and updating bashrc to setup env-variable AIMLFW_LIBS_HOME, so that script is only required to run only first time. 3. Usage example at "install_k8s.sh" 4. Adding uninstallation_libs script to remove the linux internal folder and env-variable AIMLFW_LIBS_HOME from bashrc. Issue-Id: AIMLFW-295 Change-Id: I3a2082be967d207bbb6529039e7f2682d69a28ff Signed-off-by: ashishj1729 --- diff --git a/bin/install_libs.sh b/bin/install_libs.sh new file mode 100644 index 0000000..1023636 --- /dev/null +++ b/bin/install_libs.sh @@ -0,0 +1,47 @@ +#================================================================================== +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +#!/bin/bash + +LIBS_NAME="libs" # name of your libs folder +TARGET_DIR="/usr/local/lib/aimlfw/$LIBS_NAME" # where to install +ENV_VAR_NAME="AIMLFW_LIBS_HOME" # environment variable name +BASHRC_FILE="$HOME/.bashrc" # file to append env setup + +# === STEP 1: Copy libraries === +echo "Installing libraries to $TARGET_DIR ..." +sudo mkdir -p "$TARGET_DIR" +sudo cp -r tools/$LIBS_NAME/* "$TARGET_DIR/" +sudo chmod -R 755 "$TARGET_DIR" +echo "Libraries copied successfully." + +# === STEP 2: Add environment variable and sourcing to bashrc === +if ! grep -q "$ENV_VAR_NAME" "$BASHRC_FILE"; then + echo "Adding environment variable to $BASHRC_FILE ..." + cat <> "$BASHRC_FILE" + +export $ENV_VAR_NAME="$TARGET_DIR" + +EOF + echo "Environment variable added to bashrc." +else + echo "Environment variable already exists in bashrc." +fi + +echo "" +# It is observed, when you run "./bin/install_libs.sh" instead of "source ./bin/install_libs.sh", +# Bash runs it as a child process i.e. any changes/creation done to enivornment-variables will not be propagated to main bash process. +# Therefore, it is required the user to do the following in order to apply changes +echo "Please run 'source ~/.bashrc' or restart your terminal to apply changes." \ No newline at end of file diff --git a/bin/uninstall_libs.sh b/bin/uninstall_libs.sh new file mode 100644 index 0000000..f3cf37a --- /dev/null +++ b/bin/uninstall_libs.sh @@ -0,0 +1,34 @@ +#================================================================================== +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +#!/bin/bash + +LIBS_NAME="libs" # name of your libs folder +TARGET_DIR="/usr/local/lib/aimlfw/$LIBS_NAME" # where to install +ENV_VAR_NAME="AIMLFW_LIBS_HOME" # environment variable name +BASHRC_FILE="$HOME/.bashrc" # file to append env setup + +# === STEP 1: Delete libraries === +sudo rm -rf $TARGET_DIR + +if grep -q "export $ENV_VAR_NAME=" "$BASHRC_FILE"; then + echo "Removing environment variable from $BASHRC_FILE ..." + sed -i "/export $ENV_VAR_NAME=\".*\"/d" "$BASHRC_FILE" + echo "Environment variable removed." +else + echo "No environment variable entry found in bashrc" +fi + +echo "Uninstall completed" \ No newline at end of file diff --git a/tools/kubernetes/install_k8s.sh b/tools/kubernetes/install_k8s.sh index f3e11d6..02d8964 100755 --- a/tools/kubernetes/install_k8s.sh +++ b/tools/kubernetes/install_k8s.sh @@ -26,11 +26,22 @@ CALICO_VERSION=3.30.1 NERDCTL_VERSION=1.7.6 # see https://github.com/containerd/nerdctl/releases for the latest release BUILDKIT_VERSION=0.13.2 # see https://github.com/moby/buildkit/releases for the latest release -echo "Step 0: Checking if running on WSL..." +if [ -z "$AIMLFW_LIBS_HOME" ]; then + echo "Please set AIMLFW_LIBS_HOME by running install_libs.sh first." + exit 1 +fi + +source "$AIMLFW_LIBS_HOME/loglib.sh" + +log_section_break +echo -e "\n${BOLD}${CYAN}: Starting Kubernetes Installation...${NC}\n" +START_TIME=$(date +%s) + +log_step "Step 0: Checking if running on WSL..." if is_wsl; then - echo "Running on WSL" + log_info "Running on WSL" else - echo "Not WSL" + log_info "Not WSL" fi echo "Step 1: Disabling swap memory..." diff --git a/tools/libs/loglib.sh b/tools/libs/loglib.sh new file mode 100644 index 0000000..867c9b4 --- /dev/null +++ b/tools/libs/loglib.sh @@ -0,0 +1,40 @@ +# ================================================================================== +# +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + +#!/bin/bash + +# ====== COLORS ====== +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +CYAN='\033[1;36m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +# ====== LOG FUNCTIONS ====== +log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } +log_success() { echo -e "${GREEN}[OK]${NC} $1"; } +log_step() { echo -e "\n${CYAN}${BOLD}===== $1 =====${NC}\n"; } + + +log_section_break() { + echo -e "${CYAN}------------------------------------------------------------${NC}" +} \ No newline at end of file