appassembler icon indicating copy to clipboard operation
appassembler copied to clipboard

Cannot Modify BASEDIR

Open opticyclic opened this issue 9 years ago • 4 comments

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.

opticyclic avatar Aug 29 '15 17:08 opticyclic

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...

khmarbaise avatar Aug 30 '15 11:08 khmarbaise

:+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>

to redefine BASEDIR but here didn't work beacuse of it.

jvrmaia avatar Sep 04 '15 16:09 jvrmaia

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

dantran avatar May 10 '16 16:05 dantran

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

dantran avatar May 22 '16 19:05 dantran