Project

General

Profile

« Previous | Next » 

Revision 2fb99eb9

Added by Andreas Kohlbecker almost 4 years ago

fix #3683 adding /etc/default/cdmserver to deb package also cleaning up & improving

View differences:

src/main/installer/.directory
1
[Dolphin]
2
HeaderColumnWidths=309,96,127
3
PreviewsShown=false
4
Timestamp=2020,6,16,12,0,49
5
Version=4
6
ViewMode=1
7
VisibleRoles=Details_text,Details_size,Details_modificationtime,Details_type,CustomizedDetails
8

  
9
[Settings]
10
HiddenFilesShown=true
src/main/installer/linux/Makefile
1
install :
2
	cp cdmserver $(DESTDIR)/etc/init.d/
3
	cp -r datasources.xml $(DESTDIR)/usr/sbin/
4
	cp cdmserver-standalone.jar $(DESTDIR)/usr/bin/
5
	#cp cdmserver.properties $(DESTDIR)/usr/bin/
6
clean:
src/main/installer/linux/build-deb.xml
14 14

  
15 15

  
16 16
  <!-- Various Filenames -->
17
  <property name="cdmserverscript.filename" value="cdmserver" />
18 17
  <property name="cdmserver.filename" value="cdm-server-${project.version}.jar" />
19 18
  <property name="cdmserver.destinationfilename" value="cdm-server.jar" />
20 19

  
......
41 40
  </taskdef>
42 41

  
43 42
  <target name="deb_package" description="build the deb file">
43
  	<!-- see https://github.com/mscurtescu/ant-deb-task -->
44 44
    <mkdir dir="target" />
45 45
    <deb todir="target"
46 46
        package="${package.name}"
......
58 58
        webapplication and of course with the remote component of the CDM Library.
59 59
        For more information please refer to https://cybertaxonomy.eu/cdm-server/
60 60
      </description>
61
      <tarfileset file="${linux.installer.path}/${cdmserverscript.filename}" prefix="/etc/init.d/" />
61
      <tarfileset file="${linux.installer.path}/etc/init.d/cdmserver" prefix="/etc/init.d/" />
62
      <tarfileset file="${linux.installer.path}/etc/default/cdmserver" prefix="/opt/cdmserver/templates/etc/default/" />
62 63
      <tarfileset file="${installer.path}/templates/.cdmLibrary/*" prefix="/opt/cdmserver/templates/.cdmLibrary/" />
63 64
      <tarfileset file="${maven.target.path}/${cdmserver.filename}" fullpath="/opt/cdmserver/${cdmserver.destinationfilename}" />
64 65
    </deb>
src/main/installer/linux/cdmserver
1
#! /bin/sh -e
2
#
3
# /etc/init.d/cdmserver -- startup script for cdmserver
4
# Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
5
#
6
# based on:
7
# 	/etc/init.d/jetty -- startup script for jetty 6.1.18
8
# 	Written by Philipp Meier <meier@meisterbohne.de>
9
# 	Modified for Jetty 6 by Ludovic Claude <ludovic.claude@laposte.net>
10
#
11
#
12
### BEGIN INIT INFO
13
# Provides:          cdmserver
14
# Required-Start:    $local_fs $remote_fs
15
# Required-Stop:     $local_fs $remote_fs
16
# Default-Start:     2 3 4 5
17
# Default-Stop:      0 1 6
18
# Should-Start:      mysql postgresql
19
# Short-Description: Start CDM Server daemon
20
# Description:       Starts CDM Server daemon which provides a webservice to access CDM Stores
21
### END INIT INFO
22

  
23
# Configuration files are found in
24
# /etc/cdmserver/.cdmLibrary
25

  
26
# install init script:		update-rc.d cdmserver defaults
27
# uninstall init script:	update-rc.d -f cdmserver remove
28

  
29

  
30
######################################################################
31
# variables that can be overwritten in /etc/default/cdmserver
32

  
33
NAME=cdmserver
34
DESC="CDM Server"
35
CDM_HOME=/opt/cdmserver
36
CDM_USER="cdm"
37
CDM_GROUP="cdm"
38
LOGDIR="/var/log/$NAME"
39
JAVA=/usr/bin/java
40
DAEMON=/usr/bin/jsvc
41

  
42
CONTEXT_PATH_PREFIX=/
43

  
44
CDMSERVER_PORT=8080
45

  
46
CDMSERVER_ARGS=""
47

  
48
JAVA_OPTIONS="-Xmx1024M -XX:PermSize=128m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -Duser.home=$CDM_HOME -Dcdm.logDir=$LOGDIR"
49

  
50
JSVC_JVM="server"
51

  
52
# PATH should only include /usr/* if it runs after the mountnfs.sh script
53
PATH=/usr/sbin:/usr/bin:/sbin:/bin
54

  
55
# Define other required variables
56
PIDFILE=/var/run/$NAME.pid
57
SCRIPTNAME=/etc/init.d/$NAME
58

  
59
# Timeout in seconds for the shutdown of all webapps
60
CDMSERVER_SHUTDOWN=30
61

  
62
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
63
# defined in /etc/default/jetty). Should contain a list of space separated directories.
64
JDK_DIRS="
65
    /usr/lib/jvm/default-java \
