coren has submitted this change and it was merged.

Change subject: Tool labs: fix misctools for eqiad
......................................................................


Tool labs: fix misctools for eqiad

Change-Id: I877f3100576e718848f5962611fbc84b2305ef2f
---
M debian/changelog
M misctools/become
M misctools/toolwatcher
M misctools/webservice
4 files changed, 22 insertions(+), 24 deletions(-)

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



diff --git a/debian/changelog b/debian/changelog
index bc9edd9..a3b166b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+toollabs (1.0.7) unstable; urgency=low
+
+  * Marc-André Pelletier: fixes for eqiad
+
+ -- Marc-André Pelletier <mpellet...@wikimedia.org>  Fri, 28 Feb 2014 23:20:00 
-0500
+
 toollabs (1.0.6) unstable; urgency=low
 
   * Marc-André Pelletier: add webservice
diff --git a/misctools/become b/misctools/become
index fd0e2ab..2b6fbbc 100755
--- a/misctools/become
+++ b/misctools/become
@@ -15,11 +15,12 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
+prefix=$(/bin/cat /etc/wmflabs-project)
 if [ $# -lt 1 ]; then
   echo "usage: $(basename $0) <toolname> [command [args...]]" >&2
   exit 1
 fi
-if ! id "local-$1" >/dev/null 2>&1
+if ! id "$prefix.$1" >/dev/null 2>&1
 then
   echo "$(basename $0): no such tool '$1'" >&2
   exit 1
@@ -31,5 +32,5 @@
 fi
 user="$1"
 shift
-exec /usr/bin/sudo -niu "local-$user" "$@"
+exec /usr/bin/sudo -niu "$prefix.$user" "$@"
 
diff --git a/misctools/toolwatcher b/misctools/toolwatcher
index 5ce209b..0b0d6d0 100755
--- a/misctools/toolwatcher
+++ b/misctools/toolwatcher
@@ -15,38 +15,28 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
+cd /data/project/
 export HOME=/root
+prefix=$(/bin/cat /etc/wmflabs-project)
+
 while true;do
-       cd /data/project/
-       for tool in $(getent passwd | cut -d : -f 1 | sed -n 
'/^local-/{s///;p}'); do
-               if [ ! -d "/data/project/$tool" ]; then
+
+       getent passwd | grep "^$prefix\\." | cut -d : -f 1 | sed -n 
'/^[^.]*./{s///;p}' | while read tool; do
+
+               if [ ! -d "$tool" ]; then
                        logger -t toolwatcher "Creating tool $tool"
 
                        mkdir "$tool"
                        mkdir "$tool/public_html"
                        mkdir "$tool/cgi-bin"
                        chmod -R g+rw,o+r "$tool"
-                       chown -R "local-$tool:local-$tool" "$tool"
+                       chown -R "$prefix.$tool:$prefix.$tool" "$tool"
                        find "$tool" -type d | xargs chmod g+sx,o+x
                fi
 
-    if [ -r $tool/replica.my.cnf -a ! -r 
/data/project/.system/cache/localdb-$tool ]; then
-      user="$(sed -n -e "/user='\(.*\)'/{;s//\1/;p;}" $tool/replica.my.cnf)"
-      password="$(sed -n -e "/password='\(.*\)'/{;s//\1/;p;}" 
$tool/replica.my.cnf)"
-      /usr/bin/mysql -h tools-db -u root <<-END
-        grant usage on *.* to '$user'@'%' identified by '$password';
-        grant all privileges on \`${user}__%\`.* to '$user'@'%' with grant 
option;
-        grant select on \`%_p\`.* to '$user'@'%';
-END
-      touch /data/project/.system/cache/localdb-$tool
-    fi
-
-               if ! grep -q "^$tool " /data/project/.system/webservers 
>/dev/null; then
-      echo "add '$tool' to webservers again?"
-                       echo "$tool tools-webserver-01" 
>>/data/project/.system/webservers
-               fi
        done
-       cd /tmp
+
        sleep 120
+
 done
 
diff --git a/misctools/webservice b/misctools/webservice
index f39fa9d..a7503d6 100755
--- a/misctools/webservice
+++ b/misctools/webservice
@@ -1,7 +1,8 @@
 #! /bin/bash
 
-tool=$(/usr/bin/id -nu|sed -e 's/^local-//')
-user="local-$tool"
+prefix=(/bin/cat /etc/wmflabs-project)
+tool=$(/usr/bin/id -nu|sed -e "s/^$prefix.//")
+user="$prefix.$tool"
 home=$(getent passwd $user | cut -d : -f 6 | sed -e 's/\/$//')
 if [ "$(getent group $user | cut -d : -f 1)" != "$user" ]; then
     echo "$0: $tool does not appear to be a tool" >&2

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I877f3100576e718848f5962611fbc84b2305ef2f
Gerrit-PatchSet: 1
Gerrit-Project: labs/toollabs
Gerrit-Branch: master
Gerrit-Owner: coren <mpellet...@wikimedia.org>
Gerrit-Reviewer: coren <mpellet...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to