def chown(path,user,group):
uid = pwd.getpwnam(user)[2]
gid = grp.getgrnam(group)[2]
os.chown(path,uid,gid)
def chown_recursive(path,user,group):
if path is None or path in ['/','/root','/usr','/tmp','/bin','/sbin']:
raise Error("path isn't right...")
uid = pwd.getpwnam(user)[2]
gid = grp.getgrnam(group)[2]
os.chown(root, uid, gid)
for root, dirs, files in os.walk(path):
for name in dirs:
os.chown(os.path.join(root,name), uid, gid)
for name in files:
os.chown(os.path.join(root,name), uid, gid)
Tuesday, April 6, 2010
chown in Python
The built-in chown in Python (in the os module) only uses uid/gid instead of username/groupname. So here's a couple of (simple) versions that can take usernames and groupnames. I can't remember where I borrowed some of this code from, but it was heavily inspired by code samples I found while google searching:
Wednesday, March 17, 2010
Repairing Corrupt MySQL Tables
Drat... My MythTV's MySQL database got corrupt somehow. I noticed some strange problems with the guide data over the past couple weeks and today, the guide data ran out. When I ran "mythfilldatabase" on the command-line, I noticed a weird error from MySQL suggesting the tables were corrupt.
A couple of google searches later, I found a great reference guide (http://www.thegeekstuff.com/2008/09/how-to-repair-corrupted-mysql-tables-using-myisamchk/) that discusses how to use myisamchk to find corrupt tables and then repair them. Worked like a champ.
A couple of google searches later, I found a great reference guide (http://www.thegeekstuff.com/2008/09/how-to-repair-corrupted-mysql-tables-using-myisamchk/) that discusses how to use myisamchk to find corrupt tables and then repair them. Worked like a champ.
cd /var/lib/mysql/mythconverg
myisamchk *.MYI
# in my case, only one table was corrupt
myisamchk -r CORRUPTTABLE.MYI
Monday, May 18, 2009
Reducing an LVM Volume Group that's missing disks
I put in a new hard drive and used "pvmove" to move all the physical extents (all the data) from the old drives to the new one. But then, I removed the drives without running vgreduce! Oops... Fortunately, vgreduce has a "--removemissing" flag that can remove all the missing physical volumes from a volume group and restore consistency. This is exactly what I needed since I was sure that there was no data left on those other volumes.
Tuesday, September 30, 2008
Jump-Starting a new Honda Odyssey
Yes, I'm the proud owner of a fairly new Honda Odyssey. And I did the stupid thing of leaving the lights on over part of the weekend. And when my wife went out to start the car, lo and behold, the battery was dead. Now on a car with so many electric features (there is only one key hole on the outside of the car, they expect you to use the automatic door locks for the rest of the doors), having a dead battery leaves you in a world of trouble!
It took some time to find a place that sells jumper cables. Fortunately, the local Obi (like Home Depot) has an automotive section. So I go out well before the sun rises this morning to jump start the car. And as soon as I attach the jumper cables from the good battery, the honda odyssey goes into "Help! I'm being stolen!" mode with horn a blaring. I'm sure my neighbors loved that!
Well, after almost 2 hours of frustration, I finally discovered that ADAC (the equivalent of AAA in Germany) will do a courtesy jump-start for AAA card holders overseas. And they were pretty prompt! The tech (who didn't speak hardly any English, but we were able to communicate) knew exactly how to disable the panic mode: put the key in the outside of the driver's door and lock and unlock the car. I guess my putting the key in the ignition wasn't good enough for the car, it needed to be in the outside door. I'm told that using the lock/unlock on the keyless entry would have had the same effect. But I'm disappointed that my car will always panic when I try and jump-start it from a dead battery. I guess I just can't jump start it in the dead of night without disturbing the neighbors for a few moments while I get that key into the door...
It took some time to find a place that sells jumper cables. Fortunately, the local Obi (like Home Depot) has an automotive section. So I go out well before the sun rises this morning to jump start the car. And as soon as I attach the jumper cables from the good battery, the honda odyssey goes into "Help! I'm being stolen!" mode with horn a blaring. I'm sure my neighbors loved that!
Well, after almost 2 hours of frustration, I finally discovered that ADAC (the equivalent of AAA in Germany) will do a courtesy jump-start for AAA card holders overseas. And they were pretty prompt! The tech (who didn't speak hardly any English, but we were able to communicate) knew exactly how to disable the panic mode: put the key in the outside of the driver's door and lock and unlock the car. I guess my putting the key in the ignition wasn't good enough for the car, it needed to be in the outside door. I'm told that using the lock/unlock on the keyless entry would have had the same effect. But I'm disappointed that my car will always panic when I try and jump-start it from a dead battery. I guess I just can't jump start it in the dead of night without disturbing the neighbors for a few moments while I get that key into the door...
Subscribe to:
Posts (Atom)