[Dockerapi] Fixes recent chang in exec_run return
parent
a50036477e
commit
e3854a8037
|
@ -2,7 +2,7 @@ FROM python:2-alpine
|
||||||
LABEL maintainer "Andre Peters <andre.peters@servercow.de>"
|
LABEL maintainer "Andre Peters <andre.peters@servercow.de>"
|
||||||
|
|
||||||
RUN apk add -U --no-cache iptables ip6tables
|
RUN apk add -U --no-cache iptables ip6tables
|
||||||
RUN pip install docker flask flask-restful
|
RUN pip install docker==3.0.1 flask flask-restful
|
||||||
|
|
||||||
COPY server.py /
|
COPY server.py /
|
||||||
CMD ["python2", "-u", "/server.py"]
|
CMD ["python2", "-u", "/server.py"]
|
||||||
|
|
|
@ -83,11 +83,15 @@ class container_post(Resource):
|
||||||
try:
|
try:
|
||||||
for container in docker_client.containers.list(filters={"id": container_id}):
|
for container in docker_client.containers.list(filters={"id": container_id}):
|
||||||
hash = container.exec_run(["/bin/bash", "-c", "/usr/bin/rspamadm pw -e -p '" + request.json['raw'].replace("'", "'\\''") + "' 2> /dev/null"], user='_rspamd')
|
hash = container.exec_run(["/bin/bash", "-c", "/usr/bin/rspamadm pw -e -p '" + request.json['raw'].replace("'", "'\\''") + "' 2> /dev/null"], user='_rspamd')
|
||||||
f = open("/access.inc", "w")
|
if hash.exit_code == 0:
|
||||||
f.write('enable_password = "' + re.sub('[^0-9a-zA-Z\$]+', '', hash.rstrip()) + '";\n')
|
hash = str(hash.output)
|
||||||
f.close()
|
f = open("/access.inc", "w")
|
||||||
container.restart()
|
f.write('enable_password = "' + re.sub('[^0-9a-zA-Z\$]+', '', hash.rstrip()) + '";\n')
|
||||||
return jsonify(type='success', msg='command completed successfully')
|
f.close()
|
||||||
|
container.restart()
|
||||||
|
return jsonify(type='success', msg='command completed successfully')
|
||||||
|
else:
|
||||||
|
return jsonify(type='danger', msg='command did not complete, exit code was ' + int(hash.exit_code))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify(type='danger', msg=str(e))
|
return jsonify(type='danger', msg=str(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue