First commit

This commit is contained in:
Andrew Schott 2023-06-08 02:53:48 -05:00
parent 39aa92032e
commit 6666da6770
2 changed files with 157 additions and 0 deletions

107
osupdater Executable file
View file

@ -0,0 +1,107 @@
#!/bin/bash
# Universal updater by Andrew Schott andrew@schotty.com
# Will detect and update via various packaging formats for distros I currently use.
# Globals
# edit as needed to set colors and soforth
# presuming echo thus tput is chosen here as default\
# tput text formatting
# bold=bold dim=dimmed
# rev=reverse bel=bell sound
# smul=underline on rmul=underline off
# setaf=foreground setab=background
# sgr0=clear
#
# Colors
# 0 Black 1 Red 2 Green 3 Yellow
# 4 Blue 5 Magenta 6 Cyan 7 White
#
# Default is
# * green for a true finding
# * yellow for a false finding
# * clear at the end to resume normal output for said command's output
CMD_NOTIFY="tput rev bold setaf 7 setab 0"
CMD_TRUE="tput rev bold setaf 2 setab 0"
CMD_FALSE="tput rev bold setaf 1 setab 7"
CMD_CLEAR="tput sgr0"
echo $($CMD_NOTIFY)"Looking for native package managers"$($CMD_CLEAR)
# apt -- Debian and derivatives
if `which apt &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found apt. Updating: ($(which apt))"$($CMD_CLEAR)
sudo apt udate -y
sudo apt upgrade -y
else
echo $($CMD_FALSE)"apt not found/needed"$($CMD_CLEAR)
fi
# dnf -- RHEL 8+, Fedora, Openmandriva, and derivatives
if `which dnf &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found dnf. Updating: ($(which dnf))"$($CMD_CLEAR)
sudo dnf --refresh --skip-broken --nobest -y update
else
echo $($CMD_FALSE)"dnf not found/needed"$($CMD_CLEAR)
fi
# pacman -- arch & arch derivatives
if `which pacman &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found pacman. Updating: ($(which pacman))"$($CMD_CLEAR)
sudo pacman -Syu
else
echo $($CMD_FALSE)"pacman not found/needed"$($CMD_CLEAR)
fi
# yum -- RHEL 7 > (Ignored if dnf is present)
if `which yum &> /dev/null 2>&1` && ! `which dnf &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found yum. Updating: ($(which yum))"$($CMD_CLEAR)
sudo yum --refresh --skip-broken --nobest -y update
else
echo $($CMD_FALSE)"yum not found/needed"$($CMD_CLEAR)
fi
# urpmi -- Mageia
if `which urpmi &> /dev/null 2>&1` && ! `which dnf &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found urpmi. Updating: ($(which urpmi))"$($CMD_CLEAR)
sudo urpmi --auto-update -y
else
echo $($CMD_FALSE)"urpmi not found/needed"$($CMD_CLEAR)
fi
# zypper -- SuSE products
if `which zypper &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found zypper. Updating: ($(which zypper))"$($CMD_CLEAR)
sudo zypper in -y
else
echo $($CMD_FALSE)"zypper not found/needed"$($CMD_CLEAR)
fi
echo $($CMD_NOTIFY)"Looking for sandboxed package managers"$($CMD_CLEAR)
# flatpak
if `which flatpak &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found flatpak. Updating: ($(which flatpak))"$($CMD_CLEAR)
flatpak update --user -y
sudo flatpak update -y
else
echo $($CMD_FALSE)"flatpak not found/needed"$($CMD_CLEAR)
fi
# snap
if `which snap &> /dev/null 2>&1`
then
echo $($CMD_TRUE)"Found snap. Updating: ($(which snap))"$($CMD_CLEAR)
sudo snap refresh -y
else
echo $($CMD_FALSE)"snap not found/needed"$($CMD_CLEAR)
fi

50
osupdater.py Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env python
import wx
import subprocess
class Example(wx.Frame):
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.OnQuit, fileItem)
self.SetSize((300, 200))
self.SetTitle('OS Updater')
self.Centre()
pnl = wx.Panel(self)
updateFlatpakButton = wx.Button(pnl, label='Update Flatpaks',pos=(20,20))
updateFlatpakButton.Bind(wx.EVT_BUTTON,self.OnFlatpakUpdate)
updateRPMButton = wx.Button(pnl, label='Update RPMs',pos=(20,60))
updateRPMButton.Bind(wx.EVT_BUTTON,self.OnRPMUpdate)
def OnFlatpakUpdate(self, e):
subprocess.run(["flatpak", "update", "--user"])
def OnRPMUpdate(self, e):
subprocess.run(["sudo", "dnf", "update", "-y"])
def OnQuit(self, e):
self.Close()
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()