mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Do permissions changes in a nicer way for sed_i.
This commit is contained in:
parent
638319217b
commit
d716baadfb
2 changed files with 3 additions and 5 deletions
|
@ -50,10 +50,13 @@ def sed_i(file_path, pattern, subst):
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from os import close
|
from os import close
|
||||||
|
import os
|
||||||
temp_fd, temp_path = mkstemp()
|
temp_fd, temp_path = mkstemp()
|
||||||
|
mode = os.stat(file_path).st_mode
|
||||||
with open(temp_path, 'w') as new_file:
|
with open(temp_path, 'w') as new_file:
|
||||||
with open(file_path) as old_file:
|
with open(file_path) as old_file:
|
||||||
for line in old_file:
|
for line in old_file:
|
||||||
new_file.write(line.replace(pattern, subst))
|
new_file.write(line.replace(pattern, subst))
|
||||||
close(temp_fd)
|
close(temp_fd)
|
||||||
|
os.chmod(temp_path, mode)
|
||||||
move(temp_path, file_path)
|
move(temp_path, file_path)
|
||||||
|
|
|
@ -52,11 +52,6 @@ class AdminUserCredentials(Task):
|
||||||
getcreds_path = os.path.join(info.root, 'etc/init.d/ec2-get-credentials')
|
getcreds_path = os.path.join(info.root, 'etc/init.d/ec2-get-credentials')
|
||||||
username = info.manifest.plugins['admin_user']['username']
|
username = info.manifest.plugins['admin_user']['username']
|
||||||
sed_i(getcreds_path, 'username=\'root\'', 'username=\'{username}\''.format(username=username))
|
sed_i(getcreds_path, 'username=\'root\'', 'username=\'{username}\''.format(username=username))
|
||||||
import stat
|
|
||||||
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
|
||||||
stat.S_IRGRP | stat.S_IXGRP |
|
|
||||||
stat.S_IROTH | stat.S_IXOTH)
|
|
||||||
os.chmod(getcreds_path, rwxr_xr_x)
|
|
||||||
|
|
||||||
|
|
||||||
class DisableRootLogin(Task):
|
class DisableRootLogin(Task):
|
||||||
|
|
Loading…
Add table
Reference in a new issue