1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #4754 from mscherer/fix_4648

Fix 4648, cron module is not working on solaris
This commit is contained in:
Michael DeHaan 2013-10-31 14:49:25 -07:00
commit 3705f41992

View file

@ -144,6 +144,7 @@ EXAMPLES = '''
import os
import re
import tempfile
import platform
CRONCMD = "/usr/bin/crontab"
@ -341,31 +342,31 @@ class CronTab(object):
result += '\n'
return result
def _read_file_execute(self):
"""
Returns the command line for reading a crontab
"""
return "%s -l %s" % (CRONCMD, self._user_execute())
def _read_user_execute(self):
"""
Returns the command line for reading a crontab
"""
return "%s -l %s" % (CRONCMD, self._user_execute())
user = ''
if self.user:
if platform.system() == 'SunOS':
return "su '%s' -c '%s -l'" % (self.user, CRONCMD)
else:
user = '-u %s' % self.user
return "%s %s %s" % (CRONCMD , user, '-l')
def _write_execute(self, path):
"""
Return the command line for writing a crontab
"""
return "%s %s %s" % (CRONCMD, self._user_execute(), path)
def _user_execute(self):
"""
User command switches to append to the read and write commands.
"""
user = ''
if self.user:
return "%s %s" % ('-u', str(self.user))
return ''
if platform.system() == 'SunOS':
return "chown %s %s ; su '%s' -c '%s %s'" % (self.user, path, self.user, CRONCMD, path)
else:
user = '-u %s' % self.user
return "%s %s %s" % (CRONCMD , user, path)
#==================================================