]> granicus.if.org Git - icinga2/blobdiff - pki/icinga2-setup-agent.cmake
Use /bin/sh instead of bash.
[icinga2] / pki / icinga2-setup-agent.cmake
index ff9b04b8c12e4b7a9d739bc2b8e6a9c84596ff95..cc296c9d3f7fccf6c23fc863bd40c1f4589fa5fc 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 ICINGA2PKIDIR=@CMAKE_INSTALL_FULL_DATADIR@/icinga2/pki
 ICINGA2CONFIG=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2
 
@@ -14,6 +14,11 @@ if [ -n "$1" ]; then
                exit 1
        fi
 
+       if ! base64 -d $1 2>/dev/null; then
+               echo "The bundle file is invalid or corrupted."
+               exit 1
+       fi
+
        while true; do
                echo -n "Are you setting up a new master instance? [n] "
                if ! read master; then
@@ -82,49 +87,53 @@ if [ -n "$1" ]; then
                fi
        fi
 
-       while true; do
-               echo -n "Do you want this agent instance to connect to the upstream instance? [y] "
-               if ! read upstream_connect; then
-                       exit 1
-               fi
+       upstream_connect=n
 
-               if [ "$upstream_connect" = "y" -o "$upstream_connect" = "n" -o -z "$upstream_connect" ]; then
-                       break
-               fi
-
-               echo "Please enter 'y' or 'n'."
-       done
-
-       if [ -z "$upstream_connect" ]; then
-               upstream_connect=y
-       fi
-
-       if [ "$upstream_connect" = "y" ]; then
+       if [ "$master" = "n" ]; then
                while true; do
-                       echo -n "Upstream IP address/hostname: "
-                       if ! read upstream_host; then
+                       echo -n "Do you want this agent instance to connect to the upstream instance? [y] "
+                       if ! read upstream_connect; then
                                exit 1
                        fi
 
-                       if [ -n "$upstream_host" ]; then
+                       if [ "$upstream_connect" = "y" -o "$upstream_connect" = "n" -o -z "$upstream_connect" ]; then
                                break
                        fi
 
-                       echo "Please enter the upstream instance's hostname."
+                       echo "Please enter 'y' or 'n'."
                done
 
-               while true; do
-                       echo -n "Upstream port: "
-                       if ! read upstream_port; then
-                               exit 1
-                       fi
+               if [ -z "$upstream_connect" ]; then
+                       upstream_connect=y
+               fi
 
-                       if [ -n "$upstream_port" ]; then
-                               break
-                       fi
+               if [ "$upstream_connect" = "y" ]; then
+                       while true; do
+                               echo -n "Upstream IP address/hostname: "
+                               if ! read upstream_host; then
+                                       exit 1
+                               fi
 
-                       echo "Please enter the upstream instance's port."
-               done
+                               if [ -n "$upstream_host" ]; then
+                                       break
+                               fi
+
+                               echo "Please enter the upstream instance's hostname."
+                       done
+
+                       while true; do
+                               echo -n "Upstream port: "
+                               if ! read upstream_port; then
+                                       exit 1
+                               fi
+
+                               if [ -n "$upstream_port" ]; then
+                                       break
+                               fi
+
+                               echo "Please enter the upstream instance's port."
+                       done
+               fi
        fi
 
        echo "Installing the certificate bundle..."
@@ -174,8 +183,10 @@ AGENT
        echo "Enabling agent feature..."
        @CMAKE_INSTALL_FULL_SBINDIR@/icinga2-enable-feature agent
 
-       echo "Disabling notification feature..."
-       @CMAKE_INSTALL_FULL_SBINDIR@/icinga2-disable-feature notification
+       if [ "$master" = "n" ]; then
+               echo "Disabling notification feature..."
+               @CMAKE_INSTALL_FULL_SBINDIR@/icinga2-disable-feature notification
+       fi
 
        echo ""
        echo "The key bundle was installed successfully and the agent component"