mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-25 22:07:58 +01:00
m + ensure that change stuff always has proper permissions
This commit is contained in:
parent
21eb7358f2
commit
e600c3cb47
2 changed files with 16 additions and 3 deletions
15
ponysay.py
15
ponysay.py
|
@ -804,10 +804,13 @@ class Ponysay():
|
||||||
|
|
||||||
## Get and in necessary make cache directory
|
## Get and in necessary make cache directory
|
||||||
cachedir = '/var/cache/ponysay'
|
cachedir = '/var/cache/ponysay'
|
||||||
|
shared = True
|
||||||
if not os.path.isdir(cachedir):
|
if not os.path.isdir(cachedir):
|
||||||
cachedir = HOME + '/.cache/ponysay'
|
cachedir = HOME + '/.cache/ponysay'
|
||||||
|
shared = False
|
||||||
if not os.path.isdir(cachedir):
|
if not os.path.isdir(cachedir):
|
||||||
os.makedirs(cachedir)
|
os.makedirs(cachedir)
|
||||||
|
_cachedir = '\'' + cachedir.replace('\'', '\'\\\'\'') + '\''
|
||||||
|
|
||||||
## KMS support version control, clean everything if not matching
|
## KMS support version control, clean everything if not matching
|
||||||
newversion = False
|
newversion = False
|
||||||
|
@ -815,7 +818,7 @@ class Ponysay():
|
||||||
newversion = True
|
newversion = True
|
||||||
else:
|
else:
|
||||||
with open(cachedir + '/.version', 'rb') as cachev:
|
with open(cachedir + '/.version', 'rb') as cachev:
|
||||||
if cachev.read().decode('utf8', 'replace').replace('\n', '') == KMS_VERSION:
|
if cachev.read().decode('utf8', 'replace').replace('\n', '') != KMS_VERSION:
|
||||||
newversion = True
|
newversion = True
|
||||||
if newversion:
|
if newversion:
|
||||||
for cached in os.listdir(cachedir):
|
for cached in os.listdir(cachedir):
|
||||||
|
@ -826,6 +829,8 @@ class Ponysay():
|
||||||
os.remove(cached)
|
os.remove(cached)
|
||||||
with open(cachedir + '/.version', 'w+') as cachev:
|
with open(cachedir + '/.version', 'w+') as cachev:
|
||||||
cachev.write(KMS_VERSION)
|
cachev.write(KMS_VERSION)
|
||||||
|
if shared:
|
||||||
|
Popen('chmod 666 -- ' + _cachedir + '/.version', shell=True).wait()
|
||||||
|
|
||||||
## Get kmspony directory and kmspony file
|
## Get kmspony directory and kmspony file
|
||||||
kmsponies = cachedir + '/kmsponies/' + palettefile
|
kmsponies = cachedir + '/kmsponies/' + palettefile
|
||||||
|
@ -848,16 +853,24 @@ class Ponysay():
|
||||||
if not os.path.isfile(protokmspony):
|
if not os.path.isfile(protokmspony):
|
||||||
if not os.path.isdir(protokmsponydir):
|
if not os.path.isdir(protokmsponydir):
|
||||||
os.makedirs(protokmsponydir)
|
os.makedirs(protokmsponydir)
|
||||||
|
if shared:
|
||||||
|
Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
|
||||||
if not os.system('ponysay2ttyponysay < ' + _pony + ' > ' + _protokmspony) == 0:
|
if not os.system('ponysay2ttyponysay < ' + _pony + ' > ' + _protokmspony) == 0:
|
||||||
sys.stderr.write('Unable to run ponysay2ttyponysay successfully, you need util-say for KMS support\n')
|
sys.stderr.write('Unable to run ponysay2ttyponysay successfully, you need util-say for KMS support\n')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
if shared:
|
||||||
|
Popen('chmod 666 -- ' + _protokmspony, shell=True).wait()
|
||||||
|
|
||||||
## Create kmspony
|
## Create kmspony
|
||||||
if not os.path.isdir(kmsponydir):
|
if not os.path.isdir(kmsponydir):
|
||||||
os.makedirs(kmsponydir)
|
os.makedirs(kmsponydir)
|
||||||
|
if shared:
|
||||||
|
Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
|
||||||
if not os.system('tty2colourfultty -p ' + palette + ' < ' + _protokmspony + ' > ' + _kmspony) == 0:
|
if not os.system('tty2colourfultty -p ' + palette + ' < ' + _protokmspony + ' > ' + _kmspony) == 0:
|
||||||
sys.stderr.write('Unable to run tty2colourfultty successfully, you need util-say for KMS support\n')
|
sys.stderr.write('Unable to run tty2colourfultty successfully, you need util-say for KMS support\n')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
if shared:
|
||||||
|
Popen('chmod 666 -- ' + _kmspony, shell=True).wait()
|
||||||
|
|
||||||
return kmspony
|
return kmspony
|
||||||
|
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -505,9 +505,9 @@ class Setup():
|
||||||
print('Creating directory ' + dir)
|
print('Creating directory ' + dir)
|
||||||
os.mkdir(dir)
|
os.mkdir(dir)
|
||||||
print('Setting permission mode mask for ' + dir + ' to 6777')
|
print('Setting permission mode mask for ' + dir + ' to 6777')
|
||||||
Popen('chmod -R 6777 -- ' + dir, shell=True).wait()
|
Popen('chmod -R 6777 -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait()
|
||||||
print('Setting group for ' + dir + ' users')
|
print('Setting group for ' + dir + ' users')
|
||||||
Popen('chown -R :users -- ' + dir, shell=True).wait()
|
Popen('chown -R :users -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait()
|
||||||
for shell in [item[0] for item in shells]:
|
for shell in [item[0] for item in shells]:
|
||||||
if conf[shell] is not None:
|
if conf[shell] is not None:
|
||||||
for command in commands:
|
for command in commands:
|
||||||
|
|
Loading…
Reference in a new issue