github.com/google/fleetspeak@v0.1.15-0.20240426164851-4f31f62c1aea/fleetspeak/test-package.sh (about)

     1  #!/bin/bash
     2  # Copyright 2019 Google Inc.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     https://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -ex
    17  
    18  /bin/echo 'Installing newly built server package.'
    19  apt install -y $1
    20  
    21  if [[ ! -z "$MYSQL_TEST_USER" ]]
    22  then
    23      sed -i "s/mysql_data_source_name: .*/mysql_data_source_name: \"$MYSQL_TEST_USER:$MYSQL_TEST_PASS@tcp($MYSQL_TEST_ADDR)\/$MYSQL_TEST_E2E_DB\"/g" /etc/fleetspeak-server/configurator.config
    24  fi
    25  
    26  sudo -u fleetspeak /usr/bin/fleetspeak-config --config=/etc/fleetspeak-server/configurator.config
    27  
    28  /bin/echo 'Checking that the installation was successful'
    29  ls -l /etc/fleetspeak-server
    30  find /etc/systemd/ -name 'fleetspeak*'
    31  
    32  # At this point the service is down, since right after the installation it was
    33  # started without a configuration.
    34  # Reset a list of failed services to ensure the restart below works fine.
    35  systemctl reset-failed
    36  
    37  # Restart the service.
    38  systemctl restart fleetspeak-server
    39  
    40  # Check that it's now up and running.
    41  systemctl is-active fleetspeak-server
    42  
    43  # Now copy the linux client configuration to the expected location.
    44  mkdir -p /etc/fleetspeak-client
    45  cp /etc/fleetspeak-server/linux.client.configuration /etc/fleetspeak-client/client.config
    46  
    47  # Install the client package.
    48  apt install -y $2
    49  
    50  # Check that the client is up and running.
    51  systemctl is-active fleetspeak-client
    52  
    53  journalctl -u fleetspeak-server
    54  journalctl -u fleetspeak-client
    55  systemctl -l status fleetspeak-server
    56  systemctl -l status fleetspeak-client
    57  
    58  # Check that fleetspeak_admin functions and returns info about a single client we have.
    59  fleetspeak-admin -admin_addr localhost:9000 listclients | grep "[a-z0-9]\{16\} .*client:linux"