Skip to content

Commit f9ab93a

Browse files
committed
moved informatica script
1 parent d6a429c commit f9ab93a

File tree

1 file changed

+181
-0
lines changed

1 file changed

+181
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#!/bin/bash
2+
# chkconfig: 345 96 20
3+
# description: Control infamatica process
4+
#
5+
# File: /etc/init.d/informatica
6+
# Purpose: Start and stop the Informatica server
7+
# Author: bthompso (Conundrum)
8+
# Date: 3/11/2014
9+
#
10+
# Absolutely no warranty, use at your own risk
11+
# Please include this header in any copy or reuse of the script you make
12+
#
13+
# Version 0.01
14+
#
15+
# Usage:
16+
# 1: Create file at /etc/init.d/informatica
17+
# 2: chmod 750 /etc/init.d/informatica
18+
# 3: chkconfig --add informatica
19+
#
20+
#------------------------------------
21+
#
22+
# The following values must be changed for your environment
23+
#
24+
25+
# full path to the infaservice.sh file
26+
INFOSERVICE=/APPS/Informatica/9.0.1/server/tomcat/bin
27+
# log file path, change if you don't want logs to go to /var/log
28+
LOG_PATH=/var/log
29+
30+
31+
# the following variables should not need modification
32+
SUBSYS=$(basename $0)
33+
INFO_FINGERPRINT='pmrepagent'
34+
INFO_START_TIMEOUT=300
35+
INFO_STOP_TIMEOUT=300
36+
LOCK_FILE='var/lock/subsys/'$SUBSYS
37+
START_LOG=$LOG_PATH/$SUBSYS-start.log
38+
STOP_LOG=$LOG_PATH/$SUBSYS-stop.log
39+
# source the functions library
40+
#-----------------------
41+
if [ -f /etc/rc.d/init.d/functions ]; then
42+
. /etc/rc.d/init.d/functions
43+
fi
44+
#-----------------------
45+
46+
# check paths and permissions
47+
if [ ! -f '$INFOSERVICE/infraservice.sh' ] ; then
48+
echo ''
49+
echo -n '**infaservice.sh file not found at $INFOSERVICE/infraservice.sh'
50+
echo_failure
51+
echo ''
52+
fi
53+
54+
55+
check_permissions() {
56+
abort=0
57+
58+
#check lock file
59+
if [ ! -f $LOCK_FILE ] ; then
60+
if [ $(touch $LOCK_FILE 2>&1 | grep "Permission denied" | wc -l) -ne 0 ]; then
61+
echo ''
62+
echo '** Lock file '$LOCK_FILE' is not writable by '$(whoami)' **'
63+
echo_failure
64+
echo ''
65+
abort=1
66+
fi
67+
else
68+
if [ ! -w $LOCK_FILE ]; then
69+
echo ''
70+
echo '** Lock file '$LOCK_FILE' is not writable by '$(whoami)' **'
71+
echo ''
72+
abort=1
73+
fi
74+
fi
75+
76+
#check start log
77+
78+
if [ ! -f $START_LOG ]; then
79+
if [ $(touch $START_LOG 2>&1 | grep "Permission denied" | wc -l) -ne 0 ]; then
80+
echo ''
81+
echo '** Log file '$START_LOG' is not writable by '$(whoami)' **'
82+
echo_failure
83+
echo ''
84+
abort=1
85+
fi
86+
else
87+
if [ ! -w $START_LOG ]; then
88+
echo ''
89+
echo '** Log file '$START_LOG' is not writable by '$(whoami)' **'
90+
echo_failure
91+
echo ''
92+
abort=1
93+
fi
94+
fi
95+
96+
97+
#check stop log
98+
99+
if [ ! -f $STOP_LOG ]; then
100+
if [ $(touch $STOP_LOG 2>&1 | grep "Permission denied" | wc -l) -ne 0 ]; then
101+
echo ''
102+
echo '** Log file '$STOP_LOG' is not writable by '$(whoami)' **'
103+
echo_failure
104+
echo ''
105+
abort=1
106+
fi
107+
else
108+
if [! -w $STOP_LOG ]; then
109+
echo ''
110+
echo '** Log file '$STOP_LOG' is not writable by '$(whoami)' **'
111+
echo_failure
112+
echo ''
113+
abort=1
114+
fi
115+
fi
116+
117+
if [ $abort -eq 1 ]; then
118+
echo -e '\n\n------------------------\nTo start/stop this script must be run as root (directly, or with sudo)\n\n'
119+
exit 255
120+
fi
121+
}
122+
123+
#
124+
#--------------------
125+
#
126+
127+
check_process_ports () {
128+
# Pass the 'fingerprint' of the process to check, which should be a regex to uniquely
129+
# identify the process in a pgrep -f call
130+
#
131+
# Returns:
132+
# 0 - Process not running
133+
# 1 - Process running but not listening on any port
134+
# <ports> - the port(s) on which the process is listening
135+
PID=$(pgrep -f $1)
136+
if [ $? -eq 0 ] ; then
137+
PORT=$(pgrep -f $1|xargs -I'{}' $LSOF_PATH -nPp {}|grep LISTEN|awk -F ":" '{print $2}'|cut -d " " -f 1|sort -u|paste -s)
138+
if [ -n "$PORT" ] ; then
139+
echo $PORT
140+
else
141+
echo 1
142+
fi
143+
else
144+
echo 0
145+
fi
146+
}
147+
148+
149+
echo_process_status () {
150+
rc=$(check_process_ports $1)
151+
case "$rc" in
152+
0)
153+
echo_not_running
154+
;;
155+
1)
156+
echo_in_progress
157+
;;
158+
*)
159+
echo -n "listening on port" $rc
160+
echo_success
161+
esac
162+
echo ' '
163+
}
164+
165+
status () {
166+
echo ''
167+
echo -n ' Checking Informatica Server: '
168+
echo_process_status $INFO_FINGERPRINT
169+
}
170+
171+
172+
case $i in
173+
status)
174+
status
175+
;;
176+
esac
177+
178+
179+
180+
181+

0 commit comments

Comments
 (0)