Files
os_setup/install.py
2025-10-17 20:15:58 +00:00

35 lines
988 B
Python

import os
import platform
linux_packages = [
'zsh'
]
os_type = platform.uname().system.lower()
is_linux = os_type == "linux"
is_macos = os_type == "darwin"
is_windows = os_type == "windows"
is_debian = is_linux and os.system('apt --version > /dev/null 2>&1') >> 8 == 0
is_rhel = is_linux and os.system('dnf --version > /dev/null 2>&1') >> 8 == 0
def check_os():
if is_linux or is_macos or is_windows:
print(f"Running on {os_type}")
else:
print(f"Unsupported OS family: {os_type}")
exit(1)
if __name__ == "__main__":
check_os()
if is_debian:
os.system('apt-get update && apt-get upgrade -y')
for p in linux_packages:
os.system(f'apt-get install {p} -y')
if is_rhel:
os.system('dnf upgrade -y')
for p in linux_packages:
os.system(f'dnf install {p} -y')
print(f'is_windows: {is_windows}, is_macos: {is_macos}, is_linux: {is_linux}, is_debian: {is_debian}, is_rhel: {is_rhel}')