Skip to content
Open
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
24 changes: 19 additions & 5 deletions mauro-api/docker/all/micronaut/micronaut-startup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/usr/bin/env bash
set -e

ADD_PLUGINS="true"

if [ "${PLUGINS_IS_MOUNTED}" == "true" ];
then
if [ "$(ls -1 /home/app/plugins)" != "" ];
then
echo "There are persisted plugins."
ADD_PLUGINS="false"
fi
fi

if [ -e /opt/init/micronaut ];
then
mkdir -p /home/app/plugins
mkdir -p /home/app/plugins || true
pushd /opt/init/micronaut

shopt -s nullglob
Expand All @@ -20,8 +31,11 @@ then
fi
;;
*.jar)
echo "Adding ${f} as plugin"
cp -pf ${f} /home/app/plugins/.
if [ "${ADD_PLUGINS}" == "true" ];
then
echo "Adding ${f} as plugin"
cp -pf ${f} /home/app/plugins/.
fi
;;
*)
echo "Copying ${f} to micronaut resources"
Expand Down Expand Up @@ -74,5 +88,5 @@ echo "Starting Micronaut..."
cd /home/app
# Give the directory and contents to the micronaut user
chown -R micronaut:micronaut /home/app
echo ${JAVA_BIN} "${JAVA_OPTS}" -cp "/home/app/application.jar" "${APPLICATION_MAIN_CLASS}"
gosu micronaut ${JAVA_BIN} ${JAVA_OPTS} -cp /home/app/application.jar "${APPLICATION_MAIN_CLASS}"
echo ${JAVA_BIN} "${JAVA_OPTS}" -cp "/home/app/application.jar" -DPLUGINS_IS_MOUNTED=${PLUGINS_IS_MOUNTED} "${APPLICATION_MAIN_CLASS}"
gosu micronaut ${JAVA_BIN} ${JAVA_OPTS} -cp /home/app/application.jar -DPLUGINS_IS_MOUNTED=${PLUGINS_IS_MOUNTED} "${APPLICATION_MAIN_CLASS}"
14 changes: 14 additions & 0 deletions mauro-api/docker/all/startup/docker-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ echo "Detected ${CPU_COUNT} cores"
export DOCKER_SUBNET="$(ip -o -4 addr show 2>/dev/null | awk '/scope global/ {split($4,a,"/");split(a[1],b,".");printf "%d.%d.%d.0/%s\n",b[1],b[2],b[3],a[2];exit}')"

echo "Docker subnet ${DOCKER_SUBNET}"

if [ -e /home/app/plugins ];
then
MOUNTED_PLUGINS_AT=$(df -T "/home/app/plugins" | awk 'NR==2 {print $NF}')

if [ "${MOUNTED_PLUGINS_AT}" = "/" ];
then
export PLUGINS_IS_MOUNTED="false"
else
export PLUGINS_IS_MOUNTED="true"
fi
else
export PLUGINS_IS_MOUNTED="false"
fi
24 changes: 19 additions & 5 deletions mauro-api/docker/noDB/micronaut/micronaut-startup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/usr/bin/env bash
set -e

ADD_PLUGINS="true"

if [ "${PLUGINS_IS_MOUNTED}" == "true" ];
then
if [ "$(ls -1 /home/app/plugins)" != "" ];
then
echo "There are persisted plugins."
ADD_PLUGINS="false"
fi
fi

if [ -e /opt/init/micronaut ];
then
mkdir -p /home/app/plugins
mkdir -p /home/app/plugins || true
pushd /opt/init/micronaut

shopt -s nullglob
Expand All @@ -20,8 +31,11 @@ then
fi
;;
*.jar)
echo "Adding ${f} as plugin"
cp -pf ${f} /home/app/plugins/.
if [ "${ADD_PLUGINS}" == "true" ];
then
echo "Adding ${f} as plugin"
cp -pf ${f} /home/app/plugins/.
fi
;;
*)
echo "Copying ${f} to micronaut resources"
Expand Down Expand Up @@ -74,5 +88,5 @@ echo "Starting Micronaut..."
cd /home/app
# Give the directory and contents to the micronaut user
chown -R micronaut:micronaut /home/app
echo ${JAVA_BIN} "${JAVA_OPTS}" -cp "/home/app/application.jar" "${APPLICATION_MAIN_CLASS}"
gosu micronaut ${JAVA_BIN} ${JAVA_OPTS} -cp /home/app/application.jar "${APPLICATION_MAIN_CLASS}"
echo ${JAVA_BIN} "${JAVA_OPTS}" -cp "/home/app/application.jar" -DPLUGINS_IS_MOUNTED=${PLUGINS_IS_MOUNTED} "${APPLICATION_MAIN_CLASS}"
gosu micronaut ${JAVA_BIN} ${JAVA_OPTS} -cp /home/app/application.jar -DPLUGINS_IS_MOUNTED=${PLUGINS_IS_MOUNTED} "${APPLICATION_MAIN_CLASS}"
14 changes: 14 additions & 0 deletions mauro-api/docker/noDB/startup/docker-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ echo "Detected ${CPU_COUNT} cores"
export DOCKER_SUBNET="$(ip -o -4 addr show 2>/dev/null | awk '/scope global/ {split($4,a,"/");split(a[1],b,".");printf "%d.%d.%d.0/%s\n",b[1],b[2],b[3],a[2];exit}')"

echo "Docker subnet ${DOCKER_SUBNET}"

if [ -e /home/app/plugins ];
then
MOUNTED_PLUGINS_AT=$(df -T "/home/app/plugins" | awk 'NR==2 {print $NF}')

if [ "${MOUNTED_PLUGINS_AT}" = "/" ];
then
export PLUGINS_IS_MOUNTED="false"
else
export PLUGINS_IS_MOUNTED="true"
fi
else
export PLUGINS_IS_MOUNTED="false"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.maurodata.api.Paths
import org.maurodata.api.admin.AdminApi
import org.maurodata.audit.Audit
import org.maurodata.plugin.MauroPluginDTO
import org.maurodata.service.plugin.PluginRepositoryService

import groovy.transform.CompileStatic
import io.micronaut.http.HttpStatus
Expand All @@ -12,6 +13,8 @@ import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.micronaut.http.annotation.Post
import io.micronaut.http.exceptions.HttpStatusException
import io.micronaut.scheduling.TaskExecutors
import io.micronaut.scheduling.annotation.ExecuteOn
import io.micronaut.security.annotation.Secured
import io.micronaut.security.rules.SecurityRule
import jakarta.inject.Inject
Expand Down Expand Up @@ -41,6 +44,9 @@ class AdminController implements AdminApi {
@Inject
EmailService emailService

@Inject
PluginRepositoryService service

private final EmailRepository emailRepository

AdminController(EmailRepository emailRepository) {
Expand Down Expand Up @@ -85,6 +91,22 @@ class AdminController implements AdminApi {
[]
}

@Audit
@ExecuteOn(TaskExecutors.BLOCKING)
@Get(Paths.ADMIN_AVAILABLE_PROVIDERS_LIST)
List<Map<String, String>> available() {
accessControlService.checkAdministrator()
service.listAvailablePlugins()
}

@Audit
@ExecuteOn(TaskExecutors.BLOCKING)
@Post(Paths.ADMIN_INSTALL_PROVIDER)
Map<String, Object> installPlugin(String plugin) {
accessControlService.checkAdministrator()
return service.installPlugin(plugin)
}

/**
* This is new endpoint that can be used to test sending an email. You should provide a catalogue user with a
* firstName, lastName, and emailAddress set.
Expand Down
Loading
Loading