coren has submitted this change and it was merged.

Change subject: Tools: Puppetize tips.sh
......................................................................


Tools: Puppetize tips.sh

Change-Id: Iad5685e0fe559108d36ae50d43c28fcce809eace
---
A modules/toollabs/files/motd-tips.sh
D modules/toollabs/files/profile-tool-labs.sh
M modules/toollabs/manifests/bastion.pp
M modules/toollabs/manifests/init.pp
4 files changed, 62 insertions(+), 13 deletions(-)

Approvals:
  coren: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/toollabs/files/motd-tips.sh 
b/modules/toollabs/files/motd-tips.sh
new file mode 100644
index 0000000..4e45159
--- /dev/null
+++ b/modules/toollabs/files/motd-tips.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Disable when non-interactive.
+if ! tty -s; then
+    return
+fi
+
+# Check if user wants to display tips.
+if [ -f ~/.suppresstips ]; then
+    return
+fi
+
+# Check if there is a tip DB.
+if [ ! -f /data/project/.system/tips ]; then
+    return
+fi
+
+# Don't display tips for root and tool accounts.
+if [ $UID -eq 0 ] || [ "${USER:0:6}" = "local-" ]; then
+    return
+fi
+
+# Check shell level.
+if [ "$SHLVL" -gt 1 ]; then
+    return
+fi
+
+# If user is sysadmin print the sysadmin motd instead.
+if groups | fgrep -qw local-admin; then
+    if [ -f /etc/motd.sysadmin ]; then
+        echo
+        echo
+        cat /etc/motd.sysadmin
+    fi
+
+    # We don't want to show tips to sysadmins.
+    return
+fi
+
+echo -e "\n\033[0;1;4mDid you know\033[0m that `shuf -n 1 
/data/project/.system/tips`\n"
diff --git a/modules/toollabs/files/profile-tool-labs.sh 
b/modules/toollabs/files/profile-tool-labs.sh
deleted file mode 100644
index 5759874..0000000
--- a/modules/toollabs/files/profile-tool-labs.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if tty -s
-then
-  [ -f /data/project/.system/tips.sh ] && /data/project/.system/tips.sh
-fi
diff --git a/modules/toollabs/manifests/bastion.pp 
b/modules/toollabs/manifests/bastion.pp
index 2e17bb0..9aaf51b 100644
--- a/modules/toollabs/manifests/bastion.pp
+++ b/modules/toollabs/manifests/bastion.pp
@@ -45,6 +45,26 @@
     source => "puppet:///modules/toollabs/sql",
   }
 
+  # Display tips.
+  package { 'grep':
+    ensure => present,
+  }
+
+  file { "/etc/profile.d/motd-tips.sh":
+    ensure => file,
+    mode => "0555",
+    owner => "root",
+    group => "root",
+    source => "puppet:///modules/toollabs/motd-tips.sh",
+    require => Package['grep'],
+  }
+
+  file { [ '/data/project/.system/tips.sh',
+           '/data/project/.system/bin/tips.sh',
+           '/data/project/.system/bin/tips2.sh' ]:
+    ensure => absent,
+  }
+
   package { [ 'jobutils', 'misctools' ]:
     ensure => latest,
   }
diff --git a/modules/toollabs/manifests/init.pp 
b/modules/toollabs/manifests/init.pp
index 841d5dc..b961a74 100644
--- a/modules/toollabs/manifests/init.pp
+++ b/modules/toollabs/manifests/init.pp
@@ -63,15 +63,9 @@
     target => "/data/project/.shared";
   }
 
-  # this file contains the motd tips and also the admin motd script
-  # in fact it just check if the shared script exist and if so
-  # it executes it
+  # Replaced by toollabs::bastion's /etc/profile.d/motd-tips.sh.
   file { "/etc/profile.d/tips.sh":
-    ensure => file,
-    source => "puppet:///modules/toollabs/profile-tool-labs.sh",
-    mode => "0555",
-    owner => "root",
-    group => "root",
+    ensure => absent,
   }
 
   file { "/root/.bashrc":

-- 
To view, visit https://gerrit.wikimedia.org/r/78486
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iad5685e0fe559108d36ae50d43c28fcce809eace
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Tim Landscheidt <[email protected]>
Gerrit-Reviewer: Tim Landscheidt <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: coren <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to