Merge branch 'master' of github.com:AlternC/AlternC
This commit is contained in:
commit
f5933a181b
|
@ -22,50 +22,58 @@
|
||||||
# Purpose of file: Fix permission, ACL and ownership of AlternC's files
|
# Purpose of file: Fix permission, ACL and ownership of AlternC's files
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
red () { echo -e "\e[31m$@ \e[0m" ; }
|
||||||
|
usage () {
|
||||||
|
[[ -n "$@" ]] && red "$@\n"
|
||||||
|
cat<<End-of-message
|
||||||
|
Four optionals argument to chose from
|
||||||
|
-l string : a specific login to fix
|
||||||
|
-u integer : a specific uid to fix
|
||||||
|
-f string : a specific file to fix according to a given uid
|
||||||
|
-d string : a specific subdirectory to fix according to a given uid
|
||||||
|
|
||||||
# four optionals argument to chose from
|
The u and l switch are used to fix a given user whole directory including his base directory ($ALTERNC_HTML/<letter>/<login>/
|
||||||
# -l string : a specific login to fix
|
The f and d switch are used to fix a given file or directory under the user's base directory. They use the base directory to get the permissions they should use.
|
||||||
# -u integer : a specific uid to fix
|
Be sure to have correct base directory permissions before attemplting to fix use those two switch
|
||||||
# -f string : a specific file to fix according to a given uid
|
End-of-message
|
||||||
# -d string : a specific subdirectory to fix according to a given uid
|
exit 1
|
||||||
|
}
|
||||||
# The u and l switch are used to fix a given user whole directory including his base directory ($ALTERNC_HTML/<letter>/<login>/
|
|
||||||
# The f and d switch are used to fix a given file or directory under the user's base directory. They use the base directory to get the permissions they should use.
|
|
||||||
# Be sure to have correct base directory permissions before attemplting to fix use those two switch
|
|
||||||
|
|
||||||
query="SELECT uid,login FROM membres ORDER BY login"
|
query="SELECT uid,login FROM membres ORDER BY login"
|
||||||
sub_dir=""
|
sub_dir=""
|
||||||
file=""
|
file=""
|
||||||
LOCK_FIXPERMS="/etc/alternc/disable_all_fixperms"
|
LOCK_FIXPERMS="/etc/alternc/disable_all_fixperms"
|
||||||
|
|
||||||
if [ -f "$LOCK_FIXPERMS" ] ; then
|
if [ -f "$LOCK_FIXPERMS" ] ; then
|
||||||
(
|
|
||||||
echo " ------------- "
|
usage "
|
||||||
echo '/!\ WARNING /!\ '
|
------------------------------------
|
||||||
echo "The fixperms script is disabled"
|
/!\ WARNING /!\
|
||||||
echo "To enable it, delete $LOCK_FIXPERMS "
|
The fixperms script is disabled
|
||||||
echo " ------------- "
|
To enable it, delete $LOCK_FIXPERMS
|
||||||
) 1>&2
|
------------------------------------
|
||||||
exit 0
|
"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts "l:u:f:d:" optname
|
|
||||||
|
while getopts "hl:u:f:d:" optname
|
||||||
do
|
do
|
||||||
case "$optname" in
|
case "$optname" in
|
||||||
|
"h") usage
|
||||||
|
;;
|
||||||
|
|
||||||
"l")
|
"l")
|
||||||
if [[ "$OPTARG" =~ ^[a-zA-Z0-9_]+$ ]] ; then
|
if [[ "$OPTARG" =~ ^[a-zA-Z0-9_]+$ ]] ; then
|
||||||
query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG' ORDER BY login"
|
query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG' ORDER BY login"
|
||||||
else
|
else
|
||||||
echo "Bad login provided"
|
usage "Bad login provided"
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"u")
|
"u")
|
||||||
if [[ "$OPTARG" =~ ^[0-9]+$ ]] ; then
|
if [[ "$OPTARG" =~ ^[0-9]+$ ]] ; then
|
||||||
query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG' ORDER BY login"
|
query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG' ORDER BY login"
|
||||||
else
|
else
|
||||||
echo "Bad uid provided"
|
usage "Bad uid provided"
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"f")
|
"f")
|
||||||
|
@ -79,17 +87,14 @@ do
|
||||||
echo $sub_dir
|
echo $sub_dir
|
||||||
;;
|
;;
|
||||||
"?")
|
"?")
|
||||||
echo "Unknown option $OPTARG - stop processing"
|
usage "Unknown option $OPTARG - stop processing"
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
":")
|
":")
|
||||||
echo "No argument value for option $OPTARG - stop processing"
|
usage "No argument value for option $OPTARG - stop processing"
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Should not occur
|
# Should not occur
|
||||||
echo "Unknown error while processing options"
|
usage "Unknown error while processing options"
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue