|
104 |
'logfile': '/var/log/univention/updater.log', |
104 |
'logfile': '/var/log/univention/updater.log', |
105 |
'statusfile': '/var/lib/univention-updater/univention-updater.status' |
105 |
'statusfile': '/var/lib/univention-updater/univention-updater.status' |
106 |
}, |
106 |
}, |
107 |
# no API available, and no wrapper-wrapper too (or at least, didn't find one). |
107 |
# *** IMPORTANT! *** the arg list from our request contains the COMPONENT name but the command |
108 |
# Should I write a wrapper, especially to get consistent behaviour in terms of 'logfile' and 'statusfile'? |
108 |
# here must contain the list of DEFAULTPACKAGES! |
109 |
# cmd = '/usr/share/univention-updater/univention-updater-umc-univention-install %s' % (' '.join(pkglist)) |
109 |
# cmd = '/usr/share/univention-updater/univention-updater-umc-univention-install %s' % (' '.join(pkglist)) |
110 |
'component': { |
110 |
'component': { |
111 |
'purpose': _("Install component '%s'"), |
111 |
'purpose': _("Install component '%s'"), |
|
843 |
MODULE.info(" << %s" % s) |
843 |
MODULE.info(" << %s" % s) |
844 |
# ----------------------------------- |
844 |
# ----------------------------------- |
845 |
result = None |
845 |
result = None |
846 |
job = 'unknown' |
846 |
job = '' |
847 |
if self._current_job and 'job' in self._current_job: |
847 |
if self._current_job and 'job' in self._current_job: |
848 |
job = self._current_job['job'] |
848 |
job = self._current_job['job'] |
849 |
else: |
849 |
else: |
850 |
job = request.options.get('job','none') |
850 |
job = request.options.get('job','') |
851 |
|
851 |
|
852 |
count = request.options.get('count',0) |
852 |
count = request.options.get('count',0) |
853 |
result = 0 if count < 0 else [] |
853 |
result = 0 if count < 0 else [] |
854 |
if not job in INSTALLERS: |
854 |
if not job in INSTALLERS: |
855 |
MODULE.warn(" ?? Don't know a '%s' job" % job) |
855 |
# job empty: this is the first call I can't avoid |
|
|
856 |
if job != '': |
857 |
MODULE.warn(" ?? Don't know a '%s' job" % job) |
856 |
else: |
858 |
else: |
857 |
if not 'logfile' in INSTALLERS[job]: |
859 |
if not 'logfile' in INSTALLERS[job]: |
858 |
MODULE.warn(" ?? Job '%s' has no associated log file" % job) |
860 |
MODULE.warn(" ?? Job '%s' has no associated log file" % job) |
|
900 |
job = request.options.get('job','') |
902 |
job = request.options.get('job','') |
901 |
result = {} |
903 |
result = {} |
902 |
if job in INSTALLERS: |
904 |
if job in INSTALLERS: |
903 |
result = INSTALLERS[job] |
905 |
# make a copy, not a reference! |
|
|
906 |
result = {} |
907 |
for arg in INSTALLERS[job]: |
908 |
result[arg] = INSTALLERS[job][arg] |
909 |
|
904 |
if 'statusfile' in INSTALLERS[job]: |
910 |
if 'statusfile' in INSTALLERS[job]: |
905 |
try: |
911 |
try: |
906 |
for line in open(INSTALLERS[job]['statusfile']): |
912 |
for line in open(INSTALLERS[job]['statusfile']): |
|
944 |
result['label'] = result['purpose'] % result['detail'] |
950 |
result['label'] = result['purpose'] % result['detail'] |
945 |
else: |
951 |
else: |
946 |
result['label'] = result['purpose'] |
952 |
result['label'] = result['purpose'] |
|
|
953 |
# Affordance to reboot... hopefully this gets set before |
954 |
# we stop polling on this job status |
955 |
self.ucr.load() # make it as current as possible |
956 |
result['reboot'] = self.ucr.is_true('update/reboot/required',False) |
947 |
|
957 |
|
948 |
# ----------- DEBUG ----------------- |
958 |
# ----------- DEBUG ----------------- |
949 |
MODULE.info("online/installer/status returns:") |
959 |
MODULE.info("online/installer/status returns:") |
|
972 |
at the top of the file. |
982 |
at the top of the file. |
973 |
""" |
983 |
""" |
974 |
# ----------- DEBUG ----------------- |
984 |
# ----------- DEBUG ----------------- |
975 |
MODULE.info("online/installer/execute invoked with:") |
985 |
MODULE.warn("online/installer/execute invoked with:") |
976 |
pp = pprint.PrettyPrinter(indent=4) |
986 |
pp = pprint.PrettyPrinter(indent=4) |
977 |
st = pp.pformat(request.options).split("\n") |
987 |
st = pp.pformat(request.options).split("\n") |
978 |
for s in st: |
988 |
for s in st: |
979 |
MODULE.info(" << %s" % s) |
989 |
MODULE.warn(" << %s" % s) |
980 |
# ----------------------------------- |
990 |
# ----------------------------------- |
981 |
|
991 |
|
|
|
992 |
# Clean up any stored job details ... they're now obsolete. |
993 |
self._current_job = {} |
994 |
|
982 |
result = {} |
995 |
result = {} |
983 |
result['status'] = 0 # successful. If not: set result['message'] too. |
996 |
result['status'] = 0 # successful. If not: set result['message'] too. |
984 |
|
997 |
|
|
999 |
self.finished(request.id,result) |
1012 |
self.finished(request.id,result) |
1000 |
return |
1013 |
return |
1001 |
|
1014 |
|
1002 |
cmd = INSTALLERS[subject]['command'] |
1015 |
try: |
1003 |
if cmd.find('%') != -1: |
1016 |
# Assemble the command line, now somewhat complicated: |
1004 |
cmd = cmd % request.options.get('detail','') |
1017 |
# |
1005 |
MODULE.info(" ++ Creating job: '%s'" % cmd) |
1018 |
# (1) take the 'command' entry from the INSTALLERS entry of this subject |
1006 |
self.__create_at_job(cmd,detail) |
1019 |
# (2) if it doesn't contain a percent sign -> ready. |
|
|
1020 |
# (3) if it contains a percent sign: we must format something: |
1021 |
# (4) if the subject is about 'component' we must get the 'defaultpackages' |
1022 |
# entry from the UCR tuple named by 'detail' and use that. |
1023 |
# (5) if not, we can format the 'detail' field into the command. |
1024 |
cmd = '%s' % INSTALLERS[subject]['command'] # I need a copy of this string! |
1025 |
if cmd.find('%') != -1: |
1026 |
if subject == 'component': |
1027 |
# Strictly spoken, we can't arrive here if 'defaultpackages' is not set |
1028 |
ucrs = '%s/%s/defaultpackages' % (COMPONENT_BASE,detail) |
1029 |
pkgs = self.ucr.get(ucrs,'') |
1030 |
cmd = cmd % pkgs |
1031 |
MODULE.warn(" Resolution of default packages of the '%s' component:" % detail) |
1032 |
MODULE.warn(" UCRS = '%s'" % ucrs) |
1033 |
MODULE.warn(" PKGS = '%s'" % pkgs) |
1034 |
MODULE.warn(" CMD = '%s'" % cmd) |
1035 |
else: |
1036 |
cmd = cmd % request.options.get('detail','') |
1037 |
MODULE.warn(" ++ Creating job: '%s'" % cmd) |
1038 |
self.__create_at_job(cmd,detail) |
1039 |
except Exception,ex: |
1040 |
MODULE.warn(" ERROR: %s" % str(ex)) |
1007 |
|
1041 |
|
1008 |
# ----------- DEBUG ----------------- |
1042 |
# ----------- DEBUG ----------------- |
1009 |
MODULE.info("online/installer/execute returns:") |
1043 |
MODULE.info("online/installer/execute returns:") |
|
1289 |
script = ''' |
1323 |
script = ''' |
1290 |
#:started: %s |
1324 |
#:started: %s |
1291 |
#:detail: %s |
1325 |
#:detail: %s |
|
|
1326 |
#:command: %s |
1292 |
dpkg-statoverride --add root root 0644 /usr/sbin/univention-management-console-web-server |
1327 |
dpkg-statoverride --add root root 0644 /usr/sbin/univention-management-console-web-server |
1293 |
dpkg-statoverride --add root root 0644 /usr/sbin/univention-management-console-server |
1328 |
dpkg-statoverride --add root root 0644 /usr/sbin/univention-management-console-server |
1294 |
dpkg-statoverride --add root root 0644 /usr/sbin/apache2 |
1329 |
dpkg-statoverride --add root root 0644 /usr/sbin/apache2 |
|
1301 |
dpkg-statoverride --remove /usr/sbin/univention-management-console-server |
1336 |
dpkg-statoverride --remove /usr/sbin/univention-management-console-server |
1302 |
dpkg-statoverride --remove /usr/sbin/apache2 |
1337 |
dpkg-statoverride --remove /usr/sbin/apache2 |
1303 |
chmod +x /usr/sbin/univention-management-console-server /usr/sbin/univention-management-console-web-server /usr/sbin/apache2 |
1338 |
chmod +x /usr/sbin/univention-management-console-server /usr/sbin/univention-management-console-web-server /usr/sbin/apache2 |
1304 |
''' % (started,detail,command) |
1339 |
''' % (started,detail,command,command) |
1305 |
p1 = subprocess.Popen( [ 'LC_ALL=C at now', ], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True ) |
1340 |
p1 = subprocess.Popen( [ 'LC_ALL=C at now', ], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True ) |
1306 |
(stdout,stderr) = p1.communicate( script ) |
1341 |
(stdout,stderr) = p1.communicate( script ) |
1307 |
|
1342 |
|