66
    /usr/lib/jvm/java-6-sun \
67
    /usr/lib/jvm/java-6-openjdk \
68
    /usr/lib/jvm/java-gcj \
69
    /usr/lib/kaffe/ \
70
   "
71

  
72
# End of variables that can be overwritten in /etc/default/cdmserver
73
######################################################################
74

  
75
if [ `id -u` -ne 0 ]; then
76
  echo "You need root privileges to run this script"
77
  exit 1
78
fi
79

  
80
# Exit if the package is not installed
81
[ -x "$DAEMON" ] || exit 0
82

  
83
# Read configuration variable file if it is present
84
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
85

  
86
# Load the VERBOSE setting and other rcS variables
87
[ -f /etc/default/rcS ] && . /etc/default/rcS
88

  
89
# Define LSB log_* functions.
90
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
91
. /lib/lsb/init-functions
92

  
93
#### finally compile overridable variables
94
CDMSERVER_ARGS="-httpPort=$CDMSERVER_PORT -contextPathPrefix=$CONTEXT_PATH_PREFIX $CDMSERVER_ARGS"
95

  
96
#### setting java home for JSVC ####
97

  
98

  
99
# Look for the right JVM to use
100
for jdir in $JDK_DIRS; do
101
  if [ -d "$jdir" -a -z "${JAVA_HOME}" ]; then
102
    JAVA_HOME="$jdir"
103
  fi
104
done
105

  
106
### configuring environment to use jemalloc for the jvm (see https://dev.e-taxonomy.eu/redmine/issues/5048)
107
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
108

  
109

  
110
#BOOTSTRAP_CLASS="eu.etaxonomy.cdm.server.Bootloader"
111
BOOTSTRAP_CLASS="eu.etaxonomy.cdm.server.jsvc.ServiceWrapper"
112

  
113
JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:${JAVA_HOME}/lib/tools.jar:$CDM_HOME/cdm-server.jar"
114

  
115
# Check for JAVA_HOME
116
if [ -z "$JAVA_HOME" ]; then
117
  log_failure_msg "Could not start $DESC because no Java Development Kit"
118
  log_failure_msg "(JDK) was found. Please download and install JDK 1.6 or higher and set"
119
  log_failure_msg "JAVA_HOME in /etc/default/cdmserver to the JDK's installation directory."
120
  exit 0
