Title: [opsview] [11361] Fix profiles on debian based systems
- Revision
- 11361
- Author
- dferguson
- Date
- 2013-02-06 11:48:26 +0000 (Wed, 06 Feb 2013)
Log Message
Fix profiles on debian based systems
On debian based systems sometimes sudo uses .profile and other times .bashrc, so make sure the opsview profile is added to all appropriate files, not just the first found.
Modified Paths
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2013-02-06 10:36:01 UTC (rev 11360)
+++ trunk/CHANGES 2013-02-06 11:48:26 UTC (rev 11361)
@@ -60,6 +60,7 @@
Fixed possible error message on RH systems when using init scripts
Fixed bug with community string in check_snmp_netscreen_activesessions and check_snmp_netscreen_cpu
Fixed resetting of UUID when known bad UUIDs detected
+ Fixed adding opsview profile to both .profile and .bashrc files
3.20120925
FEATURES:
Modified: trunk/opsview-core/installer/set_profile
===================================================================
--- trunk/opsview-core/installer/set_profile 2013-02-06 10:36:01 UTC (rev 11360)
+++ trunk/opsview-core/installer/set_profile 2013-02-06 11:48:26 UTC (rev 11361)
@@ -45,28 +45,34 @@
done
cd $HOME
+
+# make sure line is added to all files that exist, not just the first found
+# to fix problem with sudo on .deb based systems
+done=
for FILE in .bashrc .bash_profile .bash_login .kshrc .profile
do
- if [ -f $FILE ] && [ `grep -c nagios/bin/profile $FILE` -gt 0 ]; then
- exit 0
- fi
-done
-for FILE in .bashrc .bash_profile .bash_login .kshrc .profile
-do
- if [ -f $FILE ] && [ `grep -c nagios/bin/profile $FILE` -lt 1 ]; then
- echo "test -f /usr/local/nagios/bin/profile && . /usr/local/nagios/bin/profile" >> $FILE
- if [[ -n "$devserver" ]]; then
- echo "test -f /usr/local/nagios/bin/profile_dev && . /usr/local/nagios/bin/profile_dev" >> .profile
+ if [ -f $FILE ]; then
+ if [ `grep -c nagios/bin/profile $FILE` -lt 1 ]; then
+ echo "test -f /usr/local/nagios/bin/profile && . /usr/local/nagios/bin/profile" >> $FILE
fi
-# chown nagios.nagios $FILE
- exit 0
+ if [[ -n "$devserver" ]] && [ `grep -c nagios/bin/profile_dev $FILE` -lt 1 ]; then
+ echo "test -f /usr/local/nagios/bin/profile_dev && . /usr/local/nagios/bin/profile_dev" >> .profile
+ fi
+ done=1
fi
done
+if [ "x$done" != "x" ]; then
+ exit 0
+fi
+
# No shell files exist (possible in Debian because adduser --system doesn't create)
-echo >> .profile
-echo "test -f /usr/local/nagios/bin/profile && . /usr/local/nagios/bin/profile" >> .profile
+for FILE in .profile .bashrc
+do
+ echo >> $FILE
+ echo "test -f /usr/local/nagios/bin/profile && . /usr/local/nagios/bin/profile" >> $FILE
-if [[ -n "$devserver" ]]; then
- echo "test -f /usr/local/nagios/bin/profile_dev && . /usr/local/nagios/bin/profile_dev" >> .profile
-fi
+ if [[ -n "$devserver" ]]; then
+ echo "test -f /usr/local/nagios/bin/profile_dev && . /usr/local/nagios/bin/profile_dev" >> $FILE
+ fi
+done
_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins