Create avahi service entries for onion sites

This commit is contained in:
Bob Mottram 2015-12-31 13:02:44 +00:00
parent d074b0c3b9
commit 806175237b
1 changed files with 65 additions and 5 deletions

View File

@ -1224,25 +1224,83 @@ function set_default_onion_domains {
fi fi
if [ $OWNCLOUD_DOMAIN_NAME ]; then if [ $OWNCLOUD_DOMAIN_NAME ]; then
OWNCLOUD_DOMAIN_NAME='owncloud.onion' OWNCLOUD_DOMAIN_NAME='owncloud.local'
fi fi
if [ $MICROBLOG_DOMAIN_NAME ]; then if [ $MICROBLOG_DOMAIN_NAME ]; then
MICROBLOG_DOMAIN_NAME='microblog.onion' MICROBLOG_DOMAIN_NAME='microblog.local'
fi fi
if [ $FULLBLOG_DOMAIN_NAME ]; then if [ $FULLBLOG_DOMAIN_NAME ]; then
FULLBLOG_DOMAIN_NAME='blog.onion' FULLBLOG_DOMAIN_NAME='blog.local'
fi fi
if [ $GIT_DOMAIN_NAME ]; then if [ $GIT_DOMAIN_NAME ]; then
GIT_DOMAIN_NAME='git.onion' GIT_DOMAIN_NAME='git.local'
fi fi
if [ $WIKI_DOMAIN_NAME ]; then if [ $WIKI_DOMAIN_NAME ]; then
WIKI_DOMAIN_NAME='wiki.onion' WIKI_DOMAIN_NAME='wiki.local'
fi fi
if [ $DEFAULT_DOMAIN_NAME ]; then if [ $DEFAULT_DOMAIN_NAME ]; then
DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local" DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
fi fi
} }
function create_avahi_onion_domains {
if [ $OWNCLOUD_DOMAIN_NAME ]; then
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/owncloud.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/owncloud.service
echo '<service-group>' >> /etc/avahi/services/owncloud.service
echo ' <name replace-wildcards="yes">%h HTTP</name>' >> /etc/avahi/services/owncloud.service
echo ' <service>' >> /etc/avahi/services/owncloud.service
echo ' <type>_http._tcp</type>' >> /etc/avahi/services/owncloud.service
echo " <port>$OWNCLOUD_ONION_PORT</port>" >> /etc/avahi/services/owncloud.service
echo ' </service>' >> /etc/avahi/services/owncloud.service
echo '</service-group>' >> /etc/avahi/services/owncloud.service
fi
if [ $MICROBLOG_DOMAIN_NAME ]; then
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/microblog.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/microblog.service
echo '<service-group>' >> /etc/avahi/services/microblog.service
echo ' <name replace-wildcards="yes">%h HTTP</name>' >> /etc/avahi/services/microblog.service
echo ' <service>' >> /etc/avahi/services/microblog.service
echo ' <type>_http._tcp</type>' >> /etc/avahi/services/microblog.service
echo " <port>$MICROBLOG_ONION_PORT</port>" >> /etc/avahi/services/microblog.service
echo ' </service>' >> /etc/avahi/services/microblog.service
echo '</service-group>' >> /etc/avahi/services/microblog.service
fi
if [ $FULLBLOG_DOMAIN_NAME ]; then
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/blog.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/blog.service
echo '<service-group>' >> /etc/avahi/services/blog.service
echo ' <name replace-wildcards="yes">%h HTTP</name>' >> /etc/avahi/services/blog.service
echo ' <service>' >> /etc/avahi/services/blog.service
echo ' <type>_http._tcp</type>' >> /etc/avahi/services/blog.service
echo " <port>$BLOG_ONION_PORT</port>" >> /etc/avahi/services/blog.service
echo ' </service>' >> /etc/avahi/services/blog.service
echo '</service-group>' >> /etc/avahi/services/blog.service
fi
if [ $GIT_DOMAIN_NAME ]; then
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/git.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/git.service
echo '<service-group>' >> /etc/avahi/services/git.service
echo ' <name replace-wildcards="yes">%h HTTP</name>' >> /etc/avahi/services/git.service
echo ' <service>' >> /etc/avahi/services/git.service
echo ' <type>_http._tcp</type>' >> /etc/avahi/services/git.service
echo " <port>$GIT_ONION_PORT</port>" >> /etc/avahi/services/git.service
echo ' </service>' >> /etc/avahi/services/git.service
echo '</service-group>' >> /etc/avahi/services/git.service
fi
if [ $WIKI_DOMAIN_NAME ]; then
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/wiki.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/wiki.service
echo '<service-group>' >> /etc/avahi/services/wiki.service
echo ' <name replace-wildcards="yes">%h HTTP</name>' >> /etc/avahi/services/wiki.service
echo ' <service>' >> /etc/avahi/services/wiki.service
echo ' <type>_http._tcp</type>' >> /etc/avahi/services/wiki.service
echo " <port>$WIKI_ONION_PORT</port>" >> /etc/avahi/services/wiki.service
echo ' </service>' >> /etc/avahi/services/wiki.service
echo '</service-group>' >> /etc/avahi/services/wiki.service
fi
}
# check an individual domain name # check an individual domain name
function test_domain_name { function test_domain_name {
if [ $1 ]; then if [ $1 ]; then
@ -3272,6 +3330,7 @@ function initial_setup {
apt-get -y dist-upgrade apt-get -y dist-upgrade
apt-get -y install ca-certificates emacs24 cpulimit apt-get -y install ca-certificates emacs24 cpulimit
apt-get -y install cryptsetup libgfshare-bin obnam sshpass wget apt-get -y install cryptsetup libgfshare-bin obnam sshpass wget
apt-get -y install avahi-daemon avahi-utils avahi-discover
echo 'initial_setup' >> $COMPLETION_FILE echo 'initial_setup' >> $COMPLETION_FILE
} }
@ -9428,6 +9487,7 @@ letsencrypt_renewals
install_zeronet install_zeronet
install_watchdog_script install_watchdog_script
configure_avahi configure_avahi
create_avahi_onion_domains
install_zeronet_blog install_zeronet_blog
install_zeronet_mail install_zeronet_mail
install_zeronet_forum install_zeronet_forum