Annotation of /alx-src/branches/alxconf-060/functions/common.sh
Parent Directory | Revision Log
Revision 2032 -
(hide annotations)
(download)
(as text)
Wed May 11 09:10:03 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 545 byte(s)
Wed May 11 09:10:03 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 545 byte(s)
-added common.sh with global addconfig() and clearconfig() functions
1 | niro | 2032 | # $Id$ |
2 | |||
3 | addconfig() | ||
4 | { | ||
5 | local opts | ||
6 | |||
7 | if [[ -z ${CONFIG} ]] | ||
8 | then | ||
9 | echo "You must define \$CONFIG varibale first!" | ||
10 | return 1 | ||
11 | fi | ||
12 | |||
13 | if [[ ! -d $(dirname ${CONFIG}) ]] | ||
14 | then | ||
15 | install -d $(dirname ${CONFIG}) | ||
16 | fi | ||
17 | |||
18 | # check for opts | ||
19 | case $1 in | ||
20 | -n) shift; opts=" -n" ;; | ||
21 | -e) shift; opts=" -e" ;; | ||
22 | esac | ||
23 | |||
24 | echo ${opts} "$@" >> ${CONFIG} | ||
25 | } | ||
26 | |||
27 | clearconfig() | ||
28 | { | ||
29 | if [[ -z ${CONFIG} ]] | ||
30 | then | ||
31 | echo "You must define \$CONFIG varibale first!" | ||
32 | return 1 | ||
33 | fi | ||
34 | |||
35 | if [[ ! -d $(dirname ${CONFIG}) ]] | ||
36 | then | ||
37 | install -d $(dirname ${CONFIG}) | ||
38 | fi | ||
39 | : > ${CONFIG} | ||
40 | } |