This commit is contained in:
Alexandre Detiste 2014-07-12 12:58:54 +02:00
commit 015aa15825
2 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,6 @@
# Maintainer: Konstantin Stepanov <me@kstep.me>
pkgname=systemd-crontab-generator
pkgver=0.5.1
pkgver=0.6
pkgrel=1
pkgdesc="systemd generator to generate timers/services from crontab and anacrontab files"
url="https://github.com/kstep/systemd-crontab-generator"

View File

@ -1,5 +1,6 @@
#!/usr/bin/python2
import sys
import pwd
import os
import re
@ -25,6 +26,8 @@ DAYS_SET = range(0, 32)
DOWS_SET = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
MONTHS_SET = range(0, 13)
ROOT_USER = pwd.getpwnam('root')
try:
os.makedirs(TIMERS_DIR)
except OSError as e:
@ -63,6 +66,8 @@ def parse_crontab(filename, withuser=True, monotonic=False):
'@midnight': 'daily'
}.get(period, None) or period.lstrip('@')
environment['LOGNAME'] = environment['USER'] = 'root'
environment['HOME'] = ROOT_USER.pw_dir
yield {
'e': ' '.join('"%s=%s"' % kv for kv in environment.iteritems()),
'l': line,
@ -88,6 +93,9 @@ def parse_crontab(filename, withuser=True, monotonic=False):
user, command = (parts[1], ' '.join(parts[2:])) if withuser else (basename, ' '.join(parts[1:]))
environment['LOGNAME'] = environment['USER'] = user
environment['HOME'] = pwd.getpwnam(user).pw_dir
yield {
'e': ' '.join('"%s=%s"' % kv for kv in environment.iteritems()),
'l': line,
@ -104,6 +112,9 @@ def parse_crontab(filename, withuser=True, monotonic=False):
months, dows = parts[3:5]
user, command = (parts[5], ' '.join(parts[6:])) if withuser else (basename, ' '.join(parts[5:]))
environment['LOGNAME'] = environment['USER'] = user
environment['HOME'] = pwd.getpwnam(user).pw_dir
yield {
'e': ' '.join('"%s=%s"' % kv for kv in environment.iteritems()),
'l': line,