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

fix: repair the dagent install script in MacOS #11

Merged
merged 1 commit into from
Jul 5, 2022
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
5 changes: 2 additions & 3 deletions .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Run unit tests
run: make test
# if we go public this is free from codecov.io
# todo: replace & fix unit test coverage above
# todo: replace & fix unit test coverage above
# - uses: codecov/codecov-action@v3
# with:
# files: ./coverage.cov
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# fixes: fatal: unsafe repository
# fixes: fatal: unsafe repository
- name: Adding workspace
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

Expand Down Expand Up @@ -147,4 +147,3 @@ jobs:
cosign sign --key cosign.key ghcr.io/dyrector-io/dyrectorio/crane:${{ needs.test.outputs.tag }}
env:
COSIGN_PASSWORD: "${{ secrets.COSIGN_PASSWORD }}"

68 changes: 54 additions & 14 deletions web/crux/install.sh.hbr
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
#!/bin/sh set -e if [ `id -u` -ne 0 ] ; then echo "Installation process needs root privileges" 1>&2 sudo -s fi if [ -z
"$(which docker)" ]; then \ echo "Docker is required, make sure it is installed and available in PATH!"\ exit 1 fi echo
"Installing dyrector.io agent (dagent)..." if [ $(docker ps --no-trunc --filter name=^/dagent$ | tail -n +2 | wc -l) -eq
1 ]; then echo "DAgent is is running already, terminating" docker stop dagent fi if [ $(docker ps -a --no-trunc --filter
name=^/dagent$ | tail -n +2 | wc -l) -eq 1 ]; then docker rm dagent else echo "DAgent not running, installing..." fi
mkdir -p /srv/dagent docker pull
{{image}}

docker run \ --restart unless-stopped \ -e GRPC_TOKEN='{{token}}' \ -e HOSTNAME="$HOSTNAME || $HOST || '{{name}}'" \
#!/bin/sh

set -e

# Setup the default root folder for volumes
if [ $(uname -s) == 'Darwin' ]; then
echo "Detected: Mac OS X"
ROOT_FOLDER='/Volumes/dyrectorio/srv/dagent'
elif [ $(uname -s) == 'Linux' ]; then
echo "Detected: Linux"
ROOT_FOLDER='/srv/dagent'
else
echo "Not supported OS!"
fi


if [ $(id -u) -ne 0 ]; then
echo "Installation process needs root privileges" sudo -s 1>&2
fi

if [ -z "$(which docker)" ]; then
echo "Docker is required, make sure it is installed and available in PATH!"
exit 1
fi

echo "Installing dyrector.io agent (dagent)..."

if [ $(docker ps --no-trunc --filter name=^/dagent$ | tail -n +2 | wc -l) -eq 1 ]; then
echo "DAgent is is running already, terminating"
docker stop dagent
fi

if [ $(docker ps -a --no-trunc --filter name=^/dagent$ | tail -n +2 | wc -l) -eq 1 ]; then
docker rm dagent
else
echo "DAgent not running, installing..."
fi

mkdir -p $ROOT_FOLDER
docker pull {{image}}

docker run \
--restart unless-stopped \
-e GRPC_TOKEN='{{token}}' \
-e HOSTNAME="$HOSTNAME || $HOST || '{{name}}'" \
{{#if traefik}}
-e TRAEFIK= '' \
{{/if}}
-e DATA_MOUNT_PATH='/srv/dagent' \ -e UPDATE_METHOD='off' \ -e UPDATE_POLL_INTERVAL='600s' \
-e DATA_MOUNT_PATH=$ROOT_FOLDER \
-e UPDATE_METHOD='off' \
-e UPDATE_POLL_INTERVAL='600s' \
{{#if insecure}}
-e GRPC_INSECURE='true' \
{{/if}}
-e DAGENT_IMAGE='ghcr.io/dyrector-io/dyrectorio/dagent' \ -e DAGENT_TAG='stable' \ -e DAGENT_NAME='{{name}}' \ -v
/var/run/docker.sock:/var/run/docker.sock \ --name 'dagent' \
-e DAGENT_IMAGE='ghcr.io/dyrector-io/dyrectorio/agent/dagent' \
-e DAGENT_TAG='stable' \
-e DAGENT_NAME='{{name}}' \
-v /var/run/docker.sock:/var/run/docker.sock \
--name 'dagent' \
{{! -e UPDATE_REGISTRY_USER='' \ }}
{{! -e UPDATE_REGISTRY_PASSWORD='' \ }}
{{! -e UPDATER_CONTAINER_NAME ='' \ }}
{{! -e UPDATE_HOST_TIMEZONE='' \ }}
{{! -e HOST_DOCKER_SOCK='' \ }}
{{! -e WEBHOOK_TOKEN='' \ }}
{{! -e DISCORD_WEBHOOK_URL='' \ }}
-v /srv/dagent/:/srv/dagent \ -d \
{{image}}
-v $ROOT_FOLDER/:$ROOT_FOLDER -d {{image}}
2 changes: 1 addition & 1 deletion web/crux/src/domain/agent-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AgentInstaller {
name: name.toLowerCase().replace(/\s/g, ''),
token: this.token,
insecure: process.env.GRPC_AGENT_INSTALL_SCRIPT_INSECURE === 'true',
image: 'ghcr.io/dyrector-io/dyrectorio/dagent:stable',
image: 'ghcr.io/dyrector-io/dyrectorio/agent/dagent:stable',
})
}

Expand Down