diff --git a/ec2-create-ce b/ec2-create-ce index 916808e..14ccd48 100755 --- a/ec2-create-ce +++ b/ec2-create-ce @@ -209,18 +209,9 @@ wait_for_ssh() { } get_status() { - case "${NGCP_VERSION}" in - 2.*|3.*|mr[3-6].*|mr7.[0-4]*) - if ssh_wrapper "grep 'System configured' -q /etc/sipwise_ngcp_version"; then - echo "finished" - fi - ;; - *) - local status='' - status=$(wget --timeout=30 -q -O- "${HOSTNAME}:4242/status" || true) - echo "${status}" - ;; - esac + local status='' + status=$(wget --timeout=30 -q -O- "${HOSTNAME}:4242/status" || true) + echo "${status}" } wait_for_configuration() { @@ -427,17 +418,6 @@ fi AMI_DESCRIPTION="Official sip:provider CE AMI for release ${NGCP_VERSION} [${DATE_STRING}]" -case "${NGCP_RELEASE}" in - 2.*|3.*|mr3.*|mr4.*|mr5.*|mr6.0*|mr6.1*) - echo "*** ngcp release ${NGCP_RELEASE} doesn't support systemd" - SYSTEMD_SUPPORT=false - ;; - *) - echo "*** ngcp release ${NGCP_RELEASE} supports systemd" - SYSTEMD_SUPPORT=true - ;; -esac - USER_DATA_FILE="$(mktemp)" cat > "${USER_DATA_FILE}" << EOF #!/bin/bash @@ -454,37 +434,11 @@ if [ -f /etc/apt/sources.list.d/debian.sources ] && grep -q -- '-backports' /etc echo "backports is unexpected, disabling from /etc/apt/sources.list.d/debian.sources" sed -i -E 's/ [a-z]+-backports//' /etc/apt/sources.list.d/debian.sources fi - -if [ "${SYSTEMD_SUPPORT}" = "false" ] && [ -d /run/systemd/system ] ; then - echo "Switching from systemd to sysvinit (pre-reboot)" - apt update - apt install --yes sysvinit-core - echo "Rebooting now to switch from systemd to sysvinit" - #Temporary crontab to restart installer after reboot - (crontab -l ; echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") | crontab - - (crontab -l ; echo "@reboot FORCE=yes /usr/sbin/ngcp-installer 2>&1 | tee -a /var/log/ngcp-installer-debug.log") | crontab - - reboot -fi - -# workaround for mr4.2.1 -export HOME=/root/ EOF -init_configuration=false -case "${NGCP_RELEASE}" in - 2.8|3.*|mr[3-5].*|mr6.[0-4]*) - echo "*** ngcp release ${NGCP_RELEASE} doesn't have configuration tools" - ;; - *) - echo "*** ngcp release ${NGCP_RELEASE} has configuration tools" - init_configuration=true - ;; -esac - -if "${init_configuration}" ; then - cat >> "${USER_DATA_FILE}" << EOF +cat >> "${USER_DATA_FILE}" << EOF sed_regexp='' sed_regexp+='s/^(export FORCE)=.+$/\1=yes/;' sed_regexp+='s/^(export DHCP)=.+$/\1=true/;' @@ -503,12 +457,6 @@ while [[ "\${attempt}" -lt "\${max_attempt}" ]]; do done exit \${rc} EOF -else - cat >> "${USER_DATA_FILE}" << EOF -FORCE=yes ngcp-installer 2>&1 | tee -a /var/log/ngcp-installer-debug.log -[[ -f /tmp/ngcp-installer.log ]] && cp /tmp/ngcp-installer.log /var/log/ngcp-installer.log -EOF -fi echo "*** Generated the following user-data file:" cat "${USER_DATA_FILE}" @@ -580,10 +528,7 @@ HOSTNAME="$(aws ec2 describe-instances --region "${AWS_REGION}" --filter "Name=i retry=360 # up to 30 minutes FINISHED_NGCP_CE_INSTALLATION=false -install_log_file='/var/log/ngcp-installer-debug.log' -if "${init_configuration}" ; then - install_log_file='/var/log/ngcp-installer.log' -fi +install_log_file='/var/log/ngcp-installer.log' while [ "${FINISHED_NGCP_CE_INSTALLATION}" != "true" ] && [ ${retry} -ne 0 ] ; do ssh_wrapper "grep -q 'Installation finished. Thanks for choosing' ${install_log_file}" RC=$? @@ -636,17 +581,15 @@ else fi success=true -if "${init_configuration}"; then - echo "Configuring system..." - ssh_wrapper "sudo screen -dm bash -c 'ngcp-initial-configuration'" - wait_for_configuration || success=false - echo "Trying to retrieve ngcp-installer.log file after configuration" - scp \ - -o "StrictHostKeyChecking=no" \ - -o "UserKnownHostsFile=/dev/null" \ - -i "${KEY_FILE}" \ - "admin@${HOSTNAME}":/var/log/ngcp-installer\*log ./ || true -fi +echo "Configuring system..." +ssh_wrapper "sudo screen -dm bash -c 'ngcp-initial-configuration'" +wait_for_configuration || success=false +echo "Trying to retrieve ngcp-installer.log file after configuration" +scp \ + -o "StrictHostKeyChecking=no" \ + -o "UserKnownHostsFile=/dev/null" \ + -i "${KEY_FILE}" \ + "admin@${HOSTNAME}":/var/log/ngcp-installer\*log ./ || true # now check for available ssh connection and nginx listening on port 1443 retry=120 # up to 10 minutes