121
fi
122

  
123

  
124
#
125
# Function that starts the daemon/service
126
#
127
do_start()
128
{
129
  #[ -e "$LOG" ] && cnt=`wc -l "$LOG" | awk '{ print $1 }'` || cnt=1
130
  # Return
131
  #   0 if daemon has been started
132
  #   1 if daemon was already running
133
  #   2 if daemon could not be started
134
  log_daemon_msg "Starting $DESC ( java $JAVA_OPTIONS -jar $CDM_HOME/cdm-server.jar $CDMSERVER_ARGS )"
135

  
136
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
137
        --user "$CDM_USER" --startas "$JAVA" > /dev/null
138
  then
139

  
140
    if [ -f $PIDFILE ] ; then
141
      log_warning_msg "$PIDFILE exists, but cdmserver was not running. Ignoring $PIDFILE"
142
    fi
143

  
144
    echo $JSVC_CLASSPATH
145
    echo $JAVA_OPTIONS $BOOTSTRAP_CLASS  $CDMSERVER_ARGS
146

  
147
    # increasing the maximum number of open files
148
    ulimit -n 200000
149
    
150
    LOGFILE=$LOGDIR/startup.log
151
    
152
    rm -f $LOGFILE
153

  
154
    $DAEMON -home "$JAVA_HOME" -user "$CDM_USER" -jvm $JSVC_JVM -cp $JSVC_CLASSPATH \
155
        -outfile $LOGFILE -errfile $LOGFILE \
156
        -pidfile "$PIDFILE" $JAVA_OPTIONS $BOOTSTRAP_CLASS  $CDMSERVER_ARGS
157

  
158
    sleep 5
159
    if start-stop-daemon --test --start --pidfile "$PIDFILE" \
160
      --user $CDM_USER --startas "$JAVA" >/dev/null; then
161
      log_daemon_msg "$DESC did not start, please check $LOGFILE"
162
      return 2
163
    else
164
      log_daemon_msg "$DESC started, reachable on http://localhost:$CDMSERVER_PORT/."
165
      return 0
166
    fi
167

  
168

  
169
  else
170
    log_warning_msg "(already running)."
171
    exit 1
172
  fi
173
}
174

  
175
#
176
# Function that stops the daemon/service
177
#
178
do_stop()
179
{
180
  # Return
181
  #   0 if daemon has been stopped
182
  #   1 if daemon was already stopped
183
  #   2 if daemon could not be stopped
184
  #   other if a failure occurred
185
  log_daemon_msg "Stopping $DESC"
186

  
187
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
188
        --user "$CDM_USER" --startas "$JAVA" > /dev/null
189
  then
190
    if [ -x "$PIDFILE" ]; then
191
      log_warning_msg "(not running but $PIDFILE exists)."
192
    else
193
      log_warning_msg "(not running)."
194
    fi
195
    return 1
196
  else
197
    start-stop-daemon --quiet --stop \
198
      --pidfile $PIDFILE --user "$CDM_USER" --startas "$JAVA"  > /dev/null
199

  
200
    while ! start-stop-daemon --quiet --test --start \
201
        --pidfile "$PIDFILE" --user "$CDM_USER" --startas "$JAVA" > /dev/null; do
202
      sleep 1
203
      log_progress_msg "."
204
      CDMSERVER_SHUTDOWN=`expr $CDMSERVER_SHUTDOWN - 1` || true
205
      if [ $CDMSERVER_SHUTDOWN -ge 0 ]; then
206
        start-stop-daemon --oknodo --quiet --stop \
207
          --pidfile "$PIDFILE" --user "$CDM_USER" \
208
          --startas "$JAVA"
209
      else
210
        log_progress_msg " (killing) "
211
        start-stop-daemon --stop --signal 9 --oknodo \
212
          --quiet --pidfile "$PIDFILE" \
213
          --user "$CDM_USER"
214
      fi
215
    done
216
    rm -f $PIDFILE
217
    log_daemon_msg "$DESC stopped."
218
  fi
219
  return 0
220
}
221

  
222
#
223
# Function that sends a SIGHUP to the daemon/service
224
#
225
do_reload() {
226
  #
227
  # If the daemon can reload its configuration without
228
  # restarting (for example, when it is sent a SIGHUP),
229
  # then implement that here.
230
  #
231
  start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
232
  return 0
233
}
234

  
235
report_status() {
236
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
237
    --user "$CDM_USER" --startas "$JAVA" > /dev/null; then
238

  
239
    if [ -f "$PIDFILE" ]; then
240
        log_success_msg "$DESC is not running, but pid file exists."
241
      exit 1
242
    else
243
        log_success_msg "$DESC is not running."
244
      exit 3
245
    fi
246
  else
247
    log_success_msg "$DESC is running with pid `cat $PIDFILE`, and is reachable on http://localhost:$CDMSERVER_PORT/"
248
  fi
249
}
250

  
251
case "$1" in
252

  
253
  start)
254
  do_start
255
  case "$?" in
256
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
257
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
258
  esac
259
  ;;
260

  
261
  debug)
262
    JAVA_OPTIONS=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 $JAVA_OPTIONS"
263
    do_start
264
    case "$?" in
265
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
266
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
267
    esac
268
  ;;
269

  
270
  stop)
271
  do_stop
272
  case "$?" in
273
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
274
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
275
  esac
276
  ;;
277

  
278
  #reload|force-reload)
279
  #
280
  # If do_reload() is not implemented then leave this commented out
281
  # and leave 'force-reload' as an alias for 'restart'.
282
  #
283
  #log_daemon_msg "Reloading $DESC" "$NAME"
284
  #do_reload
