mirror of
https://github.com/myvesta/vesta
synced 2025-07-05 20:41:53 -07:00
Create v-fix-website-permissions
This commit is contained in:
parent
f39dc8edce
commit
5e72ead3b3
1 changed files with 69 additions and 0 deletions
69
bin/v-fix-website-permissions
Normal file
69
bin/v-fix-website-permissions
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
# info: v-fix-website-permissions
|
||||
# options: DOMAIN
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
whoami=$(whoami)
|
||||
if [ "$whoami" != "root" ]; then
|
||||
echo "You must be root to execute this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Importing system environment
|
||||
source /etc/profile
|
||||
|
||||
# Argument definition
|
||||
domain=$1
|
||||
|
||||
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||
USER=$user
|
||||
|
||||
# Includes
|
||||
source /usr/local/vesta/func/main.sh
|
||||
source /usr/local/vesta/func/domain.sh
|
||||
|
||||
if [ -z "$user" ]; then
|
||||
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'DOMAIN'
|
||||
is_format_valid 'domain'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
if [ ! -d "/home/$user" ]; then
|
||||
echo "User doesn't exist";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||
echo "Domain doesn't exist";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Ensure the directory exists and can be changed into
|
||||
cd /home/$USER/web/$domain || { echo "Error: Cannot change directory to /home/$USER/web/$domain. Directory does not exist."; exit 1; }
|
||||
|
||||
echo "Updating permissions for /home/$USER/web/$domain/public_html/..."
|
||||
find public_html/ -type d -exec chmod 755 {} +
|
||||
find public_html/ -type f -exec chmod 644 {} +
|
||||
chown -R $USER:$USER public_html/
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
echo "Permissions for $domain have been successfully updated."
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue