Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit 03df88a

Browse files
author
Zhen
committed
Make neorun to change default neo4j password to neo4j
If the new password is `neo4j`, then first change the default to something else and then change it back
1 parent 60cac05 commit 03df88a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

neoctl.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ def main():
6464
elif opt == "--stop":
6565
exit_code = neo4j_stop(neo4j_home=arg) or 0
6666
elif opt == "--update-password":
67-
new_password = arg
68-
if new_password == 'neo4j':
69-
exit_code = neo4j_update_password("localhost", 7474, "neo4j", "neo4j", "1234") or neo4j_update_password("localhost", 7474, "neo4j", "1234", "neo4j") or 0
70-
else:
71-
exit_code = neo4j_update_password("localhost", 7474, "neo4j", "neo4j", new_password) or 0
67+
exit_code = neo4j_update_default_password("localhost", 7474, new_password=arg) or 0
7268
else:
7369
print("Bad option %s" % opt)
7470
exit_code = 1
@@ -91,6 +87,16 @@ def neo4j_stop(neo4j_home):
9187
return call([neo4j_home+"/bin/neo4j", "stop"])
9288

9389

90+
def neo4j_update_default_password(host, http_port, new_password):
91+
exit_code = 0
92+
if new_password == 'neo4j':
93+
exit_code = neo4j_update_password(host, http_port, "neo4j", "neo4j", "1234") \
94+
or neo4j_update_password(host, http_port, "neo4j", "1234", "neo4j")
95+
else:
96+
exit_code = neo4j_update_password(host, http_port, "neo4j", "neo4j", new_password)
97+
return exit_code
98+
99+
94100
def neo4j_update_password(host, http_port, user, password, new_password):
95101
request = Request("http://%s:%s/user/neo4j/password" % (host, http_port),
96102
json_dumps({"password": new_password}, ensure_ascii=True).encode("utf-8"),
@@ -118,4 +124,4 @@ def print_help():
118124
print(__doc__)
119125

120126
if __name__ == "__main__":
121-
main()
127+
main()

neorun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import getopt
3939
from sys import argv, stdout, exit
4040
from neoget import neo4j_default_archive, neo4j_archive, download
41-
from neoctl import neo4j_start, neo4j_stop, neo4j_update_password
41+
from neoctl import neo4j_start, neo4j_stop, neo4j_update_default_password
4242
from os import path, rename
4343
import socket
4444
from time import time, sleep
@@ -88,7 +88,7 @@ def main():
8888

8989
exit_code = handle_start(archive_url, archive_name, neo4j_home=arg)
9090
if exit_code == 0 and password is not '':
91-
exit_code = neo4j_update_password("localhost", 7474, "neo4j", "neo4j", new_password=start_arg) or 0
91+
exit_code = neo4j_update_default_password("localhost", 7474, new_password=start_arg) or 0
9292

9393
elif opt == "--stop":
9494
if neo4j_status() == ServerStatus.STOPPED:

0 commit comments

Comments
 (0)