-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple script to force admin and judgehost passwords.
This will read from restapi.secret and initial_admin_password.secret and reset the DB state to match these passwords. This can be especially useful if you are importing a database from a previous contest and do not want to do update passwords manually.
- Loading branch information
Showing
3 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/dj_make_chroot_docker | ||
/dj_run_chroot | ||
/dj_judgehost_cleanup | ||
/force-passwords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/python3 | ||
|
||
import subprocess | ||
|
||
webappdir = '@domserver_webappdir@' | ||
etcdir = '@domserver_etcdir@' | ||
|
||
with open(f'{etcdir}/restapi.secret', 'r') as f: | ||
while True: | ||
line = f.readline() | ||
if line.startswith('#'): | ||
continue | ||
tokens = line.split() | ||
if len(tokens) == 4 and tokens[0] == 'default': | ||
user = tokens[2] | ||
password = tokens[3] | ||
subprocess.run([webappdir + '/bin/console', 'domjudge:reset-user-password', user, password]) | ||
break | ||
|
||
with open(f'{etcdir}/initial_admin_password.secret', 'r') as f: | ||
password = f.readline().strip() | ||
subprocess.run([webappdir + '/bin/console', 'domjudge:reset-user-password', 'admin', password]) |