285
  #log_end_msg $?
286
  #;;
287

  
288
  restart|force-reload)
289
  #
290
  # If the "reload" option is implemented then remove the
291
  # 'force-reload' alias
292
  #
293
  log_daemon_msg "Restarting $DESC"
294
  do_stop
295
  case "$?" in
296
    0|1)
297
    do_start
298
    case "$?" in
299
      0) log_end_msg 0 ;;
300
      1) log_end_msg 1 ;; # Old process is still running
301
      *) log_end_msg 1 ;; # Failed to start
302
    esac
303
    ;;
304
    *)
305
    # Failed to stop
306
    log_end_msg 1
307
    ;;
308
  esac
309
  ;;
310

  
311
  status)
312
    report_status
313
    log_end_msg 0
314
  ;;
315

  
316
  *)
317
  #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
318
  echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status|debug}" >&2
319
  exit 3
320
  ;;
321
esac
322

  
323
:
src/main/installer/linux/etc/default/cdmserver
1
#/etc/defaults/cdmserver
2

  
3
# CONTEXT_PATH_PREFIX per default is set to / in the cdmserver init script
4
# enable the below line to override this variable
5
#CONTEXT_PATH_PREFIX=cdmserver
6

  
7
# The JAVA_HOME variable
8
# must point to the location of the jdk you want to run the CDM Server with
9
#JAVA_HOME=/opt/java-oracle/jdk1.8
10

  
11
# To configure an alternative logging directory (default is /var/log/cdmserver) 
12
#LOGDIR=
13

  
14
# determine the number of processors available in the system
15
CPU_CORES=$(nproc)
16

  
17
# HEAP_SIZE=5000M
18

  
19
# jvm settings for jdk 1.8
20
#JAVA_OPTIONS="-Xms${HEAP_SIZE} -Xmx${HEAP_SIZE} -XX:+UseG1GC -XX:ParallelGCThreads=${CPU_CORES} -XX:ConcGCThreads=${CPU_CORES} -Duser.home=$CDM_HOME -Dcdm.logDir=$LOGDIR"
21

  
22
#
23
# enable jmx
24
#
25
CDMSERVER_ARGS="$CDMSERVER_ARGS -jmx"
26
JAVA_OPTIONS="$JAVA_OPTIONS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=9999"
27

  
28
#
29
# enable remode debugging
30
#
31
#JAVA_OPTIONS="$JAVA_OPTIONS -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n"
32

  
33
#
34
# user custom logback configuration file
35
#
36
#JAVA_OPTIONS="$JAVA_OPTIONS -Dlogback.configurationFile=~/.cdmLibrary/logback.xml
37

  
38
#
39
# force schema update
40
#
41
CDMSERVER_ARGS="$CDMSERVER_ARGS -forceSchemaUpdate"
src/main/installer/linux/etc/init.d/cdmserver
1
#! /bin/sh -e
2
#
3
# /etc/init.d/cdmserver -- startup script for cdmserver
4
# Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
5
#
6
# based on:
7
# 	/etc/init.d/jetty -- startup script for jetty 6.1.18
8
# 	Written by Philipp Meier <meier@meisterbohne.de>
9
# 	Modified for Jetty 6 by Ludovic Claude <ludovic.claude@laposte.net>
10
#
11
#
12
### BEGIN INIT INFO
13
# Provides:          cdmserver
14
# Required-Start:    $local_fs $remote_fs
15
# Required-Stop:     $local_fs $remote_fs
16
# Default-Start:     2 3 4 5
17
# Default-Stop:      0 1 6
18
# Should-Start:      mysql postgresql
19
# Short-Description: Start CDM Server daemon
20
# Description:       Starts CDM Server daemon which provides a webservice to access CDM Stores
21
### END INIT INFO
22

  
23
# Configuration files are found in
24
# /etc/cdmserver/.cdmLibrary
25

  
26
# install init script:		update-rc.d cdmserver defaults
27
# uninstall init script:	update-rc.d -f cdmserver remove
28

  
29

  
30
######################################################################
31
# variables that can be overwritten in /etc/default/cdmserver
32

  
33
NAME=cdmserver
34
DESC="CDM Server"
35
CDM_HOME=/opt/cdmserver
36
CDM_USER="cdm"
37
CDM_GROUP="cdm"
38
LOGDIR="/var/log/$NAME"
39
JAVA=/usr/bin/java
40
DAEMON=/usr/bin/jsvc
41

  
42
CONTEXT_PATH_PREFIX=/
43

  
44
CDMSERVER_PORT=8080
45

  
46
CDMSERVER_ARGS=""
47

  
48
JAVA_OPTIONS="-Xmx1024M -XX:PermSize=128m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -Duser.home=$CDM_HOME -Dcdm.logDir=$LOGDIR"
49

  
50
JSVC_JVM="server"
51

  
52
# PATH should only include /usr/* if it runs after the mountnfs.sh script
53
PATH=/usr/sbin:/usr/bin:/sbin:/bin
54

  
55
# Define other required variables
56
PIDFILE=/var/run/$NAME.pid
57
SCRIPTNAME=/etc/init.d/$NAME
58

  
59
# Timeout in seconds for the shutdown of all webapps
60
CDMSERVER_SHUTDOWN=30
61

  
62
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
63
# defined in /etc/default/jetty). Should contain a list of space separated directories.
64
JDK_DIRS="
65
    /usr/lib/jvm/java-8-openjdk-amd64
