From 2679bebde418ecd15150c5589803b8a84b8ccbb0 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 21 Feb 2023 21:56:34 -0600 Subject: [PATCH] Check if script is running as root --- upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh b/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh index da275a2..188f3a5 100644 --- a/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh +++ b/upgrades/extras/upgrade_ubuntu_to_20.04/upgrade.sh @@ -9,7 +9,11 @@ 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 +# Check if user is root +if [ "$(id -u)" != "0" ]; then + echo -e "${RED}Upgrade has been rejected. You must run this script as root${NO_COLOR}" + exit 0 +fi lsb_release -r -s | grep -q 20.04 if [ $? -ne 0 ]; then