Trick: Automatically Prepare SDK’s Environment when Start Apache
Here is a trick that allows system automatically prepare an SDK's environment for Puno before starting the Apache webserver.
INDEX
Introduction
One condition in order for Puno can run properly is to start apache in environment prepared by the OpenOffice.org SDK's script setsdkenv_unix. We have to run:
before we call: (with sufficient permission)#[OpenOffice.orgSDK]/setsdkenv_unix
#[ApacheBIN]/apachectl start
This can sometimes complicate the situation, when you want a quick and automatically call to start apache. The following is one of the tricks that can make a direct apachectl script automatically set the necessary environment by Puno.
Step By Step
What is setsdkenv_unix.sh? It is one result of setsdkenv_unix when it was first run.
There are 2 ways to know the location of setsdkenv_unix.sh:
- Output setsdkenv_unix
It is listed in the output of setsdkenv_unix when it was first run. Here is the example output when setsdkenv_unix was finished first run:************************************************************
* ... your SDK environment has been prepared.
* For each time you want to use this configured SDK environment, you
* have to run the "setsdkenv_unix" script file!
* Alternatively can you source one of the scripts
* "/home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.sh"
* "/home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.csh"
* to get an environment without starting a new shell.
************************************************************
************************************************************
*
* SDK environment is prepared for Linux
*
* SDK = /opt/openoffice.org/basis3.1/sdk
* Office = /opt/openoffice.org3
* Office Base = /opt/openoffice.org/basis3.1
* URE = /opt/openoffice.org/ure
* Make = /usr/bin
* Zip = /usr/bin
* C++ Compiler = /usr/bin
* Java = /usr
* SDK Output directory = /home/andreas/openoffice.org3.1_sdk
* Auto deployment = YES
*
************************************************************
- Locate Command
Second, we can locate it using command locate. Here is the example:andreas@andreas-desktop:~$ locate setsdkenv
/home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.csh
/home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.sh
/opt/openoffice.org/basis3.1/sdk/setsdkenv_unix
/opt/openoffice.org/basis3.1/sdk/setsdkenv_unix.csh.in
/opt/openoffice.org/basis3.1/sdk/setsdkenv_unix.sh.in
In the example above, the location of setsdkenv_unix.sh is in /home/andreas/openoffice.org3.1_sdk/andreas-desktop/. After we know the location, we now have to edit apachectl script file.
This is the addition:
if [ -r /home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.sh ]; then
if [ "$ARGV" = "start" ]; then
. /home/andreas/openoffice.org3.1_sdk/andreas-desktop/setsdkenv_unix.sh
fi
fi
Add it after:
ARGV="$@"
Save the file and run it. Here is the result example:
andreas@andreas-desktop:/usr/local/zend/bin$ sudo ./apachectl start
**************************************************************
*
* SDK environment is prepared for Linux
*
* SDK = /opt/openoffice.org/basis3.1/sdk
* Office = /opt/openoffice.org3
* Office Base = /opt/openoffice.org/basis3.1
* URE = /opt/openoffice.org/ure
* Make = /usr/bin
* Zip = /usr/bin
* C++ Compiler = /usr/bin
* Java = /usr
* SDK Output directory = /home/andreas/openoffice.org3.1_sdk
* Auto deployment = YES
*
************************************************************
andreas@andreas-desktop:/usr/local/zend/bin$ netstat -plaNt
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:www 0.0.0.0:* LISTEN -
andreas@andreas-desktop:/usr/local/zend/bin$
Finish. We have make it automatically prepared!
Explanation
- To make sure that setsdkenv_unix.sh in /home/andreas/openoffice.org3.1_sdk/andreas-desktop/ is available and readable.
- To make sure that only start argument, input from apachectl can setup the environment. Other argument, such as stop, restart can not setup the environement.
- Run setsdkenv_unix.sh after all the requirements are satisfied.