66
    /usr/lib/jvm/default-java \
67
    /usr/lib/jvm/java-gcj \
68
    /usr/lib/kaffe/ \
69
   "
70

  
71
# End of variables that can be overwritten in /etc/default/cdmserver
72
######################################################################
73

  
74
if [ `id -u` -ne 0 ]; then
75
  echo "You need root privileges to run this script"
76
  exit 1
77
fi
78

  
79
# Exit if the package is not installed
80
[ -x "$DAEMON" ] || exit 0
81

  
82
# Read configuration variable file if it is present
83
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
84

  
85
# Load the VERBOSE setting and other rcS variables
86
[ -f /etc/default/rcS ] && . /etc/default/rcS
87

  
88
# Define LSB log_* functions.
89
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
90
. /lib/lsb/init-functions
91

  
92
#### finally compile overridable variables
93
CDMSERVER_ARGS="-httpPort=$CDMSERVER_PORT -contextPathPrefix=$CONTEXT_PATH_PREFIX $CDMSERVER_ARGS"
94

  
95
#### setting java home for JSVC ####
96

  
97

  
98
# Look for the right JVM to use
99
for jdir in $JDK_DIRS; do
100
  if [ -d "$jdir" -a -z "${JAVA_HOME}" ]; then
101
    JAVA_HOME="$jdir"
102
  fi
103
done
104

  
105
### configuring environment to use jemalloc for the jvm (see https://dev.e-taxonomy.eu/redmine/issues/5048)
106
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
107

  
108

  
109
#BOOTSTRAP_CLASS="eu.etaxonomy.cdm.server.Bootloader"
110
BOOTSTRAP_CLASS="eu.etaxonomy.cdm.server.jsvc.ServiceWrapper"
111

  
112
JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:${JAVA_HOME}/lib/tools.jar:$CDM_HOME/cdm-server.jar"
113

  
114
# Check for JAVA_HOME
115
if [ -z "$JAVA_HOME" ]; then
116
  log_failure_msg "Could not start $DESC because no Java Development Kit"
117
  log_failure_msg "(JDK) was found. Please download and install JDK 1.6 or higher and set"
118
  log_failure_msg "JAVA_HOME in /etc/default/cdmserver to the JDK's installation directory."
119
  exit 0
