From 4736d7739b559c23a829a6962b3aad035ba0e7e2 Mon Sep 17 00:00:00 2001 From: Monocots Date: Wed, 9 Jun 2021 02:10:42 +0000 Subject: [PATCH] Add misc/fixes Includes bot alert and misc files in /tmp/tmp --- modules/rhizo_base/files/tmp/fix.sh | 14 ++++++++ modules/rhizo_base/manifests/fixes.pp | 3 ++ modules/rhizo_base/manifests/misc.pp | 42 +++++++++++++++++++++++ modules/rhizo_base/templates/alert.sh.erb | 24 +++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 modules/rhizo_base/files/tmp/fix.sh create mode 100644 modules/rhizo_base/manifests/misc.pp create mode 100644 modules/rhizo_base/templates/alert.sh.erb diff --git a/modules/rhizo_base/files/tmp/fix.sh b/modules/rhizo_base/files/tmp/fix.sh new file mode 100644 index 0000000..c0baa8d --- /dev/null +++ b/modules/rhizo_base/files/tmp/fix.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Hacks... + +if [ "$PWD" != "/var/SysmoBTS" ]; then + OLDPWD=$PWD + cd /var/SysmoBTS +fi + +# Nothing to do. + +if [ "$OLDPWD" != "" ]; then + cd $OLDPWD +fi diff --git a/modules/rhizo_base/manifests/fixes.pp b/modules/rhizo_base/manifests/fixes.pp index fcb3764..e06831b 100644 --- a/modules/rhizo_base/manifests/fixes.pp +++ b/modules/rhizo_base/manifests/fixes.pp @@ -12,6 +12,9 @@ # class rhizo_base::fixes { + + include rhizo_base::misc + contain "rhizo_base::fixes::$operatingsystem" file { '/etc/tmux.conf': diff --git a/modules/rhizo_base/manifests/misc.pp b/modules/rhizo_base/manifests/misc.pp new file mode 100644 index 0000000..8195685 --- /dev/null +++ b/modules/rhizo_base/manifests/misc.pp @@ -0,0 +1,42 @@ +# Class: rhizo_base::misc +# +# This module implements various tweaks +# that may be experimental +# + +class rhizo_base::misc { + + file { '/tmp/tmp': + ensure => directory, + source => 'puppet:///modules/rhizo_base/tmp/', + recurse => remote, + } + + $bot_alert_url = hiera('rhizo::alert_url') + + file { '/usr/local/bin/alert.sh': + ensure => present, + mode => '0750', + content => template('rhizo_base/alert.sh.erb'), + } + + $svc_name = "Boot Alert" + $svc_command = '/usr/local/bin/alert.sh %H esta arrancado' + + file { '/lib/systemd/system/boot_alert.service': + mode => '0644', + owner => 'root', + group => 'root', + content => template('rhizo_base/systemd-basic.service.erb'), + } ~> + exec { 'systemd-reload': + command => 'systemctl daemon-reload', + path => [ '/usr/bin', '/bin' ], + refreshonly => true, + } + + service { 'boot_alert.service': + enable => true, + } + +} diff --git a/modules/rhizo_base/templates/alert.sh.erb b/modules/rhizo_base/templates/alert.sh.erb new file mode 100644 index 0000000..d0c8652 --- /dev/null +++ b/modules/rhizo_base/templates/alert.sh.erb @@ -0,0 +1,24 @@ +#!/bin/bash + +# Send an Alert via IM system + +rawurlencode() { + local string="${@}" + local strlen=${#string} + local encoded="" + local pos c o + + for (( pos=0 ; pos$_ALERT"