Config file persistence
[helenos.git] / tools / list_profiles.sh
blob6e93bdf9df1ca8d5cc7944f7e7239662a606efd6
1 #!/bin/sh
4 # Copyright (c) 2021 Jiri Svoboda
5 # Copyright (c) 2019 Jiří Zárevúcky
6 # All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
12 # - Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # - Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # - The name of the author may not be used to endorse or promote products
18 # derived from this software without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 # Find out the path to the script.
33 SOURCE_DIR=`which -- "$0" 2>/dev/null`
34 # Maybe we are running bash.
35 [ -z "$SOURCE_DIR" ] && SOURCE_DIR=`which -- "$BASH_SOURCE"`
36 [ -z "$SOURCE_DIR" ] && exit 1
37 SOURCE_DIR=`dirname -- "$SOURCE_DIR"`
38 SOURCE_DIR=`cd $SOURCE_DIR && cd .. && echo $PWD`
40 CONFIG_DEFAULTS="${SOURCE_DIR}/defaults"
42 # Find the leaf subdirectories in the defaults directory.
43 level1dirs=`ls "$CONFIG_DEFAULTS"`
44 for dname in $level1dirs; do
45 l2dirs=`ls "$CONFIG_DEFAULTS"/"$dname"`
46 havel2=
47 for dn in $l2dirs; do
48 if [ -d "$CONFIG_DEFAULTS/$dname/$dn" ]; then
49 echo "$dname/$dn"
50 havel2=true
52 done
53 if [ -z "$havel2" ]; then
54 echo "$dname"
56 done