Giter VIP home page Giter VIP logo

Comments (7)

janvda avatar janvda commented on July 18, 2024 1

I managed to fix this issue by changing the generateToken() function in the bash script

from:

generateToken() { cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1; }

into:

# the original command doesn't work on macos big sur
# see https://gist.github.com/earthgecko/3089509#gistcomment-3530978
generateToken() { head -c 1024 /dev/urandom | base64 | tr -cd A-Za-z0-9  | head -c $1;}

FYI I did this change in my fork (https://github.com/janvda/devops/blob/master/mgmt-hub/deploy-mgmt-hub.sh)
and this is what I now get when running the bash script:

Jans-MBP:~ root# curl -sSL https://raw.githubusercontent.com/janvda/devops/master/mgmt-hub/deploy-mgmt-hub.sh | bash
----------- Verifying input and the host OS...
Management hub services will listen on 192.168.1.5
----------- Downloading template files...
Substituting environment variables into template files...
----------- Downloading/starting Horizon management hub services...
Downloading management hub docker images...
Pulling openhorizon/amd64_agbot:latest...
Pulling openhorizon/amd64_exchange-api:latest...
Pulling openhorizon/amd64_cloud-sync-service:latest...
Pulling postgres:latest...
Pulling mongo:latest...
Pulling openhorizon/sdo-owner-services:latest...
Starting management hub containers...
postgres is up-to-date
Recreating exchange-api ... 
Recreating exchange-api ... done
Recreating css-api      ... 
Recreating css-api      ... done
agbot is up-to-date
Waiting for the exchange
----------- Creating the user org, the admin user in both orgs, and an agbot in the exchange...
Creating exchange admin user and agbot in the system org...
Creating exchange user org and admin user...
----------- Downloading/installing Horizon agent and CLI...
Downloading the Horizon agent and CLI packages...
Installing the Horizon CLI package...
installer: Package name is horizon-cli-2.27.0-173
installer: Installing at base path /
installer: The install was successful.
Configuring the Horizon agent and CLI...
Starting the Horizon agent container...
Starting socat to listen on port 2375 and forward it to the docker API socket...
testing: Pulling from openhorizon/amd64_anax
57de4da701b5: Already exists 
cf0f3ebe9f53: Already exists 
ab20abefcadc: Pull complete 
fabffe1dd9ac: Pull complete 
74a1891b09cf: Pull complete 
0cfa3bd884f3: Pull complete 
422bdfcc07ec: Pull complete 
152b46d0b5df: Pull complete 
c6402b8b7858: Pull complete 
6916447e6ba5: Pull complete 
dd0d3cdb9660: Pull complete 
2338ede2c7ad: Pull complete 
2a7d5b34f102: Pull complete 
Digest: sha256:fd84578b134ff65b58288514056492254acff716842a48bf7edef658421863b0
Status: Downloaded newer image for openhorizon/amd64_anax:testing
docker.io/openhorizon/amd64_anax:testing
Starting the Horizon agent container openhorizon/amd64_anax:testing...
fbc173594fd2a7ff0c496743f4a3741cf3ba4c91540ebef7ad0e6f9e480b2993
Horizon agent started successfully. Now use 'hzn node list', 'hzn register ...', and 'hzn agreement list'
----------- Creating developer key pair, and installing Horizon example services, policies, and patterns...
Creating RSA PSS private and public keys, and an x509 certificate for distribution. This is a CPU-intensive operation and, depending on key length and platform, may take a while. Key generation on an amd64 or ppc64 system using the default key length will complete in less than 1 minute.
Created keys:
        /var/root/.hzn/keys/service.private.key
        /var/root/.hzn/keys/service.public.pem
Using examples repo branch v2.27 derived from the hzn version
Cloning https://github.com/open-horizon/examples.git to /tmp/open-horizon/examples ...
Switching to branch v2.27 ...
Branch 'v2.27' set up to track remote branch 'v2.27' from 'origin'.
Publishing services and patterns of edge/services/cpu_percent to IBM org...
Publishing services and patterns of edge/services/gps to IBM org...
Publishing services and patterns of edge/services/helloworld to IBM org...
Publishing deployment policy of edge/services/helloworld to myorg org...
Publishing services and patterns of edge/services/helloMMS to IBM org...
Publishing services and patterns of edge/services/hello-operator to IBM org...
Publishing deployment policy of edge/services/hello-operator to myorg org...
Publishing services and patterns of edge/evtstreams/cpu2evtstreams to IBM org...
Publishing deployment policy of edge/evtstreams/cpu2evtstreams to myorg org...
Successfully published all examples to the exchange. Removing /tmp/open-horizon/examples directory.
----------- Creating and registering the edge node with policy to run the helloworld Horizon example...
Waiting for the agent to be ready
Horizon Exchange base URL: http://192.168.1.5:3090/v1
Node myorg/node1 does not exist in the Exchange with the specified token, creating/updating it...
node added or updated
Node node1 created.
Will proceeed with the given node policy.
Updating the node policy...
Initializing the Horizon node with node type 'device'...
Note: no input file was specified. This is only valid if none of the services need variables set.
However, if there is 'userInput' specified in the node already in the Exchange, the userInput will be used.
Changing Horizon state to configured to register this node with Horizon...
Horizon node is registered. Workload services should begin executing shortly.
Waiting for up to 100 seconds for following services to start:
        IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Status of the services you are watching:
        Waiting         IBM/ibm.helloworld
Timeout waiting for some services to successfully start. Analyzing possible reasons for the timeout...
The following services are not deployed to the node, continuing analysis:
        IBM/ibm.helloworld

Currently, there are no active agreements on this node.

Currently, there are no errors recorded in the node's event log.
Use the 'hzn deploycheck all -b' or 'hzn deploycheck all -B' command to verify that node, service configuration and deployment policy is compatible.
Analysis complete.

----------- Summary of what was done:
  1. Started Horizon management hub services: agbot, exchange, postgres DB, CSS, mongo DB
  2. Created exchange resources: system org (IBM) admin user, user org (myorg) and admin user, and agbot
     - Exchange root user generated password:  XXXX
     -....
     Important: save these generated passwords/tokens in a safe place. You will not be able to query them from Horizon.
  3. Installed the Horizon agent and CLI (hzn)
  4. Created a Horizon developer key pair
  5. Installed the Horizon examples
  6. Created and registered an edge node to run the helloworld example edge service

For what to do next, see: https://github.com/open-horizon/devops/blob/master/mgmt-hub/README.md#all-in-1-what-next
Before running the commands in the What To Do Next section, copy/paste/run these commands in your terminal:
 export HZN_ORG_ID=myorg
 export HZN_EXCHANGE_USER_AUTH=admin:ybpi...uB

from devops.

janvda avatar janvda commented on July 18, 2024

FYI - I have run same script with bash option -x to get more logging:

Jans-MBP:~ root# curl -sSL https://raw.githubusercontent.com/open-horizon/devops/master/mgmt-hub/deploy-mgmt-hub.sh | bash -x
+ getopts :SPsur:vh opt
+ [[ -z '' ]]
+ [[ -n '' ]]
+ EXCHANGE_ROOT_PW_GENERATED=1
++ generateToken 30
++ cat /dev/urandom
++ env LC_CTYPE=C tr -dc a-zA-Z0-9
++ fold -w 30
++ head -n 1
Input error
+ export EXCHANGE_ROOT_PW=
+ EXCHANGE_ROOT_PW=
+ export EXCHANGE_ROOT_PW_BCRYPTED=
+ EXCHANGE_ROOT_PW_BCRYPTED=
+ [[ -z '' ]]
++ generateToken 30
++ cat /dev/urandom
++ env LC_CTYPE=C tr -dc a-zA-Z0-9
++ fold -w 30
++ head -n 1
Input error
+ export EXCHANGE_SYSTEM_ADMIN_PW=
+ EXCHANGE_SYSTEM_ADMIN_PW=
+ EXCHANGE_SYSTEM_ADMIN_PW_GENERATED=1
+ [[ -z '' ]]
++ generateToken 30
++ cat /dev/urandom
++ env LC_CTYPE=C tr -dc a-zA-Z0-9
++ fold -w 30
++ head -n 1
Input error
+ export AGBOT_TOKEN=
+ AGBOT_TOKEN=
+ AGBOT_TOKEN_GENERATED=1
+ [[ -z '' ]]
++ generateToken 30
++ cat /dev/urandom
++ env LC_CTYPE=C tr -dc a-zA-Z0-9
++ fold -w 30
++ head -n 1
Input error
+ export EXCHANGE_USER_ADMIN_PW=
+ EXCHANGE_USER_ADMIN_PW=
+ EXCHANGE_USER_ADMIN_PW_GENERATED=1
+ [[ -z '' ]]
++ generateToken 30
++ cat /dev/urandom
++ env LC_CTYPE=C tr -dc a-zA-Z0-9
++ fold -w 30
++ head -n 1
Input error
+ export HZN_DEVICE_TOKEN=
+ HZN_DEVICE_TOKEN=
+ HZN_DEVICE_TOKEN_GENERATED=1
+ export HZN_LISTEN_IP=192.168.1.5
+ HZN_LISTEN_IP=192.168.1.5
+ export HZN_TRANSPORT=http
+ HZN_TRANSPORT=http
+ export EXCHANGE_IMAGE_TAG=latest
+ EXCHANGE_IMAGE_TAG=latest
+ export EXCHANGE_PORT=3090
+ EXCHANGE_PORT=3090
+ export EXCHANGE_LOG_LEVEL=INFO
+ EXCHANGE_LOG_LEVEL=INFO
+ export EXCHANGE_SYSTEM_ORG=IBM
+ EXCHANGE_SYSTEM_ORG=IBM
+ export EXCHANGE_USER_ORG=myorg
+ EXCHANGE_USER_ORG=myorg
+ export EXCHANGE_WAIT_ITERATIONS=30
+ EXCHANGE_WAIT_ITERATIONS=30
+ export EXCHANGE_WAIT_INTERVAL=2
+ EXCHANGE_WAIT_INTERVAL=2
+ export AGBOT_IMAGE_TAG=latest
+ AGBOT_IMAGE_TAG=latest
+ export AGBOT_PORT=3091
+ AGBOT_PORT=3091
+ export AGBOT_ID=agbot
+ AGBOT_ID=agbot
+ export CSS_IMAGE_TAG=latest
+ CSS_IMAGE_TAG=latest
+ export CSS_PORT=9443
+ CSS_PORT=9443
+ export POSTGRES_IMAGE_TAG=latest
+ POSTGRES_IMAGE_TAG=latest
+ export POSTGRES_PORT=5432
+ POSTGRES_PORT=5432
+ export POSTGRES_USER=admin
+ POSTGRES_USER=admin
+ export EXCHANGE_DATABASE=exchange
+ EXCHANGE_DATABASE=exchange
+ export AGBOT_DATABASE=exchange
+ AGBOT_DATABASE=exchange
+ export MONGO_IMAGE_TAG=latest
+ MONGO_IMAGE_TAG=latest
+ export MONGO_PORT=27017
+ MONGO_PORT=27017
+ export SDO_IMAGE_TAG=latest
+ SDO_IMAGE_TAG=latest
+ export SDO_OCS_API_PORT=9008
+ SDO_OCS_API_PORT=9008
+ export SDO_RV_PORT=8040
+ SDO_RV_PORT=8040
+ export SDO_OPS_PORT=8042
+ SDO_OPS_PORT=8042
+ export SDO_OPS_EXTERNAL_PORT=8042
+ SDO_OPS_EXTERNAL_PORT=8042
+ export SDO_OCS_DB_PATH=/home/sdouser/ocs/config/db
+ SDO_OCS_DB_PATH=/home/sdouser/ocs/config/db
+ export AGENT_INSTALL_URL=https://github.com/open-horizon/anax/releases/latest/download/agent-install.sh
+ AGENT_INSTALL_URL=https://github.com/open-horizon/anax/releases/latest/download/agent-install.sh
+ export AGENT_WAIT_ITERATIONS=15
+ AGENT_WAIT_ITERATIONS=15
+ export AGENT_WAIT_INTERVAL=2
+ AGENT_WAIT_INTERVAL=2
+ export COMPOSE_PROJECT_NAME=hzn
+ COMPOSE_PROJECT_NAME=hzn
+ export HC_DOCKER_TAG=testing
+ HC_DOCKER_TAG=testing
+ OH_DEVOPS_REPO=https://raw.githubusercontent.com/open-horizon/devops/master
+ OH_ANAX_RELEASES=https://github.com/open-horizon/anax/releases/latest/download
+ OH_ANAX_MAC_PKG_TAR=horizon-agent-macos-pkg-x86_64.tar.gz
+ OH_ANAX_DEB_PKG_TAR=horizon-agent-linux-deb-amd64.tar.gz
+ OH_ANAX_RPM_PKG_TAR=horizon-agent-linux-rpm-x86_64.tar.gz
+ OH_EXAMPLES_REPO=https://raw.githubusercontent.com/open-horizon/examples/master
+ HZN_DEVICE_ID=node1
+ TMP_DIR=/tmp/horizon
+ mkdir -p /tmp/horizon
+ CURL_OUTPUT_FILE=/tmp/horizon/curlExchangeOutput
+ CURL_ERROR_FILE=/tmp/horizon/curlExchangeErrors
++ uname -s
+ SYSTEM_TYPE=Darwin
++ lsb_release -d
++ awk '{print $2" "$3}'
+ DISTRO=
+ isMacOS
+ [[ Darwin == \D\a\r\w\i\n ]]
+ return 0
+ HZN=/usr/local/bin/hzn
+ export ETC=/private/etc
+ ETC=/private/etc
+ export VOLUME_MODE=cached
+ VOLUME_MODE=cached
+ [[ 0 -gt 1 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ echo '----------- Verifying input and the host OS...'
----------- Verifying input and the host OS...
+ [[ -z '' ]]
+ fatal 1 'these environment variables must be set: EXCHANGE_ROOT_PW, EXCHANGE_ROOT_PW_BCRYPTED'
+ local exitCode=1
+ echo Error: these environment variables must be set: EXCHANGE_ROOT_PW, EXCHANGE_ROOT_PW_BCRYPTED
Error: these environment variables must be set: EXCHANGE_ROOT_PW, EXCHANGE_ROOT_PW_BCRYPTED
+ exit 1
Jans-MBP:~ root# 

from devops.

janvda avatar janvda commented on July 18, 2024

I managed to reproduce the first Input Error by following command:

Jans-MBP:~ root# cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 30
Input error

FYI when I remove | fold -w 30 from the command I am getting the following output which I had to stop (ctrl-c) as it seems to go on for ever.

Jans-MBP:~ root# cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9'
2fXf��7t�L�R8�4J��ytk3�ZKna�j��YWiys����6M�k�b���zqKXNO��ijwTdP������MչHXggul�m���5O�sd�����riQc�V��Dy�GIg6��M7�B�tϽ988��U��N���YIzy�gS5�h�Kt�Y�hP���n0P�u���EG�HM�2X�G�x���G�Q�Q��S9�����NDsyw���r0�4�NVk��o�W���tSk��RؾM�Z�u6�E��1���c�iA�Gk�mA�R�V��۹M9l����9i��v�q�VE�s�PRT�4��S��udQ��fk�nE�4��h�u����ɹan������1�o�THi��yz9i�w3�t����e�ut��w��D�I�Se�hxn��g0�n������1eyN�J�h���pi�D���f�����oJg��t�o��q7L��EM��O�f�X�g���9��Hb����VZ����r��pv8�tV���T�gۼu�p�l�y���G�f��Q�O�FV��sNa8�S�e��KP�CnttM�A�csV�6�h�Lwhus��E��dox�c�O�Z8�iTLk˲�������f�5W�mjHTD��E�B�vKO�j�np�c�B��K���ʽ�nT����Zo�n��0�����Zr�w���8��Szfg��N��fIC���bLZ��b�X���S�uL�x��f4�DiJQVp��rE��h�W�zi�1�3����VA�2ct��4x�s���m�aw�du��ZLv�8�R�5w�bu��k�VD�l�������Z�s�F�p��sf�2��B�����gO��2e��XlPieL��d�J��p�OBsBI�1ED�k��9�b2GD�QJ�A�v�ErlMpIf���jdw�bu�fW5�C�Wk�7n�J��Z�F�X�xv�U1���ξNyH�L���IJjem��W���PLPNk6�x�j1�He1�EVJ��AN��S�AS4F�9e��Z�B���Be��h�l02�PDus7���HT4��zkV���J��f�iS8��Q�e��I�������ef�joh5���s�Y���X�TyW�t�U�lC��X8c�Y�lM���5WH�6��2o���3�C���1�1ZAZ�G�t�wfsy��c��C������y�x����0gg1�7�S��l�c�s������BO�J�9����Wzv��q�MqW���WdX�5TNP6��U��E�l���C�V��FUy����G�e��6G�mFz���uz1�x���J5�h���m��H�X�����g�gfG���M3�b�1j�1I�iB9�v��9e�r����b�fY���I�3��v�����6ZZ8IrTrMYz�TW�T���X��1��s��lhu��m���Q��JTgdq�e�u��b0�6�c�j�5�V�m���ʽ����cA�v��A��x�g�qMl1hvNb����f��WL��k������HhB��u�1�m4R��kFp�D�l�5�5lf���e��mWܲ�b���o�7G��Lb�F��V�K�����ľxrwT�c��3T�w�l�5��H�n0us9K��WK�U�9�z�0���y��bvMoP�NJ�c�R�bVFF��P�u����0Q���H�8���ta��z���fټW�D�7�wT��e�G����FZ�K7l���k��kUA2Gul���zgk�wQ�VN�T��HAs��lO����Q6�Hy5�Bzw����kNS���e0tXUrfqSjɳ2�3��e9�����l�K�6���3���gL�UK��Rpi��Of�3��aNEpkn�FtCQF�pI��4y�61���Rn��GG����NG��ibl2�or����1�����sn9�S���Bx���Hw�y�DqA�fC�L9���V�Fy�dU�gU�P�33�J�G�T�b5�QG��a�aJ�Z��Q�6o���t07�hX��jlqM�7���7��8gL�o4ylv�5��me����Mi�kֽEam�GM2��HN�c��4�W��DL4p�k�w��B0kG�AǾ��U�H��MM����RK�dZHvBVwN2vH70i8xgCZ����lQl��n���wk�S�A2d���3bD�j���Klksjh�F�U4h�En����Q�oo���0k��XaN������5���p�5ZE�pc��UPM�F��u�1�PC�pR�Q�v��yj��Y�d�K���q�lC6���27isD�dz2S��h�5�EvzU�����F�D6��wi����cMUP齽�BM��X�C�JxW��v�DLuc��hciu�Za�M��kG���1X��������O�GN�zsm��F���WK�MF9��6�C5p2Z����B39X��R��Avv��U��K��O�v��b3�3K�iW�Fw2x��g�h��NB7Qm��k1�Zz�vͼC��l2��Fy�Vo�LmJ�di�n8�WGbLM��2�k�m����1UwA�G�TK��rSNW�l��C����s�b�E�F�R�N��gM��yS������e�p�aK�HPB��CdC�7b�VDXYu�Z�B�cJ�z��������k��g7�MN�rDE�i3�jtJ9�K5�IF�X��I�n�ik�8NGEHt��f�PHQ7����Tu������H�w����RuG�r�p����l������b�i�b�H�K�JB0d�4q�a��o9�tk�fai�sM�6��G�l5i�

from devops.

janvda avatar janvda commented on July 18, 2024

I think the above fix of the generateToken() function also works for unix OS.
I have tested it on centos 8 and on a raspberry pi and it is working.

on raspberrry pi:

pi@pi3one:~ $ uname -a
Linux pi3one 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
pi@pi3one:~ $ head -c 1024 /dev/urandom | base64 | tr -cd A-Za-z0-9  | head -c 30;
83snXOZige58bTiiBUkDNTGyDJxEWRpi@pi3one:~ $ 

on intel nuc - running CentOs

[root@nuc-jan ~]# uname -a
Linux nuc-jan.borsbeek 4.18.0-240.1.1.el8_3.x86_64 #1 SMP Thu Nov 19 17:20:08 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@nuc-jan ~]# head -c 1024 /dev/urandom | base64 | tr -cd A-Za-z0-9  | head -c 30;
8APfa5tdbZRZmOHlm33SMN0N1JJCT9[root@nuc-jan ~]# 

from devops.

bmpotter avatar bmpotter commented on July 18, 2024

I requested changes on PR #29

from devops.

bmpotter avatar bmpotter commented on July 18, 2024

Fixed in #52

@janvda please test this, and if it fixes the problem, comment here and close the issue.

from devops.

bmpotter avatar bmpotter commented on July 18, 2024

Since i haven't heard from @janvda in 4 months about testing this fix i'm closing the issue. It can be reopened if someone finds a problem with it.

from devops.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.