2 years ago
#61831
Tom Arm
PHP break script of option disable
In DirectAdmin I have the option:
This option variable name:installwp
When option is selected then below script is running:
#check custom pkg item installwp
if [[ $installwp == 'OFF' ]]; then
exit 0;
else
#set up DB variables
dbpass=$(openssl rand -hex 6) > /dev/null
ext=$(openssl rand -hex 2) > /dev/null
dbuser="wp${ext}" # do not include the username_ for dataskq here as DA adds this
wpconfigdbuser="${username}_wp${ext}"
wpadminpass=$(openssl rand -hex 6) > /dev/null
# install wp
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.php ]; then
echo "WARNING: There appears to be an index file already located in this directory, which indicates that an installation is already present! Empty the directory before running the script again."
exit
else
#Disable DAs index.html file
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.html ]; then
mv /home/$username/domains/$domain/public_html/$subdomain/index.html{,.bak}
fi
When option is not selected then we exit script:
if [[ $installwp == 'OFF' ]]; then
exit 0;
OK, this works fine.
This second option have variable: installwptwentytwenty
.
And now I need first whole code break and run second code for second option. Second option have name installwptwentytwenty
.
So I try use break first variable installwp
and run installwptwentytwenty
. So I try add below code:
**** THIS CODE NOW WE NEED TO SKIP*************
#check custom pkg item installwp
if [[ $installwp == 'OFF' ]]; then
break 0;
else
#set up DB variables
dbpass=$(openssl rand -hex 6) > /dev/null
ext=$(openssl rand -hex 2) > /dev/null
dbuser="wp${ext}" # do not include the username_ for dataskq here as DA adds this
wpconfigdbuser="${username}_wp${ext}"
wpadminpass=$(openssl rand -hex 6) > /dev/null
# install wp
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.php ]; then
echo "WARNING: There appears to be an index file already located in this directory, which indicates that an installation is already present! Empty the directory before running the script again."
exit
else
#Disable DAs index.html file
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.html ]; then
mv /home/$username/domains/$domain/public_html/$subdomain/index.html{,.bak}
fi
**** THIS CODE NOW WE NEED TO RUN IF SECOND OPTION IS SELECT*************
#check custom pkg item installwp
if [[ $installwptwentytwenty == 'OFF' ]]; then
exit 0;
else
#set up DB variables
dbpass=$(openssl rand -hex 6) > /dev/null
ext=$(openssl rand -hex 2) > /dev/null
dbuser="wp${ext}" # do not include the username_ for dataskq here as DA adds this
wpconfigdbuser="${username}_wp${ext}"
wpadminpass=$(openssl rand -hex 6) > /dev/null
# install wp
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.php ]; then
echo "WARNING: There appears to be an index file already located in this directory, which indicates that an installation is already present! Empty the directory before running the script again."
exit
else
#Disable DAs index.html file
if [ -f /home/$username/domains/$domain/public_html/$subdomain/index.html ]; then
mv /home/$username/domains/$domain/public_html/$subdomain/index.html{,.bak}
fi
But now it doesn't work, nothing happens.
I checked in log error:
line 121: syntax error: unexpected end of file
Please note: Currently, the two codes for the two options look the same. But in fact, two other operations will be performed in the future so we need full separate this.
php
directadmin
0 Answers
Your Answer