Skip to content

Instantly share code, notes, and snippets.

tml /
Created Jul 15, 2019 — forked from andrewmkhoury/
Migrating AEM Users, Groups and ACLs between instances
  1. Migrate users and groups (If users were not imported automatically via LDAP) Package users and groups (2 separate packages) on the old system (excluding admin and anonymous OOTB users)
    1. Go to CRXDE lite app /crx/de/index.jsp and log in as admin user (on the old system)
    2. Go to "Tools" => "Query"
    3. In the bottom "Query" box enter this query to find the admin user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="admin"]
    4. Click "Execute" and copy the path of the admin user node in the results to a text file
    5. Repeat step 3 with a query for anonymous user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="anonymous"]
    6. Click "Execute" and copy the path of the anonymous user node in the results to a text file (so now you should have two paths, one for "admin" and one for "anonymous")
tml /
Created Jul 15, 2019 — forked from andrewmkhoury/
oak-run Groovy script to reset the Adobe AEM "admin" user password

To run this script:

  1. Download the oak-run version matching the version of Oak installed in AEM:
  2. Download the attached adminUtils.groovy script
  3. Upload the adminUtils.groovy script and the oak-run jar to your AEM server
  4. Run the command to start the oak-run console. For example:
    java -Xmx2048m -jar /tmp/oak-run-1.6.1.jar console /app/aem/aem63/crx-quickstart/repository/segmentstore --read-write
  5. Once the oak-run console is open then load the groovy script using this command:
tml / 1 Instructions - Find Oak
Created Jul 15, 2019 — forked from andrewmkhoury/1 Instructions - Find Oak
Oak count node check in script console - use while AEM / Oak is running
View 1 Instructions - Find Oak
  1. Go to http://host:port/system/console/bundles and install these two bundles
  2. Go to http://host/system/console/configMgr/
  3. Add org.apache.felix.webconsole.plugins.scriptconsole to "Whitelist regexp" and save
  4. After the two bundles fully install then go to http://host:port/system/console/sc
  5. Select "Groovy" as the language
  6. Copy/Paste the contents of countNodes-*.groovy script below which matches your oak version to the script console
  7. Click "Execute"
  8. Don't close the browser, the output is displayed in the console UI
View 1-Oak SegmentNotFoundException repair

The objective here is to find all SegmentNotFoundException type corruption and remove it (as we don't have a valid backup)

Before running any of the below steps we created an index.json file (see the file below) which contains only the index definitions of the corrupted indexes.

  1. This generates the file indexing-results\index-definities.json
java -Xmx8g -jar oak-run-1.8.12.jar index --fds-path=crx-quickstart\repository\datastore crx-quickstart\repository\segmentstore --index-definitions
  1. From that file we copied only the definitions we needed and created index.json (file attached here )
View gist:e467515f8814fdc59de7511e836205ae
# Contributor: Joey Smith <>
# Maintainer:
pkgdesc="FLIF is a lossless image format which outperforms PNG, lossless WebP, lossless BPG, lossless JPEG2000, and lossless JPEG XR."
tml / checkBlobs.groovy
Last active Feb 5, 2019
View checkBlobs.groovy
import ch.qos.logback.classic.Level
import org.apache.jackrabbit.oak.api.Blob
import org.apache.jackrabbit.oak.api.PropertyState
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.commons.PathUtils
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeState
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils
import org.apache.jackrabbit.oak.spi.state.NodeStore
View gist:5fac802de028b8e8024ebf95902b9951
root@ip-172-31-19-81:~# cat >> .bash_profile <<EOT
> echo "I ran the .bash_profile for root"
root@ip-172-31-19-81:~# logout
(main) 23:33:16 [ joey@ip-172-31-19-81:0 ] ~ 2126 -->sudo -s
23:33:20 [ root@ip-172-31-19-81:0 ] ~ 494 -->exit
(main) 23:33:21 [ joey@ip-172-31-19-81:0 ] ~ 2127 -->sudo -i
I ran the .bash_profile for root
View path-debugger.php
$path = '';
foreach(array_filter(explode('/', '/var/run/memcached/memcached.socket')) as $p) {
$path .= '/'.$p;
if (file_exists($path)) {
echo "{ '$path' : ", json_encode(stat($path)), "} \n";
} else {
echo "PHP cannot see $path.\n";
def u_filter(func, iterable):
if f is None:
return (item for item in iterable if item)
return (item for item in iterable if func(item))
View gist:fb4b8ac960f66eddbb12dd97d2626402