Skip to content

Instantly share code, notes, and snippets.

@knennigtri
Last active April 28, 2017 05:23
Show Gist options
  • Save knennigtri/f6fd1195ddf4a29c5cb1e90b22b6faa7 to your computer and use it in GitHub Desktop.
Save knennigtri/f6fd1195ddf4a29c5cb1e90b22b6faa7 to your computer and use it in GitHub Desktop.
AEM Instance Creator. A Wizard to create AEM instance with pre-installed content packages
--This wizard allows you to configure an AEM instance with pre installed packages
--Make sure the "Instances" folder, "Content Packages" folder and license.properties file are siblings of this script
--Instances - Put any AEM instances you want to use with the tool in this folder
--Content Packages - Put any content packages you want installed on the AEM instance in this folder
set creatorPath to POSIX path of ((path to me as text) & "::")
--Put all AEM instances in "./Instances"
--Put all Content Packages in "./Content Packages"
--Put the license file in "./license.properties"
tell application "System Events"
set aemInstances to POSIX path of disk items of folder (creatorPath & "Instances")
set contentPackages to POSIX path of disk items of folder (creatorPath & "Content Packages")
set licenseFile to POSIX path of file (creatorPath & "license.properties")
end tell
set instance to choose from list aemInstances with prompt "Select target instance" OK button name "Select" cancel button name "Cancel"
set text item delimiters to "/"
POSIX path of instance
set instanceName to text item -1 of result
--Cancels the creator script
if instance is equal to false then
return
end if
--Choose AEM run mode-----------------------------------------
set runmode to choose from list {"author", "publish"} with prompt "Choose a runmode"
--Cancels the creator script
if runmode is equal to false then
return
end if
--Choose port number-----------------------------------------
set defPort to 4502
if (runmode as text) is equal to "publish" then
set defPort to 4503
end if
display dialog "Choose a port number" default answer defPort
try
set portNum to (text returned of result) as number
on error
display dialog "Invalid input. Setting port to " & defPort
set portNum to defPort
end try
--Cancels the creator script
if portNum is equal to false then
return
end if
if (portNum > 65535) or (portNum < 0) then
display dialog "Invalid port number. Setting port to " & defPort
set portNum to defPort
end if
--Select content packages for initial install
set selectedPackages to choose from list contentPackages with prompt "Select content packages. Press ctrl for multiselect" OK button name "Select" cancel button name "None" with multiple selections allowed
--Select the instance installation folder-----------------------------------------
set root_folder to choose folder with prompt "Select the destination folder for instance"
--Cancels the creator script
if root_folder is equal to false then
return
end if
set dest_folder to POSIX path of root_folder & runmode
--Copy any selected content packages-----------------------------------------
if selectedPackages is not equal to false then
do shell script "mkdir -m 777 -p '" & dest_folder & "/crx-quickstart/install'"
repeat with cPackage in selectedPackages
do shell script "cp '" & cPackage & "' '" & dest_folder & "/crx-quickstart/install/'"
end repeat
end if
--Copy the jar and license file. Also create a .version file specifying the aem instance-----------------------------------------
do shell script "mkdir -m 777 -p '" & dest_folder & "'"
do shell script "cp '" & instance & "' '" & dest_folder & "/aem-" & runmode & "-" & portNum & ".jar'"
do shell script "cp '" & licenseFile & "' '" & dest_folder & "'"
do shell script "touch '" & dest_folder & "/" & instanceName & ".version'"
--open up the built instance in Finder-----------------------------------------
set the_folder to (POSIX file dest_folder) as alias
tell application "Finder"
activate
if window 1 exists then
set target of window 1 to the_folder
else
reveal the_folder
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment