Back

Bash Script to rebuild dotCMS index

  • Created: Jun 09, 2020

Description

This is a down and dirty bash script that calls a full Reindex in dotCMS. This really should be available as a restful endpoint in dotCMS but until dotCMS has that, this code can stand in.

Code

#!/bin/sh

SITE="http://localhost:8080"

## get the auth cookie
curl -c cookiestore -H  "Content-Type:application/json" -s  -X POST -d  '{ "user":"admin@dotcms.com", "password":"admin", "expirationDays": 10000 }' $SITE/api/v1/authentication/api-token


curl -v -L -b cookiestore \
-d "cmd=cache" \
-d "defaultStructure=Rebuild Whole Index" \
-d "shards=1" \
-d "cacheName=CACHE_CONTENTS_INDEX" \
-d "p_p_id=maintenance" \
-d "p_p_mode=view" \
-d "p_p_state=maximized" \
-d "p_p_action=1" \
-d "_maintenance_struts_action=/ext/cmsmaintenance/view_cms_maintenance" \
-d "_maintenance_cmd=cache" \
-H "referer:$SITE/c/portal/layout" \
-XPOST "$SITE/c/portal/layout"

rm cookiestore    

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor