16 Commits

Author SHA1 Message Date
pnetlabrepo
95ef408d04 Update version 2023-01-17 02:12:21 -03:00
pnetlabrepo
2c81ae0673 Update ishare2 2023-01-17 02:11:50 -03:00
pnetlabrepo
d5c5869aa8 Update README.md 2023-01-17 02:10:10 -03:00
pnetlabrepo
2fdd1ce655 Update README.md 2023-01-17 02:09:42 -03:00
pnetlabrepo
7bd23fb5db Update CHANGELOG.md 2023-01-17 02:04:54 -03:00
pnetlabrepo
142144bf2e Update CHANGELOG.md 2023-01-17 02:04:29 -03:00
pnetlabrepo
d21fff1c08 Update ishare2 2023-01-17 02:02:44 -03:00
pnetlabrepo
820ddfe905 Update CHANGELOG.md 2023-01-16 09:33:26 -03:00
pnetlabrepo
c517e64850 Update version 2023-01-16 09:29:31 -03:00
pnetlabrepo
646a913ccb Update ishare2 2023-01-16 09:29:14 -03:00
pnetlabrepo
ff3e77b47b Update id_list 2023-01-16 08:06:16 -03:00
pnetlabrepo
06e0a62a51 Update CHANGELOG.md 2023-01-16 08:03:55 -03:00
pnetlabrepo
04980423d3 Update CHANGELOG.md 2023-01-16 07:46:06 -03:00
pnetlabrepo
612bfbabfb Update version 2023-01-16 07:40:50 -03:00
pnetlabrepo
65d40b1b15 Update ishare2 2023-01-16 07:40:31 -03:00
pnetlabrepo
d40caaf705 Update CHANGELOG.md 2023-01-14 02:20:34 -03:00
5 changed files with 136 additions and 74 deletions

View File

@@ -1,9 +1,28 @@
# Changelog
All notable changes to this project will be documented in this file. You can upgrade ishare2 to the latest version using `ishare2 upgrade`
All notable changes to this project will be documented in this file. You can upgrade ishare2 to the latest version using `ishare2 upgrade` and then selecting option 1
## [v1.4.8] - 2023-Jan-17
1) Added: A menu was added into the `ishare2 upgrade` command. This menu allows users to upgrade ishare2 and PNETLab to their latest versions
## [v1.4.7] - 2023-Jan-16
1) Added: A function called set_url_constants() was added to the code and to the main() execution. This function contains all of the URL needed in the project.
2) Modified: Function called set_color_variables() was renamed to set_color_constants()
## [v1.4.6] - 2023-Jan-16
1) Modified: Minor changes in code: A function called set_color_variables() was created to define all color variables in there. Added to main() execution
2) Deleted: Minor changes in code: Every definition of those variables was removed to get a cleaner code
Note: This update does not change how the code works in any way
## [v1.4.5] - 2023-Jan-13
1) Modified: Minor changes in code. Changes are not important at all
1) Modified: Minor changes in code: A line was changed from: ls -lh -R /opt/unetlab/addons/iol/bin to: ls -lh -R /opt/unetlab/addons/iol/bin/
2) Deleted: Minor changes in code: A comment stating "# Main code" was deleted from the code
Note: This update does not change how the code works in any way
## [v1.4.4] - 2023-Jan-11

View File

@@ -31,7 +31,7 @@ Note: There is no need to be in the same directory where *ishare2* file is insta
labs : Show labs on server and download images for those labs
mylabs : Same as labs command but using a customized path to labs
relicense : Generate a new iourc license for bin images
upgrade : Upgrade ishare2 code to the latest version
upgrade : Retrieves a menu that allows users to upgrade ishare2 and PNETLab VM
changelog : Show the latest changes made to ishare2
help : Show useful information
@@ -104,7 +104,7 @@ Note: There is no need to be in the same directory where *ishare2* file is insta
* For problems, use our Telegram Channel describing your problem and sending a screenshot and/or a video
* For new files to be uploaded, you can also use our Telegram Channel: In this case, you can send or ask for new images to be uploaded
* Using ishare2 upgrade will result in upgrading this utility (ishare2). It will not upgrade your PNETLab Ubuntu VM version
* Using ishare2 upgrade will display a menu that allows users to upgrade ishare2 and PNETLab.
* If CiscoIOUKeygen.py, iourc and/or keepalive.pl files in /opt/unetlab/addons/iol/bin/ are deleted, you can recover them by using ishare2 relicense. This will not affect images in there
Also, this command when used, will generate a new license file called "iourc", needed for bin files
@@ -122,6 +122,8 @@ Note: There is no need to be in the same directory where *ishare2* file is insta
- Upgrade from v4.2.10 to v5.0.1: [Instructions](https://github.com/pnetlabrepo/ishare2/tree/main/upgrades/from_4.2.10_to_5.0.1)
- Upgrade from v4.2.10 to v5.2.7: [Instructions](https://github.com/pnetlabrepo/ishare2/tree/main/upgrades/from_4.2.10_to_5.2.7)
- Upgrade from v5.0.1 to v5.2.7: [Instructions](https://github.com/pnetlabrepo/ishare2/tree/main/upgrades/from_5.0.1_to_5.2.7)
Note: You can also upgrade PNETLab using `ishare2 upgrade`, then selecting option 2 and finally one more option from the list
## Known limitations

View File

@@ -2,4 +2,3 @@ GOOGLE=2PACX-1vR-RCxKCkhzzW2ZDDQOUIAxq2QTPwcCJZXuFyGD0hvXDC60TMU0_Yx1fx02S1_H9h7
BIN=0
QEMU=647866092
DYNAMIPS=1118397071
CREDENTIALS=1957719637

178
ishare2
View File

@@ -1,12 +1,31 @@
#!/bin/bash
#October, 2022
function set_color_constants() {
RED='\033[31m'
YELLOW='\033[1;33m'
GREEN='\033[32m'
NO_COLOR='\033[0m'
}
function set_url_constants() {
URL_ID_LIST=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/id_list
URL_VERSION=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/version
URL_ISHARE2=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/ishare2
URL_CHANGELOG_MD=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/CHANGELOG.md
URL_CISCO_IOU_KEYGEN_PY=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/iol/bin/CiscoIOUKeygen.py
URL_KEEPALIVE_PL=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/iol/bin/keepalive.pl
URL_I86BI_LINUX_L2_YML=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/i86bi_linux_l2/i86bi_linux_l2.yml
URL_I86BI_LINUX_L3_YML=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/i86bi_linux_l3/i86bi_linux_l3.yml
URL_C2600_YML=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/cisco/c2600.yml
URL_C1760_YML=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/cisco/c1760.yml
URL_UPGRADE_PNETLAB_FROM_4_2_10_TO_5_0_1=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/upgrades/from_4.2.10_to_5.0.1/upgrade.sh
URL_UPGRADE_PNETLAB_FROM_4_2_10_TO_5_2_7=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/upgrades/from_4.2.10_to_5.2.7/upgrade.sh
URL_UPGRADE_PNETLAB_FROM_5_0_1_TO_5_2_7=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/upgrades/from_5.0.1_to_5.2.7/upgrade.sh
}
function check_user_is_root() {
user=$(whoami)
RED='\033[31m'
NO_COLOR='\033[0m'
if [[ "$user" != "root" ]]; then
echo -e "${RED}[!] Current user ($user) is not root, please change user as root to execute this script${NO_COLOR}"
exit 1
@@ -14,7 +33,7 @@ function check_user_is_root() {
}
function get_initial_information() {
ID_LIST="$(curl -s https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/id_list)"
ID_LIST="$(curl -s $URL_ID_LIST)"
GOOGLE_SHEETS_ID=$( echo "$ID_LIST" | awk -F= '/^GOOGLE/ { print $2 }' )
BIN_GID=$( echo "$ID_LIST" | awk -F= '/^BIN/ { print $2 }' )
@@ -161,13 +180,9 @@ function mylabs_install_lab_images_just_for_only_readable_labs() {
if [[ $NUMBER -gt $counter_for_readable_labs || $NUMBER -le 0 ]]; then
if [[ $counter_for_readable_labs -eq 1 ]]; then
STR="Last parameter must be 1 because you have only one lab"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
else
STR="Last parameter must be a number between 1 and $counter_for_readable_labs"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
fi
@@ -217,9 +232,6 @@ function mylabs_install_lab_images_just_for_only_readable_labs() {
echo -e "\nImages found on lab\n"
GREEN='\033[32m'
NO_COLOR='\033[0m'
echo -e "${GREEN}--- bin images ---${NO_COLOR}"
if [[ BIN_FLAG -eq 1 ]]; then
echo No bin images found
@@ -459,13 +471,9 @@ function install_lab_images_just_for_only_readable_labs() {
if [[ $NUMBER -gt $counter_for_readable_labs || $NUMBER -le 0 ]]; then
if [[ $counter_for_readable_labs -eq 1 ]]; then
STR="Last parameter must be 1 because you have only one lab"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
else
STR="Last parameter must be a number between 1 and $counter_for_readable_labs"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
fi
@@ -515,9 +523,6 @@ function install_lab_images_just_for_only_readable_labs() {
echo -e "\nImages found on lab"
GREEN='\033[32m'
NO_COLOR='\033[0m'
echo -e "${GREEN}--- bin images ---${NO_COLOR}"
if [[ BIN_FLAG -eq 1 ]]; then
echo No bin images found
@@ -724,8 +729,6 @@ function download_lab_iol_images() {
if [[ $FLAG -eq 0 ]]; then
STR="(BIN) WARNING: Image $BIN_NAME has not been found"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
fi
done < $filename1
@@ -761,8 +764,6 @@ function download_lab_dynamips_images() {
if [[ $FLAG -eq 0 ]]; then
STR="(DYNAMIPS) WARNING: Image $DYNAMIPS_NAME has not been found"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
fi
done < $filename1
@@ -802,8 +803,6 @@ function download_lab_qemu_images() {
if [[ $FLAG -eq 0 ]]; then
STR="(QEMU) WARNING: Image $QEMU_NAME has not been found"
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${YELLOW}$STR${NO_COLOR}"
fi
done < $filename1
@@ -811,10 +810,6 @@ function download_lab_qemu_images() {
}
function check_docker_service_status() {
RED='\033[31m'
GREEN='\033[32m'
NO_COLOR='\033[0m'
if service docker status | grep -q "active (running)"; then
return 0 # 0 means "no failures"
fi
@@ -926,13 +921,13 @@ function download_lab_docker_images() {
function check_ishare2_version_file_exists() {
if ! [[ -e /usr/sbin/ishare2_version ]]; then
echo -n "$(curl -s https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/version)" >> /usr/sbin/ishare2_version
echo -n "$(curl -s $URL_VERSION)" >> /usr/sbin/ishare2_version
fi
}
function upgrade_ishare2() {
LOCAL_VALUE=$(cat /usr/sbin/ishare2_version)
REMOTE_VALUE=$(curl -s https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/version)
REMOTE_VALUE=$(curl -s $URL_VERSION)
if [[ $LOCAL_VALUE == "$REMOTE_VALUE" ]]; then
echo "ishare2 $REMOTE_VALUE is currently the newest version available"
@@ -940,7 +935,7 @@ function upgrade_ishare2() {
fi
rm /usr/sbin/ishare2
wget -O /usr/sbin/ishare2 https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/ishare2 > /dev/null 2>&1
wget -O /usr/sbin/ishare2 $URL_ISHARE2 > /dev/null 2>&1
chmod +x /usr/sbin/ishare2
echo "ishare2 was upgraded from $LOCAL_VALUE to $REMOTE_VALUE"
@@ -948,12 +943,82 @@ function upgrade_ishare2() {
echo "$REMOTE_VALUE" >> /usr/sbin/ishare2_version
}
function menu_ishare2_upgrade_pnetlab() {
prompt="Please, select an option: "
options=(
"Upgrade PNETLab 4.2.10 to 5.0.1"
"Upgrade PNETLab 4.2.10 to 5.2.7"
"Upgrade PNETLab 5.0.1 to 5.2.7"
)
PS3="$prompt"
select opt in "${options[@]}" "Exit"; do
case "$REPLY" in
1)
wget -O upgrade.sh $URL_UPGRADE_PNETLAB_FROM_4_2_10_TO_5_0_1 > /dev/null 2>&1
chmod +x upgrade.sh
bash upgrade.sh
break
;;
2)
wget -O upgrade.sh $URL_UPGRADE_PNETLAB_FROM_4_2_10_TO_5_2_7 > /dev/null 2>&1
chmod +x upgrade.sh
bash upgrade.sh
break
;;
3)
wget -O upgrade.sh $URL_UPGRADE_PNETLAB_FROM_5_0_1_TO_5_2_7 > /dev/null 2>&1
chmod +x upgrade.sh
bash upgrade.sh
break
;;
$((${#options[@]}+1)))
break
;;
*)
STR="Invalid option: Select a number from 1 to 4"
echo -e "${RED}$STR${NO_COLOR}"
continue
;;
esac
done
}
function menu_ishare2_upgrade() {
prompt="Please, select an option: "
options=(
"Upgrade ishare2"
"Upgrade PNETLab"
)
PS3="$prompt"
select opt in "${options[@]}" "Exit"; do
case "$REPLY" in
1)
upgrade_ishare2
break
;;
2)
menu_ishare2_upgrade_pnetlab
break
;;
$((${#options[@]}+1)))
break
;;
*)
STR="Invalid option: Select a number from 1 to 3"
echo -e "${RED}$STR${NO_COLOR}"
continue
;;
esac
done
}
function show_changelog() {
FILE=/root/CHANGELOG.md
if [[ -e $FILE ]]; then rm $FILE ; fi
CHANGELOG_URL=https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/CHANGELOG.md
DATA="$(wget -q $CHANGELOG_URL -P /root)"
DATA="$(wget -q $URL_CHANGELOG_MD -P /root)"
head -n 15 $FILE
rm $FILE
}
@@ -984,11 +1049,11 @@ function generate_a_new_license() {
if [[ -e $PYTHON_FILE ]]; then rm $PYTHON_FILE ; fi
wget -O $PYTHON_FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/iol/bin/CiscoIOUKeygen.py > /dev/null 2>&1
wget -O $PYTHON_FILE $URL_CISCO_IOU_KEYGEN_PY > /dev/null 2>&1
python $PYTHON_FILE > /dev/null 2>&1
if ! [[ -e $PERL_FILE ]]; then
wget -O $PERL_FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/iol/bin/keepalive.pl > /dev/null 2>&1
wget -O $PERL_FILE $URL_KEEPALIVE_PL > /dev/null 2>&1
fi
echo "Done"
}
@@ -1236,9 +1301,6 @@ function pull_bin() {
}
function show_help_info() {
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "1) For problems, use our Telegram Channel describing your problem and sending a screenshot and/or a video"
echo -e "\n2) For new files to be uploaded, you can use our Telegram Channel too"
echo -e "In this case, you can send or ask for new images to be uploaded"
@@ -1254,12 +1316,9 @@ function show_ishare2_usage() {
# For ishare2
ISHARE2_VERSION_USAGE=$(cat /usr/sbin/ishare2_version)
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
STR=""
LOCAL_VALUE=$ISHARE2_VERSION_USAGE
REMOTE_VALUE=$(curl -s https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/version)
REMOTE_VALUE=$(curl -s $URL_VERSION)
if ! [[ $LOCAL_VALUE == "$REMOTE_VALUE" ]]; then
STR="New ishare2 version available: $REMOTE_VALUE"
@@ -1285,7 +1344,7 @@ action:
labs : Show labs on server and download images for those labs
mylabs : Same as labs command but using a customized path to labs
relicense : Generate a new iourc license for bin images
upgrade : Upgrade ishare2 code to the latest version
upgrade : Retrieves a menu that allows users to upgrade ishare2 and PNETLab VM
changelog : Show the latest changes made to ishare2
help : Show useful information
@@ -1621,7 +1680,7 @@ function corrections_for_iol_images() {
FILE="$YML_DIR"i86bi_linux_l2.yml
if ! [[ -e $FILE ]]; then
wget -O $FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/i86bi_linux_l2/i86bi_linux_l2.yml > /dev/null 2>&1
wget -O $FILE $URL_I86BI_LINUX_L2_YML > /dev/null 2>&1
fi
fi
@@ -1630,7 +1689,7 @@ function corrections_for_iol_images() {
FILE="$YML_DIR"i86bi_linux_l3.yml
if ! [[ -e $FILE ]]; then
wget -O $FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/i86bi_linux_l3/i86bi_linux_l3.yml > /dev/null 2>&1
wget -O $FILE $URL_I86BI_LINUX_L3_YML > /dev/null 2>&1
fi
fi
}
@@ -1699,13 +1758,13 @@ function corrections_for_dynamips_images() {
SUBSTRING="c2600"
if [[ "$NAME" == *"$SUBSTRING"* ]]; then
FILE="$YML_DIR"c2600.yml
wget -O $FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/cisco/c2600.yml > /dev/null 2>&1
wget -O $FILE $URL_C2600_YML > /dev/null 2>&1
fi
SUBSTRING="c1760"
if [[ "$NAME" == *"$SUBSTRING"* ]]; then
FILE="$YML_DIR"c1760.yml
wget -O $FILE https://raw.githubusercontent.com/pnetlabrepo/ishare2/main/templates/cisco/c1760.yml > /dev/null 2>&1
wget -O $FILE $URL_C1760_YML > /dev/null 2>&1
fi
}
@@ -1978,9 +2037,6 @@ function selector() {
pull_qemu "$3"
else
STR="Last parameter not detected"
RED='\033[31m'
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${RED}$STR${NO_COLOR}"
echo -e "Syntax: ishare2 pull qemu ${YELLOW}<number>${NO_COLOR}"
fi
@@ -1989,9 +2045,6 @@ function selector() {
pull_dynamips "$3"
else
STR="Last parameter not detected"
RED='\033[31m'
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${RED}$STR${NO_COLOR}"
echo -e "Syntax: ishare2 pull dynamips ${YELLOW}<number>${NO_COLOR}"
fi
@@ -2000,9 +2053,6 @@ function selector() {
pull_bin "$3"
else
STR="Last parameter not detected"
RED='\033[31m'
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${RED}$STR${NO_COLOR}"
echo -e "Syntax: ishare2 pull bin ${YELLOW}<number>${NO_COLOR}"
fi
@@ -2015,9 +2065,6 @@ function selector() {
elif [[ "$1" = "installed" ]]; then # ishare2 installed
if [[ "$2" ]]; then
if [[ "$2" = "all" ]]; then
GREEN='\033[32m'
NO_COLOR='\033[0m'
echo -e "${GREEN}----- QEMU -----${NO_COLOR}"
ishare2 installed qemu
echo -e "${GREEN}----- DYNAMIPS -----${NO_COLOR}"
@@ -2042,14 +2089,10 @@ function selector() {
list_dockers
count_dockers
else
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "Syntax:\n\nishare2 installed <type>"
echo -e "${YELLOW}type: all, bin, qemu, dynamips or docker${NO_COLOR}"
fi
else
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "Syntax:\n\nishare2 installed ${YELLOW}<type>${NO_COLOR}"
echo -e "type: all, bin, qemu, dynamips or docker"
fi
@@ -2074,9 +2117,6 @@ function selector() {
mylabs_install_lab_images_just_for_only_readable_labs $2 $3
else
STR="The last parameter must be a number"
RED='\033[31m'
YELLOW='\033[1;33m'
NO_COLOR='\033[0m'
echo -e "${RED}$STR${NO_COLOR}"
echo -e "ishare2 mylabs <path> ${YELLOW}<number>${NO_COLOR}"
fi
@@ -2092,7 +2132,7 @@ function selector() {
elif [[ "$1" = "relicense" ]]; then # ishare2 relicense
generate_a_new_license
elif [[ "$1" = "upgrade" ]]; then # ishare2 upgrade
upgrade_ishare2
menu_ishare2_upgrade
elif [[ "$1" = "changelog" ]]; then # ishare2 changelog
show_changelog
elif [[ "$1" = "help" ]]; then # ishare2 help
@@ -2103,6 +2143,8 @@ function selector() {
}
function main(){
set_color_constants
set_url_constants
check_user_is_root
get_initial_information
set_yml_template_folder_location

View File

@@ -1 +1 @@
v1.4.5
v1.4.8