From: mj Date: Tue, 2 Oct 2001 10:11:05 +0000 (+0000) Subject: Added a script to set file and directories permissions automatically. X-Git-Tag: prexmlproducerconfig~378 X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=commitdiff_plain;h=d629d9481e10ee8b835fa8858a9b85ccb1db58f9 Added a script to set file and directories permissions automatically. Added some lines to the configuration --- diff --git a/doc/INSTALL.mir b/doc/INSTALL.mir index d74d5ecd..989d14cc 100755 --- a/doc/INSTALL.mir +++ b/doc/INSTALL.mir @@ -65,7 +65,15 @@ as user postgres: There, read INSTALL and follow the instructions. -10. chmod 777 Mir/log +10. Set permissions + We provide a script that sets all files' and direcories' permissions to + a quite reasonable state. + + cp perms.sh-dist perms.sh + # Now, change the install directory and group in perms.sh + edit perms.sh + ./perms.sh + 11. restart tomcat diff --git a/perms.sh-dist b/perms.sh-dist new file mode 100755 index 00000000..04a376c5 --- /dev/null +++ b/perms.sh-dist @@ -0,0 +1,49 @@ +#!/bin/sh + +# Where the installed system resides +INSTDIR=../Mir + +# The group all files belong to +GROUP=www-data + + +# No config required after this point. Hopefully. +################################################################## + +# Needed to correct permissions + +function chm() +{ + # Parameters. $1 permissions + # $2 directory or file + # $3 mode: [d|f] (dir or file) + + LIST=$(find $2 -type $3) + if [ "$LIST" != "" ]; then + echo "$LIST" + chmod $1 $LIST + fi +} + +function grant() +{ + # Parameters: $1: permissions for dirs + # $2: permissions for files + # $3: directory or file + + chmod $1 $3 + UMASK=$(umask) + umask 044 +# chmod $1 $(find $3 -type d) +# chmod $2 $(find $3 -type f) + chm $1 $3 d + chm $2 $3 f + umask $UMASK +} + +chgrp $GROUP $INSTDIR -R > /dev/null 2>&1 +grant 775 664 $INSTDIR > /dev/null 2>&1 +grant 750 640 $INSTDIR/WEB-INF/classes/config.properties +grant 740 640 $INSTDIR/src/config.properties +#grant 755 644 $INSTDIR/templates +#grant 755 644 $INSTDIR/produced