#!/bin/sh ########################################################################### ## Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### PERMISSIONS_FILE=/etc/default/permissions cat $PERMISSIONS_FILE | while read p; do FILE=`echo $p | awk '{ print $1 }'` T_USER=`echo $p | awk '{ print $2 }'` T_GROUP=`echo $p | awk '{ print $3 }'` T_PERM=`echo $p | awk '{ print $4 }'` if [ ! -e "$FILE" ]; then continue fi USER_CHECK=`grep "^${T_USER}:" /etc/passwd` if [ -z "$USER_CHECK" ]; then continue fi GROUP_CHECK=`grep "^${T_GROUP}:" /etc/group` if [ -z "$GROUP_CHECK" ]; then continue fi C_STAT=`stat --format="%U %G %a" $FILE` C_USER=`echo $C_STAT | awk '{ print $1 }'` if [ $T_USER != $C_USER ]; then chown $T_USER $FILE fi C_GRUP=`echo $C_STAT | awk '{ print $2 }'` if [ $T_GROUP != $C_GRUP ]; then chgrp $T_GROUP $FILE fi C_PERM=`echo $C_STAT | awk '{ print $3 }'` if [ $T_PERM != $C_PERM ]; then chmod $T_PERM $FILE fi done