From 890150296b85f4af6d7cdad536e7e04879122f3d Mon Sep 17 00:00:00 2001 From: pnetlabrepo <115958905+pnetlabrepo@users.noreply.github.com> Date: Tue, 7 Feb 2023 04:17:32 -0300 Subject: [PATCH] Add files via upload --- .../extras/upgrade_ubuntu_to_20.04/README.md | 19 +++++++++ .../extras/upgrade_ubuntu_to_20.04/upgrade.sh | 42 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 upgrades/extras/upgrade_ubuntu_to_20.04/README.md create mode 100644 upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh diff --git a/upgrades/extras/upgrade_ubuntu_to_20.04/README.md b/upgrades/extras/upgrade_ubuntu_to_20.04/README.md new file mode 100644 index 0000000..cdab59f --- /dev/null +++ b/upgrades/extras/upgrade_ubuntu_to_20.04/README.md @@ -0,0 +1,19 @@ +```linux +This script allows to upgrade dependencies in PNETLab UBUNTU 20.04 + +File pnetlabv6_offline.zip will be downloaded from unetlab.cloud +``` +## upgrade.sh +`This script cannot be used in cases where PNETLab UBUNTU version is not 20.04: For those cases, an error message will be displayed and the script execution will be finished` + +### Upgrade +Apply this command using the terminal +```linux +wget -O upgrade.sh https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh > /dev/null 2>&1 && chmod +x upgrade.sh && bash upgrade.sh +``` + +When you run this command from above, the steps will be executed as follows: + +1) A file called [upgrade.sh](https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh) will be downloaded from this repository +2) Execution permissions will be applied to this file +3) Finally, this script will be executed in order to make the upgrade diff --git a/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh b/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh new file mode 100644 index 0000000..ae50332 --- /dev/null +++ b/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Script designed to upgrade dependencies in PNETLab UBUNTU 20.04 +# Requirement: You need to have UBUNTU 20.04 + +# CONSTANTS +GREEN='\033[32m' +RED='\033[31m' +NO_COLOR='\033[0m' + +ZIP_FILENAME=pnetlabv6_offline.zip +URL_ZIP_FILE=https://unetlab.cloud/api/raw/?path=/UNETLAB%20I/upgrades_pnetlab/extras/upgrade_to_ubuntu_20.04/pnetlabv6_offline.zip + +lsb_release -r -s | grep -q 20.04 +if [ $? -ne 0 ]; then + echo -e "${RED}Upgrade has been rejected. You need to have UBUNTU 20.04 to use this script${NO_COLOR}" + exit 0 +fi + +echo -e "${GREEN}Downloading $ZIP_FILENAME...${NO_COLOR}" +wget --content-disposition -q --show-progress -O /tmp/$ZIP_FILENAME $URL_ZIP_FILE +echo -e "${GREEN}$ZIP_FILENAME has been downloaded successfully${NO_COLOR}" + +cd /tmp && rm -rf upgrade + +echo -e "${GREEN}Unzipping zip file...${NO_COLOR}" +unzip $ZIP_FILENAME -d ./upgrade > /dev/null 2>&1 +echo -e "${GREEN}Zip file has been unzipped successfully...${NO_COLOR}" + +chmod 755 -R upgrade +find upgrade -type f -print0 | xargs -0 dos2unix > /dev/null 2>&1 + +echo -e "${GREEN}Executing upgrade script...${NO_COLOR}" +./upgrade/install_pnetlab_v6_offline.sh +echo -e "${GREEN}Upgrade has been done successfully${NO_COLOR}" + +rm -rf upgrade +rm /tmp/$ZIP_FILENAME + +echo -e "${GREEN}PNETLab VM will be rebooted right now...${NO_COLOR}" +echo -e "${GREEN}Try to connect again in about a minute with these credentials: username=root password=pnet${NO_COLOR}" +reboot