Skip to content

Commit

Permalink
Merge pull request #161 from 21pages/main
Browse files Browse the repository at this point in the history
use conf.d if sites-available and sites-enabled don't exist
  • Loading branch information
rustdesk authored Nov 27, 2023
2 parents 29daee0 + 39a769d commit e0138ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 15 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,21 @@ Do you want to install Certbot with snap? (recommended)"
fi

# Add Nginx config
if [ ! -f "/etc/nginx/sites-available/rustdesk.conf" ]
if [ -d "/etc/nginx/sites-available" ] && [ -d "/etc/nginx/sites-enabled" ]
then
touch "/etc/nginx/sites-available/rustdesk.conf"
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/sites-available/rustdesk.conf"
SITES_CONF_DIR="sites-available"
elif [ -d "/etc/nginx/conf.d" ]
then
SITES_CONF_DIR="conf.d"
else
msg_box "Couldn't find the Nginx config directory. Please check your system!"
exit 1
fi

if [ ! -f "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf" ]
then
touch "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf"
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf"
server {
server_name ${RUSTDESK_DOMAIN};
location / {
Expand All @@ -417,7 +428,7 @@ NGINX_RUSTDESK_CONF
fi

# Enable the Nginx config file
if [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
if [ "$SITES_CONF_DIR" = "sites-available" ] && [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
then
ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
fi
Expand Down
13 changes: 11 additions & 2 deletions restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,18 @@ server {
}
EOF
)"
echo "${rustdesknginx}" | sudo tee /etc/nginx/sites-available/rustdesk.conf >/dev/null

sudo ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
if [ -d "/etc/nginx/sites-available" ] && [ -d "/etc/nginx/sites-enabled" ]
then
echo "${rustdesknginx}" | sudo tee /etc/nginx/sites-available/rustdesk.conf >/dev/null
sudo ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
elif [ -d "/etc/nginx/conf.d" ]
then
echo "${rustdesknginx}" | sudo tee /etc/nginx/conf.d/rustdesk.conf >/dev/null
else
msg_box "Couldn't find the Nginx config directory. Please check your system!"
exit 1
fi

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
Expand Down

0 comments on commit e0138ce

Please sign in to comment.