mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-09 17:39:31 +00:00
Fixed SSH configuration write issues
This commit is contained in:
parent
4604bcb666
commit
1386c24692
162
main.py
162
main.py
|
@ -168,11 +168,13 @@ def enableSSH():
|
||||||
|
|
||||||
readWriteFileDescriptor = open("/etc/nixos/configuration.nix", "wt")
|
readWriteFileDescriptor = open("/etc/nixos/configuration.nix", "wt")
|
||||||
|
|
||||||
writeOperationStatus = readWriteFileDescriptor.write(fileContent)
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
readWriteFileDescriptor.close()
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=writeOperationStatus
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Bitwarden
|
# Bitwarden
|
||||||
|
@ -181,66 +183,88 @@ def enableSSH():
|
||||||
|
|
||||||
def enableBitwarden():
|
def enableBitwarden():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = false;", "enable = true;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = false;", "enable = true;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/bitwarden/disable", methods=["POST"])
|
@app.route("/services/bitwarden/disable", methods=["POST"])
|
||||||
|
|
||||||
def disableBitwarden():
|
def disableBitwarden():
|
||||||
|
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = true;", "enable = false;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/passmgr/bitwarden.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#Gitea
|
#Gitea
|
||||||
|
|
||||||
@app.route("/services/gitea/disable", methods=["POST"])
|
@app.route("/services/gitea/disable", methods=["POST"])
|
||||||
|
|
||||||
def disableGitea():
|
def disableGitea():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/git/gitea.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/git/gitea.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/git/gitea.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = true;", "enable = false;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/git/gitea.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/gitea/enable", methods=["POST"])
|
@app.route("/services/gitea/enable", methods=["POST"])
|
||||||
|
|
||||||
def enableGitea():
|
def enableGitea():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/git/gitea.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/git/gitea.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/git/gitea.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = false;", "enable = true;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = false;", "enable = true;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/git/gitea.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
#Nextcloud
|
#Nextcloud
|
||||||
|
@ -248,33 +272,43 @@ def enableGitea():
|
||||||
@app.route("/services/nextcloud/disable", methods=["POST"])
|
@app.route("/services/nextcloud/disable", methods=["POST"])
|
||||||
|
|
||||||
def disableNextcloud():
|
def disableNextcloud():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/nextcloud/nextcloud.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/cloud/nextcloud.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/nextcloud/nextcloud.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = true;", "enable = false;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/cloud/nextcloud.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/nextcloud/enable", methods=["POST"])
|
@app.route("/services/nextcloud/enable", methods=["POST"])
|
||||||
|
|
||||||
def enableNextcloud():
|
def enableNextcloud():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/nextcloud/nextcloud.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/cloud/nextcloud.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/nextcloud/nextcloud.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = false;", "enable = true;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = false;", "enable = true;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/cloud/nextcloud.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
#Pleroma
|
#Pleroma
|
||||||
|
@ -283,32 +317,42 @@ def enableNextcloud():
|
||||||
|
|
||||||
def disablePleroma():
|
def disablePleroma():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/social/pleroma.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/social/pleroma.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/social/pleroma.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = true;", "enable = false;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/social/pleroma.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/pleroma/enable", methods=["POST"])
|
@app.route("/services/pleroma/enable", methods=["POST"])
|
||||||
|
|
||||||
def enablePleroma():
|
def enablePleroma():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/social/pleroma.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/social/pleroma.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/social/pleroma.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = false;", "enable = true;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = false;", "enable = true;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/social/pleroma.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
#Ocserv
|
#Ocserv
|
||||||
|
@ -317,32 +361,42 @@ def enablePleroma():
|
||||||
|
|
||||||
def disableOcserv():
|
def disableOcserv():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = true;", "enable = false;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/ocserv/enable", methods=["POST"])
|
@app.route("/services/ocserv/enable", methods=["POST"])
|
||||||
|
|
||||||
def enableOcserv():
|
def enableOcserv():
|
||||||
readOnlyFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "rt")
|
readOnlyFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "rt")
|
||||||
readWriteFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "wt")
|
|
||||||
|
|
||||||
for line in readOnlyFileDescriptor:
|
|
||||||
readWriteFileDescriptor.write(line.replace("enable = false;", "enable = true;"))
|
|
||||||
|
|
||||||
readWriteFileDescriptor.close()
|
fileContent = readOnlyFileDescriptor.read()
|
||||||
|
|
||||||
|
fileContent = fileContent.replace("enable = true;", "enable = false;")
|
||||||
readOnlyFileDescriptor.close()
|
readOnlyFileDescriptor.close()
|
||||||
|
|
||||||
|
readWriteFileDescriptor = open("/etc/nixos/vpn/ocserv.nix", "wt")
|
||||||
|
|
||||||
|
writeOperationDescriptor = readWriteFileDescriptor.write(fileContent)
|
||||||
|
readWriteFileDescriptor.close()
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
status=0
|
status=0,
|
||||||
|
descriptor=writeOperationDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/services/ssh/key/send", methods=["PUT"])
|
@app.route("/services/ssh/key/send", methods=["PUT"])
|
||||||
|
|
Loading…
Reference in a new issue