Skip to content

Commit

Permalink
add windows-agent.yaml
Browse files Browse the repository at this point in the history
try zip all
  • Loading branch information
jean-christophe81 committed Jul 19, 2024
1 parent 89d703d commit d1bf5e2
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 47 deletions.
42 changes: 1 addition & 41 deletions .github/scripts/collect-prepare-test-robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,7 @@ ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -P "" <<<y
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -P "" <<<y
mkdir -p /run/sshd

if [ $database_type == 'mysql' ]; then
echo "########################### Start MySQL ######################################"
#workaround of forbidden execution of mysqld
cp /usr/libexec/mysqld /usr/libexec/mysqldtoto
/usr/libexec/mysqldtoto --user=root --initialize-insecure
/usr/libexec/mysqldtoto --user=root &

while [ ! -S /var/lib/mysql/mysql.sock ] && [ ! -S /var/run/mysqld/mysqld.sock ]; do
sleep 10
done

sleep 5
echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon'"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon'"
else
echo "########################### Start MariaDB ######################################"
if [ "$distrib" = "ALMALINUX" ]; then
mysql_install_db --user=root --basedir=/usr --datadir=/var/lib/mysql
mariadbd --socket=/var/lib/mysql/mysql.sock --user=root > /dev/null 2>&1 &
else
mkdir -p /run/mysqld
chown mysql:mysql /run/mysqld
mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 &
fi
sleep 5

echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon'"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon'"
fi

mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost'"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'"

cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql

mysql -u root_centreon -pcentreon < resources/centreon_storage.sql
mysql -u root_centreon -pcentreon < /tmp/centreon.sql
.github/scripts/collect-setup-database.sh $database_type

if [ $database_type == 'mysql' ]; then
killall -w mysqldtoto
Expand Down
50 changes: 50 additions & 0 deletions .github/scripts/collect-setup-database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e
set -x


database_type=$1

. /etc/os-release
distrib=${ID}
distrib=$(echo $distrib | tr '[:lower:]' '[:upper:]')


if [ $database_type == 'mysql' ]; then
echo "########################### Start MySQL ######################################"
#workaround of forbidden execution of mysqld
cp /usr/libexec/mysqld /usr/libexec/mysqldtoto
/usr/libexec/mysqldtoto --user=root --initialize-insecure
/usr/libexec/mysqldtoto --user=root &

while [ ! -S /var/lib/mysql/mysql.sock ] && [ ! -S /var/run/mysqld/mysqld.sock ]; do
sleep 10
done

else
echo "########################### Start MariaDB ######################################"
if [ "$distrib" = "ALMALINUX" ]; then
mysql_install_db --user=root --basedir=/usr --datadir=/var/lib/mysql
mariadbd --socket=/var/lib/mysql/mysql.sock --user=root > /dev/null 2>&1 &
else
mkdir -p /run/mysqld
chown mysql:mysql /run/mysqld
mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 &
fi
fi

sleep 5
echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon'"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon'"


mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost'"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'"

cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql

mysql -u root_centreon -pcentreon < resources/centreon_storage.sql
mysql -u root_centreon -pcentreon < /tmp/centreon.sql

78 changes: 76 additions & 2 deletions .github/workflows/windows-agent-robot-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,82 @@ on:
workflow_dispatch:

jobs:
get-version:
uses: ./.github/workflows/get-version.yml
with:
version_file: CMakeLists.txt

build-agent:
needs: [get-version]
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: distrib availables
run: wsl --list --online

- name: install debian
uses: Vampire/setup-wsl@v3
with:
distribution: Debian
use-cache: 'true'
# update: 'true'
# additional-packages:
# mariadb-server
# libmariadb3
# librrd8
# liblua5.3
# python3
# python3-pip
# rrdtool

- name: check install
run: |
Write-Host installed
wsl --list --verbose
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: calc current path
run: |
$current_dir = (pwd).Path
$wsl_path = "/mnt/" + $current_dir.SubString(0,1).ToLower() + "/" + $current_dir.SubString(3).replace('\','/')
[System.Environment]::SetEnvironmentVariable("WSL_COLLECT_DIR", $wsl_path)
Write-Host "collect is there: " $env:WSL_COLLECT_DIR
wsl cd $env:WSL_COLLECT_DIR `&`& cat .github/scripts/collect-setup-database.sh
- name: install mariadb
run: |
wsl cd $env:WSL_COLLECT_DIR `&`& .github/scripts/collect-setup-database.sh mariadb
- name: ps
shell: wsl-bash {0}
run: ps -ef
# - name: docker login
# shell: wsl-bash {0}
# env:
# DOCKER_REGISTRY_ID: ${{ secrets.DOCKER_REGISTRY_ID }}
# DOCKER_REGISTRY_PASSWD: ${{ secrets.DOCKER_REGISTRY_PASSWD }}

# run: docker login -u $env:DOCKER_REGISTRY_ID -p $env:DOCKER_REGISTRY_PASSWD ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}

# - name: Checkout sources
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# - name: Login to Registry
# uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
# with:
# registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
# username: ${{ secrets.DOCKER_REGISTRY_ID }}
# password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}


# - name: Test in container
# uses: ./.github/actions/runner-docker
# with:
# registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
# script_name: ./.github/scripts/collect-test-robot-with-windows.sh
# image_name: centreon-collect-alma9-test
# image_version: ${{ needs.get-version.outputs.test_img_version }}

4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ set(COLLECT_MINOR 07)
set(COLLECT_PATCH 0)
set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}")

add_definitions("-DCOLLECT_MAJOR=${COLLECT_MAJOR}")
add_definitions("-DCOLLECT_MINOR=${COLLECT_MINOR}")
add_definitions("-DCOLLECT_PATCH=${COLLECT_PATCH}")


if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
include(CMakeListsLinux.txt)
Expand Down
4 changes: 4 additions & 0 deletions CMakeListsLinux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ find_package(Boost REQUIRED COMPONENTS url)
find_package(ryml CONFIG REQUIRED)
add_definitions("-DSPDLOG_FMT_EXTERNAL")

add_definitions("-DCOLLECT_MAJOR=${COLLECT_MAJOR}")
add_definitions("-DCOLLECT_MINOR=${COLLECT_MINOR}")
add_definitions("-DCOLLECT_PATCH=${COLLECT_PATCH}")

include(FindPkgConfig)
pkg_check_modules(MARIADB REQUIRED libmariadb)
pkg_check_modules(LIBSSH2 REQUIRED libssh2)
Expand Down
17 changes: 17 additions & 0 deletions CMakeListsWindows.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
#
# Copyright 2009-2023 Centreon
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# For more information : contact@centreon.com
#

find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
Expand Down

0 comments on commit d1bf5e2

Please sign in to comment.