#!/bin/sh
# this script should set all needed chattr stuff installed under chroot.
# should be runned before any rpm installations under chroot.
# (c) Light Olli, license is GNU like.

###### variables..

chrootdir=/users/userchroot
# set to "-V" if wanna verbose operations
verbosity="-V"
#verbosity=

###### work begins here:

find $chrootdir -type f -a \( -perm +4111 -o -perm +2111 \) -exec chattr $verbosity +i {} \;
# user dirs & apache dir.
# chattr с пользовательских бинарей внутри их домашних каталогов снят.
find $chrootdir/home -type f -a \( -perm +4111 -o -perm +2111 \) -exec chattr $verbosity -i {} \;
# only apache binaries; shure it's dirty, but quick in writing
find $chrootdir/home/httpd -type f -a \( -perm +4111 -o -perm +2111 \) -exec chattr $verbosity +i {} \;
find $chrootdir/etc -type f -exec chattr $verbosity +i {} \;
find $chrootdir/etc -type d -exec chattr $verbosity +i {} \;
find $chrootdir -type f -name .bash_history -exec chattr $verbosity +a {} \;
find $chrootdir/usr/local/apache/conf -type f -exec chattr $verbosity +i {} \;
chattr +i /users/userchroot/bin
find $chrootdir/lib -type d -exec chattr +i {} \;
find $chrootdir/sbin -type d -exec chattr +i {} \;
#these shouldn't have +i for correct work.
chattr $verbosity -i $chrootdir/etc/mtab
chattr $verbosity -i $chrootdir/etc
