Tuesday, February 7, 2012

my teeth chattr

need i say more?
#!/bin/sh

# changes ext2 or ext3 file attributes

for file in resolv.conf passwd shadow group motd hosts hostname
do
    if [ "$1" == "" ]    ; then lsattr    /etc/$file ; fi
    if [ "$1" == "on" ]  ; then chattr +i /etc/$file ; fi
    if [ "$1" == "off" ] ; then chattr -i /etc/$file ; fi
done

No comments: