Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create start-aem script #5

Merged
merged 6 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/aem-sdk/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
## Step 3: Visual Studio Code
* Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). And open the project folder.
* VSCode will detect `.devcontainer/devcontainer.json`. And prompt you to reopen the project in a devcontainer.
* After the container gets created, the feature will run the setup scripts. They will create the folder structure for an author and publish service. And unpack the dispatcher tools.

## Run AEM Services
In VSCode, open the terminal window. This is a terminal inside the docker container. You can run any command as needed, including Maven and Node.

Additionally, the feature will have added some helpful aliases
* `start-author`
* `start-publish`
* `start-dispatcher`
There will be a script named `start-aem`. Use this to start the author, publish or dispatcher.
* Start author: `start-aem author`
* Start publish: `start-aem publish`
* Start dispatcher: `start-aem dispatcher`

The feature also sets up volume mounts for the author and publish services. This is where the services will persist the repository. So that if the container gets deleted and/or rebuilt, the repository will persist.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ sudo bash -c "${installscript}"
sudo rm ${installscript}
cd ${cwd}

# rename directory and add bin to PATH
# rename directory
sudo find ${AEM_SDK_FEATURE_DIR}/dispatcher-sdk-* -maxdepth 0 -type d -execdir mv {} dispatcher \;
add_line_to_shell_rc "export PATH=${PATH}:${AEM_SDK_FEATURE_DIR}/dispatcher/bin"

# alias to start dispatcher
add_line_to_shell_rc "alias start-dispatcher='cd dispatcher && ${AEM_SDK_FEATURE_DIR}/dispatcher/bin/docker_run.sh src host.docker.internal:${AEM_SDK_PUBLISH_PORT} ${AEM_SDK_DISPATCHER_PORT}'"
add_line_to_shell_rc "alias start-dispatcher='docker_run.sh src host.docker.internal:${AEM_SDK_PUBLISH_PORT} ${AEM_SDK_DISPATCHER_PORT}'"
36 changes: 36 additions & 0 deletions src/aem-sdk/bin/start-aem
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

usage() {
cat <<EOM
Usage: $(basename $0) <service>
where
<service> is 'dispatcher' or 'author' or 'publish'
EOM
exit 1
}

[ "${1}" = 'dispatcher' ] && service="${1}"
[ "${1}" = 'author' ] && service="${1}"
[ "${1}" = 'publish' ] && service="${1}"
[ -z "${service}" ] && usage

source "$(dirname $0)/_globals.sh"

if [[ "${service}" == "dispatcher" ]]; then

toolsdir="${AEM_SDK_FEATURE_DIR}/dispatcher"
# setup if dispatcher directory is missing
if [[ ! -d ${toolsdir} ]]; then
$(dirname $0)/aem-sdk-setup-dispatcher.sh
fi

elif [[ "${service}" == "author" || "${service}" == "publish" ]]; then

jar="${AEM_SDK_FEATURE_DIR}/${service}/$(get_runmode_jar ${service})"
# setup aem if jar file is missing
if [[ ! -f ${jar} ]]; then
$(dirname $0)/aem-sdk-setup-service.sh ${service}
fi
fi

