View | Details | Raw Unified | Return to bug 38232
Collapse All | Expand All

(-)a/branches/ucs-4.0/ucs-4.0-1/services/univention-s4-connector/debian/univention-s4-connector.init (-25 / +62 lines)
 Lines 30-78    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
S4CONNECTORPID=/var/run/univention-s4-connector
33
PATH=/sbin:/usr/sbin:/bin:/usr/bin
34
DESC="Uniention Samba4 Connector"
35
NAME="univention-s4-connector"
36
DAEMON="/usr/sbin/$NAME"
37
DAEMON_ARGS=
38
PIDFILE="/var/run/$NAME"
39
SCRIPTNAME="/etc/init.d/$NAME"
34
40
35
test -x /usr/sbin/univention-s4-connector || exit 0
41
test -x "$DAEMON" || exit 0
36
42
43
. /lib/init/vars.sh
37
. /lib/lsb/init-functions
44
. /lib/lsb/init-functions
38
45
46
do_start () {
47
	start-stop-daemon --start --quiet --pidfile "$PIDFILE" --startas "$DAEMON" --test > /dev/null ||
48
		return 1
49
	start-stop-daemon --start --quiet --pidfile "$PIDFILE" --startas "$DAEMON" -- $DAEMON_ARGS ||
50
		return 2
51
}
52
53
do_stop () {
54
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile "$PIDFILE"
55
	RETVAL="$?"
56
	[ "$RETVAL" = 2 ] && return 2
57
	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --name "main.py"
58
	[ "$?" = 2 ] && return 2
59
	rm -f "$PIDFILE"
60
	return "$RETVAL"
61
}
62
39
case "$1" in
63
case "$1" in
40
	start)
64
	start)
41
		# check ucr autostart setting
42
		if [ -f "/usr/share/univention-config-registry/init-autostart.lib" ]; then
65
		if [ -f "/usr/share/univention-config-registry/init-autostart.lib" ]; then
43
			. "/usr/share/univention-config-registry/init-autostart.lib"
66
			. "/usr/share/univention-config-registry/init-autostart.lib"
44
			check_autostart s4-connector connector/s4/autostart
67
			check_autostart s4-connector connector/s4/autostart
45
		fi	
46
		log_action_msg "Starting univention-s4-connector daemon"
47
		if start-stop-daemon --start --quiet --pidfile "$S4CONNECTORPID" -a /usr/sbin/univention-s4-connector; then
48
			log_action_end_msg 0
49
		else
50
			log_action_end_msg 1
51
		fi
68
		fi
69
		[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
70
		do_start
71
		case "$?" in
72
			0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
73
			2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
74
		esac
52
		;;
75
		;;
53
	stop)
76
	stop)
54
		log_action_msg "Stopping univention-s4-connector daemon"
77
		[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
55
		if start-stop-daemon --stop --retry TERM/300/KILL/5 --quiet --pidfile "$S4CONNECTORPID" -a /usr/sbin/univention-s4-connector; then
78
		do_stop
56
			log_action_end_msg 0
79
		case "$?" in
57
		else
80
			0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
58
			log_action_end_msg 1
81
			2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
59
		fi
82
		esac
83
		;;
84
	status)
85
		status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
60
		;;
86
		;;
61
	restart|force-reload)
87
	restart|force-reload)
62
		$0 stop
88
		log_daemon_msg "Restarting $DESC" "$NAME"
63
		sleep 2 # give it some time to die
89
		do_stop
64
		$0 start
90
		case "$?" in
91
			0|1)
92
				sleep 2 # give it some time to die
93
				do_start
94
				case "$?" in
95
					0) log_end_msg 0 ;;
96
					1) log_end_msg 1 ;; # Old process is still running
97
					*) log_end_msg 1 ;; # Failed to start
98
				esac
99
				;;
100
			*)
101
				# Failed to stop
102
				log_end_msg 1
103
				;;
104
		esac
65
		;;
105
		;;
66
	crestart)
106
	crestart)
67
		S4CONNECTOR=`cat $S4CONNECTORPID 2>/dev/null`
107
		pidofproc -p "$PIDFILE" "$daemon" >/dev/null && "$SCRIPTNAME" restart
68
		if [ -n "$S4CONNECTOR" ]; then
69
		    ps xaw | grep connector | grep -q "$S4CONNECTOR" && $0 restart
70
		fi
71
		;;
108
		;;
72
	*)
109
	*)
73
		echo "Usage: /etc/init.d/univention-s4-connector {start|stop|restart|crestart|force-reload}"
110
		echo "Usage: $SCRIPTNAME {start|stop|status|restart|crestart|force-reload}"
74
		exit 1
111
		exit 3
75
		;;
112
		;;
76
esac
113
esac
77
114
78
115
:
(-)a/branches/ucs-4.0/ucs-4.0-1/services/univention-s4-connector/modules/univention/s4connector/s4/main.py (-17 / +15 lines)
 Lines 30-42    Link Here 
30
# License with the Debian GNU/Linux or Univention distribution in file
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
32
# <http://www.gnu.org/licenses/>.
33
from warnings import filterwarnings
34
filterwarnings("ignore")
33
35
34
36
import sys
35
import sys, string, os, time, signal, shutil
37
import os
38
import time
39
import signal
36
from optparse import OptionParser
40
from optparse import OptionParser
37
41
38
import fcntl
42
import fcntl
39
import ldap, traceback
43
import ldap
44
import traceback
40
import univention
45
import univention
41
import univention.s4connector
46
import univention.s4connector
42
import univention.s4connector.s4
47
import univention.s4connector.s4
 Lines 55-64   if options.configbasename: Link Here 
55
	CONFIGBASENAME = options.configbasename
60
	CONFIGBASENAME = options.configbasename
56
STATUSLOGFILE = "/var/log/univention/%s-s4-status.log" % CONFIGBASENAME
61
STATUSLOGFILE = "/var/log/univention/%s-s4-status.log" % CONFIGBASENAME
57
62
58
sys.path=['/etc/univention/%s/s4/' % CONFIGBASENAME]+sys.path
63
from imp import load_source
59
64
mapping = load_source('mapping', '/etc/univention/%s/s4/mapping.py' % CONFIGBASENAME)
60
61
import mapping
62
65
63
66
64
def daemon(lock_file):
67
def daemon(lock_file):
 Lines 146-152   def connect(): Link Here 
146
			s4_ldap_bindpw=s4_ldap_bindpw[0:-1]
149
			s4_ldap_bindpw=s4_ldap_bindpw[0:-1]
147
	else:
150
	else:
148
		s4_ldap_bindpw=None
151
		s4_ldap_bindpw=None
149
	
152
150
	poll_sleep=int(baseConfig['%s/s4/poll/sleep' % CONFIGBASENAME])
153
	poll_sleep=int(baseConfig['%s/s4/poll/sleep' % CONFIGBASENAME])
151
	s4_init=None
154
	s4_init=None
152
	while not s4_init:
155
	while not s4_init:
 Lines 166-172   def connect(): Link Here 
166
			print "Warning: Can't initialize LDAP-Connections, wait..."
169
			print "Warning: Can't initialize LDAP-Connections, wait..."
167
			sys.stdout.flush()
170
			sys.stdout.flush()
168
			time.sleep(poll_sleep)
171
			time.sleep(poll_sleep)
169
			pass
170
172
171
173
172
	# Initialisierung auf UCS und S4 Seite durchfuehren
174
	# Initialisierung auf UCS und S4 Seite durchfuehren
 Lines 179-190   def connect(): Link Here 
179
			ucs_init=True
181
			ucs_init=True
180
		except ldap.SERVER_DOWN:
182
		except ldap.SERVER_DOWN:
181
			print "Can't contact LDAP server during ucs-poll, sync not possible."
183
			print "Can't contact LDAP server during ucs-poll, sync not possible."
182
 			sys.stdout.flush()
184
			sys.stdout.flush()
183
			time.sleep(poll_sleep)
185
			time.sleep(poll_sleep)
184
			s4.open_s4()
186
			s4.open_s4()
185
			s4.open_ucs()
187
			s4.open_ucs()
186
			pass
187
	
188
188
189
	while not s4_init:
189
	while not s4_init:
190
		try:
190
		try:
 Lines 192-202   def connect(): Link Here 
192
			s4_init=True
192
			s4_init=True
193
		except ldap.SERVER_DOWN:
193
		except ldap.SERVER_DOWN:
194
			print "Can't contact LDAP server during ucs-poll, sync not possible."
194
			print "Can't contact LDAP server during ucs-poll, sync not possible."
195
 			sys.stdout.flush()
195
			sys.stdout.flush()
196
			time.sleep(poll_sleep)
196
			time.sleep(poll_sleep)
197
			s4.open_s4()
197
			s4.open_s4()
198
			s4.open_ucs()
198
			s4.open_ucs()
199
			pass
200
199
201
	f.close()
200
	f.close()
202
	retry_rejected=0
201
	retry_rejected=0
 Lines 250-256   def connect(): Link Here 
250
		except ldap.SERVER_DOWN:
249
		except ldap.SERVER_DOWN:
251
			print "Can't contact LDAP server during resync rejected, sync not possible."
250
			print "Can't contact LDAP server during resync rejected, sync not possible."
252
			connected = False
251
			connected = False
253
 			sys.stdout.flush()
252
			sys.stdout.flush()
254
			change_counter=0
253
			change_counter=0
255
			retry_rejected+=1
254
			retry_rejected+=1
256
255
 Lines 285-291   def main(): Link Here 
285
			f=open(STATUSLOGFILE, 'w+')
284
			f=open(STATUSLOGFILE, 'w+')
286
			sys.stdout=f
285
			sys.stdout=f
287
			print time.ctime()
286
			print time.ctime()
288
			
287
289
			text = ''
288
			text = ''
290
			exc_info = sys.exc_info()
289
			exc_info = sys.exc_info()
291
			lines = apply(traceback.format_exception, exc_info)
290
			lines = apply(traceback.format_exception, exc_info)
 Lines 304-307   def main(): Link Here 
304
303
305
if __name__ == "__main__":
304
if __name__ == "__main__":
306
	main()
305
	main()
307
(-)a/branches/ucs-4.0/ucs-4.0-1/services/univention-s4-connector/univention-s4-connector (-4 / +3 lines)
 Lines 32-38    Link Here 
32
32
33
33
34
# before starting the ad connector, generate the mapping file
34
# before starting the ad connector, generate the mapping file
35
cat /etc/univention/connector/s4/mapping | univention-config-registry filter --encode-utf8 >/etc/univention/connector/s4/mapping.py
35
univention-config-registry filter --encode-utf8 </etc/univention/connector/s4/mapping >/etc/univention/connector/s4/mapping.py
36
37
/usr/bin/python2.7 -W ignore /usr/lib/pymodules/python2.7/univention/s4connector/s4/main.py
38
36
39
- 
37
exec /usr/lib/pymodules/python2.7/univention/s4connector/s4/main.py
38
exec python2.7 -m univention.s4connector.s4.main

Return to bug 38232