appassembler
appassembler copied to clipboard
Cannot Modify BASEDIR
When I generate-daemons I want to change the directory of the scripts to the root instead of in a bin dir.
It appears that the BASEDIR is hard coded like this:
# discover BASEDIR
BASEDIR=`dirname "$0"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
The BASEDIR gets set to the level above the location of the script. This makes sense when you are in bin but not if you are in the root or even if you are in a nested dir.
BASEDIR should be configurable.
By BASEDIR all other things are calculated conf/logs folder etc. This will be a bigger change...If you like to provide a PR incl. tests i would appreciate that...But at the moment i don't see a real advantage nor a use case for it...May be you can explain more in detail your use case or the reasons for trying to...
:+1:
my /etc/init.d/appname
...
# Application
APP_NAME="appname"
APP_LONG_NAME="appname"
# discover BASEDIR
BASEDIR=`dirname "$0"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
ls -l "$0" | grep -e '->' > /dev/null 2>&1
if [ $? = 0 ]; then
#this is softlink
_PWD=`pwd`
_EXEDIR=`dirname "$0"`
cd "$_EXEDIR"
_BASENAME=`basename "$0"`
_REALFILE=`ls -l "$_BASENAME" | sed 's/.*->\ //g'`
BASEDIR=`dirname "$_REALFILE"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
cd "$_PWD"
fi
[ -f "$BASEDIR"/bin/../conf/pre-run.sh ] && . "$BASEDIR"/bin/../conf/pre-run.sh
# Debugger
echo $0 $@ " --- " $BASEDIR >> /tmp/debug.log
# Wrapper
WRAPPER_CMD="./wrapper"
WRAPPER_CONF="$BASEDIR/etc/wrapper.conf"
...
debugger output:
/etc/rc0.d/K80appname stop --- /etc
/etc/init.d/appname stop --- /opt/appname
/etc/rc3.d/S20appname start --- /etc
/etc/init.d/appname start --- /opt/appname
this is my point to set BASEDIR.
I tried it in pom.xml:
<environmentSetupFileName>/opt/appname/config_basedir.sh</environmentSetupFileName>
I think BASEDIR should be internal only to allow appassembler generated scripts to call each others without worry about the possibility of external BASEDIR can interfere
For init.d script, i create softlink to the real script. that should work
Also 'enronmentSetupFileName as documented, must be under bin directory which also has the generated script