From e587c8883f3e4bef7aebe53a935675fcf16deff0 Mon Sep 17 00:00:00 2001 From: mishalabdullah Date: Fri, 30 Aug 2024 10:09:32 +0530 Subject: [PATCH 1/4] testing docker installation --- onix-gui/start.sh | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/onix-gui/start.sh b/onix-gui/start.sh index 8ffc509..755f8c7 100755 --- a/onix-gui/start.sh +++ b/onix-gui/start.sh @@ -2,24 +2,14 @@ # Installing dependencies -sudo apt-get update -sudo apt-get install ca-certificates curl - -sudo install -m 0755 -d /etc/apt/keyrings -sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc -sudo chmod a+r /etc/apt/keyrings/docker.asc - -# Add the repository to Apt sources: -echo \ -"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ -$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ -sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - -sudo apt-get update -sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - -sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose -sudo chmod +x /usr/local/bin/docker-compose +# Execute the package_manager.sh script to handle Docker installation +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "$SCRIPT_DIR/../../install/scripts/package_manager.sh" + +# Run the package_manager.sh script without passing any arguments +# The script will handle the installation of required packages +# including Docker and Docker Compose as defined within it. +# No need to call install_package function explicitly. echo "installing node" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && From 97647cf497ea9f7c2bfb0ec721ce99abf71a95d3 Mon Sep 17 00:00:00 2001 From: mishalabdullah Date: Fri, 30 Aug 2024 10:17:58 +0530 Subject: [PATCH 2/4] updated file path --- onix-gui/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onix-gui/start.sh b/onix-gui/start.sh index 755f8c7..73c2a68 100755 --- a/onix-gui/start.sh +++ b/onix-gui/start.sh @@ -4,7 +4,7 @@ # Execute the package_manager.sh script to handle Docker installation SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$SCRIPT_DIR/../../install/scripts/package_manager.sh" +source "../install/scripts/package_manager.sh" # Run the package_manager.sh script without passing any arguments # The script will handle the installation of required packages From 94942488140f12912d6c0a39b676c4f907a640d4 Mon Sep 17 00:00:00 2001 From: mishalabdullah Date: Fri, 30 Aug 2024 11:49:47 +0530 Subject: [PATCH 3/4] removed unsed var --- onix-gui/start.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/onix-gui/start.sh b/onix-gui/start.sh index 73c2a68..29a3d31 100755 --- a/onix-gui/start.sh +++ b/onix-gui/start.sh @@ -3,7 +3,6 @@ # Installing dependencies # Execute the package_manager.sh script to handle Docker installation -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "../install/scripts/package_manager.sh" # Run the package_manager.sh script without passing any arguments @@ -13,16 +12,16 @@ source "../install/scripts/package_manager.sh" echo "installing node" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && -source ~/.bashrc && -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + source ~/.bashrc && + export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 && -npm i -g localtunnel && + npm i -g localtunnel && -# Add user to the docker group and apply permissions -sudo groupadd docker & -sudo usermod -aG docker $USER & + # Add user to the docker group and apply permissions + sudo groupadd docker & +sudo usermod -aG docker $USER & newgrp docker & # Set script variables @@ -33,13 +32,13 @@ TUNNEL_SERVICE="lt" # Change to the project directory cd "$PROJECT_DIR" || exit nvm use 20 && -npm i && + npm i && -# Build and start the Next.js app -echo "installing Dependencies" + # Build and start the Next.js app + echo "installing Dependencies" echo "Building and starting Next.js app..." npx next build && -echo "Builing Web App = True" + echo "Builing Web App = True" sleep 3 npx next start -p "$PORT" & @@ -48,7 +47,7 @@ npx next start -p "$PORT" & # Install the tunnel service if not installed sleep 3 echo "Exposing local port $PORT using $TUNNEL_SERVICE..." -lt --port "$PORT" > /tmp/lt.log 2>&1 & +lt --port "$PORT" >/tmp/lt.log 2>&1 & # Wait for the tunnel service to start echo "Waiting for tunnel service to start..." @@ -61,8 +60,8 @@ TUNNEL_URL=$(grep -o 'https://[^[:blank:]]*' /tmp/lt.log) echo "Getting Tunnel Password" TUNNEL_PASSWORD=$(curl https://loca.lt/mytunnelpassword) && -# Print the tunnel URL and password -echo "---------------------------------------" + # Print the tunnel URL and password + echo "---------------------------------------" echo "Next.js app is running locally on port $PORT" echo "Tunnel Service URL: $TUNNEL_URL" echo "Tunnel Password: $TUNNEL_PASSWORD" From 604908014e131879c7a56551a64f3193d608c3c7 Mon Sep 17 00:00:00 2001 From: mishalabdullah Date: Fri, 30 Aug 2024 12:06:11 +0530 Subject: [PATCH 4/4] testing port 3005 process kill --- onix-gui/start.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/onix-gui/start.sh b/onix-gui/start.sh index 29a3d31..c4a5e40 100755 --- a/onix-gui/start.sh +++ b/onix-gui/start.sh @@ -1,5 +1,13 @@ #!/bin/bash +# Function to kill previous processes if they are running +kill_previous_processes() { + echo "Checking for running processes on port $PORT..." + lsof -i :$PORT | grep LISTEN | awk '{print $2}' | xargs -r kill -9 + echo "Checking for running tunnel services..." + pkill -f "lt --port $PORT" +} + # Installing dependencies # Execute the package_manager.sh script to handle Docker installation @@ -29,6 +37,9 @@ PROJECT_DIR="GUI" PORT=3005 TUNNEL_SERVICE="lt" +# Kill previous processes if they are running +kill_previous_processes + # Change to the project directory cd "$PROJECT_DIR" || exit nvm use 20 &&