mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
Create v-fix-user-permissions
This commit is contained in:
parent
5518e0e059
commit
25d3fef4aa
1 changed files with 55 additions and 0 deletions
55
bin/v-fix-user-permissions
Normal file
55
bin/v-fix-user-permissions
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
# info:
|
||||
# This script will fix files permissions for desired user (if ownership is lost or files have wrong chmod)
|
||||
|
||||
# options: user
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
whoami=$(whoami)
|
||||
if [ "$whoami" != "root" ] && [ "$whoami" != "admin" ] ; then
|
||||
echo "You must be root or admin to execute this script";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'USER'
|
||||
is_format_valid 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
find /home/$user/conf/mail/ -type d -exec chown Debian-exim:mail {} \;
|
||||
find /home/$user/conf/mail/*/ -type f -exec chown Debian-exim:mail {} \;
|
||||
find /home/$user/conf/mail/*/ -name "passwd" -type f -exec chown dovecot:mail {} \;
|
||||
find /home/$user/mail/ -type d -exec chown $user:mail {} \;
|
||||
find /home/$user/mail/*/ -type d -exec chown $user:mail {} \;
|
||||
find /home/$user/mail/*/ -type f -exec chown $user:mail {} \;
|
||||
|
||||
find /home/$user/conf/dns/ -type f -exec chown root:bind {} \;
|
||||
find /home/$user/conf/ -type d -exec chown root:root {} \;
|
||||
|
||||
find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} +
|
||||
find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} +
|
||||
find /home/$user/web/*/public_html/ -exec chown $user:$user {} \;
|
||||
|
||||
echo "Done, permissions fixed for user: $user"
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue