fix sudo file exists

This commit is contained in:
Christian Rotzoll
2019-04-02 03:22:00 +01:00
parent 6d16b9f5e7
commit b2d9ef8161

View File

@@ -87,7 +87,7 @@ if sys.argv[1] == "on":
# generate custom service config # generate custom service config
service_data = SERVICETEMPLATE.replace("[PLACEHOLDER]", additional_parameters) service_data = SERVICETEMPLATE.replace("[PLACEHOLDER]", additional_parameters)
# DEBUG exit # debug print out service
print() print()
print("*** New systemd service: %s" % (SERVICENAME)) print("*** New systemd service: %s" % (SERVICENAME))
print(service_data) print(service_data)
@@ -101,7 +101,9 @@ if sys.argv[1] == "on":
# check if SSH keys for root user need to be created # check if SSH keys for root user need to be created
print() print()
print("*** Checking root SSH keys") print("*** Checking root SSH keys")
if Path("/root/.ssh/id_rsa.pub").exists() == False: sshkeys_exist = subprocess.check_output("sudo ls /root/.ssh/id_rsa.pub | grep -c 'id_rsa.pub'", shell=True, universal_newlines=True)
print(sshkeys_exist)
if str(sshkeys_exist).count("1") == 0:
print("Generating root SSH keys ...") print("Generating root SSH keys ...")
subprocess.call("sudo -u root ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N \"\"", shell=True) subprocess.call("sudo -u root ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N \"\"", shell=True)
print("DONE") print("DONE")