Commands
Usefull commands for bookstack container using php artisan.
folder where php artisan can execute isn't at the same place for the vanilla or linux server version ! (can cause "Could not open input file: artisan" error)
Bookstack vanilla : /var/www/html
Linux server version : /app/www
Create an Admin User
Create a new admin user via the command line. Can offer a good last resort if you ever get locked out the system. Will use the details provided as options otherwise will request them interactively.
# Interactive usage
php artisan bookstack:create-admin
# Non-interactive usage example
php artisan bookstack:create-admin --email="barry@example.com" --name="Bazza" --password="hunter2"
# Defining "External Authentication ID" instead of password for LDAP/SAML2/OIDC environments
php artisan bookstack:create-admin --email="barry.booker@example.com" --name="Bazza" --external-auth-id="bbooker"
Copy Shelf Permission
By default shelf permissions will not auto-cascade since a book can be in many shelves. This command will copy the permissions of a shelf to all child books. This can be done for a single shelf or for all shelves in the system:
# Run for all shelves
php artisan bookstack:copy-shelf-permissions --all
# Run for a single shelf
php artisan bookstack:copy-shelf-permissions --slug=my_shelf_slug
Update System URL
BookStack will store absolute URL paths for some content, such as images, in the database. If you change your base URL for BookStack this can be problematic. This command will essentially run a find & replace operation on all relevant tables in the database. Be sure to take a database backup for running this command.
# Searches for <oldUrl> and replaces it with <newUrl>
php artisan bookstack:update-url <oldUrl> <newUrl>
# Example:
php artisan bookstack:update-url http://docs.example.com https://demo.bookstackapp.com
Reset User MFA Methods
This will reset/clear any existing multi-factor-authentication methods for the given user. If MFA is enforced for one of their roles they’ll be prompted to reconfigure MFA upon next login.
# Via email address:
php artisan bookstack:reset-mfa --email=john@example.com
# Via system ID:
php artisan bookstack:reset-mfa --id=5
Regenerate Access Permissions
BookStack pre-calculates and stores certain access permissions in the database so that access can be calculated in a performant manner. The below command will regenerate these permissions. This is primarily used in development but can be useful if manually adding content via the database.
php artisan bookstack:regenerate-permissions
Sources
- Create an Admin User
- Copy Shelf Permission
- Update System URL
- Reset User MFA Methods
- Delete All Activity History
- Delete Page Revisions
- Delete Page Views
- Cleanup Unused Images
- Regenerate the Search Index
- Regenerate Access Permissions
- Regenerate Reference Index
- Regenerate Comment Content
- Delete Users
- Generate UTF8mb4 SQL Upgrade Commands