diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fca8882..4321a4a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ jobs: - name: Install dependencies run: | sudo snap install yq - sudo snap install rockcraft --classic --edge --revision=687 + sudo snap install rockcraft --classic --edge sudo snap install charmcraft --classic --revision 1349 - name: Build ROCK run: | diff --git a/rockcraft.yaml b/rockcraft.yaml index f031b22..6a6bbb6 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -10,15 +10,14 @@ description: | as a NoSQL database program, MongoDB uses JSON -like documents with optional schemas. license: Apache-2.0 # your application's SPDX license -entrypoint: - - /usr/bin/setpriv - - --clear-groups - - --reuid - - mongodb - - --regid - - mongodb - - -- - - /usr/bin/mongod + +services: + mongod: + summary: Start Mongod + override: replace + startup: enabled + command: "/bin/bash /bin/start.sh" + platforms: # The platforms this ROCK should be built on and run on amd64: @@ -44,13 +43,16 @@ parts: useradd -R $CRAFT_OVERLAY -M -r -g mongodb -u 584788 mongodb override-prime: | craftctl default + # Give permission and create the required directories mkdir -p $CRAFT_PRIME/data/db chmod 0755 $CRAFT_PRIME/data/db chown -R 584788:584788 $CRAFT_PRIME/data/db + # enable security monitoring rocks=usr/share/rocks/ mkdir -p ${rocks} + ## for deb packages declare -a arr=() arr+=('${db:Status-Abbrev},') @@ -59,6 +61,7 @@ parts: arr+=('${source:Package},') arr+=('${Source:Version}\n') dpkg-query -W -f "${arr[*]}" > ${rocks}/dpkg.query + ## for snap packages cp snap.charmed-mongodb/manifest.yaml ${rocks} cp snap.charmed-mongodb/snapcraft.yaml ${rocks} diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100644 index 0000000..1f7b4ea --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/bin/setpriv --clear-groups --reuid mongodb --regid mongodb -- /usr/bin/mongod \ No newline at end of file