forked from nashcom/domino-startscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrc_domino_script
executable file
·3418 lines (2673 loc) · 79.4 KB
/
rc_domino_script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# change this to #!/bin/ksh for AIX
###########################################################################
# Main Script Logic - Start/Stop Script for Domino on xLinux/zLinux/AIX #
# Version V3.7.0 09.01.2022 #
# #
# (C) Copyright Daniel Nashed/NashCom 2005-2022 #
# Feedback domino_unix@nashcom.de #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.#
# See the License for the specific language governing permissions and #
# limitations under the License. #
###########################################################################
DOMINO_SCRIPT_VERSION=3.7.0
VERBOSE_INFO="yes"
# Get Linux version and platform
LINUX_VERSION=$(cat /etc/os-release | grep "VERSION_ID="| cut -d= -f2 | xargs)
LINUX_PRETTY_NAME=$(cat /etc/os-release | grep "PRETTY_NAME="| cut -d= -f2 | xargs)
LINUX_ID=$(cat /etc/os-release | grep "^ID="| cut -d= -f2 | xargs)
# check if inside docker
if [ -e "/.dockerenv" ]; then
DOCKER_ENV=yes
fi
# other container run-time
if [ -e "/run/.containerenv" ]; then
DOCKER_ENV=yes
fi
# K8s environment
if [ -n "$KUBERNETES_SERVICE_HOST" ]; then
DOCKER_ENV=yes
fi
if [ -z "$LOGNAME" ]; then
if [ "$DOCKER_ENV"="yes" ]; then
# in Docker environments check LOGNAME first. If not present use whoami, which could also fail
# some environments use --user to map a name, which isn't listed in the container
# in that case use the UID
LOGNAME=`whoami 2>/dev/null`
if [ -z "$LOGNAME" ]; then
LOGNAME=`id -u`
fi
export LOGNAME
fi
fi
# Determine Notes/OS level user
DOMINO_USER=$LOGNAME
if [ -z "$DOMINO_USER" ]; then
echo "Empty login name. Please check your configuration"
exit 1
fi
# Reading global and specifiy configuration if present
DOMINO_CONFIG_FILE=/etc/sysconfig/rc_domino_config_$DOMINO_USER
DOMINO_DEFAULT_CONFIG_FILE=/etc/sysconfig/rc_domino_config
if [ -r "$DOMINO_DEFAULT_CONFIG_FILE" ]; then
. $DOMINO_DEFAULT_CONFIG_FILE
if [ "$VERBOSE_INFO" = "yes" ]; then
echo "Using Domino config File [$DOMINO_DEFAULT_CONFIG_FILE]"
fi
fi
# Include server specific config file if a exists and is readable
if [ -r "$DOMINO_CONFIG_FILE" ]; then
. $DOMINO_CONFIG_FILE
if [ "$VERBOSE_INFO" = "yes" ]; then
echo "Using Domino config File [$DOMINO_CONFIG_FILE]"
fi
fi
# Reading environment variable file (variables defined in config file overwrirte environment)
if [ -r "$DOMINO_ENV_FILE" ]; then
. $DOMINO_ENV_FILE
if [ "$VERBOSE_INFO" = "yes" ]; then
echo "Using environment File [$DOMINO_ENV_FILE]"
fi
fi
if [ -z "$DOMINO_CONFIGURED" ]; then
# Configuraiton is either loaded from external config file /etc/sysconfig/rc_domino_config.
# or defined in environment variables (not recommended).yyo
echo "Domino Server for '$DOMINO_USER' not configured"
exit 1
fi
if [ "$DOCKER_ENV" = "yes" ]; then
# On Docker allow additional configuration file in data directory
if [ -r "$DOMINO_DATA_PATH/rc_domino_config" ]; then
. $DOMINO_DATA_PATH/rc_domino_config
if [ "$VERBOSE_INFO" = "yes" ]; then
echo "Using Domino config File on Docker [$DOMINO_DATA_PATH/rc_domino_config]"
fi
fi
fi
# --- Begin of Special Configuration Parameters ---
# The following option allows you to ensure a certain owner for all external scripts that can be executed
#EXECUTE_SCRIPT_CHECK_OWNER=root
# Base directory for domino server partitions
if [ -z "$DOMINO_DATA_PATH_BASE" ]; then
DOMINO_DATA_PATH_BASE="/local/domino"
fi
if [ -z "$DOMINO_NEXTSTART_COMPACT_STATUSFILE" ]; then
DOMINO_NEXTSTART_COMPACT_STATUSFILE=$DOMINO_DATA_PATH/domino_nextstartcompact
fi
# Enable to use the Java Server Controller
if [ -z "$DOMINO_USE_JAVA_CONTROLLER" ]; then
DOMINO_USE_JAVA_CONTROLLER="no"
fi
if [ -z "$DOMINO_BROADCAST_SHUTDOWN_MESSAGE" ]; then
DOMINO_BROADCAST_SHUTDOWN_MESSAGE="no"
fi
# Compress command used e.g. for log file compression
if [ -z "$COMPRESS_COMMAND" ]; then
COMPRESS_COMMAND="gzip --best"
fi
# Remove command used for temp file delete
if [ -z "$REMOVE_COMMAND_TEMP" ]; then
REMOVE_COMMAND_TEMP="rm -f"
fi
# Remove command used for cleanup file delete
if [ -z "$REMOVE_COMMAND_CLEANUP" ]; then
REMOVE_COMMAND_CLEANUP="rm -f"
fi
# Edit command
if [ -z "$EDIT_COMMAND" ]; then
EDIT_COMMAND="vi"
fi
# Show log command
if [ -z "$SHOW_LOG_COMMAND" ]; then
SHOW_LOG_COMMAND="vi"
fi
# Extension command descriptions
if [ -z "$EXTENSION_COMMAND_TEXT" ]; then
EXTENSION_COMMAND_TEXT="Custom Commands"
fi
# Enable script debug output
if [ -z "$DOMINO_DEBUG_MODE" ]; then
DOMINO_DEBUG_MODE="no"
fi
if [ -z "$DOMINO_SHUTDOWN_DELAYED_SECONDS" ]; then
DOMINO_SHUTDOWN_DELAYED_SECONDS=20
fi
if [ -z "$DOMINO_TIKA_SHUTDOWN_TERM_SECONDS" ]; then
DOMINO_TIKA_SHUTDOWN_TERM_SECONDS=30
fi
# -- init.d service name used for configuration --
if [ -z "$DOMINO_RC_NAME" ]; then
DOMINO_RC_NAME=rc_domino
fi
# -- systemd service name used for configuration --
if [ -z "$DOMINO_SYSTEMD_NAME" ]; then
DOMINO_SYSTEMD_NAME=domino.service
fi
# -- by default use server -c ... to send server command --
if [ -z "$DOMINO_CONSOLE_SERVERC" ]; then
DOMINO_CONSOLE_SERVERC="yes"
fi
# --- End of special configuration parameters ---
# Determine architecture and platform
if [ `uname` = AIX ]; then
LARCH=ibmpow
PLATFORM_NAME=AIX
elif [ `uname` = Linux ]; then
LARCH=linux
UNAME=`uname -m`
if [ $UNAME = s390 ]; then
PLATFORM_NAME=zLinux
elif [ $UNAME = s390x ]; then
PLATFORM_NAME=zLinux
else
PLATFORM_NAME=xLinux
fi
# Query linux distribution
if [ ${LARCH} = "linux" ]; then
if [ -e /etc/SuSE-release ]; then
LINUX_DISTRIBUTION=suse
elif [ -e /etc/redhat-release ]; then
LINUX_DISTRIBUTION=redhat
else
LINUX_DISTRIBUTION=unknown
fi
fi
fi
if [ -z "$LARCH" ]; then
echo "Unknown platform `uname`"
exit 1
fi
TAIL_CMD=tail
if [ ${LARCH} = "sunspa" ]; then
# Solaris has a separate directory containing POSIX command line tools
TAIL_CMD=/usr/xpg4/bin/tail
fi
# --- Default configuration begin ---
# Domino shutdown timeout in seconds
if [ -z "$DOMINO_SHUTDOWN_TIMEOUT" ]; then
DOMINO_SHUTDOWN_TIMEOUT=600
fi
# Set Domino binary directory if not yet set
if [ -z "$LOTUS" ]; then
if [ -x /opt/hcl/domino/bin/server ]; then
LOTUS=/opt/hcl/domino
elif [ -x /opt/ibm/domino/bin/server ]; then
LOTUS=/opt/ibm/domino
else
LOTUS=/opt/hcl/domino
fi
fi
# --- Default configuration end ---
# Additional internal script variables
SCRIPT_NAME=$0
SCRIPT_DIR_NAME=$(dirname $SCRIPT_NAME)
PARAM=$1
PARAM1=$1
PARAM2=$2
PARAM3=$3
PARAM4=$4
PARAM5=$5
PARAM6=$6
DOMINO_BIN=$LOTUS/bin/server
DOMINO_FIXUP_BIN=$LOTUS/bin/fixup
PS_COMMAND="ps"
if [ -z "$DOMINO_COMPACT_TASK" ]; then
DOMINO_COMPACT_TASK=compact
fi
DOMINO_COMPACT_BIN=$LOTUS/bin/$DOMINO_COMPACT_TASK
if [ "$DOMINO_DEBUG_MODE" = "yes" ]; then
NSD_BIN="$LOTUS/bin/nsd -debug"
else
NSD_BIN=$LOTUS/bin/nsd
fi
if [ -z "$DOMINO_INSDIR" ]; then
DOMINO_INSDIR=$LOTUS
fi
# Set notes exec directory for domino c-api add-on software
Notes_ExecDirectory=$LOTUS/notes/latest/$LARCH
# Used to check for running processes
LOTUS_BIN_DIR=$LOTUS/notes
# Export lib search path per platform
if [ ${LARCH} = "ibmpow" ]; then
LIBPATH=$Notes_ExecDirectory:$LIBPATH
export LIBPATH
fi
if [ ${LARCH} = "sunspa" ]; then
LD_LIBRARY_PATH=$Notes_ExecDirectory:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
fi
if [ ${LARCH} = "linux" ]; then
# include ST directories
LD_LIBRARY_PATH=$Notes_ExecDirectory:$LD_LIBRARY_PATH:$Notes_ExecDirectory/STOpenSSL:$Notes_ExecDirectory/sticc
export LD_LIBRARY_PATH
fi
if [ ${LARCH} = "linux" ]; then
PS_COMMAND="ps -w"
fi
# sanity check for compact task. dbmt might not have a start link
if [ ! -x $DOMINO_COMPACT_BIN ]; then
DOMINO_COMPACT_BIN=$Notes_ExecDirectory/$DOMINO_COMPACT_TASK
fi
# Check if data path has been already set. else set it based on user-name and base directory.
if [ -z "$DOMINO_DATA_PATH" ]; then
DOMINO_DATA_PATH=$DOMINO_DATA_PATH_BASE/$DOMINO_USER/notesdata # path for server data directory
fi
# General environment parameters (if defaults are not set)
if [ -z "$DOMINO_SERVER" ]; then
DOMINO_SERVER=$DOMINO_USER # Name of Domino Server
fi
# Set Domino PID File if not present
if [ -z "$DOMINO_PID_FILE" ]; then
# -- Domino PID file per Partition which has to match the PIDFile setting in the "domino.service" --
DOMINO_PID_FILE=/tmp/domino.pid
fi
DOMINO_INI_PATH=$DOMINO_DATA_PATH/notes.ini
PATH=$DOMINO_DATA_PATH:$LOTUS/bin:$Notes_ExecDirectory:$Notes_ExecDirectory/res/C:$PATH
# Check if log path has been already set. else set it based on user-name and base directory.
if [ -z "$DOMINO_LOG_DIR" ]; then
DOMINO_LOG_DIR=$DOMINO_DATA_PATH
fi
if [ -z "$DOMINO_OUTPUT_LOG" ]; then
DOMINO_OUTPUT_LOG=$DOMINO_LOG_DIR/$DOMINO_SERVER.log # Output file for server console
fi
if [ -z "$DOMINO_INPUT_FILE" ]; then
DOMINO_INPUT_FILE=$DOMINO_LOG_DIR/$DOMINO_SERVER.input # Input file for server console
fi
if [ "$DOMINO_USE_JAVA_CONTROLLER" = "yes" ]; then
JAVA_CONTROLLER_STRING="-jc -c"
fi
# Export all variables that might be useful for other scripts
export LOTUS
export LARCH
export PLATFORM_NAME
export Notes_ExecDirectory
export PATH
export DOMINO_SERVER
export DOMINO_DATA_PATH
export DOMINO_USER
export DOMINO_INI_PATH
export DOMINO_OUTPUT_LOG
export DOMINO_INPUT_FILE
export DOMINO_LOG_PATH
export DOMINO_LOG_DIR
export DOMINO_LOG_BACKUP_DIR
export DOMINO_SHUTDOWN_TIMEOUT
export DOMINO_INSDIR
export DOMINO_VIEW_REBUILD_DIR
export DOMINO_TEMP_DIR
export DOMINO_SCRIPT_DIR
export DOMINO_CUSTOM_COMMAND_BASEPATH
export DOMINO_MONITOR_FILTER_STRING
export DOMINO_DEBUG_MODE
export DOMINO_SCRIPT_VERSION
export DOMINO_3RD_PARTY_BIN_DIRS
export DOMINO_LOG_CLEAR_DAYS
export DOMINO_LOG_BACKUP_CLEAR_DAYS
export DOMINO_CUSTOM_LOG_CLEAR_DAYS
export DOMINO_LOG_DB_DAYS
export DOMINO_LOG_DB_BACKUP
export DOMINO_LOG_DB_BACKUP_DIR
export DOMINO_DOMLOG_DB_DAYS
export DOMINO_DOMLOG_DB_BACKUP
export DOMINO_DOMLOG_DB_BACKUP_DIR
# -- Standard Compact Options Domino --
# Some Options are only available in D9 and late 8.5.3 versions
# -# nn Execute up to nn compactions in parallel using different threads. Up to a maximum of 20 Threads with a default of 1.
# -W nn Only compact databases which haven't been compacted successfully in last nn days. Ordered by last compact time.
#DOMINO_COMPACT_TASK="compact"
#DOMINO_COMPACT_OPTIONS="-#4 -C systemdbs.ind"
#DOMINO_START_COMPACT_OPTIONS="-#4 -W7 -C systemdbs.ind"
#DOMINO_LOG_COMPACT_OPTIONS="-C log.nsf"
#DOMINO_LOG_START_COMPACT_OPTIONS="-C -W7 log.nsf"
# -- Fixup Options --
#DOMINO_START_FIXUP_OPTIONS="-f -j systemdbs.ind"
#DOMINO_FIXUP_OPTIONS="-f -j systemdbs.ind"
# -- DBMT Compact Options Domino 9.x --
#DOMINO_COMPACT_TASK="dbmt"
#DOMINO_COMPACT_OPTIONS="-compactThreads 4 -updallThreads 0 systemdbs.ind"
#DOMINO_START_COMPACT_OPTIONS="-compactThreads 4 -updallThreads 0 systemdbs.ind"
#DOMINO_LOG_COMPACT_OPTIONS="-compactThreads 1 log.nsf"
#DOMINO_LOG_START_COMPACT_OPTIONS="-compactThreads 1 log.nsf"
# -- Custom Command Base Path --
#DOMINO_CUSTOM_COMMAND_BASEPATH="$LOTUS/commands"
# -- Monitor Filter String --
#DOMINO_MONITOR_FILTER_STRING="Opened session for|Closed session for"
# Special Parameters
# TN 1249226 / SPR DMAT6DTTHH / D7.0.x In certain cases, running NSD manually can cause a Domino server to crash on Unix 3systems.
# This crash can occur when a process such as the Agent Manager (AMGR) or Web Server (HTTP) is executing Java code.
# This parameter prevents the crash.
AMQ_NO_SIGWAIT_SIGTRAP=1
export AMQ_NO_SIGWAIT_SIGTRAP
# RC routines for older SuSE versions that need rc their routines for init.d and dummy functions for other platforms
if [ "$LINUX_DISTRIBUTION" = "suse" ] && [ -z "$DOMINO_SYSTEMD_NAME" ]; then
# init suse rc
. /etc/rc.status
else
# Dummy functions for non-SuSE platforms and also for SLES with systemd
rc_status ()
{
return 0
}
rc_check ()
{
return 0
}
rc_exit ()
{
exit $_rc_status_all
}
rc_failed ()
{
_rc_status_all=$1
return 0
}
rc_reset ()
{
_rc_status_all=0
return 0
}
fi
# Reset status of this service
rc_reset
# --- Helper functions ---
DebugText ()
{
if [ "$DOMINO_DEBUG_MODE" = "yes" ]; then
if [ -z "$DOMINO_DEBUG_FILE" ]; then
echo "$(date '+%F %T') Debug:" $@
else
echo "$(date '+%F %T') Debug:" $@ >> $DOMINO_DEBUG_FILE
fi
fi
return 0
}
errmsg ()
{
echo $1 >&2
return 0
}
errmsg_and_exit ()
{
errmsg "$1"
rc_failed 1
rc_status -v
rc_exit
}
print_delim ()
{
echo "--------------------------------------------------------------------------------"
}
nsd_check_set_posix_locale ()
{
if [ "$NSD_SET_POSIX_LC" = "yes" ]; then
LANG=POSIX
export LANG
fi
return 0
}
stop_monitor ()
{
DebugText "stoping_monitor for MONITOR_PID:" [$MONITOR_PID]
kill -9 $MONITOR_PID > /dev/null 2>&1
echo "Live Console closed."
echo
echo
exit 0
}
remove_file ()
{
if [ -z "$1" ]; then
return 1
fi
if [ ! -e "$1" ]; then
return 2
fi
rm -rf "$1"
return 0
}
remove_tempfiles_default ()
{
if [ ! -z "$DOMINO_DATA_PATH" ]; then
if [ -w "$DOMINO_DATA_PATH" ]; then
echo "Removing tempfiles:" [$DOMINO_DATA_PATH/*.DTF]
find $DOMINO_DATA_PATH -name "*.DTF" -exec $REMOVE_COMMAND_TEMP '{}' \;
echo "Removing tempfiles:" [$DOMINO_DATA_PATH/*.TMP]
find $DOMINO_DATA_PATH -type f -name "*.TMP" -exec $REMOVE_COMMAND_TEMP '{}' \;
fi
fi
if [ ! -z "$DOMINO_VIEW_REBUILD_DIR" ]; then
if [ -w "$DOMINO_VIEW_REBUILD_DIR" ]; then
echo "Removing view rebuild tempfiles:" [$DOMINO_VIEW_REBUILD_DIR/*.DTF]
find "$DOMINO_VIEW_REBUILD_DIR" -name "*.DTF" -exec $REMOVE_COMMAND_TEMP '{}' \;
fi
fi
return 0
}
show_version ()
{
echo "Nash!Com Linux/Unix Start Script Version ($DOMINO_SCRIPT_VERSION)"
return 0
}
get_notes_ini_var ()
{
# $1 = filename
# $2 = ini.variable
ret_ini_var=""
if [ -z "$1" ]; then
return 0
fi
if [ -z "$2" ]; then
return 0
fi
ret_ini_var=`awk -F '(=| =)' -v SEARCH_STR="$2" '{if (tolower($1) == tolower(SEARCH_STR)) print $2}' $1 | xargs`
return 0
}
edit_config_file ()
{
if [ -z "$1" ]; then
if [ -r "$DOMINO_CONFIG_FILE" ]; then
$EDIT_COMMAND "$DOMINO_CONFIG_FILE"
else
if [ -r "$DOMINO_DEFAULT_CONFIG_FILE" ]; then
$EDIT_COMMAND $DOMINO_DEFAULT_CONFIG_FILE
fi
fi
elif [ "$1" = "default" ]; then
$EDIT_COMMAND "$DOMINO_DEFAULT_CONFIG_FILE"
elif [ "$1" = "server" ]; then
$EDIT_COMMAND "$DOMINO_DEFAULT_CONFIG"
elif [ -r "$1" ]; then
$EDIT_COMMAND "$1"
else
echo "Wrong config edit option [$1] specified"
fi
}
edit_debug_file()
{
if [ -z "$DOMINO_DEBUG_FILE" ]; then
return 0
fi
if [ ! -r "$DOMINO_DEBUG_FILE" ]; then
return 0
fi
if [ -z "$1" ]; then
$EDIT_COMMAND "$DOMINO_DEBUG_FILE"
else
$1 "$DOMINO_DEBUG_FILE"
fi
}
list_config_file ()
{
if [ -z "$1" ]; then
if [ -r "$DOMINO_CONFIG_FILE" ]; then
cat "$DOMINO_CONFIG_FILE" | grep . | grep -v "^#"
else
if [ -r "$DOMINO_DEFAULT_CONFIG_FILE" ]; then
cat $DOMINO_DEFAULT_CONFIG_FILE | grep . | grep -v "^#"
fi
fi
elif [ "$1" = "default" ]; then
if [ -r "$DOMINO_DEFAULT_CONFIG_FILE" ]; then
cat "$DOMINO_DEFAULT_CONFIG_FILE" | grep . | grep -v "^#"
else
echo "Config file not found"
fi
elif [ "$1" = "server" ]; then
if [ -r "$DOMINO_CONFIG_FILE" ]; then
cat "$DOMINO_CONFIG_FILE" | grep . | grep -v "^#"
else
echo "Config file not found"
fi
elif [ -r "$1" ]; then
cat "$1" | grep . | grep -v "^#"
else
echo "Wrong config list option [$1] specified"
fi
}
edit_systemd_cfg ()
{
if [ ! -z "$DOMINO_SYSTEMD_NAME" ]; then
SYSTEMD_NAME=/etc/systemd/system/$DOMINO_SYSTEMD_NAME
if [ -r "$SYSTEMD_NAME" ]; then
$EDIT_COMMAND $SYSTEMD_NAME
else
echo "systemd not configured!"
fi
fi
}
show_log ()
{
if [ -z "$1" ]; then
CURRENT_SHOW_LOG_COMMAND=$SHOW_LOG_COMMAND
else
CURRENT_SHOW_LOG_COMMAND="$@"
fi
$CURRENT_SHOW_LOG_COMMAND $REAL_OUTPUT_FILE
}
run_external_script ()
{
if [ -z "$1" ]; then
return 0
fi
if [ ! -x $1 ]; then
echo "Cannot execute script " [$1]
return 0
fi
if [ -z "$EXECUTE_SCRIPT_CHECK_OWNER" ]; then
DebugText "not checking script owner for [$1]"
else
SCRIPT_OWNER=`stat -c %U $1`
if [ "$SCRIPT_OWNER" = "$EXECUTE_SCRIPT_CHECK_OWNER" ]; then
DebugText "execution check script [$1] OK -- Owner: $SCRIPT_OWNER"
else
echo "Wrong owner for script -- not executing" [$1]
return 0
fi
fi
DebugText "BEGIN $2 " [$1]
$1
DebugText "END $2 " [$1]
return 0
}
remove_tempfile_check ()
{
if [ "$DOMINO_REMOVE_TEMPFILES" = "yes" ]; then
if [ -z "$DOMINO_CUSTOM_REMOVE_TEMPFILES_SCRIPT" ]; then
remove_tempfiles_default
else
run_external_script "$DOMINO_CUSTOM_REMOVE_TEMPFILES_SCRIPT" "custom remove tempfiles script"
fi
fi
}
clear_backup_logs ()
{
DebugText "clear_backup_logs PARAM: '$1' '$2'"
if [ -z "$1" ]; then
if [ -z "$DOMINO_LOG_BACKUP_CLEAR_DAYS" ]; then
return 0
fi
DebugText "log clear days from config:" $DOMINO_LOG_BACKUP_CLEAR_DAYS
else
DOMINO_LOG_BACKUP_CLEAR_DAYS=$1
DebugText "log clear days from parameter:" $DOMINO_LOG_BACKUP_CLEAR_DAYS
fi
echo "Removing log backup files - days: $DOMINO_LOG_BACKUP_CLEAR_DAYS"
if [ -z "$DOMINO_LOG_BACKUP_DIR" ]; then
if [ -w "$DOMINO_DATA_PATH" ]; then
DebugText "Removing old log backup files from : $DOMINO_DATA_PATH"
echo "Removing old log-files from data dir: [$DOMINO_DATA_PATH/$DOMINO_SERVER_*.log.gz - days: $DOMINO_LOG_BACKUP_CLEAR_DAYS]"
find "$DOMINO_DATA_PATH" -maxdepth 1 -type f -mtime +$DOMINO_LOG_BACKUP_CLEAR_DAYS -name "$DOMINO_SERVER_*.log.gz" -exec $REMOVE_COMMAND_CLEANUP {} \;
fi
else
if [ -w "$DOMINO_LOG_BACKUP_DIR" ]; then
DebugText "Removing files from : $DOMINO_LOG_BACKUP_DIR"
echo "Removing log-files from backup dir: [$DOMINO_LOG_BACKUP_DIR/$DOMINO_SERVER_*.log.gz - days: $DOMINO_LOG_BACKUP_CLEAR_DAYS]"
find "$DOMINO_LOG_BACKUP_DIR" -maxdepth 1 -type f -mtime +$DOMINO_LOG_BACKUP_CLEAR_DAYS -name "$DOMINO_SERVER_*.log.gz" -exec $REMOVE_COMMAND_CLEANUP {} \;
fi
fi
}
clear_logs ()
{
DebugText "clear_logs PARAM: '$1' '$2'"
if [ -z "$1" ]; then
if [ -z "$DOMINO_LOG_CLEAR_DAYS" ]; then
return 0
fi
DebugText "log clear days from config: $DOMINO_LOG_CLEAR_DAYS"
else
DOMINO_LOG_CLEAR_DAYS=$1
DebugText "log clear days from parameter: $DOMINO_LOG_CLEAR_DAYS"
fi
echo "Removing log files - days: $DOMINO_LOG_CLEAR_DAYS"
if [ ! -z "$DOMINO_LOG_PATH" ]; then
if [ -w "$DOMINO_LOG_PATH" ]; then
DebugText "Removing files from : $DOMINO_LOG_PATH"
echo "Removing log-files: [$DOMINO_LOG_PATH/* - days: $DOMINO_LOG_CLEAR_DAYS]"
find "$DOMINO_LOG_PATH" -type f -mtime +$DOMINO_LOG_CLEAR_DAYS -exec $REMOVE_COMMAND_CLEANUP {} \;
fi
fi
if [ ! -z "$DOMINO_IBM_TECHNICAL_SUPPORT_DIR" ]; then
if [ -w "$DOMINO_IBM_TECHNICAL_SUPPORT_DIR" ]; then
DebugText "Removing files from : $DOMINO_IBM_TECHNICAL_SUPPORT_DIR"
echo "Removing log-files: [$DOMINO_IBM_TECHNICAL_SUPPORT_DIR/* - days: $DOMINO_LOG_CLEAR_DAYS]"
find "$DOMINO_IBM_TECHNICAL_SUPPORT_DIR" -type f -mtime +$DOMINO_LOG_CLEAR_DAYS -exec $REMOVE_COMMAND_CLEANUP {} \;
fi
fi
return 0
}
clear_custom_logs ()
{
DebugText "clear_custom_logs PARAM: '$1' '$2'"
if [ -z "$1" ]; then
if [ -z "$DOMINO_CUSTOM_LOG_CLEAR_DAYS" ]; then
return 0
fi
DebugText "custom-log clear days from config: $DOMINO_CUSTOM_LOG_CLEAR_DAYS"
else
DOMINO_CUSTOM_LOG_CLEAR_DAYS=$1
DebugText "custom-log clear days from parameter: $DOMINO_CUSTOM_LOG_CLEAR_DAYS"
fi
if [ -z "$2" ]; then
if [ -z "$DOMINO_CUSTOM_LOG_CLEAR_PATH" ]; then
echo "No custom-log clear path specified"
return 0
fi
DebugText "custom-log clear path from config: $DOMINO_CUSTOM_LOG_CLEAR_PATH"
else
DOMINO_CUSTOM_LOG_CLEAR_PATH=$2
DebugText "custom-log clear path from parameter: $DOMINO_CUSTOM_LOG_CLEAR_PATH"
fi
if [ ! -z "$DOMINO_CUSTOM_LOG_CLEAR_PATH" ]; then
if [ -w "$DOMINO_CUSTOM_LOG_CLEAR_PATH" ]; then
DebugText "Removing custom-log files - days: $DOMINO_CUSTOM_LOG_CLEAR_DAYS path: $DOMINO_CUSTOM_LOG_CLEAR_PATH"
echo "Removing log-files: [$DOMINO_CUSTOM_LOG_CLEAR_PATH - days: $DOMINO_CUSTOM_LOG_CLEAR_DAYS]"
find "$DOMINO_CUSTOM_LOG_CLEAR_PATH" -type f -mtime +$DOMINO_CUSTOM_LOG_CLEAR_DAYS -exec $REMOVE_COMMAND_CLEANUP {} \;
fi
fi
return 0
}
log_clear_operations ()
{
if [ -z "$DOMINO_CUSTOM_LOG_CLEAR_SCRIPT" ]; then
clear_logs "$1"
clear_custom_logs "$1"
clear_backup_logs "$2"
else
run_external_script "$DOMINO_CUSTOM_LOG_CLEAR_SCRIPT" "custom log clear script"
fi
return 0
}
startup_remove_file_check ()
{
DOMINO_LOADMON_FILE=$DOMINO_DATA_PATH/loadmon.ncf
DebugText "DOMINO_LOADMON_FILE:" [$DOMINO_LOADMON_FILE]
if [ "$DOMINO_RESET_LOADMON" = "yes" ]; then
if [ -w $DOMINO_LOADMON_FILE ]; then
rm $DOMINO_LOADMON_FILE
if [ $? -eq 0 ]; then
echo "Removed LoadMon-Data '$DOMINO_LOADMON_FILE'"
else
echo "Cannot remove LoadMon-Data '$DOMINO_LOADMON_FILE'"
fi
fi
fi
if [ "$DOMINO_CLEAR_LOGS_STARTUP" = "yes" ]; then
log_clear_operations
fi
remove_tempfile_check
return 0
}
check_create_dir ()
{
if [ -z "$1" ]; then
return 0
fi
if [ -e "$1" ]; then
return 0
else
mkdir -p "$1"
if [ -w "$1" ]; then
echo "Successfully created $2 ($1)"
return 0
else
echo "Error creating $2 ($1)"
return 1
fi
fi
return 0
}
check_create_directories ()
{
DebugText "check create for DOMINO_VIEW_REBUILD_DIR" [$DOMINO_VIEW_REBUILD_DIR]
check_create_dir "$DOMINO_VIEW_REBUILD_DIR" "View Rebuild Dir"
DebugText "check create for DOMINO_TEMP_DIR" [$DOMINO_TEMP_DIR]
check_create_dir "$DOMINO_TEMP_DIR" "Domino Temp Path"
DebugText "check create for DOMINO_LOG_PATH" [$DOMINO_LOG_PATH]
check_create_dir "$DOMINO_LOG_PATH" "Domino Log Path"
DebugText "check create for DOMINO_LOG_DIR" [$DOMINO_LOG_DIR]
check_create_dir "$DOMINO_LOG_DIR" "Domino Log Dir"
DebugText "check create for DOMINO_LOG_BACKUP_DIR" [$DOMINO_LOG_BACKUP_DIR]
check_create_dir "$DOMINO_LOG_BACKUP_DIR" "Domino Log Backup Dir"
return 0
}
check_log_db_age()
{
if [ -z "$DOMINO_LAST_LOG_DB_FILE" ]; then
DOMINO_LAST_LOG_DB_FILE="$DOMINO_DATA_PATH/domino_last_log_db.txt"
fi
if [ -z "$DOMINO_LOG_DB_DAYS" ]; then
DebugText "No DOMINO_LOG_DB_DAYS specified"
return 0
fi
if [ ! -r "$DOMINO_LAST_LOG_DB_FILE" ]; then
DebugText "$DOMINO_LAST_LOG_DB_FILE not present -> first run"
LANG=C date > $DOMINO_LAST_LOG_DB_FILE
return 1
fi
last_log_db_date=`cat $DOMINO_LAST_LOG_DB_FILE`
DebugText "last_log_db_date: $last_log_db_date"
if [ -z "$last_log_db_date" ]; then
LANG=C date > $DOMINO_LAST_LOG_DB_FILE
DebugText "Empty status file -> first run"
return 1
fi
d1=$(LANG=C date -d "now" +%s)
d2=$(LANG=C date -d "$last_log_db_date" +%s)
diff_days=$(( (d1 - d2) / 86400 ))
DebugText "days since last log rename: $diff_days"
if [ $diff_days -ge $DOMINO_LOG_DB_DAYS ]; then
DebugText "Sufficient Days leapsed -> renaming log"
LANG=C date > $DOMINO_LAST_LOG_DB_FILE
return 1
fi
return 0
}
check_domlog_db_age()
{
if [ -z "$DOMINO_LAST_DOMLOG_DB_FILE" ]; then
DOMINO_LAST_DOMLOG_DB_FILE="$DOMINO_DATA_PATH/domino_last_domlog_db.txt"
fi
if [ -z "$DOMINO_DOMLOG_DB_DAYS" ]; then
DebugText "No DOMINO_DOMLOG_DB_DAYS specified"
return 0
fi
if [ ! -r "$DOMINO_LAST_DOMLOG_DB_FILE" ]; then
DebugText "$DOMINO_LAST_DOMLOG_DB_FILE not present -> first run"
LANG=C date > $DOMINO_LAST_DOMLOG_DB_FILE
return 1