feat: add package upgrade and keyring management commands to svc utility
This commit is contained in:
parent
8969e26033
commit
d9c449e8de
1 changed files with 49 additions and 4 deletions
53
svc.bash
53
svc.bash
|
@ -76,6 +76,45 @@ pkg_update() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkg_upgrade() {
|
||||||
|
case $(detect_pkg_manager) in
|
||||||
|
apt)
|
||||||
|
sudo apt upgrade -y
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
sudo dnf upgrade -y
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
sudo pacman -Syu --noconfirm
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: No supported package manager found."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_keyring() {
|
||||||
|
case $(detect_pkg_manager) in
|
||||||
|
apt)
|
||||||
|
echo "No keyring management needed for apt."
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
echo "No keyring management needed for dnf."
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
echo "Refreshing pacman keyring..."
|
||||||
|
sudo pacman-key --refresh-keys
|
||||||
|
echo "Updating archlinux-keyring..."
|
||||||
|
sudo pacman -S archlinux-keyring --noconfirm
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: No supported package manager found."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
pkg_search() {
|
pkg_search() {
|
||||||
local pkg="$1"
|
local pkg="$1"
|
||||||
case $(detect_pkg_manager) in
|
case $(detect_pkg_manager) in
|
||||||
|
@ -111,7 +150,7 @@ service_cmd() {
|
||||||
|
|
||||||
service_list() {
|
service_list() {
|
||||||
if command -v systemctl >/dev/null 2>&1; then
|
if command -v systemctl >/dev/null 2>&1; then
|
||||||
# List systemd services with status, using original clean logic
|
# List systemd services with status, using clean logic
|
||||||
systemctl list-units --type=service --all --no-pager --no-legend | \
|
systemctl list-units --type=service --all --no-pager --no-legend | \
|
||||||
awk '$1 !~ /^●$/ && $1 != "" {if ($2 == "not-found") print $1, "not-found"; else if ($3 == "active" && $4 == "running") print $1, "running"; else if ($3 == "active" && $4 == "exited") print $1, "exited"; else print $1, "stopped"}' | \
|
awk '$1 !~ /^●$/ && $1 != "" {if ($2 == "not-found") print $1, "not-found"; else if ($3 == "active" && $4 == "running") print $1, "running"; else if ($3 == "active" && $4 == "exited") print $1, "exited"; else print $1, "stopped"}' | \
|
||||||
column -t
|
column -t
|
||||||
|
@ -140,11 +179,17 @@ case "$1" in
|
||||||
update)
|
update)
|
||||||
pkg_update
|
pkg_update
|
||||||
;;
|
;;
|
||||||
|
upgrade)
|
||||||
|
pkg_upgrade
|
||||||
|
;;
|
||||||
|
keyring)
|
||||||
|
pkg_keyring
|
||||||
|
;;
|
||||||
search)
|
search)
|
||||||
pkg_search "$3"
|
pkg_search "$3"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: svc pkg {install|remove|update|search} [package]"
|
echo "Usage: svc pkg {install|remove|update|upgrade|keyring|search} [package]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -156,7 +201,7 @@ case "$1" in
|
||||||
service_list
|
service_list
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: svc {start|stop|restart|enable|disable} <service> | svc list | svc pkg {install|remove|update|search} [package]"
|
echo "Usage: svc {start|stop|restart|enable|disable} <service> | svc list | svc pkg {install|remove|update|upgrade|keyring|search} [package]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
Loading…
Add table
Add a link
Reference in a new issue