120
fi
121

  
122

  
123
#
124
# Function that starts the daemon/service
125
#
126
do_start()
127
{
128
  #[ -e "$LOG" ] && cnt=`wc -l "$LOG" | awk '{ print $1 }'` || cnt=1
129
  # Return
130
  #   0 if daemon has been started
131
  #   1 if daemon was already running
132
  #   2 if daemon could not be started
133
  log_daemon_msg "Starting $DESC ( java $JAVA_OPTIONS -jar $CDM_HOME/cdm-server.jar $CDMSERVER_ARGS )"
134

  
135
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
136
        --user "$CDM_USER" --startas "$JAVA" > /dev/null
137
  then
138

  
139
    if [ -f $PIDFILE ] ; then
140
      log_warning_msg "$PIDFILE exists, but cdmserver was not running. Ignoring $PIDFILE"
141
    fi
142

  
143
    echo $JSVC_CLASSPATH
144
    echo $JAVA_OPTIONS $BOOTSTRAP_CLASS  $CDMSERVER_ARGS
145

  
146
    # increasing the maximum number of open files
147
    ulimit -n 200000
148
    
149
    LOGFILE=$LOGDIR/startup.log
150
    
151
    rm -f $LOGFILE
152

  
153
    $DAEMON -home "$JAVA_HOME" -user "$CDM_USER" -jvm $JSVC_JVM -cp $JSVC_CLASSPATH \
154
        -outfile $LOGFILE -errfile $LOGFILE \
155
        -pidfile "$PIDFILE" $JAVA_OPTIONS $BOOTSTRAP_CLASS  $CDMSERVER_ARGS
156

  
157
    sleep 5
158
    if start-stop-daemon --test --start --pidfile "$PIDFILE" \
159
      --user $CDM_USER --startas "$JAVA" >/dev/null; then
160
      log_daemon_msg "$DESC did not start, please check $LOGFILE"
161
      return 2
162
    else
163
      log_daemon_msg "$DESC started, reachable on http://localhost:$CDMSERVER_PORT/."
164
      return 0
165
    fi
166

  
167

  
168
  else
169
    log_warning_msg "(already running)."
170
    exit 1
171
  fi
172
}
173

  
174
#
175
# Function that stops the daemon/service
176
#
177
do_stop()
178
{
179
  # Return
180
  #   0 if daemon has been stopped
181
  #   1 if daemon was already stopped
182
  #   2 if daemon could not be stopped
183
  #   other if a failure occurred
184
  log_daemon_msg "Stopping $DESC"
185

  
186
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
187
        --user "$CDM_USER" --startas "$JAVA" > /dev/null
188
  then
189
    if [ -x "$PIDFILE" ]; then
190
      log_warning_msg "(not running but $PIDFILE exists)."
191
    else
192
      log_warning_msg "(not running)."
193
    fi
194
    return 1
195
  else
196
    start-stop-daemon --quiet --stop \
197
      --pidfile $PIDFILE --user "$CDM_USER" --startas "$JAVA"  > /dev/null
198

  
199
    while ! start-stop-daemon --quiet --test --start \
200
        --pidfile "$PIDFILE" --user "$CDM_USER" --startas "$JAVA" > /dev/null; do
201
      sleep 1
202
      log_progress_msg "."
203
      CDMSERVER_SHUTDOWN=`expr $CDMSERVER_SHUTDOWN - 1` || true
204
      if [ $CDMSERVER_SHUTDOWN -ge 0 ]; then
205
        start-stop-daemon --oknodo --quiet --stop \
206
          --pidfile "$PIDFILE" --user "$CDM_USER" \
207
          --startas "$JAVA"
208
      else
209
        log_progress_msg " (killing) "
210
        start-stop-daemon --stop --signal 9 --oknodo \
211
          --quiet --pidfile "$PIDFILE" \
212
          --user "$CDM_USER"
213
      fi
214
    done
215
    rm -f $PIDFILE
216
    log_daemon_msg "$DESC stopped."
217
  fi
218
  return 0
219
}
220

  
221
#
222
# Function that sends a SIGHUP to the daemon/service
223
#
224
do_reload() {
225
  #
226
  # If the daemon can reload its configuration without
227
  # restarting (for example, when it is sent a SIGHUP),
228
  # then implement that here.
229
  #
230
  start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
231
  return 0
232
}
233

  
234
report_status() {
235
  if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
236
    --user "$CDM_USER" --startas "$JAVA" > /dev/null; then
237

  
238
    if [ -f "$PIDFILE" ]; then
239
        log_success_msg "$DESC is not running, but pid file exists."
240
      exit 1
241
    else
242
        log_success_msg "$DESC is not running."
243
      exit 3
244
    fi
245
  else
246
    log_success_msg "$DESC is running with pid `cat $PIDFILE`, and is reachable on http://localhost:$CDMSERVER_PORT/"
247
  fi
248
}
249

  
250
case "$1" in
251

  
252
  start)
253
  do_start
254
  case "$?" in
255
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
256
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
257
  esac
258
  ;;
259

  
260
  debug)
261
    JAVA_OPTIONS=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 $JAVA_OPTIONS"
262
    do_start
263
    case "$?" in
264
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
265
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
266
    esac
267
  ;;
268

  
269
  stop)
270
  do_stop
271
  case "$?" in
272
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
273
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
274
  esac
275
  ;;
276

  
277
  #reload|force-reload)
278
  #
279
  # If do_reload() is not implemented then leave this commented out
