|
@@ -40,10 +40,14 @@
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
#echo color
|
|
|
+WHITE_COLOR="\E[1;37m";
|
|
|
+RED_COLOR="\E[1;31m";
|
|
|
+BLUE_COLOR='\E[1;34m';
|
|
|
GREEN_COLOR="\E[1;32m";
|
|
|
+YELLOW_COLOR="\E[1;33m";
|
|
|
RES="\E[0m";
|
|
|
|
|
|
-echo -ne "${GREEN_COLOR}"
|
|
|
+printf "${GREEN_COLOR}\n"
|
|
|
cat<<EOT
|
|
|
|
|
|
--------------------------------------------
|
|
@@ -58,7 +62,31 @@ cat<<EOT
|
|
|
--------------------------------------------
|
|
|
|
|
|
EOT
|
|
|
-echo -ne "${RES}";
|
|
|
+printf "${RES}\n";
|
|
|
+
|
|
|
+echo_r () {
|
|
|
+ # Color red: Error, Failed
|
|
|
+ [ $# -ne 1 ] && return 1
|
|
|
+ printf "[${BLUE_COLOR}opencron${RES}] ${RED_COLOR}$1${RES}\n"
|
|
|
+}
|
|
|
+
|
|
|
+echo_g () {
|
|
|
+ # Color green: Success
|
|
|
+ [ $# -ne 1 ] && return 1
|
|
|
+ printf "[${BLUE_COLOR}opencron${RES}] ${GREEN_COLOR}$1${RES}\n"
|
|
|
+}
|
|
|
+
|
|
|
+echo_y () {
|
|
|
+ # Color yellow: Warning
|
|
|
+ [ $# -ne 1 ] && return 1
|
|
|
+ printf "[${BLUE_COLOR}opencron${RES}] ${YELLOW_COLOR}$1${RES}\n"
|
|
|
+}
|
|
|
+
|
|
|
+echo_w () {
|
|
|
+ # Color yellow: White
|
|
|
+ [ $# -ne 1 ] && return 1
|
|
|
+ printf "[${BLUE_COLOR}opencron${RES}] ${WHITE_COLOR}$1${RES}\n"
|
|
|
+}
|
|
|
|
|
|
|
|
|
# OS specific support. $var _must_ be set to either true or false.
|
|
@@ -116,13 +144,13 @@ fi
|
|
|
# as this is used as the separator in the classpath and Java provides no
|
|
|
# mechanism for escaping if the same character appears in the path.
|
|
|
case $OPENCRON_HOME in
|
|
|
- *:*) echo "Using OPENCRON_HOME: $OPENCRON_HOME";
|
|
|
- echo "Unable to start as OPENCRON_HOME contains a colon (:) character";
|
|
|
+ *:*) echo_w "Using OPENCRON_HOME: $OPENCRON_HOME";
|
|
|
+ echo_w "Unable to start as OPENCRON_HOME contains a colon (:) character";
|
|
|
exit 1;
|
|
|
esac
|
|
|
case $OPENCRON_BASE in
|
|
|
- *:*) echo "Using OPENCRON_BASE: $OPENCRON_BASE";
|
|
|
- echo "Unable to start as OPENCRON_BASE contains a colon (:) character";
|
|
|
+ *:*) echo_w "Using OPENCRON_BASE: $OPENCRON_BASE";
|
|
|
+ echo_w "Unable to start as OPENCRON_BASE contains a colon (:) character";
|
|
|
exit 1;
|
|
|
esac
|
|
|
|
|
@@ -187,7 +215,7 @@ OPENCRON_PIDDIR="/var/run";
|
|
|
OPENCRON_PID="$OPENCRON_PIDDIR/opencron.pid";
|
|
|
|
|
|
#opencron version
|
|
|
-OPENCRON_VERSION="1.2.0-RELEASE"
|
|
|
+OPENCRON_VERSION="1.1.0-RELEASE"
|
|
|
|
|
|
# Add bootstrap.jar to classpath
|
|
|
if [ ! -z "$CLASSPATH" ] ; then
|
|
@@ -215,17 +243,17 @@ fi
|
|
|
|
|
|
# Bugzilla 37848: only output this if we have a TTY
|
|
|
if [ $have_tty -eq 1 ]; then
|
|
|
- echo "Using OPENCRON_BASE: $OPENCRON_BASE"
|
|
|
- echo "Using OPENCRON_HOME: $OPENCRON_HOME"
|
|
|
- echo "Using OPENCRON_TMPDIR: $OPENCRON_TMPDIR"
|
|
|
+ echo_w "Using OPENCRON_BASE: $OPENCRON_BASE"
|
|
|
+ echo_w "Using OPENCRON_HOME: $OPENCRON_HOME"
|
|
|
+ echo_w "Using OPENCRON_TMPDIR: $OPENCRON_TMPDIR"
|
|
|
if [ "$1" = "debug" ] ; then
|
|
|
- echo "Using JAVA_HOME: $JAVA_HOME"
|
|
|
+ echo_w "Using JAVA_HOME: $JAVA_HOME"
|
|
|
else
|
|
|
- echo "Using JRE_HOME: $JRE_HOME"
|
|
|
+ echo_w "Using JRE_HOME: $JRE_HOME"
|
|
|
fi
|
|
|
- echo "Using CLASSPATH: $CLASSPATH"
|
|
|
+ echo_w "Using CLASSPATH: $CLASSPATH"
|
|
|
if [ ! -z "$OPENCRON_PID" ]; then
|
|
|
- echo "Using OPENCRON_PID: $OPENCRON_PID"
|
|
|
+ echo_w "Using OPENCRON_PID: $OPENCRON_PID"
|
|
|
fi
|
|
|
fi
|
|
|
|
|
@@ -257,21 +285,21 @@ case "$1" in
|
|
|
|
|
|
if [ -z "$OPENCRON_PORT" ];then
|
|
|
OPENCRON_PORT=1577;
|
|
|
- echo "opencron port not input,will be used port:1577"
|
|
|
+ echo_w "opencron port not input,will be used port:1577"
|
|
|
elif [ $OPENCRON_PORT -lt 0 ] || [ $OPENCRON_PORT -gt 65535 ];then
|
|
|
- echo "port error,muse be between 0 and 65535!"
|
|
|
+ echo_r "port error,muse be between 0 and 65535!"
|
|
|
fi
|
|
|
|
|
|
if [ -z "$OPENCRON_PASSWORD" ];then
|
|
|
#.password file not exists
|
|
|
if [ ! -f "$OPENCRON_BASE/.password" ];then
|
|
|
OPENCRON_PASSWORD="opencron";
|
|
|
- echo "opencron password not input,will be used password:opencron"
|
|
|
+ echo_w "opencron password not input,will be used password:opencron"
|
|
|
else
|
|
|
#.password file already exists but empty
|
|
|
if [ x`cat "$OPENCRON_BASE/.password"` = x"" ];then
|
|
|
OPENCRON_PASSWORD="opencron";
|
|
|
- echo "opencron password not input,will be used password:opencron"
|
|
|
+ echo_r "opencron password not input,will be used password:opencron"
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
@@ -279,36 +307,36 @@ case "$1" in
|
|
|
if [ ! -z "$OPENCRON_PID" ]; then
|
|
|
if [ -f "$OPENCRON_PID" ]; then
|
|
|
if [ -s "$OPENCRON_PID" ]; then
|
|
|
- echo "Existing PID file found during start."
|
|
|
+ echo_w "Existing PID file found during start."
|
|
|
if [ -r "$OPENCRON_PID" ]; then
|
|
|
PID=`cat "$OPENCRON_PID"`
|
|
|
ps -p $PID >/dev/null 2>&1
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
- echo "opencron appears to still be running with PID $PID. Start aborted."
|
|
|
- echo "If the following process is not a opencron process, remove the PID file and try again:"
|
|
|
+ echo_r "opencron appears to still be running with PID $PID. Start aborted."
|
|
|
+ echo_r "If the following process is not a opencron process, remove the PID file and try again:"
|
|
|
ps -f -p $PID
|
|
|
exit 1
|
|
|
else
|
|
|
- echo "Removing/clearing stale PID file."
|
|
|
+ echo_w "Removing/clearing stale PID file."
|
|
|
rm -f "$OPENCRON_PID" >/dev/null 2>&1
|
|
|
if [ $? != 0 ]; then
|
|
|
if [ -w "$OPENCRON_PID" ]; then
|
|
|
cat /dev/null > "$OPENCRON_PID"
|
|
|
else
|
|
|
- echo "Unable to remove or clear stale PID file. Start aborted."
|
|
|
+ echo_r "Unable to remove or clear stale PID file. Start aborted."
|
|
|
exit 1
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
else
|
|
|
- echo "Unable to read PID file. Start aborted."
|
|
|
+ echo_r "Unable to read PID file. Start aborted."
|
|
|
exit 1
|
|
|
fi
|
|
|
else
|
|
|
rm -f "$OPENCRON_PID" >/dev/null 2>&1
|
|
|
if [ $? != 0 ]; then
|
|
|
if [ ! -w "$OPENCRON_PID" ]; then
|
|
|
- echo "Unable to remove or write to empty PID file. Start aborted."
|
|
|
+ echo_r "Unable to remove or write to empty PID file. Start aborted."
|
|
|
exit 1
|
|
|
fi
|
|
|
fi
|
|
@@ -332,7 +360,7 @@ case "$1" in
|
|
|
if [ ! -z "$OPENCRON_PID" ]; then
|
|
|
echo $! > "$OPENCRON_PID"
|
|
|
fi
|
|
|
- echo "opencron started."
|
|
|
+ echo_g "opencron started."
|
|
|
exit $?
|
|
|
;;
|
|
|
|
|
@@ -362,14 +390,14 @@ case "$1" in
|
|
|
#kill..
|
|
|
kill -0 `cat "$OPENCRON_PID"` >/dev/null 2>&1
|
|
|
if [ $? -gt 0 ]; then
|
|
|
- echo "PID file found but no matching process was found. Stop aborted."
|
|
|
+ echo_r "PID file found but no matching process was found. Stop aborted."
|
|
|
exit 1
|
|
|
fi
|
|
|
else
|
|
|
- echo "PID file is empty and has been ignored."
|
|
|
+ echo_r "PID file is empty and has been ignored."
|
|
|
fi
|
|
|
else
|
|
|
- echo "\$OPENCRON_PID was set but the specified file does not exist. Is opencron running? Stop aborted."
|
|
|
+ echo_r "\$OPENCRON_PID was set but the specified file does not exist. Is opencron running? Stop aborted."
|
|
|
exit 1
|
|
|
fi
|
|
|
fi
|
|
@@ -378,12 +406,12 @@ case "$1" in
|
|
|
-classpath "\"$CLASSPATH\"" \
|
|
|
-Dopencron.home="$OPENCRON_HOME" \
|
|
|
-Dopencron.pid="$OPENCRON_PID" \
|
|
|
- org.opencron.agent.Bootstrap stop
|
|
|
+ org.opencron.agent.AgentBootstrap stop
|
|
|
|
|
|
# stop failed. Shutdown port disabled? Try a normal kill.
|
|
|
if [ $? != 0 ]; then
|
|
|
if [ ! -z "$OPENCRON_PID" ]; then
|
|
|
- echo "The stop command failed. Attempting to signal the process to stop through OS signal."
|
|
|
+ echo_r "The stop command failed. Attempting to signal the process to stop through OS signal."
|
|
|
kill -15 `cat "$OPENCRON_PID"` >/dev/null 2>&1
|
|
|
fi
|
|
|
fi
|
|
@@ -400,21 +428,21 @@ case "$1" in
|
|
|
# If opencron has stopped don't try and force a stop with an empty PID file
|
|
|
FORCE=0
|
|
|
else
|
|
|
- echo "The PID file could not be removed or cleared."
|
|
|
+ echo_r "The PID file could not be removed or cleared."
|
|
|
fi
|
|
|
fi
|
|
|
- echo "opencron stopped."
|
|
|
+ echo_r "opencron stopped."
|
|
|
break
|
|
|
fi
|
|
|
if [ $SLEEP -gt 0 ]; then
|
|
|
sleep 1
|
|
|
fi
|
|
|
if [ $SLEEP -eq 0 ]; then
|
|
|
- echo "opencron did not stop in time."
|
|
|
+ echo_w "opencron did not stop in time."
|
|
|
if [ $FORCE -eq 0 ]; then
|
|
|
- echo "PID file was not removed."
|
|
|
+ echo_w "PID file was not removed."
|
|
|
fi
|
|
|
- echo "To aid diagnostics a thread dump has been written to standard out."
|
|
|
+ echo_w "To aid diagnostics a thread dump has been written to standard out."
|
|
|
kill -3 `cat "$OPENCRON_PID"`
|
|
|
fi
|
|
|
SLEEP=`expr $SLEEP - 1 `;
|
|
@@ -425,11 +453,11 @@ case "$1" in
|
|
|
KILL_SLEEP_INTERVAL=5
|
|
|
if [ $FORCE -eq 1 ]; then
|
|
|
if [ -z "$OPENCRON_PID" ]; then
|
|
|
- echo "Kill failed: \$OPENCRON_PID not set"
|
|
|
+ echo_w "Kill failed: \$OPENCRON_PID not set"
|
|
|
else
|
|
|
if [ -f "$OPENCRON_PID" ]; then
|
|
|
PID=`cat "$OPENCRON_PID"`
|
|
|
- echo "Killing opencron with the PID: $PID"
|
|
|
+ echo_w "Killing opencron with the PID: $PID"
|
|
|
kill -9 $PID
|
|
|
while [ $KILL_SLEEP_INTERVAL -ge 0 ]; do
|
|
|
kill -0 `cat "$OPENCRON_PID"` >/dev/null 2>&1
|
|
@@ -439,10 +467,10 @@ case "$1" in
|
|
|
if [ -w "$OPENCRON_PID" ]; then
|
|
|
cat /dev/null > "$OPENCRON_PID"
|
|
|
else
|
|
|
- echo "The PID file could not be removed."
|
|
|
+ echo_r "The PID file could not be removed."
|
|
|
fi
|
|
|
fi
|
|
|
- echo "The opencron process has been killed."
|
|
|
+ echo_w "The opencron process has been killed."
|
|
|
break
|
|
|
fi
|
|
|
if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then
|
|
@@ -451,7 +479,7 @@ case "$1" in
|
|
|
KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 `
|
|
|
done
|
|
|
if [ $KILL_SLEEP_INTERVAL -lt 0 ]; then
|
|
|
- echo "opencron has not been killed completely yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE."
|
|
|
+ echo_r "opencron has not been killed completely yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE."
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
@@ -460,12 +488,12 @@ case "$1" in
|
|
|
;;
|
|
|
|
|
|
*)
|
|
|
- echo "Unknown command: $1"
|
|
|
- echo "Usage: $PROGRAM ( commands ... )"
|
|
|
- echo "commands:"
|
|
|
- echo " start Start opencron"
|
|
|
- echo " stop Stop opencron"
|
|
|
- echo " are you running?"
|
|
|
+ echo_g "Unknown command: $1"
|
|
|
+ echo_g "Usage: $PROGRAM ( commands ... )"
|
|
|
+ echo_g "commands:"
|
|
|
+ echo_g " start Start opencron"
|
|
|
+ echo_g " stop Stop opencron"
|
|
|
+ echo_g " are you running?"
|
|
|
exit 1
|
|
|
;;
|
|
|
esac
|