mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
Create v-cd-www
This commit is contained in:
parent
62b0e672a6
commit
2e66899997
1 changed files with 69 additions and 0 deletions
69
bin/v-cd-www
Normal file
69
bin/v-cd-www
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
# info: Change directory to the public_html folder of a domain
|
||||
# usage: v-cd-www DOMAIN
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
echo "This script must be sourced to change the current directory."
|
||||
echo "Usage: source v-cd-www DOMAIN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
whoami=$(whoami)
|
||||
if [ "$whoami" != "root" ]; then
|
||||
echo "You must be root to execute this script"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Importing system environment
|
||||
source /etc/profile
|
||||
|
||||
SILENT_MODE=1
|
||||
|
||||
# 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"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'DOMAIN'
|
||||
is_format_valid 'domain'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
if [ ! -d "/home/$user" ]; then
|
||||
echo "User $user doesn't exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||
echo "Domain $domain doesn't have a public_html directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
cd "/home/$user/web/$domain/public_html"
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
return 0
|
Loading…
Add table
Add a link
Reference in a new issue