summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Filion <gabster@lelutin.ca>2014-03-12 16:26:42 -0400
committerGabriel Filion <gabster@lelutin.ca>2014-03-12 16:26:42 -0400
commit0f817282af914c531dcbe19c1be6ac3209986984 (patch)
treed76ce0e88c2fa53d673dceb4843cece0be51063a
parent102de3b0e7c6e2f1ace419e028ed1c3920735d42 (diff)
parent3c93ba233924d640c77a5b4d153360d1636d0964 (diff)
Merge branch 'mention_path'
-rw-r--r--README7
-rw-r--r--files/scripts/CentOS/setmysqlpass.sh20
-rw-r--r--files/scripts/Debian/setmysqlpass.sh21
3 files changed, 48 insertions, 0 deletions
diff --git a/README b/README
index dde3203..f0ef1ed 100644
--- a/README
+++ b/README
@@ -16,6 +16,13 @@ installed, specifically it must have nagios::plugin::deploy functionality.
You will need to have activated storedconfigs on the puppetmaster.
+You need to ensure that the PATH environment variable contains the appropriate
+directories else the root password will not be set correctly to the requested
+value. Since the variable is empty by default when running puppet, you need to
+have something similar to this somewhere in your manifests:
+
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
+
Special Notes
=============
diff --git a/files/scripts/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh
index 01d8fbf..b643edb 100644
--- a/files/scripts/CentOS/setmysqlpass.sh
+++ b/files/scripts/CentOS/setmysqlpass.sh
@@ -2,6 +2,26 @@
test -f /root/.my.cnf || exit 1
+must_have ()
+{
+ # Here, using "which" would not be appropriate since it also depends on
+ # PATH being set correctly. The type builtin command is unaffected by the
+ # environment.
+ type $1 >/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Command '$1' not found, did you correctly set PATH ? Its current value is: $PATH" >&2
+ exit 1
+ fi
+}
+
+# Since this script is doing something rather unsafe with the database, we want
+# to be really careful to have all the necessary tools before doing anything so
+# that we don't end up in an inconsistent state.
+must_have sleep
+must_have mysql
+must_have killall
+must_have chown
+
rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/')
/sbin/service mysqld stop
diff --git a/files/scripts/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh
index f7d5357..f4ebee6 100644
--- a/files/scripts/Debian/setmysqlpass.sh
+++ b/files/scripts/Debian/setmysqlpass.sh
@@ -2,6 +2,27 @@
test -f /root/.my.cnf || exit 1
+must_have ()
+{
+ # Here, using "which" would not be appropriate since it also depends on
+ # PATH being set correctly. The type builtin command is unaffected by the
+ # environment.
+ type $1 >/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Command '$1' not found, did you correctly set PATH ? Its current value is: $PATH" >&2
+ exit 1
+ fi
+}
+
+# Since this script is doing something rather unsafe with the database, we want
+# to be really careful to have all the necessary tools before doing anything so
+# that we don't end up in an inconsistent state.
+must_have sleep
+must_have mysql
+must_have killall
+must_have ls
+must_have chown
+
rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/')
/etc/init.d/mysql stop