add: apt, xbps, and dnf support, help section

This commit is contained in:
mollusk 2018-07-19 15:17:03 -07:00
parent 8f97d1807f
commit 89edde9b5c

143
tux.sh
View File

@ -2,7 +2,7 @@
: 'The MIT License (MIT) : 'The MIT License (MIT)
Copyright (c) 2015 Joe Martella Copyright (c) 2018 Justin moore
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -22,5 +22,144 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.' SOFTWARE.'
############################################ # Colors
RED='\033[0;31m'
LRED="\033[1;31m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
PURPLE="\033[0;35m"
LPURPLE="\033[1;35m"
BWHITE="\e[1m"
######################
## PATHS & DEBUG ##
######################
WORK_DIR="/usr/bin"
DEBUG="false" # shows debug mesages, values: true, false
#######################
## PACKAGE MANAGERS ##
#######################
# Add your package manager to the list
declare -a MANAGER=(
'apt'
'dnf'
'xbps-install')
######################
for i in "${MANAGER[@]}";do
if [ -f ${WORK_DIR}/${i} ];then
MANAGER=$i
if [ "${DEBUG}" = "true" ];then
echo -e "\n${LGREEN}Detected '$MANAGER${NC}'\n"
fi
elif [ -z ${i} ];then
echo -e "\n${LRED}Unsupported distribution${NC}\n"
fi
done
###########################
## PACKAGE MANAGER ARGS ##
###########################
# Create additional 'elif' and add specific commands for your package manager
if [ "${MANAGER}" = "apt" ];then
installCmd="${MANAGER} install"
cleanCmd="${MANAGER} clean"
orphanCmd="${MANAGER} autoremove"
reinstallCmd="${MANAGER} install --reinstall"
removeCmd="${MANAGER} remove"
searchCmd="${MANAGER} search"
supCmd="${MANAGER} update && ${MANAGER} upgrade"
elif [ "${MANAGER}" = "dnf" ];then
installCmd="${MANAGER} install"
cleanCmd="${MANAGER} clean all"
orphanCmd="${MANAGER} autoremove"
removeCmd="${MANAGER} remove"
reinstallCmd="${MANAGER} reinstall"
searchCmd="${MANAGER} search"
supCmd="${MANAGER} --refresh upgrade"
elif [ "${MANAGER}" = "xbps-install" ];then
installCmd="${MANAGER}"
cleanCmd="${MANAGER} -o"
orphanCmd="${MANAGER} -O"
removeCmd="xbps-remove"
reinstallCmd="${MANAGER} -f"
searchCmd="xbps-query -Rs"
supCmd="${MANAGER} -Su"
fi
checkArg(){
if [ -z "${1}" ];then
echo -e "\n${YELLOW}You need to supply and argument!${NC}\n"
exit 1;
fi
}
#find ${WORK_DIR}/ -iname ${MANAGERS}
case ${1} in
i | -i | install)
${installCmd} "${2}"
;;
c | -c | clean)
${cleanCmd}
;;
o | -o | orphans)
${orphanCmd}
;;
ri | -ri | reinstall)
checkArg ${2}
${reinstallCmd} "${2}"
;;
s | -s | search)
checkArg ${2}
${searchCmd} "${2}"
;;
-Syu | -Su | sup)
${supCmd}
;;
r | -r | remove)
checkArg ${2}
${removeCmd} "${2}"
;;
* | -h | --help | help)
echo -e "${0} [option] <argument>\n\n"
echo -e "i,-i,install Install package(s)\n"
echo -e "c,-c,clean Clean package cache\n"
echo -e "o,-o,orphans Remove disassociated packages\n"
echo -e "ri,-ri,reinstall Reinstall package(s)\n"
echo -e "r,-r,remove Remove package(s)\n"
echo -e "s,-s,search Search for packages\n"
echo -e "-Syu,-Su,sup Sync repodata and upgrade all\n"
esac