summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Lacerda <alacerda@alpinelinux.org>2015-04-30 17:19:28 +0000
committerAlan Lacerda <alacerda@alpinelinux.org>2015-04-30 17:19:28 +0000
commit674448cd2a078ff70f9e45508ad3da39b3628e8e (patch)
tree3fddead40330d3e9a106c3ed07c781c9f43123f4
parentadd01f0e1a1d32ca06ebad37b4bbf4aceec9f6ed (diff)
downloadsetup-box-674448cd2a078ff70f9e45508ad3da39b3628e8e.tar.bz2
setup-box-674448cd2a078ff70f9e45508ad3da39b3628e8e.tar.xz
setup-box: fixing getopts for -s option
-rwxr-xr-xsetup-box56
1 files changed, 35 insertions, 21 deletions
diff --git a/setup-box b/setup-box
index 86c7633..78f2192 100755
--- a/setup-box
+++ b/setup-box
@@ -62,12 +62,14 @@ __EOF__
# Installing all dependencies for setup-box.
insdep() {
- apk add -q --virtual .setup-box $DEPS || exit 126
+ apk add -q --virtual .setup-box $DEPS \
+ || exit 126
}
# Once setup-box has finished its job, we can get rid of all dependencies previously installed
deldep() {
- apk del -q .setup-box || exit 126
+ apk del -q .setup-box \
+ || exit 126
}
# We need to exclude $desktop_json from the list. This is due to the fact that
@@ -86,25 +88,32 @@ for i in $(ls $JSON_DIR/*.json); do
# group to be installed
## Called by -s option
search_sub_group() {
- for f in $json_files; do
- if [ "${1%.*}" != "desktop" ]; then
- if [ $(cat $f | jq ".${1%.*} | length") ]; then
- for j in $@; do
- core=$(echo $j | cut -d. -f1)
- sub=$(echo $j | cut -d. -f2)
-
- packages=$(cat $f \
- | jq ".$core[] \
- | select(.$sub)" \
- | egrep -Ev '\{|:|]|}' \
- | sed 's/\"//g' \
- | sed 's/,//g')
-
- final_pack="$final_pack "$packages
- done
+ for f in $json_files; do
+ if [ "${1%.*}" != "desktop" ]; then
+ if [ $(cat $f | jq ".${1%.*} | length") ]; then
+ for j in $@; do
+ core=$(echo $j | cut -d. -f1)
+ sub=$(echo $j | cut -d. -f2)
+
+ packages=$(cat $f \
+ | jq ".$core[] \
+ | select(.$sub)" \
+ | egrep -Ev '\{|:|]|}' \
+ | sed 's/\"//g' \
+ | sed 's/,//g')
+
+ services=$(cat $f \
+ | jq ".$core[].$sub[].services[]" \
+ | egrep -Ev '\{|:|]|}' \
+ | sed 's/\"//g' \
+ | sed 's/,//g')
+
+ final_pack="$final_pack "$packages
+ final_serv="$final_serv "$services
+ done
+ fi
fi
- fi
- done
+ done
}
# Selecting a whole meta-group to be installed
@@ -156,8 +165,13 @@ search_desktop() {
| egrep -Ev '\{|:|]|}' \
| sed 's/\"//g' \
| sed 's/,//g')
+
+ services=$(cat $desktop_json \
+ | jq ".desktop[].$1[].services[]" \
+ | sed 's/\"//g')
final_pack="$final_pack "$packages
+ final_serv="$final_serv "$services
fi
}
@@ -219,7 +233,7 @@ main () {
fi
# If there is any argument... let's work
- while getopts "d:e:g:hlvV" opt ; do
+ while getopts "d:s:g:hlvV" opt ; do
case $opt in
d) search_desktop "$OPTARG";;
s) search_sub_group "$OPTARG";;