Commit 802e009c611d74deeefa4ddec1e3c4af28395307

Authored by Kevin G Fourie
Committed by General KT Account
1 parent c7a35e21

Updated the dmsctl.sh example file which was very out of date.

Signed-off-by: General KT Account <kt-sysadmin@knowledgetree.com>
Showing 1 changed file with 80 additions and 106 deletions
examples/linux/init/dmsctl.sh
@@ -11,15 +11,17 @@ RETVAL=0 @@ -11,15 +11,17 @@ RETVAL=0
11 PID="" 11 PID=""
12 ERROR=0 12 ERROR=0
13 SERVER=all 13 SERVER=all
14 -USEXVFB=0  
15 VDISPLAY="99" 14 VDISPLAY="99"
16 -INSTALL_PATH=@@BITROCK_INSTALLDIR@@ 15 +INSTALL_PATH=/opt/ktdms
17 JAVABIN=$INSTALL_PATH/java/jre/bin/java 16 JAVABIN=$INSTALL_PATH/java/jre/bin/java
18 export MAGICK_HOME=$INSTALL_PATH/common 17 export MAGICK_HOME=$INSTALL_PATH/common
19 export LD_LIBRARY_PATH="$INSTALL_PATH/apache2/lib:$INSTALL_PATH/common/lib:$INSTALL_PATH/mysql/lib:$LD_LIBRARY_PATH" 18 export LD_LIBRARY_PATH="$INSTALL_PATH/apache2/lib:$INSTALL_PATH/common/lib:$INSTALL_PATH/mysql/lib:$LD_LIBRARY_PATH"
20 export PATH=$PATH:$INSTALL_PATH/php/bin 19 export PATH=$PATH:$INSTALL_PATH/php/bin
21 export PHPRC=$INSTALL_PATH/php/etc 20 export PHPRC=$INSTALL_PATH/php/etc
22 21
  22 +# LDAP
  23 +export LDAPCONF=$INSTALL_PATH/common/etc/openldap/ldap.conf
  24 +
23 # Apache 25 # Apache
24 HTTPD_PIDFILE=$INSTALL_PATH/apache2/logs/httpd.pid 26 HTTPD_PIDFILE=$INSTALL_PATH/apache2/logs/httpd.pid
25 HTTPD_PID="" 27 HTTPD_PID=""
@@ -29,18 +31,18 @@ HTTPD_STATUS=&quot;&quot; @@ -29,18 +31,18 @@ HTTPD_STATUS=&quot;&quot;
29 # MySQL 31 # MySQL
30 MYSQL_PIDFILE=$INSTALL_PATH/mysql/data/mysqld.pid 32 MYSQL_PIDFILE=$INSTALL_PATH/mysql/data/mysqld.pid
31 MYSQL_PID="" 33 MYSQL_PID=""
32 -#MYSQL_START="$INSTALL_PATH/mysql/bin/safe_mysqld --port=@@BITROCK_MYSQL_PORT@@ --socket=$INSTALL_PATH/mysql/tmp/mysql.sock --old-passwords --datadir=$INSTALL_PATH/mysql/data --pid-file=$INSTALL_PATH/mysql/data/mysqld.pid"  
33 -MYSQL_START="$INSTALL_PATH/mysql/bin/safe_mysqld --port=@@BITROCK_MYSQL_PORT@@ --socket=$INSTALL_PATH/mysql/tmp/mysql.sock --old-passwords --datadir=$INSTALL_PATH/mysql/data --log-error=$INSTALL_PATH/mysql/data/mysqld.log --pid-file=$INSTALL_PATH/mysql/data/mysqld.pid"  
34 -MYSQL_STOP="$INSTALL_PATH/mysql/bin/mysqladmin --socket=$INSTALL_PATH/mysql/tmp/mysql.sock -u root -p shutdown" 34 +#MYSQL_START="$INSTALL_PATH/mysql/bin/safe_mysqld --port=3306 --socket=$INSTALL_PATH/mysql/tmp/mysql.sock --old-passwords --datadir=$INSTALL_PATH/mysql/data --pid-file=$INSTALL_PATH/mysql/data/mysqld.pid"
  35 +MYSQL_START="$INSTALL_PATH/mysql/bin/safe_mysqld --defaults-file=${INSTALL_PATH}/mysql/my.cnf --old-passwords --datadir=$INSTALL_PATH/mysql/data --log-error=$INSTALL_PATH/mysql/data/mysqld.log --pid-file=$INSTALL_PATH/mysql/data/mysqld.pid"
  36 +MYSQL_STOP="$INSTALL_PATH/mysql/bin/mysqladmin --defaults-file=${INSTALL_PATH}/mysql/my.cnf -u root -p shutdown"
