-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
uni
executable file
·102 lines (95 loc) · 3.9 KB
/
uni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
operating_system=`cat /etc/os-release | grep -oP '(?<=^ID=)(.*)'`
operating_system_based=`cat /etc/os-release | grep -oP '(?<=^ID_LIKE=)(.*)'`
uni_version=`cat /usr/share/uni/version.txt`
declare -i version_without_dots="${uni_version//'.'}"
if [[ "$operating_system_based" == "ubuntu" || "$operating_system" == "deepin" ]]; then
operating_system='ubuntu'
fi
# Include UNI Styles
. /usr/share/uni/src/tools/styles
# Include Bake function
. /usr/share/uni/src/tools/bake
while [ "$#" -gt 0 ]; do
case "$1" in
# system updaate
update | u | --update | -u)
. /usr/share/uni/src/$operating_system/update.sh
update
;;
# system upgrade
upgrade | up | --upgrade | -up)
. /usr/share/uni/src/$operating_system/upgrade.sh
upgrade
;;
# upgrade UNI
upgrade-me | up-me | --upgrade-me | -up-me)
. /usr/share/uni/src/tools/upgrade
upgradeUni
;;
# remove UNI
remove-me | rm-me | --remove-me | -rm-me)
. /usr/share/uni/src/tools/remove
removeUni
;;
# remove a package or recipe
remove | rm | --remove | -rm)
. /usr/share/uni/src/$operating_system/remove.sh
package="${@:2}"
remove
;;
# add a repo
add | a | --add | -a)
. /usr/share/uni/src/$operating_system/add.sh
repo="${@:2}"
add
;;
# install a package
install | i | --install | -i)
. /usr/share/uni/src/$operating_system/install.sh
package="${@:2}"
install
;;
# bake a recipe
bake | b | --bake | -b)
if [ "$2" == "how" ]; then
. /usr/share/uni/src/tools/bake_how
recipes="${@:3}"
bake_how
else
recipes="${@:2}"
bake
fi
;;
# check version
--version | -v) printf "${STYLE_LIGHT_CYAN}\n UNI${STYLE_BOLD} v${uni_version}\n\n";;
# get current list of recipes from github
--recipes | -r)
# get README from github
RECIPES_URL="https://raw.githubusercontent.com/uni-linux/recipes/master/src/daltonmenezes/README.md"
RECIPES_PAGE="$(wget -q -O - ${RECIPES_URL} | sed -e 's/<[^>]*>//g' -e 's/- \[/ \\e[33m /g' -e 's/\]/ \\e[0m /g' -e '/> username: daltonmenezes/,/# My Recipes/c\username:\\e[36m daltonmenezes\\n\\n\\e[1mRecipes\\e[0m' -e 's/([^()]*)//g')"
printf "${RECIPES_PAGE}\n\n";;
# display usage info
--help | help | -h | h)
HELP_INFO="
${STYLE_LIGHT_CYAN}${STYLE_BOLD}Usage: ${RESET_STYLE}${STYLE_BOLD}uni [OPTIONS]
${STYLE_LIGHT_CYAN}Options:${RESET_STYLE}
${STYLE_BOLD} -h, --help${RESET_STYLE} Shows available commands
${STYLE_BOLD} -v, --version${RESET_STYLE} Shows the current UNI version installed
${STYLE_BOLD} -r, --recipes${RESET_STYLE} Shows available recipes in the UNI GitHub
${STYLE_BOLD} a, add${RESET_STYLE} Adds one or more repositories
${STYLE_BOLD} b, bake ${STYLE_YELLOW}<recipe>${RESET_STYLE} Cooks one or more given recipes
${STYLE_BOLD} b how, bake how ${STYLE_YELLOW}<recipe>${RESET_STYLE} Shows what one or more recipes does
${STYLE_BOLD} i, install ${STYLE_YELLOW}<package>${RESET_STYLE} Installs one or more packages
${STYLE_BOLD} u, update${RESET_STYLE} Updates the package lists from your repositories
${STYLE_BOLD} up, upgrade${RESET_STYLE} Upgrades deeply the system and remove useless dependencies
${STYLE_BOLD} up-me, upgrade-me${RESET_STYLE} Looks for UNI upgrades, if available it will be upgraded
${STYLE_BOLD} rm, remove ${STYLE_YELLOW}<package>${RESET_STYLE} Removes one or more packages
${STYLE_BOLD} rm-me, remove-me${RESET_STYLE} Removes UNI from the system
"
printf "${HELP_INFO}";;
# unexpected argument
*) printf "${STYLE_RED}\nThe ${RESET_STYLE}'$1'${STYLE_RED} argument doesn't exists. Beep...\n\n"; exit 0;;
esac;
exit 0
done