diff --git a/modules/rhizo_base/files/ssh/config b/modules/rhizo_base/files/ssh/config index 03cb6d1..aa4ba0d 100644 --- a/modules/rhizo_base/files/ssh/config +++ b/modules/rhizo_base/files/ssh/config @@ -3,3 +3,7 @@ Include ~/.ssh/config2 Host dev.rhizomatica.org Hostname dev.rhizomatica.org IdentityFile ~/.ssh/bsc_dev + +Host 172.16.0.* + User root + IdentityFile ~/.ssh/bts_key diff --git a/modules/rhizo_base/files/var/SysmoBTS/authorized_keys b/modules/rhizo_base/files/var/SysmoBTS/authorized_keys new file mode 100644 index 0000000..83ad39a --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/authorized_keys @@ -0,0 +1,2 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDB91GjYXXkQmawOsLuGIBM3/V6BoCuXYiFr+Zokn+zTi9g1WwFL+wR4W2KSdGwUZT1TUi1O2IeQiQhQnR9A0eBLLYAgLVIP+Zs10k34qbPeMP7fdUr73hFQU9ruTCLtfczL4EqouXov6EybVX31f5OHvhDRPwNn6ERfpD3RZK0D0D5KaJLSWqL7fgQiPLbDD2+WzZlJWTcdiT3TQc0AmpYL0MG8GZYJXZy4pJWY3tigBSMoNbOyEOQ1/wMAWhs+NjmECz/95AkEFUg/WxvDKcnd70mxckvgMrTJu1Gn2u4FtQ9c164GOgVIg36KEV+a+DyNdvptmtyY+cm1zsCWCub + diff --git a/modules/rhizo_base/files/var/SysmoBTS/led.service b/modules/rhizo_base/files/var/SysmoBTS/led.service index e8c5849..6d99214 100644 --- a/modules/rhizo_base/files/var/SysmoBTS/led.service +++ b/modules/rhizo_base/files/var/SysmoBTS/led.service @@ -8,3 +8,4 @@ Type=oneshot [Install] WantedBy=default.target + diff --git a/modules/rhizo_base/files/var/SysmoBTS/leds.sh b/modules/rhizo_base/files/var/SysmoBTS/leds.sh old mode 100755 new mode 100644 diff --git a/modules/rhizo_base/files/var/SysmoBTS/master/gpsd b/modules/rhizo_base/files/var/SysmoBTS/master/gpsd new file mode 100644 index 0000000..73cea1e --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/master/gpsd @@ -0,0 +1,5 @@ +# If you must specify a non-NMEA driver, uncomment and modify the next line +GPSD_SOCKET="/var/run/gpsd.sock" +GPSD_OPTIONS="-n -G" +GPS_DEVICES="/dev/ttyS2" + diff --git a/modules/rhizo_base/files/var/SysmoBTS/master/ntp.conf b/modules/rhizo_base/files/var/SysmoBTS/master/ntp.conf new file mode 100644 index 0000000..e6e7466 --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/master/ntp.conf @@ -0,0 +1,16 @@ +driftfile /etc/ntp.drift + +# GPS Serial data reference (NTP0) +server 127.127.28.0 +fudge 127.127.28.0 refid GPS + +# GPS PPS reference (NTP1) +server 127.127.28.1 prefer +fudge 127.127.28.1 refid PPS + +# Defining a default security setting + +restrict 127.0.0.1 mask 255.255.255.0 +restrict 0.0.0.0 netmask 0.0.0.0 nomodify notrap + +logfile /var/log/ntp.log \ No newline at end of file diff --git a/modules/rhizo_base/files/var/SysmoBTS/provision.sh b/modules/rhizo_base/files/var/SysmoBTS/provision.sh new file mode 100644 index 0000000..8d6b0e7 --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/provision.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This script will copy files to the 2050 BTS(s) on the site +# running the script more than once should be safe. + +if [ "$PWD" != "/var/SysmoBTS" ]; then + OLDPWD=$PWD + cd /var/SysmoBTS +fi +SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/tmp/known-$RANDOM" +. /home/rhizomatica/bin/vars.sh + +for bts in "${!BTS[@]}" ; do + + scp $SSH_OPTS authorized_keys root@${BTS[$bts]}:/home/root/.ssh/ + scp $SSH_OPTS udhcpc root@${BTS[$bts]}:/etc/default/udhcpc + ssh $SSH_OPTS root@${BTS[$bts]} "echo 'root:$BTSPASS' | /usr/sbin/chpasswd" + ssh $SSH_OPTS root@${BTS[$bts]} "date -s '$(date)'" + + if [ "$(ssh $SSH_OPTS ${BTS[$bts]} sysmobts-util trx-nr)" == "0" ] ; then + # Master Verified. + echo "BTS is a 2050 Master" + ssh $SSH_OPTS root@${BTS[$bts]} "echo '$SITE-Master-$bts' > /etc/hostname; echo nameserver 1.1.1.1 > /etc/resolv.conf; echo nameserver 9.9.9.9 >> /etc/resolv.conf" + scp $SSH_OPTS master/gpsd root@${BTS[$bts]}:/etc/default/gpsd + scp $SSH_OPTS master/ntp.conf root@${BTS[$bts]}:/etc/ntp.conf + scp $SSH_OPTS leds.sh root@${BTS[$bts]}:/etc/init.d/leds.sh + scp $SSH_OPTS led.service root@${BTS[$bts]}:/lib/systemd/system/led.service + scp $SSH_OPTS osmo-bts.service root@${BTS[$bts]}:/lib/systemd/system/osmo-bts.service + fi + + if [ "$(ssh $SSH_OPTS ${BTS[$bts]} sysmobts-util trx-nr)" == "1" ] ; then + # Slave Verified. + echo "BTS is a 2050 Slave" + ssh $SSH_OPTS root@${BTS[$bts]} "echo '$SITE-Slave-$bts' > /etc/hostname; echo nameserver 1.1.1.1 > /etc/resolv.conf; echo nameserver 9.9.9.9 >> /etc/resolv.conf" + scp $SSH_OPTS slave/gpsdate root@${BTS[$bts]}:/etc/default/gpsdate + fi + +done + +if [ "$OLDPWD" != "" ]; then + cd $OLDPWD +fi diff --git a/modules/rhizo_base/files/var/SysmoBTS/slave/gpsdate b/modules/rhizo_base/files/var/SysmoBTS/slave/gpsdate new file mode 100644 index 0000000..0a6c393 --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/slave/gpsdate @@ -0,0 +1,2 @@ +GPSDATE_HOST=172.16.0.11 +GPSDATE_PORT=2947 diff --git a/modules/rhizo_base/files/var/SysmoBTS/udhcpc b/modules/rhizo_base/files/var/SysmoBTS/udhcpc new file mode 100644 index 0000000..722e69b --- /dev/null +++ b/modules/rhizo_base/files/var/SysmoBTS/udhcpc @@ -0,0 +1,5 @@ +# Uncomment the following line, if udhcpc should not touch /etc/resolv.conf +STATIC_DNS="yes" + +# Uncomment the following line if udhcpc should not install a default route +#INSTALL_DEFAULT_ROUTE="no" diff --git a/modules/rhizo_base/manifests/init.pp b/modules/rhizo_base/manifests/init.pp index 4fcf032..cf77bad 100644 --- a/modules/rhizo_base/manifests/init.pp +++ b/modules/rhizo_base/manifests/init.pp @@ -46,6 +46,7 @@ class rhizo_base { #BTSs configuration $bts = hiera('rhizo::bts') + $bts_pass = hiera('rhizo::bts_pass') $bts_type = hiera('rhizo::bts_type') $bts_amps = hiera('rhizo::bts_amps', "on") $bts1_ip_address = hiera('rhizo::bts1_ip_address') @@ -491,6 +492,22 @@ schedule { 'repo': mode => '0750' } + file { '/var/SysmoBTS/provision.sh': + source => 'puppet:///modules/rhizo_base/var/SysmoBTS/provision.sh', + mode => '0750' + } + + file { '/var/SysmoBTS/chk_masq': + source => 'puppet:///modules/rhizo_base/var/SysmoBTS/chk_masq', + mode => '0750' + } + + file { '/root/.ssh/bts_key': + ensure => present, + mode => '0600', + content => hiera('rhizo::bts_key'), + } + file { '/var/log/rccn': ensure => link, target => '/var/rhizomatica/rccn/log', diff --git a/modules/rhizo_base/templates/vars.sh.erb b/modules/rhizo_base/templates/vars.sh.erb index 259dfcf..98637c2 100644 --- a/modules/rhizo_base/templates/vars.sh.erb +++ b/modules/rhizo_base/templates/vars.sh.erb @@ -6,6 +6,8 @@ function logc() { echo "[`date '+%d-%m-%Y %H:%M:%S'`] $txt" >> $LOGFILE } +SITE=<%= @site_name %> + #BTSs IP addresses (for amps etc) declare -a BTS declare -a BTS_MASTER @@ -17,6 +19,8 @@ BTS_MASTER[<%= index %>]=<%= bts["ip"] %> <% end -%> <% end -%> +BTSPASS=<%= @bts_pass %> + LATENCY_HOST=<%= @latency_check_address %> LATENCY_TINC=<%= @latency_check_vpn %> STAT_DISK=<%= @stats_disk %>