-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrapper for package manipulation
- Loading branch information
1 parent
3740e7d
commit a4087db
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# interface_package.sh | ||
|
||
declare -A module_options | ||
module_options+=( | ||
["package,author"]="@dimitry-ishenko" | ||
["package,desc"]="Install package" | ||
["package,example"]="pkg_install neovim" | ||
["package,feature"]="pkg_install" | ||
["package,status"]="Interface" | ||
) | ||
|
||
pkg_install() | ||
{ | ||
local apt=(apt-get -y) | ||
[[ $- == *i* ]] && apt=(debconf-apt-progress -- ${apt[@]}) | ||
${apt[@]} install "$@" | ||
} | ||
|
||
module_options+=( | ||
["package,author"]="@dimitry-ishenko" | ||
["package,desc"]="Remove package" | ||
["package,example"]="pkg_remove nmap" | ||
["package,feature"]="pkg_remove" | ||
["package,status"]="Interface" | ||
) | ||
|
||
pkg_remove() | ||
{ | ||
local apt=(apt-get -y) | ||
[[ $- == *i* ]] && apt=(debconf-apt-progress -- ${apt[@]}) | ||
${apt[@]} autopurge "$@" | ||
} | ||
|
||
module_options+=( | ||
["package,author"]="@dimitry-ishenko" | ||
["package,desc"]="Check package status: 0 = installed, 1 = otherwise" | ||
["package,example"]="pkg_check mc" | ||
["package,feature"]="pkg_check" | ||
["package,status"]="Interface" | ||
) | ||
|
||
pkg_check() | ||
{ | ||
local status=$(dpkg -s "$1" 2>/dev/null | sed -n "s/Status: //p") | ||
! [[ -z "$status" || "$status" = *deinstall* || "$status" = *not-installed* ]] | ||
} |