62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
import os
|
|
import platform
|
|
|
|
rhel_packages = [
|
|
'epel-release'
|
|
]
|
|
|
|
linux_packages = [
|
|
'git',
|
|
'unzip',
|
|
'neovim',
|
|
'zsh'
|
|
]
|
|
|
|
linux_after_command = {
|
|
'zsh': 'sudo chsh -s $(which zsh) $(whoami) && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'
|
|
}
|
|
|
|
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 update_system():
|
|
if is_debian:
|
|
os.system('sudo apt-get update && sudo apt-get upgrade -y')
|
|
elif is_rhel:
|
|
os.system('sudo dnf upgrade -y')
|
|
else:
|
|
print(f"Update not supported for: {os_type}")
|
|
exit(1)
|
|
|
|
def install(package):
|
|
if is_debian:
|
|
os.system(f'sudo apt-get install {p} -y')
|
|
elif is_rhel:
|
|
os.system(f'sudo dnf install {p} -y')
|
|
else:
|
|
print(f"Install not supported for: {os_type}")
|
|
exit(1)
|
|
if is_linux and package in linux_after_command:
|
|
os.system(linux_after_command[package])
|
|
|
|
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__":
|
|
print(f'is_windows: {is_windows}, is_macos: {is_macos}, is_linux: {is_linux}, is_debian: {is_debian}, is_rhel: {is_rhel}')
|
|
check_os()
|
|
update_system()
|
|
if is_rhel:
|
|
for p in rhel_packages: install(p)
|
|
if is_linux:
|
|
for p in linux_packages: install(p) |