35 MYSQL_STATUS="" 37 MYSQL_STATUS=""
36 MYSQL_PASSWORD="" 38 MYSQL_PASSWORD=""
37 39
38 -# Xvfb  
39 -XVFB_PIDFILE=$INSTALL_PATH/Xvfb/xvfb.pid  
40 -XVFB_PID=""  
41 -XVFBBIN=$INSTALL_PATH/Xvfb/bin/Xvfb  
42 -XVFB="$XVFBBIN :$VDISPLAY -screen 0 800x600x8 -fbdir $INSTALL_PATH/Xvfb/var/run -fp $INSTALL_PATH/Xvfb/misc"  
43 -XVFB_STATUS="" 40 +# Agent
  41 +AGENT_PIDFILE="$INSTALL_PATH/updates/agent.pid"
  42 +AGENT_PID=""
  43 +AGENT="$INSTALL_PATH/updates/agent.bin"
  44 +AGENT_STATUS=""
  45 +AGENT_BIN=agent.bin
44 46
45 # OpenOffice 47 # OpenOffice
46 SOFFICE_PATH="$INSTALL_PATH/openoffice/program" 48 SOFFICE_PATH="$INSTALL_PATH/openoffice/program"
@@ -48,17 +50,14 @@ SOFFICE_PIDFILE=$INSTALL_PATH/openoffice/soffice.bin.pid @@ -48,17 +50,14 @@ SOFFICE_PIDFILE=$INSTALL_PATH/openoffice/soffice.bin.pid
48 SOFFICE_PID="" 50 SOFFICE_PID=""
49 SOFFICE_PORT="8100" 51 SOFFICE_PORT="8100"
50 SOFFICEBIN=$INSTALL_PATH/openoffice/program/soffice.bin 52 SOFFICEBIN=$INSTALL_PATH/openoffice/program/soffice.bin
51 -if [ $USEXVFB -eq 1 ]; then  
52 - SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -display :$VDISPLAY -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager"  
53 -else  
54 - SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager"  
55 -fi 53 +#SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=pipe,name=pypipe;urp;StarOffice.ServiceManager"
  54 +SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager"
