diff --git a/2.Common_services/2.NTP/0_setup.py b/2.Common_services/2.NTP/0_setup.py index b5c15bb375e9d240f89c5a4f460c0e59fc36b212..c562acfc0a87bfd2b9a84cc735cae4f4cd204784 100644 --- a/2.Common_services/2.NTP/0_setup.py +++ b/2.Common_services/2.NTP/0_setup.py @@ -9,7 +9,7 @@ def setup(interactive=True): # NTP 'echo "Replacing /etc/ntp.conf"', dict(line='write', template='%s/ntp.conf' % dir_path, target='/etc/ntp.conf', params=( - ('{{ NTP_SERVER1 }}', utils.get_conf('NTP_SERVER1') or 'ntp.ubuntu.com'), + ('{{ NTP_SERVER }}', utils.get_conf('NTP_SERVER') or utils.get_conf('NTP_SERVER1') or 'ntp.ubuntu.com'), )), 'service ntp restart', ] diff --git a/2.Common_services/2.NTP/ntp.conf b/2.Common_services/2.NTP/ntp.conf index 4a0077d8af5473118f81976a46447ffe5f95528e..b37943fb240f1ca4c897318b643238f1e2f44d25 100644 --- a/2.Common_services/2.NTP/ntp.conf +++ b/2.Common_services/2.NTP/ntp.conf @@ -21,8 +21,8 @@ server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org -# Use Ubuntu's ntp server as a fallback. -server {{ NTP_SERVER1 }} +# Fallback server. +server {{ NTP_SERVER }} # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> diff --git a/20.Client_configuration/1.Apply_client_configuration/0_setup.sh b/20.Client_configuration/1.Apply_client_configuration/0_setup.sh index 6317dc1265aa3a4cd4f2e281898de95371740e8f..7fa75fd1052d7febc7ce44db6e40f3af34cbd32c 100755 --- a/20.Client_configuration/1.Apply_client_configuration/0_setup.sh +++ b/20.Client_configuration/1.Apply_client_configuration/0_setup.sh @@ -25,16 +25,9 @@ echo "nameserver ${NETWORK_DNS2}" >> /etc/resolv.conf # set customer NTP sed -i "s@^server .*@@" /etc/ntp.conf echo "" >> /etc/ntp.conf -echo "server ${NTP_SERVER1}" >> /etc/ntp.conf - -if ( ! test -z ${NTP_SERVER2} ) -then -echo "server ${NTP_SERVER2}" >> /etc/ntp.conf -fi - -if ( ! test -z ${NTP_SERVER3} ) +if ( ! test -z ${NTP_SERVER} ) then -echo "server ${NTP_SERVER3}" >> /etc/ntp.conf +echo "server ${NTP_SERVER}" >> /etc/ntp.conf fi service ntp restart diff --git a/3.New_server_deployment/3.Initialize_APT/0_setup.sh b/3.New_server_deployment/3.Initialize_APT/0_setup.sh deleted file mode 100755 index f47a48d485a2d764e7a78be038fb518d62daf790..0000000000000000000000000000000000000000 --- a/3.New_server_deployment/3.Initialize_APT/0_setup.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -source /root/envsetup/global-conf.sh - -# modify sources.list to use ubicast cache -if ( ! test -z ${APT_CACHE_HOST} ); then - if ( ! grep "${APT_CACHE_HOST}" /etc/apt/sources.list >/dev/null ); then - echo "Updating sources.list to use cache ${APT_CACHE_HOST}." - sed -i "s@http://@http://${APT_CACHE_HOST}/@" /etc/apt/sources.list - fi -fi - -# migrate to Ubuntu 16.04 / apply sources.list -if ( rgrep '14.04' /etc/lsb-release >/dev/null ); then - echo "Upgrading to Ubuntu 16.04." - apt-get update - apt-get dist-upgrade -y - cp sources16.list /etc/apt/sources.list - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -o Dpkg::Options::="--force-confold" --force-yes -y - apt-get install -f -y - apt-get dist-upgrade -y -else - echo "Updating Ubuntu 16.04 sources.list file." - cp sources16.list /etc/apt/sources.list - apt-get update - apt-get dist-upgrade -y -fi - -# APT https support -apt-get install -y apt-transport-https - -# APT panel -if ( ! test -z ${SKYREACH_API_KEY} ); then - echo "Adding skyreach.list to APT sources." - wget -q "https://${SKYREACH_HOST}/media/public.gpg" -O- | sudo apt-key add - - echo "deb https://${SKYREACH_HOST} packaging/apt/${SKYREACH_API_KEY}/" > /etc/apt/sources.list.d/skyreach.list -fi - -# update -apt-get update -apt-get dist-upgrade -y - -# unattended-upgrades -echo "Installing and configuring unattended-upgrades." -apt-get install -y unattended-upgrades -sed -i 's@//Unattended-Upgrade::Mail "root";@Unattended-Upgrade::Mail "root";@' /etc/apt/apt.conf.d/50unattended-upgrades -sed -i 's@//*.*"vim";@"mysql-server";@' /etc/apt/apt.conf.d/50unattended-upgrades -sed -i 's@//*.*"libc6";@"mysql-client";@' /etc/apt/apt.conf.d/50unattended-upgrades diff --git a/1.Base/4.Proxy_settings/0_setup.py b/3.New_server_deployment/3.Proxy_settings/0_setup.py similarity index 100% rename from 1.Base/4.Proxy_settings/0_setup.py rename to 3.New_server_deployment/3.Proxy_settings/0_setup.py diff --git a/3.New_server_deployment/4.APT_upgrade/0_setup.sh b/3.New_server_deployment/4.APT_upgrade/0_setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..793ab1006f16baa12b3ee41f03eb2c9829737088 --- /dev/null +++ b/3.New_server_deployment/4.APT_upgrade/0_setup.sh @@ -0,0 +1,65 @@ +#!/bin/bash +source /root/envsetup/global-conf.sh + +# move 50unattended-upgrades conf if any +if ( ls /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist 2>&1 >/dev/null ); then + mv /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist /etc/apt/apt.conf.d/50unattended-upgrades +fi + +# update sources.list +rm -f /etc/apt/sources.list~ +echo "Updating sources.list file." +cp sources16.list /etc/apt/sources.list +if ( rgrep '14.04' /etc/lsb-release >/dev/null ); then + sed -i 's@xenial@trusty@' /etc/apt/sources.list +fi + +# modify sources.list to use ubicast cache +if ( ! test -z ${APT_CACHE_HOST} ); then + if ( ! grep "${APT_CACHE_HOST}" /etc/apt/sources.list >/dev/null ); then + echo "Updating sources.list to use cache ${APT_CACHE_HOST}." + sed -i "s@http://@http://${APT_CACHE_HOST}/@" /etc/apt/sources.list + fi +fi + +# update packages +DEBIAN_FRONTEND=noninteractive +export DEBIAN_FRONTEND +apt-get update +apt-get install -f -y -o Dpkg::Options::="--force-confold" +apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" +apt-get install -y apt-transport-https +apt-get autoremove -y + +# migrate to Ubuntu 16.04 if needed +if ( rgrep '14.04' /etc/lsb-release >/dev/null ); then + echo "Upgrading to Ubuntu 16.04." + sed -i 's@trusty@xenial@' /etc/apt/sources.list + apt-get update + apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" || apt-get install -f -y -o Dpkg::Options::="--force-confold" + apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" || apt-get install -f -y -o Dpkg::Options::="--force-confold" + apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" + apt-get autoremove -y + echo "16.04 migration ok." + echo "The server is rebooting, please wait at least 2 minutes" + echo " before restarting the script to continue the configuration." + echo "Date: $(date)." + echo "Ignore the following message about reboot problem if any." + reboot + exit 1 +fi +systemctl unmask nginx || true + +# APT panel +if ( ! test -z ${SKYREACH_API_KEY} ); then + echo "Adding skyreach.list to APT sources." + wget -q "https://${SKYREACH_HOST}/media/public.gpg" -O- | sudo apt-key add - + echo "deb https://${SKYREACH_HOST} packaging/apt/${SKYREACH_API_KEY}/" > /etc/apt/sources.list.d/skyreach.list +fi + +# update +apt-get update +apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" + +# unattended-upgrades +apt-get install -y unattended-upgrades diff --git a/3.New_server_deployment/3.Initialize_APT/sources16.list b/3.New_server_deployment/4.APT_upgrade/sources16.list similarity index 100% rename from 3.New_server_deployment/3.Initialize_APT/sources16.list rename to 3.New_server_deployment/4.APT_upgrade/sources16.list diff --git a/3.New_server_deployment/4.Dell_openmanage/0_setup.sh b/3.New_server_deployment/5.Dell_openmanage/0_setup.sh similarity index 100% rename from 3.New_server_deployment/4.Dell_openmanage/0_setup.sh rename to 3.New_server_deployment/5.Dell_openmanage/0_setup.sh diff --git a/global-conf.sh b/global-conf.sh index da2822ab88fba4d801219873eb226a92ba83abfd..36fe5195061e7d7ee60d03b878c9a07598f52e71 100644 --- a/global-conf.sh +++ b/global-conf.sh @@ -17,14 +17,12 @@ NC='\033[0m' SKYREACH_HOST='panel.ubicast.eu' SKYREACH_API_KEY= # NTP -NTP_SERVER1='ntp.ubuntu.com' -NTP_SERVER2= -NTP_SERVER3= +NTP_SERVER='ntp.ubuntu.com' # SSL certificate SSL_CERTIFICATE='/etc/ssl/certs/ssl-cert-snakeoil.pem' SSL_CERTIFICATE_KEY='/etc/ssl/private/ssl-cert-snakeoil.key' # APT sources -APT_CACHE_HOST='panel.ubicast.eu' +APT_CACHE_HOST= # -- Shell -- # ubicast shell account diff --git a/launcher.sh b/launcher.sh index dc38bc30955ff1a9615486c9a9a8f3fc8e992c1f..880ff184cf8311baff0f9e20b85f6177df93f9bb 100755 --- a/launcher.sh +++ b/launcher.sh @@ -20,6 +20,7 @@ init() { python3 /root/envsetup/envsetup.py 32 python3 /root/envsetup/envsetup.py 33 python3 /root/envsetup/envsetup.py 34 + python3 /root/envsetup/envsetup.py 35 python3 /root/envsetup/envsetup.py 11 python3 /root/envsetup/envsetup.py 12 diff --git a/tests/test_ntp.py b/tests/test_ntp.py index 5764e1bb4bd6da9ff4b89b7c071ad4d919a57016..393a582c13df3369bf075ea0a194d376a7cbce32 100755 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Copyright 2017, Florent Thiery ''' -Check that the server is synchronized with the configured NTP server +Check that the server is synchronized with the configured NTP server. ''' import os import sys @@ -24,7 +24,7 @@ print('Checking NTP server conforms to conf') if os.path.isfile('../utils.py'): es_utils = imp.load_source('es_utils', '../utils.py') conf = es_utils.load_conf() - NTP_SERVER = conf.get('NTP_SERVER1') + NTP_SERVER = conf.get('NTP_SERVER') or conf.get('NTP_SERVER1') or 'ntp.ubuntu.com' with open('/etc/ntp.conf', 'r') as f: d = f.read()