Skip to content
Snippets Groups Projects
Commit ce610ca4 authored by Bob Mottram's avatar Bob Mottram
Browse files

Include onion domain in website config

parent 740c58df
No related branches found
No related tags found
No related merge requests found
......@@ -45,15 +45,19 @@ if [ ! -d /root/${PROJECT_NAME}/website ]; then
exit 1
fi
if [ -f "$CONFIGURATION_FILE" ]; then
ONION_ONLY=$(grep 'ONION_ONLY=' "$CONFIGURATION_FILE" | head -n 1 | awk -F '=' '{print $2}')
fi
if [[ "$ONION_ONLY" != 'no' ]]; then
site_domain=${PROJECT_NAME}_web
fi
dest_dir="/var/www/${site_domain}/htdocs"
if [ ! -d "$dest_dir" ]; then
mkdir -p "$dest_dir"
fi
if [ -f "$CONFIGURATION_FILE" ]; then
ONION_ONLY=$(grep 'ONION_ONLY=' "$CONFIGURATION_FILE" | head -n 1 | awk -F '=' '{print $2}')
fi
if ! grep -q ":$site_onion_port" /etc/torrc.d/${PROJECT_NAME}; then
{ echo "HiddenServiceDir /var/lib/tor/hidden_service_${PROJECT_NAME}/";
echo 'HiddenServiceVersion 3';
......@@ -61,6 +65,8 @@ if ! grep -q ":$site_onion_port" /etc/torrc.d/${PROJECT_NAME}; then
systemctl restart tor
fi
site_onion_domain=$(cat /var/lib/tor/hidden_service_${PROJECT_NAME}/hostname)
if [[ "$ONION_ONLY" == 'no' ]]; then
{ echo 'server {';
echo ' listen 80;';
......@@ -190,7 +196,7 @@ fi
{ echo 'server {';
echo " listen 127.0.0.1:${site_onion_port} default_server;";
echo " server_name ${site_domain};";
echo " server_name ${site_onion_domain};";
echo '';
echo ' add_header X-Frame-Options DENY;';
echo ' add_header X-Content-Type-Options nosniff;';
......@@ -227,7 +233,7 @@ fi
echo '';
echo 'server {';
echo ' listen 127.0.0.1:8110 default_server;';
echo " server_name ${site_domain};";
echo " server_name ${site_onion_domain};";
echo '';
echo ' add_header X-Frame-Options DENY;';
echo ' add_header X-Content-Type-Options nosniff;';
......@@ -284,3 +290,5 @@ chown -R www-data:www-data "$dest_dir"
systemctl restart nginx
echo "Website deployed to $dest_dir"
echo "$site_domain"
cat "$site_onion_domain"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment