/
sqoop-metastore.sh.suse
139 lines (122 loc) · 3.48 KB
/
sqoop-metastore.sh.suse
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
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
# Starts a Hadoop @HADOOP_DAEMON@
#
# chkconfig: 2345 85 15
# description: Sqoop allows easy imports and exports of data sets between \
# databases and the Hadoop Distributed File System (HDFS). The Sqoop \
# metastore allows users to define saved jobs for repeated execution and \
# share them with other users of the cluster.
# processname: java
#
### BEGIN INIT INFO
# Provides: Sqoop
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $named
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Sqoop allows easy imports and exports of data sets between databases and the Hadoop Distributed File System (HDFS).
### END INIT INFO
source /lib/lsb/init-functions
STATUS_RUNNING=0
STATUS_DEAD=1
STATUS_DEAD_AND_LOCK=2
STATUS_NOT_RUNNING=3
ERROR_PROGRAM_NOT_INSTALLED=5
ERROR_PROGRAM_NOT_CONFIGURED=6
RETVAL=0
NAME=sqoop-metastore
DESC="Sqoop metastore"
PID_FILE=/var/run/sqoop/sqoop-metastore.pid
LOCKFILE="/var/lock/subsys/sqoop-metastore"
LOGDIR=/var/log/sqoop
SQOOP_BIN_PATH="/usr/lib/sqoop/bin"
USER="sqoop"
GROUP="sqoop"
start() {
[ -x ${SQOOP_BIN_PATH}/start-metastore.sh ] || exit $ERROR_PROGRAM_NOT_INSTALLED
# Pid files created in sqoop-specific directory under /var/run.
# The dir should be recreated first.
local piddir=`dirname "$PID_FILE"`
install -d -m 0755 -o $USER -g $GROUP "$piddir"
log_success_msg "Starting $DESC: "
start_daemon -u $USER ${SQOOP_BIN_PATH}/start-metastore.sh -p $PID_FILE -l $LOGDIR
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
[ -x ${SQOOP_BIN_PATH}/stop-metastore.sh ] || exit $ERROR_PROGRAM_NOT_INSTALLED
log_success_msg "Stopping $DESC: "
start_daemon -u $USER ${SQOOP_BIN_PATH}/stop-metastore.sh -p $PID_FILE
RETVAL=$?
sleep 5
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PIDFILE
}
restart() {
stop
start
}
checkstatus(){
pidofproc -p $PID_FILE java > /dev/null
status=$?
case "$status" in
$STATUS_RUNNING)
log_success_msg "$DESC is running"
;;
$STATUS_DEAD)
log_failure_msg "$DESC is dead and pid file exists"
;;
$STATUS_DEAD_AND_LOCK)
log_failure_msg "$DESC is dead and lock file exists"
;;
$STATUS_NOT_RUNNING)
log_failure_msg "$DESC is not running"
;;
*)
log_failure_msg "$DESC status is unknown"
;;
esac
return $status
}
condrestart(){
[ -e $LOCKFILE ] && restart || :
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
checkstatus
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|try-restart}"
exit 1
esac
exit $RETVAL