56 SOFFICE_STATUS="" 55 SOFFICE_STATUS=""
57 56
58 # Lucene 57 # Lucene
59 LUCENE_PIDFILE=$INSTALL_PATH/knowledgeTree/bin/luceneserver/lucene.pid 58 LUCENE_PIDFILE=$INSTALL_PATH/knowledgeTree/bin/luceneserver/lucene.pid
60 LUCENE_PID="" 59 LUCENE_PID=""
61 -LUCENE="$JAVABIN -jar ktlucene.jar" 60 +LUCENE="$JAVABIN -Xms512M -Xmx512M -jar ktlucene.jar"
62 LUCENE_STATUS="" 61 LUCENE_STATUS=""
63 62
64 # Scheduler 63 # Scheduler
@@ -92,23 +91,23 @@ get_apache_pid() { @@ -92,23 +91,23 @@ get_apache_pid() {
92 fi 91 fi
93 } 92 }
94 93
95 -get_mysql_pid() {  
96 - get_pid $MYSQL_PIDFILE 94 +get_agent_pid() {
  95 + get_pid $AGENT_PIDFILE
97 if [ ! $PID ]; then 96 if [ ! $PID ]; then
98 return 97 return
99 fi 98 fi
100 if [ $PID -gt 0 ]; then 99 if [ $PID -gt 0 ]; then
101 - MYSQL_PID=$PID 100 + AGENT_PID=$PID
102 fi 101 fi
103 } 102 }
104 103
105 -get_xvfb_pid() {  
106 - get_pid $XVFB_PIDFILE 104 +get_mysql_pid() {
  105 + get_pid $MYSQL_PIDFILE
107 if [ ! $PID ]; then 106 if [ ! $PID ]; then
108 return 107 return
109 fi 108 fi
110 if [ $PID -gt 0 ]; then 109 if [ $PID -gt 0 ]; then
111 - XVFB_PID=$PID 110 + MYSQL_PID=$PID
112 fi 111 fi
113 } 112 }
114 113
@@ -164,26 +163,26 @@ is_mysql_running() { @@ -164,26 +163,26 @@ is_mysql_running() {
164 return $RUNNING 163 return $RUNNING
165 } 164 }
166 165
167 -is_apache_running() {  
168 - get_apache_pid  
169 - is_service_running $HTTPD_PID 166 +is_agent_running() {
  167 + get_agent_pid
  168 + is_service_running $AGENT_PID
170 RUNNING=$? 169 RUNNING=$?
171 if [ $RUNNING -eq 0 ]; then 170 if [ $RUNNING -eq 0 ]; then
172 - HTTPD_STATUS="apache not running" 171 + AGENT_STATUS="agent not running"
173 else 172 else
174 - HTTPD_STATUS="apache already running" 173 + AGENT_STATUS="agent already running"
175 fi 174 fi
176 return $RUNNING 175 return $RUNNING
177 } 176 }
178 177
179 -is_xvfb_running() {  
180 - get_xvfb_pid  
181 - is_service_running $XVFB_PID 178 +is_apache_running() {
  179 + get_apache_pid
  180 + is_service_running $HTTPD_PID
182 RUNNING=$? 181 RUNNING=$?
183 if [ $RUNNING -eq 0 ]; then 182 if [ $RUNNING -eq 0 ]; then
184 - XVFB_STATUS="Xvfb not running" 183 + HTTPD_STATUS="apache not running"
185 else 184 else
186 - XVFB_STATUS="Xvfb already running" 185 + HTTPD_STATUS="apache already running"
187 fi 186 fi
188 return $RUNNING 187 return $RUNNING
189 } 188 }
@@ -242,7 +241,7 @@ start_mysql() { @@ -242,7 +241,7 @@ start_mysql() {
242 else 241 else
243 $MYSQL_START &> $INSTALL_PATH/var/log/dmsctl.log & 242 $MYSQL_START &> $INSTALL_PATH/var/log/dmsctl.log &
244 if [ $? -eq 0 ]; then 243 if [ $? -eq 0 ]; then
245 - echo "$0 $ARG: mysql started at port @@BITROCK_MYSQL_PORT@@" 244 + echo "$0 $ARG: mysql started at port 3306"
246 sleep 2 245 sleep 2
247 else 246 else
248 echo "$0 $ARG: mysql could not be started" 247 echo "$0 $ARG: mysql could not be started"
@@ -276,89 +275,84 @@ stop_mysql() { @@ -276,89 +275,84 @@ stop_mysql() {
276 fi 275 fi
277 } 276 }
278 277
279 -start_apache() {  
280 - test_apache_config  
281 - is_apache_running 278 +start_agent() {
  279 + is_agent_running
282 RUNNING=$? 280 RUNNING=$?
283 -  
284 if [ $RUNNING -eq 1 ]; then 281 if [ $RUNNING -eq 1 ]; then
285 - echo "$0 $ARG: httpd (pid $HTTPD_PID) already running" 282 + echo "$0 $ARG: agent (pid $AGENT_PID) already running"
286 else 283 else
287 - if $HTTPD &> $INSTALL_PATH/var/log/dmsctl.log; then  
288 - echo "$0 $ARG: httpd started at port @@BITROCK_APACHE_PORT@@"  
289 - else  
290 - echo "$0 $ARG: httpd could not be started"  
291 - ERROR=3  
292 - fi  
293 -fi 284 + $AGENT &> $INSTALL_PATH/var/log/dmsctl.log &
  285 + sleep 5
  286 + get_agent_pid
  287 + if [ $AGENT_PID -gt 0 ]; then
  288 + echo "$0 $ARG: agent started"
  289 + else
  290 + echo "$0 $ARG: agent could not be started"
  291 + ERROR=3
  292 + fi
  293 + fi
294 } 294 }
295 295
296 -stop_apache() { 296 +stop_agent() {
297 NO_EXIT_ON_ERROR=$1 297 NO_EXIT_ON_ERROR=$1
298 - test_apache_config  
299 - is_apache_running 298 + is_agent_running
300 RUNNING=$? 299 RUNNING=$?
301 300
302 if [ $RUNNING -eq 0 ]; then 301 if [ $RUNNING -eq 0 ]; then
303 - echo "$0 $ARG: $HTTPD_STATUS" 302 + echo "$0 $ARG: $AGENT_STATUS"
304 if [ "x$NO_EXIT_ON_ERROR" != "xno_exit" ]; then 303 if [ "x$NO_EXIT_ON_ERROR" != "xno_exit" ]; then
305 exit 304 exit
306 else 305 else
307 return 306 return
308 fi 307 fi
309 - fi  
310 - get_apache_pid  
311 - if kill $HTTPD_PID ; then  
312 - echo "$0 $ARG: httpd stopped"  
313 - else  
314 - echo "$0 $ARG: httpd could not be stopped"  
315 - ERROR=4  
316 - fi 308 + fi
  309 + get_agent_pid
  310 + if kill $AGENT_PID ; then
  311 + echo "$0 $ARG: agent stopped"
  312 + else
  313 + echo "$0 $ARG: agent could not be stopped"
  314 + ERROR=4
  315 + fi
317 } 316 }
318 317
319 -start_xvfb() {  
320 -if [ $USEXVFB -eq 1 ]; then  
321 - is_xvfb_running 318 +start_apache() {
  319 + test_apache_config
  320 + is_apache_running
322 RUNNING=$? 321 RUNNING=$?
323 322
324 if [ $RUNNING -eq 1 ]; then 323 if [ $RUNNING -eq 1 ]; then
325 - echo "$0 $ARG: Xvfb (pid $XVFB_PID) already running" 324 + echo "$0 $ARG: httpd (pid $HTTPD_PID) already running"
326 else 325 else
327 - nohup $XVFB &> $INSTALL_PATH/var/log/dmsctl.log &  
328 - if [ $? -eq 0 ]; then  
329 - echo "$0 $ARG: Xvfb started on display $VDISPLAY"  
330 - ps ax | grep $XVFBBIN | awk {'print $1'} > $XVFB_PIDFILE  
331 - sleep 2 326 + if $HTTPD &> $INSTALL_PATH/var/log/dmsctl.log; then
  327 + echo "$0 $ARG: httpd started at port 8080"
332 else 328 else
333 - echo "$0 $ARG: xvfb could not be started" 329 + echo "$0 $ARG: httpd could not be started"
334 ERROR=3 330 ERROR=3
335 fi 331 fi
336 - fi  
337 fi 332 fi
338 } 333 }
339 334
340 -stop_xvfb() {  
341 -if [ $USEXVFB -eq 1 ]; then 335 +stop_apache() {
342 NO_EXIT_ON_ERROR=$1 336 NO_EXIT_ON_ERROR=$1
343 - is_xvfb_running 337 + test_apache_config
  338 + is_apache_running
344 RUNNING=$? 339 RUNNING=$?
345 340
346 if [ $RUNNING -eq 0 ]; then 341 if [ $RUNNING -eq 0 ]; then
347 - echo "$0 $ARG: $XVFB_STATUS" 342 + echo "$0 $ARG: $HTTPD_STATUS"
348 if [ "x$NO_EXIT_ON_ERROR" != "xno_exit" ]; then 343 if [ "x$NO_EXIT_ON_ERROR" != "xno_exit" ]; then
349 exit 344 exit
350 else 345 else
351 return 346 return
352 fi 347 fi
353 fi 348 fi
354 - get_xvfb_pid  
355 - if kill $XVFB_PID ; then  
356 - echo "$0 $ARG: Xvfb stopped" 349 + get_apache_pid
  350 + if kill $HTTPD_PID ; then
  351 + echo "$0 $ARG: httpd stopped"
357 else 352 else
358 - echo "$0 $ARG: Xvfb could not be stopped" 353 + echo "$0 $ARG: httpd could not be stopped"
359 ERROR=4 354 ERROR=4
360 fi 355 fi
361 -fi  
362 } 356 }
363 357
364 start_soffice() { 358 start_soffice() {
@@ -368,10 +362,6 @@ start_soffice() { @@ -368,10 +362,6 @@ start_soffice() {
368 if [ $RUNNING -eq 1 ]; then 362 if [ $RUNNING -eq 1 ]; then
369 echo "$0 $ARG: openoffice (pid $SOFFICE_PID) already running" 363 echo "$0 $ARG: openoffice (pid $SOFFICE_PID) already running"
370 else 364 else
371 - if [ $USEXVFB -eq 1 ]; then  
372 - start_xvfb  
373 - sleep 2  
374 - fi  
375 nohup $SOFFICE &> $INSTALL_PATH/var/log/dmsctl.log & 365 nohup $SOFFICE &> $INSTALL_PATH/var/log/dmsctl.log &
376 if [ $? -eq 0 ]; then 366 if [ $? -eq 0 ]; then
377 echo "$0 $ARG: openoffice started at port $SOFFICE_PORT" 367 echo "$0 $ARG: openoffice started at port $SOFFICE_PORT"
@@ -397,9 +387,6 @@ stop_soffice() { @@ -397,9 +387,6 @@ stop_soffice() {
397 return 387 return
398 fi 388 fi
399 fi 389 fi
400 - if [ $USEXVFB -eq 1 ]; then  
401 - stop_xvfb  
402 - fi  
403 get_soffice_pid 390 get_soffice_pid
404 if killall $SOFFICEBIN ; then 391 if killall $SOFFICEBIN ; then
405 echo "$0 $ARG: openoffice stopped" 392 echo "$0 $ARG: openoffice stopped"
@@ -446,6 +433,7 @@ stop_lucene() { @@ -446,6 +433,7 @@ stop_lucene() {
446 get_lucene_pid 433 get_lucene_pid
447 cd $INSTALL_PATH/knowledgeTree/search2/indexing/bin 434 cd $INSTALL_PATH/knowledgeTree/search2/indexing/bin
448 $INSTALL_PATH/php/bin/php shutdown.php positive &> $INSTALL_PATH/var/log/dmsctl.log 435 $INSTALL_PATH/php/bin/php shutdown.php positive &> $INSTALL_PATH/var/log/dmsctl.log
  436 + sleep 5
449 if [ $? -eq 0 ]; then 437 if [ $? -eq 0 ]; then
450 echo "$0 $ARG: lucene stopped" 438 echo "$0 $ARG: lucene stopped"
451 else 439 else
@@ -501,10 +489,10 @@ help() { @@ -501,10 +489,10 @@ help() {
501 echo " $0 (start|stop|restart)" 489 echo " $0 (start|stop|restart)"
502 echo " $0 (start|stop|restart) apache" 490 echo " $0 (start|stop|restart) apache"
503 echo " $0 (start|stop|restart) mysql" 491 echo " $0 (start|stop|restart) mysql"
  492 + echo " $0 (start|stop|restart) agent"
504 echo " $0 (start|stop|restart) scheduler" 493 echo " $0 (start|stop|restart) scheduler"
505 echo " $0 (start|stop|restart) soffice" 494 echo " $0 (start|stop|restart) soffice"
506 echo " $0 (start|stop|restart) lucene" 495 echo " $0 (start|stop|restart) lucene"
507 - echo " $0 (start|stop|restart) xvfb"  
508 cat <<EOF 496 cat <<EOF
509 497
510 help - this screen 498 help - this screen
@@ -517,14 +505,14 @@ exit 0 @@ -517,14 +505,14 @@ exit 0
517 } 505 }
518 506
519 noserver() { 507 noserver() {
520 - echo -e "ERROR: $1 is not a valid server. Please, select 'mysql', 'apache', 'scheduler', 'soffice', 'lucene' or 'xvfb'\n" 508 + echo -e "ERROR: $1 is not a valid server. Please, select 'mysql', 'apache', 'agent', 'scheduler', 'soffice' or 'lucene'\n"
521 help 509 help
522 } 510 }
523 511
524 [ $# -lt 1 ] && help 512 [ $# -lt 1 ] && help
525 513
526 if [ ! -z ${2} ]; then 514 if [ ! -z ${2} ]; then
527 - [ "${2}" != "mysql" ] && [ "${2}" != "apache" ] && [ "${2}" != "scheduler" ] && [ "${2}" != "soffice" ] && [ "${2}" != "lucene" ] && [ "${2}" != "xvfb" ] && noserver $2 515 + [ "${2}" != "mysql" ] && [ "${2}" != "apache" ] && [ "${2}" != "agent" ] && [ "${2}" != "scheduler" ] && [ "${2}" != "soffice" ] && [ "${2}" != "lucene" ] && noserver $2
528 SERVER=$2 516 SERVER=$2
529 fi 517 fi
530 518
@@ -543,11 +531,7 @@ case $1 in @@ -543,11 +531,7 @@ case $1 in
543 else 531 else
544 start_mysql 532 start_mysql
545 start_apache 533 start_apache
546 - if [ -x $INSTALL_PATH/bin/networkservice.sh ]; then  
547 - $INSTALL_PATH/bin/networkservice.sh start  
548 - fi  
549 - start_xvfb  
550 - sleep 2 534 + start_agent
551 start_soffice 535 start_soffice
552 start_lucene 536 start_lucene
553 start_scheduler 537 start_scheduler
@@ -559,11 +543,8 @@ case $1 in @@ -559,11 +543,8 @@ case $1 in
559 stop_scheduler "no_exit" 543 stop_scheduler "no_exit"
560 stop_lucene "no_exit" 544 stop_lucene "no_exit"
561 stop_soffice "no_exit" 545 stop_soffice "no_exit"
562 - stop_xvfb "no_exit"  
563 stop_apache "no_exit" 546 stop_apache "no_exit"
564 - if [ -x $INSTALL_PATH/bin/networkservice.sh ]; then  
565 - $INSTALL_PATH/bin/networkservice.sh stop  
566 - fi 547 + stop_agent "no_exit"
567 stop_mysql 548 stop_mysql
568 fi 549 fi
569 ;; 550 ;;
@@ -575,19 +556,12 @@ case $1 in @@ -575,19 +556,12 @@ case $1 in
575 stop_scheduler "no_exit" 556 stop_scheduler "no_exit"
576 stop_lucene "no_exit" 557 stop_lucene "no_exit"
577 stop_soffice "no_exit" 558 stop_soffice "no_exit"
578 - stop_xvfb "no_exit"  
579 stop_apache "no_exit" 559 stop_apache "no_exit"
580 - if [ -x $INSTALL_PATH/bin/networkservice.sh ]; then  
581 - $INSTALL_PATH/bin/networkservice.sh stop  
582 - fi 560 + stop_agent "no_exit"
583 stop_mysql "no_exit" 561 stop_mysql "no_exit"
584 start_mysql 562 start_mysql
585 start_apache 563 start_apache
586 - if [ -x $INSTALL_PATH/bin/networkservice.sh ]; then  
587 - $INSTALL_PATH/bin/networkservice.sh start  
588 - fi  
589 - start_xvfb  
590 - sleep 2 564 + start_agent
591 start_soffice 565 start_soffice
592 start_lucene 566 start_lucene
593 start_scheduler 567 start_scheduler