From ad575508927b48a05d251947b41ae0692dc9c895 Mon Sep 17 00:00:00 2001
From: Massimiliano Adamo <maxadamo@gmail.com>
Date: Mon, 1 Feb 2021 19:13:55 +0100
Subject: [PATCH] check if the user is root

---
 ubuntu-kernel-cleanup.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ubuntu-kernel-cleanup.py b/ubuntu-kernel-cleanup.py
index 1613e2d..dec4e84 100755
--- a/ubuntu-kernel-cleanup.py
+++ b/ubuntu-kernel-cleanup.py
@@ -88,6 +88,11 @@ def get_version(full_pkg_name):
 
 if __name__ == '__main__':
 
+    if os.geteuid() != 0:
+        print("You need to have root privileges to run this script")
+        print("Please try again, this time using 'sudo'. Exiting.")
+        os.sys.exit()
+
     CFG_ONE = os.path.join(
         os.path.expanduser('~'), ".ubuntu-kernel-cleanup.ini")
     CFG_TWO = '/etc/ubuntu-kernel-cleanup.ini'
-- 
GitLab