[mirrorbrain-commits] r8314 - /trunk/tools/create_timestamp

From: <poeml_at_mirrorbrain.org>
Date: Thu, 02 Jan 2014 21:18:42 -0000
Author: poeml
Date: Thu Jan  2 22:18:41 2014
New Revision: 8314

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8314&view=rev
Log:
create_timestamp script:
- make it openSUSE-independent. Usage:

  create_timestamp [username:groupname] timestampfile1 [timestampfile2...]

Modified:
    trunk/tools/create_timestamp

Modified: trunk/tools/create_timestamp
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/tools/create_timestamp?rev=8314&r1=8313&r2=8314&view=diff
==============================================================================
--- trunk/tools/create_timestamp	(original)
+++ trunk/tools/create_timestamp	Thu Jan  2 22:18:41 2014
_at_@ -12,7 +12,7 @@
 #
 # 
 # Copyright 2008,2009 Peter Poeml <poeml_at_cmdline.net>, Novell Inc.
-# Copyright 2008,2009,2010,2011,2012 Peter Poeml <poeml_at_cmdline.net>
+# Copyright 2008-2014 Peter Poeml <poeml_at_cmdline.net>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License version 2
_at_@ -30,6 +30,7 @@
 
 
 import os
+import sys
 import time
 import tempfile
 import pwd, grp
_at_@ -38,15 +39,19 @@
 utc = time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime())
 
 explanation = """
-Should you wonder about this file, it serves as timestamp that can be
+Should you wonder about this file, it supplies timestamps that can be
 used to assess possible lags in mirroring.
+
+These are not used by MirrorBrain for mirror checking, but can help
+human beings with verifying a mirrors setup. (Maybe MirrorBrain could/should
+make use of these timestamps in the future.)
 
 In addition, the .timestamp_invisible is supposed to be not visible
 through HTTP, FTP or rsync. This serves to ensure that a mirrors's
 permission setup is correct. Keeping certain files temporarily
-unreadable is an important step in the process of publishing content.
+unreadable can be an important step in the process of publishing content.
 
-Feel free to contact admin at opensuse org for more information!
+Feel free to contact mirrorbrain at mirrorbrain org for more information;
 Thanks.
 
 """
_at_@ -57,16 +62,27 @@
             '/srv/ftp-stage/pub/opensuse/distribution/.timestamp',
             '/srv/ftp-stage/pub/opensuse/distribution/.timestamp_invisible' ]
 
+if len(sys.argv) < 2:
+    sys.exit("""Missing argument.
+Usage: 
+
+  %s [username:groupname] timestampfile1 [timestampfile2...]
+""" % os.path.basename(sys.argv[0]))
+
+if not '/' in sys.argv[1] and ':' in sys.argv[1]:
+    user, group = sys.argv[1].split(':')
+    user = pwd.getpwnam(user).pw_uid 
+    group = grp.getgrnam(group).gr_gid
+    tstamps = sys.argv[2:]
+else:
+    user = os.geteuid()
+    group = os.getegid()
+    tstamps = sys.argv[1:]
 
 for tstamp in tstamps:
     # we might write in a directory not owned by root
     (fd, tmpfilename) = tempfile.mkstemp(prefix = os.path.basename(tstamp), 
                                          dir = os.path.dirname(tstamp))
-
-    if 'ftp-stage' in tstamp:
-        group = 'stage'
-    else:
-        group = 'nogroup'
 
     if tstamp.endswith('invisible'):
         mode = 0640
_at_@ -74,8 +90,8 @@
         mode = 0644
 
     os.chown(tmpfilename, 
-             pwd.getpwnam('mirror').pw_uid, 
-             grp.getgrnam(group).gr_gid)
+             user, 
+             group)
 
     os.chmod(tmpfilename, mode)
     




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Thu Jan 02 2014 - 21:18:46 GMT

This archive was generated by hypermail 2.3.0 : Thu Jan 02 2014 - 21:32:06 GMT