bash -ci "start-${service}"
18 changes: 3 additions & 15 deletions src/aem-sdk/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aem-sdk",
"version": "1.0.0",
"version": "1.1.0",
"name": "Adobe Experience Manager SDK",
"description": "Setup author and publish services. And the dispatcher tools. Requires the AEM as a Cloud Service SDK.",
"options": {
Expand Down Expand Up @@ -31,7 +31,8 @@
}
},
"containerEnv": {
"AEM_SDK_FEATURE_DIR": "/aem-sdk"
"AEM_SDK_FEATURE_DIR": "/aem-sdk",
"PATH": "/aem-sdk/bin:/aem-sdk/dispatcher/bin:${PATH}"
},
"mounts": [
{
Expand All @@ -45,19 +46,6 @@
"type": "volume"
}
],
"onCreateCommand": {
"publish-instance": [
"/aem-sdk/scripts/setup-service.sh",
"publish"
],
"author-instance": [
"/aem-sdk/scripts/setup-service.sh",
"author"
],
"dispatcher": [
"/aem-sdk/scripts/setup-dispatcher.sh"
]
},
"dependsOn": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
Expand Down
3 changes: 1 addition & 2 deletions src/aem-sdk/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ echo "AEM_SDK_DISPATCHER_PORT=\"${DISPATCHERPORT:-'8080'}\"" >> ${propertiesFile
source ${propertiesFile}

# copy custom scripts
cp -r "$(dirname $0)/scripts" ${AEM_SDK_FEATURE_DIR}
#find "${AEM_SDK_FEATURE_DIR}/scripts" -name "*.sh" -exec chmod +x {} \;
cp -r "$(dirname $0)/bin" ${AEM_SDK_FEATURE_DIR}
31 changes: 10 additions & 21 deletions test/aem-sdk/defaults-with-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,15 @@ check "publish port default" \
[ "${AEM_SDK_PUBLISH_PORT}" = "4503" ]
check "dispatcher port default" \
[ "${AEM_SDK_DISPATCHER_PORT}" = "8080" ]
# Check setup scripts installed
check "_globals is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/_globals.sh | grep 'x.*x.*x'
check "setup-dispatcher is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-dispatcher.sh | grep 'x.*x.*x'
check "setup-service is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-service.sh | grep 'x.*x.*x'
# Check instance jars and dispatcher run script installed
check "author jar installed" \
[ -f "${AEM_SDK_FEATURE_DIR}/author/aem-author-p${AEM_SDK_AUTHOR_PORT}.jar" ]
check "publish jar installed" \
[ -f "${AEM_SDK_FEATURE_DIR}/publish/aem-publish-p${AEM_SDK_PUBLISH_PORT}.jar" ]
check "dispatcher tools installed" \
[ -d "${AEM_SDK_FEATURE_DIR}/dispatcher/bin" ]
# Check aliases added can execute the mock files from the mock sdk
check "can run start-author mock" \
bash -ci "start-author | grep 'hello, world'"
check "can run start-publish mock" \
bash -ci "start-author | grep 'hello, world'"
check "can run start-dispatcher mock" \
bash -ci "start-author | grep 'hello, world'"
# Check start-aem in PATH is executable
check "start-aem is +x" \
stat -c '%A' $(which start-aem) | grep 'x.*x.*x'
# Check that author/publish/dispatcher installs and starts
check "can install & run author" \
bash -ci "start-aem author | grep 'hello, world'"
check "can install & run publish" \
bash -ci "start-aem publish | grep 'hello, world'"
check "can install & run dispatcher" \
bash -ci "start-aem dispatcher | grep 'All your base are belong to us'"

reportResults
Binary file modified test/aem-sdk/defaults-with-sdk/aem-sdk-mock-2024.03.01.zip
Binary file not shown.
31 changes: 10 additions & 21 deletions test/aem-sdk/options-with-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,15 @@ check "publish port default" \
[ "${AEM_SDK_PUBLISH_PORT}" = "3002" ]
check "dispatcher port default" \
[ "${AEM_SDK_DISPATCHER_PORT}" = "8090" ]
# Check setup scripts installed
check "_globals is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/_globals.sh | grep 'x.*x.*x'
check "setup-dispatcher is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-dispatcher.sh | grep 'x.*x.*x'
check "setup-service is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-service.sh | grep 'x.*x.*x'
# Check instance jars and dispatcher run script installed
check "author jar installed" \
[ -f "${AEM_SDK_FEATURE_DIR}/author/aem-author-p${AEM_SDK_AUTHOR_PORT}.jar" ]
check "publish jar installed" \
[ -f "${AEM_SDK_FEATURE_DIR}/publish/aem-publish-p${AEM_SDK_PUBLISH_PORT}.jar" ]
check "dispatcher tools installed" \
[ -d "${AEM_SDK_FEATURE_DIR}/dispatcher/bin" ]
# Check aliases added can execute the mock files from the mock sdk
check "can run start-author mock" \
bash -ci "start-author | grep 'hello, world'"
check "can run start-publish mock" \
bash -ci "start-author | grep 'hello, world'"
check "can run start-dispatcher mock" \
bash -ci "start-author | grep 'hello, world'"
# Check start-aem in PATH is executable
check "start-aem is +x" \
stat -c '%A' $(which start-aem) | grep 'x.*x.*x'
# Check that author/publish/dispatcher installs and starts
check "can install & run author" \
bash -ci "start-aem author | grep 'hello, world'"
check "can install & run publish" \
bash -ci "start-aem publish | grep 'hello, world'"
check "can install & run dispatcher" \
bash -ci "start-aem dispatcher | grep 'All your base are belong to us'"

reportResults
Binary file not shown.
10 changes: 3 additions & 7 deletions test/aem-sdk/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ check "publish port default" \
[ "${AEM_SDK_PUBLISH_PORT}" = "4503" ]
check "dispatcher port default" \
[ "${AEM_SDK_DISPATCHER_PORT}" = "8080" ]
# Check setup scripts installed
check "_globals is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/_globals.sh | grep 'x.*x.*x'
check "setup-dispatcher is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-dispatcher.sh | grep 'x.*x.*x'
check "setup-service is +x" \
stat -c '%A' ${AEM_SDK_FEATURE_DIR}/scripts/setup-service.sh | grep 'x.*x.*x'
# Check start-aem in PATH is executable
check "start-aem is +x" \
stat -c '%A' $(which start-aem) | grep 'x.*x.*x'
# Check instance jars and dispatcher run script not installed
check "no author jar" \
[ ! -f "${AEM_SDK_FEATURE_DIR}/author/aem-author-p${AEM_SDK_AUTHOR_PORT}.jar" ]
Expand Down
Loading