Twitter (was mache ich gerade?)

    Suche

     

    Credits

    Archiv

    Dezember 2008
    Mo
    Di
    Mi
    Do
    Fr
    Sa
    So
     1 
     3 
     5 
     6 
     8 
     9 
    11
    12
    13
    14
    16
    17
    18
    20
    23
    25
    26
    27
    28
    30
    31
     
     
     
     
     

    Status

    Online seit 6909 Tagen
    Zuletzt aktualisiert: 17. Apr, 22:03

    Counter & Co.

    Egoload - Verträumter Idealist
    Mein
Koordinaten auf der EgoMap:  93,2
    100% Heidnisch

    Locations of visitors to this page

    Montag, 15. Dezember 2008

    permfix.zsh: Fix broken permissions

    Yesterday I messed up my NetBSD system while moving /usr and /var to a new, encrypted partition. I didn't reckon that NetBSDs tar needs "-p" to preserve the meta information attached to a directory or file, so I lost ownerships, groups and especially permissions. And as I discovered the mess I already had continue with setting up the system, installing ports, pkgsrc, /usr/src and so on...
    Luckily I didn't simply remove the original directories, but kept them as "/usr.old" and "/var.old". So I wrote a small script using zsh and the "zsh/stat" module to fix it. So in case something like this might happen to you, too, here's a simple solution:
     
    #!/usr/pkg/bin/zsh
    
    zmodload zsh/stat
    
    typeset srcdir dstdir 
    typeset -A srcobj dstobj
    typeset -i srcmode dstmode
    
    [[ $# != 2 ]] && {
        echo "Error: ${0:t} requires exactly two arguments: sourcedir and destdir"
        exit 1
    }  
    [[ ! -d $1 ]] && {
        echo "Error: $1 is not a directory or does not exist."
        exit 1
    }
    [[ ! -d $2 ]] && {
        echo "Error: $2 is not a directory or does not exist."
        exit 1
    }
    
    srcdir=$1
    dstdir=$2
    
    for obj in $( cd $srcdir ; find . )
    do
        [[ -e $dstdir/$obj ]] && {
            stat -oH srcobj $srcdir/$obj
            stat -oH dstobj $dstdir/$obj
            srcmode=${${srcobj[mode]}[4,7]}
            dstmode=${${dstobj[mode]}[4,7]}
            [[ $srcmode -ne $dstmode ]] && {
                echo "Changing $obj perm from $dstmode to $srcmode"
                chmod $srcmode $dstdir/$obj
            }
            [[ $srcobj[uid] != $dstobj[uid] ]] && {
                echo "Changing $obj owner from $dstobj[uid] to $srcobj[uid]"
                chown $srcobj[uid] $dstdir/$obj
            }
            [[ $srcobj[gid] != $dstobj[gid] ]] && {
                echo "Changing $obj group from $dstobj[gid] to $srcobj[gid]"
                chgrp $srcobj[gid] $dstdir/$obj
            }
        }
    done

     
    There might be a shorter solution, but I wanted to keep this simple and readable. ;-)

    Aktuelle Beiträge

    Im happy I finally registered
    Excellent write-up. I absolutely love this site. Continue...
    http://mittenmail3.isblog.net/pick-a-winner-via-hashtag-entry-for-twitter-and-instagram-woobox-bl... (Gast) - 17. Apr, 22:03
    Just want to say Hi!
    I all the time emailed this blog post page to all...
    how to get instagram likes (Gast) - 30. Mär, 23:20
    Im happy I now signed...
    Hello, There's no doubt that your website could possibly...
    buy instagram followers cheap (Gast) - 30. Mär, 09:27
    Hallo Miau!
    Ich will einen schönen Tag wünschen, mit unseren Schmusekatzen....
    SCHLAGLOCH - 4. Apr, 14:51
    Sehe hier nut Tag und...
    Wo ist das Jahr an dem der Text geschrieben wurde?
    Gast (Gast) - 3. Mär, 20:38

    User Status

    Du bist nicht angemeldet.

    ...wenn man trotzdem lacht
    Atari Mega ST
    Auf Arbeit
    Bloggen
    Bookmarks & Links
    BSD
    Bundeswehr
    CCC07
    Computing
    Contentmafia
    Datenschutz
    DRM
    Fahrrad
    Finanzkrise
    Fundsachen
    G8
    ... weitere
    Profil
    Abmelden
    Weblog abonnieren