Skip to content

Commit

Permalink
also delete directory in /usr/src
Browse files Browse the repository at this point in the history
  • Loading branch information
Grotax committed Feb 10, 2024
1 parent 5b9a181 commit 938e428
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions roles/batman/files/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import subprocess
import sys
import re
import shutil

def delete_directory(directory):
try:
shutil.rmtree(directory)
print("Directory deleted successfully!")
except OSError as error:
print("Error deleting directory:", error)

# Retrieve the desired version from command line input
desired_version = sys.argv[1]
Expand Down Expand Up @@ -33,6 +41,8 @@
if module_version != desired_version:
subprocess.call(["dkms", "remove", module_name, "-v", module_version])
print(f"Uninstalled batman_adv version {module_version}")
batman_folder = f"/usr/src/{module_name}-{module_version}"
delete_directory(batman_folder)
except subprocess.CalledProcessError:
print(f"Error: Module '{module_name}' might not exist or is unavailable for removal.")

Expand Down

0 comments on commit 938e428

Please sign in to comment.