xref: /aosp_15_r20/external/libconfig/contrib/ls-config/sample/script (revision 2e9d491483b805f09ea864149eadd5680efcc72a)
1*2e9d4914SAndroid Build Coastguard Worker#!/bin/bash
2*2e9d4914SAndroid Build Coastguard Worker
3*2e9d4914SAndroid Build Coastguard Worker#title          :script
4*2e9d4914SAndroid Build Coastguard Worker#description    :this script only demonstrate usage of ls-config
5*2e9d4914SAndroid Build Coastguard Worker#author         :Łukasz A. Grabowski <[email protected]>
6*2e9d4914SAndroid Build Coastguard Worker#date           :20130928
7*2e9d4914SAndroid Build Coastguard Worker#version        :1.0.3
8*2e9d4914SAndroid Build Coastguard Worker#notes          :This only read one value from configuration file
9*2e9d4914SAndroid Build Coastguard Worker#               :this script MUST be run from subdirectory of dir
10*2e9d4914SAndroid Build Coastguard Worker#               :where ls-config (bin) and lslib-core are stored
11*2e9d4914SAndroid Build Coastguard Worker#               :to place script in other places You must reconfigure paths
12*2e9d4914SAndroid Build Coastguard Worker#bash_version   :4.2.37(1)-release
13*2e9d4914SAndroid Build Coastguard Worker#copywrite      :Copyright (C) 2013 Łukasz A. Grabowski
14*2e9d4914SAndroid Build Coastguard Worker#license        :This program is free software: you can redistribute
15*2e9d4914SAndroid Build Coastguard Worker#               :it and/or modify it under the terms of the GNU General
16*2e9d4914SAndroid Build Coastguard Worker#               :Public License as published by the Free Software
17*2e9d4914SAndroid Build Coastguard Worker#               :Foundation, either version 2 of the License or
18*2e9d4914SAndroid Build Coastguard Worker#               :any later version.
19*2e9d4914SAndroid Build Coastguard Worker#               :
20*2e9d4914SAndroid Build Coastguard Worker#               :This program is distributed in the hope that it will
21*2e9d4914SAndroid Build Coastguard Worker#               :be useful, but WITHOUT ANY WARRANTY; without even the
22*2e9d4914SAndroid Build Coastguard Worker#               :implied warranty of MERCHANTABILITY or FITNESS FOR
23*2e9d4914SAndroid Build Coastguard Worker#               :A PARTICULAR PURPOSE. See the GNU General Public
24*2e9d4914SAndroid Build Coastguard Worker#               :License for more details.
25*2e9d4914SAndroid Build Coastguard Worker#               :
26*2e9d4914SAndroid Build Coastguard Worker#               :You should have received a copy of the GNU General
27*2e9d4914SAndroid Build Coastguard Worker#               :Public License along with this program. If not, see
28*2e9d4914SAndroid Build Coastguard Worker#               :http://www.gnu.org/licenses/.
29*2e9d4914SAndroid Build Coastguard Worker#=======================================================================
30*2e9d4914SAndroid Build Coastguard Worker
31*2e9d4914SAndroid Build Coastguard Worker
32*2e9d4914SAndroid Build Coastguard Worker#set app flag
33*2e9d4914SAndroid Build Coastguard WorkerLS_EXEC=1
34*2e9d4914SAndroid Build Coastguard Worker
35*2e9d4914SAndroid Build Coastguard Worker#set configuration directory
36*2e9d4914SAndroid Build Coastguard WorkerCFGD="./"
37*2e9d4914SAndroid Build Coastguard Worker
38*2e9d4914SAndroid Build Coastguard Worker#source bash library to manipulate config
39*2e9d4914SAndroid Build Coastguard Workersource ../lslib-core
40*2e9d4914SAndroid Build Coastguard Worker
41*2e9d4914SAndroid Build Coastguard Worker#path direcrories onlny for this sample
42*2e9d4914SAndroid Build Coastguard WorkerPACD="../"
43*2e9d4914SAndroid Build Coastguard WorkerLIBD=""
44*2e9d4914SAndroid Build Coastguard Worker#end path
45*2e9d4914SAndroid Build Coastguard Worker
46*2e9d4914SAndroid Build Coastguard Worker#read data from configuration file
47*2e9d4914SAndroid Build Coastguard WorkerTEST=$(cfg_f_g "config" "info")
48*2e9d4914SAndroid Build Coastguard WorkerERR="$?"
49*2e9d4914SAndroid Build Coastguard Worker
50*2e9d4914SAndroid Build Coastguard Worker#show data
51*2e9d4914SAndroid Build Coastguard Workerecho "Info value: $TEST"
52*2e9d4914SAndroid Build Coastguard Workerecho "Reading error: $ERR"
53*2e9d4914SAndroid Build Coastguard Worker
54*2e9d4914SAndroid Build Coastguard Worker#show other method of reading value:
55*2e9d4914SAndroid Build Coastguard Worker
56*2e9d4914SAndroid Build Coastguard Worker#output space and info
57*2e9d4914SAndroid Build Coastguard Workerecho ""
58*2e9d4914SAndroid Build Coastguard Workerecho "Reading using binary:"
59*2e9d4914SAndroid Build Coastguard Worker
60*2e9d4914SAndroid Build Coastguard Worker#read data from configuration file
61*2e9d4914SAndroid Build Coastguard WorkerTEST=$(${PACD}ls-config -f config --get="info" -vq)
62*2e9d4914SAndroid Build Coastguard WorkerERR="$?"
63*2e9d4914SAndroid Build Coastguard Worker
64*2e9d4914SAndroid Build Coastguard Worker#show data
65*2e9d4914SAndroid Build Coastguard Workerecho "Info value: $TEST"
66*2e9d4914SAndroid Build Coastguard Workerecho "Reading error: $ERR"
67*2e9d4914SAndroid Build Coastguard Worker
68*2e9d4914SAndroid Build Coastguard Workerexit 0;
69