280
  # and leave 'force-reload' as an alias for 'restart'.
281
  #
282
  #log_daemon_msg "Reloading $DESC" "$NAME"
283
  #do_reload
284
  #log_end_msg $?
285
  #;;
286

  
287
  restart|force-reload)
288
  #
289
  # If the "reload" option is implemented then remove the
290
  # 'force-reload' alias
291
  #
292
  log_daemon_msg "Restarting $DESC"
293
  do_stop
294
  case "$?" in
295
    0|1)
296
    do_start
297
    case "$?" in
298
      0) log_end_msg 0 ;;
299
      1) log_end_msg 1 ;; # Old process is still running
300
      *) log_end_msg 1 ;; # Failed to start
301
    esac
302
    ;;
303
    *)
304
    # Failed to stop
305
    log_end_msg 1
306
    ;;
307
  esac
308
  ;;
309

  
310
  status)
311
    report_status
312
    log_end_msg 0
313
  ;;
314

  
315
  *)
316
  #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
317
  echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status|debug}" >&2
318
  exit 3
319
  ;;
320
esac
321

  
322
:
src/main/installer/linux/postinst
7 7
# variables
8 8
#
9 9
CDM_HOME="/opt/cdmserver"
10
CDM_CONFIG_TEMPLATE="/opt/cdmserver/templates/.cdmLibrary"
10
TEMPLATE_DIR="/opt/cdmserver/templates"
11 11
CDM_LOG="/var/log/cdmserver"
12 12

  
13 13
INIT_SCRIPT="cdmserver"
......
92 92
    if [ ! -d $ETC_CDMSERVER ]
93 93
    then
94 94
      mkdir -p $ETC_CDMSERVER
95
      cp -r $CDM_CONFIG_TEMPLATE/* $ETC_CDMSERVER/
95
      cp -r $TEMPLATE_DIR/etc/cdmserver/* $ETC_CDMSERVER/
96 96
    fi
97
		#
98
		# create a .cdmLibrary folder in user home, it will hold temporary files
99
		# and symlinks to the configfiles
100
		#
101
		if [ ! -e $CDM_USER_HOME/.cdmLibrary ]
102
		then
103
			mkdir $CDM_USER_HOME/.cdmLibrary
104
		fi
105
		cd $CDM_USER_HOME/.cdmLibrary
97
    
98
    if [ ! -e /etc/default/cdmserver ]
99
    then
100
      cp $TEMPLATE_DIR/etc/default/cdmserver /etc/default/cdmserver
101
    fi
102
    
103
	#
104
	# create a .cdmLibrary folder in user home, it will hold temporary files
105
	# and symlinks to the configfiles
106
	#
107
	if [ ! -e $CDM_USER_HOME/.cdmLibrary ]
108
	then
109
		mkdir $CDM_USER_HOME/.cdmLibrary
110
	fi
111
	
112
	cd $CDM_USER_HOME/.cdmLibrary
113
	
106 114
    ln -sf $ETC_CDMSERVER/datasources.xml datasources.xml
107
		ln -sf $ETC_CDMSERVER/cdm-server-realm.properties cdm-server-realm.properties
115
    ln -sf $ETC_CDMSERVER/cdm-server-realm.properties cdm-server-realm.properties
116
    
117
    # clean up
118
    rm -rf $TEMPLATE_DIR
108 119

  
109
		#
110
		# set group and owner for home directory
111
		#
112
		chown -R $CDM_USER:$CDM_GROUP $CDM_HOME
120
    #
121
    # set group and owner for home directory
122
    #
123
    chown -R $CDM_USER:$CDM_GROUP $CDM_HOME
113 124

  
114 125
    # let the cdm server start automatically on boot
115 126
    update-rc.d $INIT_SCRIPT defaults 98 02
src/main/installer/linux/postrm
91 91
    then
92 92
      rm -r $ETC_CDMSERVER
93 93
    fi
94
    
95
    rm -f /etc/default/cdmserver
94 96

  
95 97
    return 0
96 98
}
src/main/installer/templates/.directory
1
[Dolphin]
2
HeaderColumnWidths=309,96,127
3
PreviewsShown=false
4
Timestamp=2020,6,16,12,0,42
5
Version=4
6
ViewMode=1
7
VisibleRoles=Details_text,Details_size,Details_modificationtime,Details_type,CustomizedDetails
8

  
9
[Settings]
10
HiddenFilesShown=true

Also available in: Unified diff