Skip to content

Instantly share code, notes, and snippets.

@tmkasun
Last active October 17, 2019 09:02
Show Gist options
  • Select an option

  • Save tmkasun/2217956f1872d29bc50a0ed322e2b7fe to your computer and use it in GitHub Desktop.

Select an option

Save tmkasun/2217956f1872d29bc50a0ed322e2b7fe to your computer and use it in GitHub Desktop.
Setup APIM server and Run it with it's depending servers, Will only be useful until API manager product properly pack the dependencies in to final product. Till we get there ...
#! /usr/bin/env bash
# HOW TO USE: Put this file inside the directory where you would like to extract and run the product-APIM build file (.zip file)
# Change the below path variables accordingly *** NOTE: No trailing `/` slashes has been used
# This will only work with APIM 3.0.0 M9 and later Since the carbon kernel update to 5.2.0
# Need to remove IS 5.4.0 Service Providers before login to any app If you are re-using same WSO2 Identity Server Instance with new APIM pack
source_path="/home/tmkasun/Documents/wso2/dev/products/team/apim/carbon-apimgt-forked/features/apimgt"
product_apimgt_path="/home/tmkasun/Documents/wso2/dev/products/team/apim/product-apim-forked"
pack_name="wso2apim-3.0.0-SNAPSHOT"
ballerina_build_path="${product_apimgt_path}/modules/gateway/target"
action=$1
create_symlink() {
sources=$1
destination=$2
mv $destination "${destination}_back"
ln -s "${sources}" "${destination}"
}
symlink_apps() {
artifact_id=$1
dir_name=$2
source="${source_path}/${artifact_id}/src/main/resources/${dir_name}"
create_symlink "${source}/public" "${pack_name}/deployment/web-ui-apps/${dir_name}/public"
}
run() {
echo "Running the setup ..."
echo "Starting activeMQ ..."
echo "Starting ballerina APIM Gateway Server ..."
# Intentionally delayed to sync with APIM server startup
(sleep 30 && cd "${ballerina_build_path}/wso2apim-gateway-3.0.0-SNAPSHOT/" && sed -i -e 's/\r$//' ./bin/ballerina && gnome-terminal --tab -e "./bin/ballerina run service services.bsz") &
echo "Starting APIM key-manager profile..."
gnome-terminal --tab -e "./${pack_name}/wso2/key-manager/bin/carbon.sh"
echo "Starting APIM ..."
./${pack_name}/wso2/default/bin/carbon.sh
}
setup() {
echo "Setting-up the environment ..."
echo "coping ${pack_name}zip from product apimgt build path to here ..."
cp "${product_apimgt_path}/modules/distribution/target/${pack_name}.zip" .
echo "Removing existing $pack_name"
rm -R ${pack_name}
echo "Unziping $pack_name"
code=$(unzip "${pack_name}.zip")
echo "Unzipping gateway server ..."
rm -R "${ballerina_build_path}/wso2apim-gateway-3.0.0-SNAPSHOT"
(cd ${ballerina_build_path} && unzip "wso2apim-gateway-3.0.0-SNAPSHOT.zip")
echo "Creating symlinks for Publisher ..."
symlink_apps "org.wso2.carbon.apimgt.publisher.feature" "publisher"
echo "Creating symlinks for Store ..."
symlink_apps "org.wso2.carbon.apimgt.store.feature" "store"
run
}
if [ "$action" == "setup" ]; then
setup
elif [ "$action" == "run" ]; then
run
else
echo "Unknown parameter. Type either 'setup' or 'run'"
fi
exit 1
@bhathiya
Copy link
Copy Markdown

bhathiya commented Jul 19, 2017

at the end of line 37, it should be "./bin/ballerina run service services.bsz"

@tmkasun
Copy link
Copy Markdown
Author

tmkasun commented Aug 4, 2017

Thank you @bhathiya ๐Ÿ˜Š
I have added that change to the gist ๐Ÿ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment