Contents of /alx-src/trunk/alxinstall-ng/functions/generic.sh
Parent Directory | Revision Log
Revision 6829 -
(show annotations)
(download)
(as text)
Thu Jul 23 11:50:00 2015 UTC (8 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 557 byte(s)
Thu Jul 23 11:50:00 2015 UTC (8 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 557 byte(s)
-introduce addconfig() and clearconfig() function
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | addconfig() |
5 | { |
6 | local opts |
7 | |
8 | if [[ -z ${CONFIG} ]] |
9 | then |
10 | echo "You must define \$CONFIG varibale first!" |
11 | return 1 |
12 | fi |
13 | |
14 | if [[ ! -d $(dirname ${CONFIG}) ]] |
15 | then |
16 | install -d $(dirname ${CONFIG}) |
17 | fi |
18 | |
19 | # check for opts |
20 | case $1 in |
21 | -n) shift; opts=" -n" ;; |
22 | -e) shift; opts=" -e" ;; |
23 | esac |
24 | |
25 | echo ${opts} "$@" >> ${CONFIG} |
26 | } |
27 | |
28 | clearconfig() |
29 | { |
30 | if [[ -z ${CONFIG} ]] |
31 | then |
32 | echo "You must define \$CONFIG varibale first!" |
33 | return 1 |
34 | fi |
35 | |
36 | if [[ ! -d $(dirname ${CONFIG}) ]] |
37 | then |
38 | install -d $(dirname ${CONFIG}) |
39 | fi |
40 | : > ${CONFIG} |
41 | } |