Skip to content

Commit

Permalink
tools-site improvements
Browse files Browse the repository at this point in the history
- Not delete site assigned as tools-site.
- Now we can reset tools-site to default.
  • Loading branch information
QROkes committed Oct 30, 2019
1 parent b5b6729 commit 9eb4cb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/sites
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,15 @@ db_delete() {


deletesite() {
if [[ $domain == $(conf_read tools-site) || $domain == $(conf_read default-site) ]]; then
if [[ ( $domain == $(conf_read tools-site) || $domain == $(conf_read default-site) ) && -z $delete_all ]]; then
echo "${red}[WARNING] This site is set as default site or used to access your server tools."
echo "Deleting this site can cause unexpected behaviour in your server, please reassign your default/tools site to an existing domain."
echo "${end}"
fi
if [[ $domain == $(conf_read tools-site) && -z $delete_all ]]; then
echo "${red}[ERROR] Can not delete a site that is assigned to access your server tools (Tools-Site)!${end}"
exit 1
fi

[[ $delete == "force" ]] && local dbdel="Y"
[[ $delete == "keep-db" ]] && local dbdel="N"
Expand Down
10 changes: 9 additions & 1 deletion plugins/webinoly
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ elif [[ -n $tools_site ]]; then
tools_site=${tools_site:-NeverMatchDotCom}
fi

if [[ -a /etc/nginx/sites-available/$tools_site ]]; then
if [[ -a /etc/nginx/sites-available/$tools_site && -a /etc/nginx/sites-available/$(conf_read tools-port) && $tools_site != "default" ]]; then
# Check for previous assigned domain and remove
if [[ -n $(conf_read tools-site) ]]; then
sudo sed -i '/server_name/d' /etc/nginx/sites-available/$(conf_read tools-port)
Expand Down Expand Up @@ -167,6 +167,14 @@ elif [[ -n $tools_site ]]; then

conf_write tools-site $tools_site
echo "${gre}Domain ${blu}- ${tools_site}:$(conf_read tools-port) -${gre} was successfully assigned to access your server tools!${end}"
elif [[ $tools_site == "default" ]]; then
sudo rm -rf /etc/nginx/sites-available/$(conf_read tools-port)
sudo cp /opt/webinoly/templates/nginx/22222 /etc/nginx/sites-available/$(conf_read tools-port)
sudo sed -i "s/22222/$(conf_read tools-port)/g" /etc/nginx/sites-available/$(conf_read tools-port)
echo "${gre}Tools Site settings has been reset successfully!${end}"
elif [[ -a /etc/nginx/sites-available/$tools_site && ! -a /etc/nginx/sites-available/$(conf_read tools-port) ]]; then
echo "${red}[ERROR] Tools Site is not enabled! ${end}"
exit 1
else
echo "${red}[ERROR] Domain/site not found. ${end}"
exit 1
Expand Down

0 comments on commit 9eb4cb9

Please sign in to comment.