[GH-ISSUE #734] Feature Request: Add env var options ARCHIVEBOX_USERNAME and ARCHIVEBOX_PASSWORD to initialize admin user on first run without prompting #465

Closed
opened 2026-03-01 14:43:49 +03:00 by kerem · 12 comments
Owner

Originally created by @marco10x15 on GitHub (May 2, 2021).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/734

I have succesfully deploied via docker using portainer a container on my Synology NAS.
I can access the web gui but i haven't found in the documentation the Admin Password to be used to acces.
How can I find the password or what ENV variable I must set up?
Thank.
Marco.

Originally created by @marco10x15 on GitHub (May 2, 2021). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/734 I have succesfully deploied via docker using portainer a container on my Synology NAS. I can access the web gui but i haven't found in the documentation the Admin Password to be used to acces. How can I find the password or what ENV variable I must set up? Thank. Marco.
Author
Owner

@pirate commented on GitHub (May 3, 2021):

Right now you have to run archivebox init --setup or archivebox manage createsuperuser using the CLI (it prompts you to choose the admin username and password during initial setup).

I'll add some env vars to initialize the admin user without having to run that command ^ in the next version.

Screenshot of creating archivebox superuser via docker terminal in Synology NAS admin
<!-- gh-comment-id:831588497 --> @pirate commented on GitHub (May 3, 2021): Right now you have to run `archivebox init --setup` or `archivebox manage createsuperuser` using the CLI (it prompts you to choose the admin username and password during initial setup). I'll add some env vars to initialize the admin user without having to run that command ^ in the next version. <img src="https://user-images.githubusercontent.com/3637842/186575300-4f6ea0ee-242b-4ca4-998c-c5108acb97d0.png" alt="Screenshot of creating archivebox superuser via docker terminal in Synology NAS admin" width="400px"/>
Author
Owner

@mhfowler commented on GitHub (Aug 17, 2021):

I'm currently working on creating a yunohost package for archivebox, and this feature will also be needed for that.

Or some other way, which I can supply an initial admin and password for archivebox during setup (perhaps as CLI arguments?), without an interactive prompt with the user (since the app is installed via a GUI, without a user directly interacting with the terminal)

<!-- gh-comment-id:900297494 --> @mhfowler commented on GitHub (Aug 17, 2021): I'm currently working on creating a [yunohost package](https://yunohost.org/en) for archivebox, and this feature will also be needed for that. Or some other way, which I can supply an initial admin and password for archivebox during setup (perhaps as CLI arguments?), without an interactive prompt with the user (since the app is installed via a GUI, without a user directly interacting with the terminal)
Author
Owner

@mhfowler commented on GitHub (Aug 18, 2021):

for now I was able to achieve what I needed using expect, but having CLI args for archivebox would probably be cleaner. e.g.

/usr/bin/expect<<EOF
set timeout -1
spawn sh -c "cd $datadir && archivebox manage createsuperuser --username $admin --email $admin_mail"
match_max 100000
expect "*?assword: "
send -- "$password\r"
expect "*?assword (again): "
send -- "$password\r"
expect eof
EOF
<!-- gh-comment-id:900946203 --> @mhfowler commented on GitHub (Aug 18, 2021): for now I was able to achieve what I needed using expect, but having CLI args for archivebox would probably be cleaner. e.g. ``` /usr/bin/expect<<EOF set timeout -1 spawn sh -c "cd $datadir && archivebox manage createsuperuser --username $admin --email $admin_mail" match_max 100000 expect "*?assword: " send -- "$password\r" expect "*?assword (again): " send -- "$password\r" expect eof EOF ```
Author
Owner

@mhfowler commented on GitHub (Oct 20, 2021):

I've still been running into some bugs with this from users,
for example "install fails with password similar to username"
and "install fails if password contains $ signs"

I could make the expect script more complicated to handle these cases, but actually the best solution would still be if there was ARCHIVEBOX_USERNAME and ARCHIVEBOX_PASSWORD env vars, so I could not use expect at all

<!-- gh-comment-id:947398584 --> @mhfowler commented on GitHub (Oct 20, 2021): I've still been running into some bugs with this from users, for example ["install fails with password similar to username"](https://github.com/YunoHost-Apps/archivebox_ynh/issues/13) and "install fails if password contains $ signs" I could make the expect script more complicated to handle these cases, but actually the best solution would still be if there was ARCHIVEBOX_USERNAME and ARCHIVEBOX_PASSWORD env vars, so I could not use expect at all
Author
Owner

@pirate commented on GitHub (Oct 20, 2021):

Those are the default Django password validators kicking in (see settings.py) to try and keep people safe, I suppose we can disable them with another env var or specifically in the case that the pass is loaded via env vars.

<!-- gh-comment-id:948097067 --> @pirate commented on GitHub (Oct 20, 2021): Those are the default Django password validators kicking in (see settings.py) to try and keep people safe, I suppose we can disable them with another env var or specifically in the case that the pass is loaded via env vars.
Author
Owner

@mhfowler commented on GitHub (Oct 21, 2021):

ah interesting. yes I'm having trouble imagining how to pass these validator warnings back to the user, given its non-interactive, so to disable these warnings in the case that a pass is loaded via env vars sounds like a good option to me if possible

<!-- gh-comment-id:948449541 --> @mhfowler commented on GitHub (Oct 21, 2021): ah interesting. yes I'm having trouble imagining how to pass these validator warnings back to the user, given its non-interactive, so to disable these warnings in the case that a pass is loaded via env vars sounds like a good option to me if possible
Author
Owner

@solarchemist commented on GitHub (Jan 19, 2022):

This would be good for Ansible also.

I tried using the expect plugin (which has worked for me before when no other options were available), and it actually worked, but only during the first run of the playbook:

- name: Create Archivebox superuser account
  ansible.builtin.expect:
    command: archivebox manage createsuperuser
    timeout: 10
    responses:
      'Username': "{{ archivebox_admin.user }}"
      'Email address': "{{ archivebox_admin.email }}"
      'Password': "{{ archivebox_admin.pwd }}"
      'Password (again)': "{{ archivebox_admin.pwd }}"
  become: true
  become_user: "{{ ansible_env.USER }}"
  args:
    chdir: "{{ archivebox_pwd }}"

For some reason beyond my understanding, subsequent runs of this task would just freeze indefinitely (this is not a request for support, just noting the weird behaviour and moving on).

Anyway, so that's another reason why it would be great to be able to set the admin user non-interactively. The expect command can be rather fragile at times.

<!-- gh-comment-id:1016956474 --> @solarchemist commented on GitHub (Jan 19, 2022): This would be good for Ansible also. I tried using the expect plugin (which has worked for me before when no other options were available), and it actually worked, but only during the first run of the playbook: ``` - name: Create Archivebox superuser account ansible.builtin.expect: command: archivebox manage createsuperuser timeout: 10 responses: 'Username': "{{ archivebox_admin.user }}" 'Email address': "{{ archivebox_admin.email }}" 'Password': "{{ archivebox_admin.pwd }}" 'Password (again)': "{{ archivebox_admin.pwd }}" become: true become_user: "{{ ansible_env.USER }}" args: chdir: "{{ archivebox_pwd }}" ``` For some reason beyond my understanding, subsequent runs of this task would just freeze indefinitely (this is not a request for support, just noting the weird behaviour and moving on). Anyway, so that's another reason why it would be great to be able to set the admin user non-interactively. The expect command can be rather fragile at times.
Author
Owner

@pirate commented on GitHub (Jan 22, 2022):

Note that you can also insert a USER row directly into the index.sqlite3 db as a temporary hack (instead of using expect). (see here for instructions: https://github.com/ArchiveBox/ArchiveBox/issues/928#issuecomment-1075758078 and https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives#modify-the-archivebox-sqlite3-db-directly)

<!-- gh-comment-id:1019365563 --> @pirate commented on GitHub (Jan 22, 2022): Note that you can also insert a USER row directly into the `index.sqlite3` db as a temporary hack (instead of using expect). (see here for instructions: https://github.com/ArchiveBox/ArchiveBox/issues/928#issuecomment-1075758078 and https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives#modify-the-archivebox-sqlite3-db-directly)
Author
Owner

@solarchemist commented on GitHub (Jan 23, 2022):

Thanks for the suggestion! If I get the time, I'll look into doing that.

PS. I just pushed the Ansible role I used to install ArchiveBox to Codeberg. The role is quite tailored to my needs, but the more Ansible roles, the merrier, right? :-)

<!-- gh-comment-id:1019573582 --> @solarchemist commented on GitHub (Jan 23, 2022): Thanks for the suggestion! If I get the time, I'll look into doing that. PS. I just pushed [the Ansible role I used to install ArchiveBox to Codeberg](https://codeberg.org/ansible/archivebox). The role is quite tailored to my needs, but the more Ansible roles, the merrier, right? :-)
Author
Owner

@pirate commented on GitHub (Mar 22, 2022):

For people here looking for a temporary solution, I posted instructions on how to insert a User row directly into the SQLite3 DB here: https://github.com/ArchiveBox/ArchiveBox/issues/928#issuecomment-1075758078 and here https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives#modify-the-archivebox-sqlite3-db-directly.

<!-- gh-comment-id:1075759957 --> @pirate commented on GitHub (Mar 22, 2022): For people here looking for a temporary solution, I posted instructions on how to insert a User row directly into the SQLite3 DB here: https://github.com/ArchiveBox/ArchiveBox/issues/928#issuecomment-1075758078 and here https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives#modify-the-archivebox-sqlite3-db-directly.
Author
Owner

@Nezteb commented on GitHub (Mar 30, 2023):

Chiming in to say that I'd love this feature. The SQLite workaround is cool but I'd rather not mess with that in case the implementation eventually changes.

I'm deploying to https://fly.io/ and for most services I host there, I just need a single Dockerfile and a fly.toml without ever needing to start a remote shell to run a startup/config command.

<!-- gh-comment-id:1491047105 --> @Nezteb commented on GitHub (Mar 30, 2023): Chiming in to say that I'd love this feature. The SQLite workaround is cool but I'd rather not mess with that in case the implementation eventually changes. I'm deploying to https://fly.io/ and for most services I host there, I just need a single `Dockerfile` and a `fly.toml` without ever needing to start a remote shell to run a startup/config command.
Author
Owner

@pirate commented on GitHub (Oct 18, 2023):

This is done and merged into dev, thanks @benmuth!

I'll update the docs to reflect the new feature. For anyone that wants to use this immediately you can run the dev branch like so: https://github.com/ArchiveBox/ArchiveBox#install-and-run-a-specific-github-branch

<!-- gh-comment-id:1769133096 --> @pirate commented on GitHub (Oct 18, 2023): This is done and merged into `dev`, thanks @benmuth! I'll update the docs to reflect the new feature. For anyone that wants to use this immediately you can run the `dev` branch like so: https://github.com/ArchiveBox/ArchiveBox#install-and-run-a-specific-github-branch
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#465
No description provided.