Commit 0d8d2d990b4f7c84afb2ca83e760095dac89722e
1 parent
740cf394
Exists in
master
and in
1 other branch
Adicionado arquivo script de init para servidores ubuntu/debian
Showing
5 changed files
with
203 additions
and
86 deletions
Show diff stats
INSTALL.txt
1 | -# OCR Server 1.0.1 - (c) Agencia Nacional de Telecomunicacoees | |
1 | +# OCR Server 1.0.4 - (c) Agencia Nacional de Telecomunicacoees | |
2 | 2 | # |
3 | 3 | # This script monitors a set of input directories for PDF files |
4 | 4 | # once a new file is detected, it is processes through tesseract OCR |
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | # 1.0.1 Solving error when file has no images |
23 | 23 | # 1.0.2 Fix bug when counting cores for AMD processors |
24 | 24 | # 1.0.3 Added better image type detection |
25 | +# 1.0.4 Fix: added ubuntu init script | |
25 | 26 | # |
26 | 27 | # TODO: - Changes get_imgs and OCR processing to enable pages with more than one image -- it |
27 | 28 | # would not work on previous versions that assumed #pages = #imgs. Version 1.1 counts them |
... | ... | @@ -144,12 +145,13 @@ cd poppler && ./autogen.sh && LIBOPENJPEG_LIBS=-l/usr/local/lib/libopenjp2.so LI |
144 | 145 | # Criação do usuário |
145 | 146 | adduser ocr |
146 | 147 | |
147 | -# Copie os arquivos ocr ocr-init* para o /home/ocr e, conforme o sistema operacional | |
148 | -cp /home/ocr/ocr /usr/local/bin | |
149 | -cp /home/ocr/ocr-init-rh /etc/init.d/ocr (OU) | |
150 | -cp /home/ocr/ocr-init-Ubuntu /etc/init/ocr | |
148 | +# Copie os arquivos ocr ocr-* para os diretórios corretos, conforme o sistema operacional | |
149 | +cp ./usr/local/bin/ocr /usr/local/bin | |
150 | +cp ./usr/local/etc/init.d/ocr-redhat /etc/init.d/ocr (OU) | |
151 | +cp ./usr/local/etc/init.d/ocr-ubuntu /etc/init.d/ocr | |
151 | 152 | |
152 | 153 | # Auto start (RedHat 6.7) |
154 | +mv /etc | |
153 | 155 | chkconfig --add ocr |
154 | 156 | chkconfig --level 2345 ocr on |
155 | 157 | ... | ... |
etc/init.d/ocr
... | ... | @@ -1,80 +0,0 @@ |
1 | -#!/bin/sh | |
2 | -# | |
3 | -# chkconfig: - 24 73 | |
4 | -# description: Starts and stops the Samba winbind daemon | |
5 | -# # | |
6 | -# pidfile: /var/run/winbindd.pid | |
7 | -# config: /etc/samba/smb.conf | |
8 | - | |
9 | - | |
10 | -# Source function library. | |
11 | -. /etc/rc.d/init.d/functions | |
12 | - | |
13 | -# Avoid using root's TMPDIR | |
14 | -unset TMPDIR | |
15 | - | |
16 | -RETVAL=0 | |
17 | - | |
18 | - | |
19 | -start() { | |
20 | - KIND="OCR" | |
21 | - echo -n $"Starting $KIND services: " | |
22 | - daemon /usr/local/bin/ocr | |
23 | - RETVAL=$? | |
24 | - echo | |
25 | - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ocr || RETVAL=1 | |
26 | - return $RETVAL | |
27 | -} | |
28 | - | |
29 | -stop() { | |
30 | - echo | |
31 | - KIND="OCR" | |
32 | - echo -n $"Shutting down $KIND services: " | |
33 | - killproc ocr | |
34 | - RETVAL=$? | |
35 | - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ocr | |
36 | - echo "" | |
37 | - return $RETVAL | |
38 | -} | |
39 | - | |
40 | -restart() { | |
41 | - stop | |
42 | - start | |
43 | -} | |
44 | - | |
45 | -rhstatus() { | |
46 | - status ocr | |
47 | - return $? | |
48 | -} | |
49 | - | |
50 | -# Allow status as non-root. | |
51 | -if [ "$1" = status ]; then | |
52 | - rhstatus | |
53 | - exit $? | |
54 | -fi | |
55 | - | |
56 | -# Check that we are root ... so non-root users stop here | |
57 | -[ `id -u` -eq "0" ] || exit 4 | |
58 | - | |
59 | -case "$1" in | |
60 | - start) | |
61 | - start | |
62 | - ;; | |
63 | - stop) | |
64 | - stop | |
65 | - ;; | |
66 | - restart) | |
67 | - restart | |
68 | - ;; | |
69 | - status) | |
70 | - rhstatus | |
71 | - ;; | |
72 | - condrestart) | |
73 | - [ -f /var/lock/subsys/ocr ] && restart || : | |
74 | - ;; | |
75 | - *) | |
76 | - echo $"Usage: $0 {start|stop|restart|status|condrestart}" | |
77 | - exit 2 | |
78 | -esac | |
79 | - | |
80 | -exit $? |
... | ... | @@ -0,0 +1,80 @@ |
1 | +#!/bin/sh | |
2 | +# | |
3 | +# chkconfig: - 24 73 | |
4 | +# description: Starts and stops the Samba winbind daemon | |
5 | +# # | |
6 | +# pidfile: /var/run/winbindd.pid | |
7 | +# config: /etc/samba/smb.conf | |
8 | + | |
9 | + | |
10 | +# Source function library. | |
11 | +. /etc/rc.d/init.d/functions | |
12 | + | |
13 | +# Avoid using root's TMPDIR | |
14 | +unset TMPDIR | |
15 | + | |
16 | +RETVAL=0 | |
17 | + | |
18 | + | |
19 | +start() { | |
20 | + KIND="OCR" | |
21 | + echo -n $"Starting $KIND services: " | |
22 | + daemon /usr/local/bin/ocr | |
23 | + RETVAL=$? | |
24 | + echo | |
25 | + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ocr || RETVAL=1 | |
26 | + return $RETVAL | |
27 | +} | |
28 | + | |
29 | +stop() { | |
30 | + echo | |
31 | + KIND="OCR" | |
32 | + echo -n $"Shutting down $KIND services: " | |
33 | + killproc ocr | |
34 | + RETVAL=$? | |
35 | + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ocr | |
36 | + echo "" | |
37 | + return $RETVAL | |
38 | +} | |
39 | + | |
40 | +restart() { | |
41 | + stop | |
42 | + start | |
43 | +} | |
44 | + | |
45 | +rhstatus() { | |
46 | + status ocr | |
47 | + return $? | |
48 | +} | |
49 | + | |
50 | +# Allow status as non-root. | |
51 | +if [ "$1" = status ]; then | |
52 | + rhstatus | |
53 | + exit $? | |
54 | +fi | |
55 | + | |
56 | +# Check that we are root ... so non-root users stop here | |
57 | +[ `id -u` -eq "0" ] || exit 4 | |
58 | + | |
59 | +case "$1" in | |
60 | + start) | |
61 | + start | |
62 | + ;; | |
63 | + stop) | |
64 | + stop | |
65 | + ;; | |
66 | + restart) | |
67 | + restart | |
68 | + ;; | |
69 | + status) | |
70 | + rhstatus | |
71 | + ;; | |
72 | + condrestart) | |
73 | + [ -f /var/lock/subsys/ocr ] && restart || : | |
74 | + ;; | |
75 | + *) | |
76 | + echo $"Usage: $0 {start|stop|restart|status|condrestart}" | |
77 | + exit 2 | |
78 | +esac | |
79 | + | |
80 | +exit $? | ... | ... |
... | ... | @@ -0,0 +1,114 @@ |
1 | +#! /bin/sh | |
2 | + | |
3 | +### BEGIN INIT INFO | |
4 | +# Provides: ocr | |
5 | +# Required-Start: $remote_fs $syslog | |
6 | +# Required-Stop: $remote_fs $syslog | |
7 | +# Default-Start: 2 3 4 5 | |
8 | +# Default-Stop: | |
9 | +# Short-Description: OCR daemon | |
10 | +### END INIT INFO | |
11 | + | |
12 | +set -e | |
13 | + | |
14 | +# /etc/init.d/ocr: start and stop the OpenBSD "secure shell(tm)" daemon | |
15 | +umask 022 | |
16 | + | |
17 | +. /lib/lsb/init-functions | |
18 | + | |
19 | +# Are we running from init? | |
20 | +run_by_init() { | |
21 | + ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ] | |
22 | +} | |
23 | + | |
24 | +check_for_upstart() { | |
25 | + if init_is_upstart; then | |
26 | + exit $1 | |
27 | + fi | |
28 | +} | |
29 | + | |
30 | +check_dev_null() { | |
31 | + if [ ! -c /dev/null ]; then | |
32 | + if [ "$1" = log_end_msg ]; then | |
33 | + log_end_msg 1 || true | |
34 | + fi | |
35 | + if ! run_by_init; then | |
36 | + log_action_msg "/dev/null is not a character device!" || true | |
37 | + fi | |
38 | + exit 1 | |
39 | + fi | |
40 | +} | |
41 | + | |
42 | +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
43 | + | |
44 | +case "$1" in | |
45 | + start) | |
46 | + log_daemon_msg "Starting OCR daemon" "ocr" || true | |
47 | + if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ocr.pid --exec /usr/local/bin/ocr -- $SSHD_OPTS; then | |
48 | + log_end_msg 0 || true | |
49 | + else | |
50 | + log_end_msg 1 || true | |
51 | + fi | |
52 | + ;; | |
53 | + stop) | |
54 | + log_daemon_msg "Stopping OCR daemon" "ocr" || true | |
55 | + if start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/ocr.pid; then | |
56 | + log_end_msg 0 || true | |
57 | + else | |
58 | + log_end_msg 1 || true | |
59 | + fi | |
60 | + killall ocr | |
61 | + ;; | |
62 | + | |
63 | + restart) | |
64 | + log_daemon_msg "Restarting OCR daemon" "ocr" || true | |
65 | + start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/ocr.pid | |
66 | + sleep 1 | |
67 | + killall ocr | |
68 | + sleep 1 | |
69 | + if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ocr.pid --exec /usr/local/bin/ocr -- $SSHD_OPTS; then | |
70 | + log_end_msg 0 || true | |
71 | + else | |
72 | + log_end_msg 1 || true | |
73 | + fi | |
74 | + ;; | |
75 | + | |
76 | + try-restart) | |
77 | + log_daemon_msg "Restarting OCR daemon" "ocr" || true | |
78 | + RET=0 | |
79 | + start-stop-daemon --stop --quiet --retry 30 --pidfile /var/run/ocr.pid || RET="$?" | |
80 | + sleep 1 | |
81 | + killall ocr | |
82 | + sleep 1 | |
83 | + case $RET in | |
84 | + 0) | |
85 | + # old daemon stopped | |
86 | + if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ocr.pid --exec /usr/local/bin/ocr -- $SSHD_OPTS; then | |
87 | + log_end_msg 0 || true | |
88 | + else | |
89 | + log_end_msg 1 || true | |
90 | + fi | |
91 | + ;; | |
92 | + 1) | |
93 | + # daemon not running | |
94 | + log_progress_msg "(not running)" || true | |
95 | + log_end_msg 0 || true | |
96 | + ;; | |
97 | + *) | |
98 | + # failed to stop | |
99 | + log_progress_msg "(failed to stop)" || true | |
100 | + log_end_msg 1 || true | |
101 | + ;; | |
102 | + esac | |
103 | + ;; | |
104 | + | |
105 | + status) | |
106 | + status_of_proc -p /var/run/ocr.pid /usr/local/bin/ocr ocr && exit 0 || exit $? | |
107 | + ;; | |
108 | + | |
109 | + *) | |
110 | + log_action_msg "Usage: /etc/init.d/ocr {start|stop|reload|force-reload|restart|try-restart|status}" || true | |
111 | + exit 1 | |
112 | +esac | |
113 | + | |
114 | +exit 0 | ... | ... |
usr/local/bin/ocr
1 | 1 | #! /usr/bin/perl -w |
2 | 2 | # |
3 | -# OCR Server 1.0.1 - (c) Agencia Nacional de Telecomunicacoes | |
3 | +# OCR Server 1.0.4 - (c) Agencia Nacional de Telecomunicacoes | |
4 | 4 | # |
5 | 5 | # This script monitors a set of input directories for PDF files |
6 | 6 | # once a new file is detected, it is processes through tesseract OCR |
... | ... | @@ -24,6 +24,7 @@ |
24 | 24 | # 1.0.1 Solving error when file has no images |
25 | 25 | # 1.0.2 Fix bug when counting cores for AMD processors |
26 | 26 | # 1.0.3 Added better image type detection |
27 | +# 1.0.4 Fix: added ubuntu init script | |
27 | 28 | # |
28 | 29 | # TODO: - Changes get_imgs and OCR processing to enable pages with more than one image -- it |
29 | 30 | # would not work on previous versions that assumed #pages = #imgs. Version 1.1 counts them | ... | ... |