Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bin/mkenvdir
blob: 3b3b9ad305e2d012416752bfe4f1d7b717200058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
import os, sys
from os.path import join, exists, isdir
from rainbow.util import make_dirs

if len(sys.argv) < 2:
    print sys.argv[0] + " DIR"
    sys.exit(1)

dir = sys.argv[1]

if not exists(dir):
    uid = os.geteuid()
    gid = os.getegid()
    make_dirs(dir, os.geteuid(), os.getegid(), 0755)

def writable(path):
    return os.access(path, os.W_OK)

if exists(dir) and not (isdir(dir) and writable(dir)):
    print 'DIR is not a writable directory.'
    exit(1)

for k,v in os.environ.iteritems():
    open(join(dir, k), 'w').write(v)