def install_service_dir(path, owner, mode):
if not os.path.exists('/var/prologin'):
mkdir('/var/prologin', mode=0o755, owner='root:root')
name = os.path.basename(path) # strip service kind from path (eg. django)
# Nothing in Python allows merging two directories together...
# Be careful with rsync(1) arguments: to merge two directories, trailing
# slash are meaningful.
system('rsync -rv %s/ /var/prologin/%s' % (path, name))
user, group = owner.split(':')
shutil.chown('/var/prologin/%s' % name, user, group)
os.chmod('/var/prologin/%s' % name, mode)
for root, dirs, files in os.walk('/var/prologin/%s' % name):
for dir in dirs:
shutil.chown(os.path.join(root, dir), user, group)
os.chmod(os.path.join(root, dir), mode)
for file in files:
shutil.chown(os.path.join(root, file), user, group)
os.chmod(os.path.join(root, file), mode)
评论列表
文章目录