[Bashburn-info] NEW bashburn config file determination
Brought to you by:
bashburn
From: Markus K. <mar...@on...> - 2008-09-30 16:20:59
|
I was nerved to only get bashburn to work by running "Install.sh" which then in turn modifies "BashBurn.sh" to the correct "BBROOTDIR". This may work but has some disadvantages: 1. Programs modifying other programs code is not always nice and clear. And if someone does not know the typeset BBROOTDIR='@@BBROOTDIR@@' construct there could happen ugly things. Also it may become a maintenance nightmare. 2. Distributions can not clearly build their own package installer since bashburn does not work unless bashburn "Install.sh" is executed. 3. The user expects traditionally under unixes following strategies to search for config-file: -> search user's $HOME for config. -> search system wide config (mostly in "/etc/"). -> fetch some (hard-coded) default config or ask user interactively for config source or values. I have now changed "BashBurn.sh" in my local trunk and added following (note that for this to work in "bashburn.rc" "BBROOTDIR" has to be added and set again): ------- #!/bin/bash ############################################################################### # Checks whether given file is readable and a actual config file of bashburn. # IN[1]: FILENAME. # OUT[SUCCESS]: <TRUE> # OUT[FAILURE]: <FALSE> function is_valid_configfile { test -r $1 && grep -q "VERSION: 3.x" $1 } ## Determine the root directory (BBROOTDIR) of bashburn where all ## additional programm files for basburn are. ## CASE1: user config from $HOME: if is_valid_configfile "$HOME/.bashburnrc" then typeset BBROOTDIR=$(grep "BBROOTDIR" $HOME/.bashburnrc | cut -d: -f2) ## CASE2: global config from /etc/ elif is_valid_configfile "/etc/.bashburnrc" then typeset BBROOTDIR=$(grep "BBROOTDIR" /etc/.bashburnrc | cut -d: -f2) ## CASE3: Config from bashburn Install.sh: else # NOTE: BBROOTDIR will be later actualized by bashburn installation script # "Install.sh". typeset BBROOTDIR='@@BBROOTDIR@@' fi ----------- Let me know what you think. I have not checked it in yet, since our svn-server seems not online in the moment. Like you see I have left the "@@BBROOTDIR@@" as last option, but maybe we should delete it if there is no good reason against it. Markus |