Avahi services for zeronet
This commit is contained in:
parent
ac92ca8bc1
commit
e0b9926101
142
src/freedombone
142
src/freedombone
|
@ -1613,6 +1613,146 @@ function mesh_cjdns_tools {
|
|||
echo 'mesh_cjdns_tools' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function install_zeronet_blog {
|
||||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -Fxq "install_zeronet_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /home/$MY_USERNAME/README ]; then
|
||||
touch /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
if grep -q "ZeroNet Blog address" /home/$MY_USERNAME/README; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/avahi ]; then
|
||||
echo 'Avahi is not installed'
|
||||
exit 736
|
||||
fi
|
||||
|
||||
cd /opt/zeronet
|
||||
python zeronet.py --batch siteCreate 2> /opt/zeronet/blog.txt
|
||||
if [ ! -f /opt/zeronet/blog.txt ]; then
|
||||
echo 'Unable to create blog'
|
||||
exit 479
|
||||
fi
|
||||
blog_address=$(cat blog.txt | grep "Site address" | awk -F ':' '{print $2}')
|
||||
blog_private_key=$(cat blog.txt | grep "Site private key" | awk -F ':' '{print $2}')
|
||||
ZERONET_BLOG_ADDRESS=${blog_address//[[:blank:]]/}
|
||||
ZERONET_BLOG_PRIVATE_KEY=${blog_private_key//[[:blank:]]/}
|
||||
|
||||
if [ ! -d "/opt/zeronet/data/$ZERONET_BLOG_ADDRESS" ]; then
|
||||
echo "Unable to find site directory: /opt/zeronet/data/$ZERONET_BLOG_ADDRESS"
|
||||
exit 7638
|
||||
fi
|
||||
|
||||
git clone $ZERONET_BLOG_REPO ZeroBlog
|
||||
if [ ! -d /opt/zeronet/ZeroBlog ]; then
|
||||
echo 'ZeroBlog repo could not be cloned'
|
||||
exit 6739
|
||||
fi
|
||||
echo "Blog address: $ZERONET_BLOG_ADDRESS"
|
||||
echo "Blog private key: $ZERONET_BLOG_PRIVATE_KEY"
|
||||
cp -r /opt/zeronet/ZeroBlog/* /opt/zeronet/data/$ZERONET_BLOG_ADDRESS
|
||||
python zeronet.py siteSign $ZERONET_BLOG_ADDRESS $ZERONET_BLOG_PRIVATE_KEY
|
||||
|
||||
# Add an avahi service
|
||||
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-blog.service
|
||||
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-blog.service
|
||||
echo '<service-group>' >> /tmp/zeronet-blog.service
|
||||
echo ' <name replace-wildcards="yes">%h ZeroNet Blog</name>' >> /tmp/zeronet-blog.service
|
||||
echo ' <service>' >> /tmp/zeronet-blog.service
|
||||
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-blog.service
|
||||
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-blog.service
|
||||
echo " <txt-record>$ZERONET_URL/$ZERONET_BLOG_ADDRESS</txt-record>" >> /tmp/zeronet-blog.service
|
||||
echo ' </service>' >> /tmp/zeronet-blog.service
|
||||
echo '</service-group>' >> /tmp/zeronet-blog.service
|
||||
sudo cp /tmp/zeronet-blog.service /etc/avahi/services/zeronet-blog.service
|
||||
|
||||
if ! grep -q "ZeroNet Blog address" /home/$MY_USERNAME/README; then
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Blog address: $ZERONET_BLOG_ADDRESS" >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Blog private key: $ZERONET_BLOG_PRIVATE_KEY" >> /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
echo 'install_zeronet_blog' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function install_zeronet_forum {
|
||||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -Fxq "install_zeronet_forum" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /home/$MY_USERNAME/README ]; then
|
||||
touch /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
if grep -q "ZeroNet Forum address" /home/$MY_USERNAME/README; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/avahi ]; then
|
||||
echo 'Avahi is not installed'
|
||||
exit 736
|
||||
fi
|
||||
|
||||
cd /opt/zeronet
|
||||
python zeronet.py --batch siteCreate 2> /opt/zeronet/forum.txt
|
||||
if [ ! -f /opt/zeronet/forum.txt ]; then
|
||||
echo 'Unable to create forum'
|
||||
exit 479
|
||||
fi
|
||||
forum_address=$(cat forum.txt | grep "Site address" | awk -F ':' '{print $2}')
|
||||
forum_private_key=$(cat forum.txt | grep "Site private key" | awk -F ':' '{print $2}')
|
||||
ZERONET_FORUM_ADDRESS=${forum_address//[[:blank:]]/}
|
||||
ZERONET_FORUM_PRIVATE_KEY=${forum_private_key//[[:blank:]]/}
|
||||
|
||||
if [ ! -d "/opt/zeronet/data/$ZERONET_FORUM_ADDRESS" ]; then
|
||||
echo "Unable to find site directory: /opt/zeronet/data/$ZERONET_FORUM_ADDRESS"
|
||||
exit 7638
|
||||
fi
|
||||
|
||||
git clone $ZERONET_FORUM_REPO ZeroTalk
|
||||
if [ ! -d /opt/zeronet/ZeroTalk ]; then
|
||||
echo 'ZeroTalk repo could not be cloned'
|
||||
exit 6739
|
||||
fi
|
||||
echo "Forum address: $ZERONET_FORUM_ADDRESS"
|
||||
echo "Forum private key: $ZERONET_FORUM_PRIVATE_KEY"
|
||||
cp -r /opt/zeronet/ZeroTalk/* /opt/zeronet/data/$ZERONET_FORUM_ADDRESS
|
||||
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY
|
||||
|
||||
# Add an avahi service
|
||||
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-forum.service
|
||||
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-forum.service
|
||||
echo '<service-group>' >> /tmp/zeronet-forum.service
|
||||
echo ' <name replace-wildcards="yes">%h ZeroNet Forum</name>' >> /tmp/zeronet-forum.service
|
||||
echo ' <service>' >> /tmp/zeronet-forum.service
|
||||
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-forum.service
|
||||
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-forum.service
|
||||
echo " <txt-record>$ZERONET_URL/$ZERONET_FORUM_ADDRESS</txt-record>" >> /tmp/zeronet-forum.service
|
||||
echo ' </service>' >> /tmp/zeronet-forum.service
|
||||
echo '</service-group>' >> /tmp/zeronet-forum.service
|
||||
sudo cp /tmp/zeronet-forum.service /etc/avahi/services/zeronet-forum.service
|
||||
|
||||
if ! grep -q "ZeroNet Forum address" /home/$MY_USERNAME/README; then
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Forum address: $ZERONET_FORUM_ADDRESS" >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Forum private key: $ZERONET_FORUM_PRIVATE_KEY" >> /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
echo 'install_zeronet_forum' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function install_zeronet {
|
||||
if grep -Fxq "install_zeronet" $COMPLETION_FILE; then
|
||||
return
|
||||
|
@ -10451,6 +10591,8 @@ create_upgrade_script
|
|||
install_zeronet
|
||||
install_watchdog_script
|
||||
configure_avahi
|
||||
install_zeronet_blog
|
||||
install_zeronet_forum
|
||||
install_atheros_wifi
|
||||
configure_firewall_for_cjdns
|
||||
mesh_cjdns
|
||||
|
|
|
@ -13,6 +13,7 @@ ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
|
|||
ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
|
||||
ZERONET_DIR=~/zeronet
|
||||
ZERONET_URL=http://127.0.0.1:43110
|
||||
ZERONET_PORT=15441
|
||||
TRACKER_PORT=6969
|
||||
|
||||
MY_USERNAME=$USER
|
||||
|
@ -26,6 +27,11 @@ function install_zeronet_blog {
|
|||
return
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/avahi ]; then
|
||||
echo 'Avahi is not installed'
|
||||
exit 736
|
||||
fi
|
||||
|
||||
cd $ZERONET_DIR
|
||||
python zeronet.py --batch siteCreate 2> $ZERONET_DIR/blog.txt
|
||||
if [ ! -f $ZERONET_DIR/blog.txt ]; then
|
||||
|
@ -38,7 +44,7 @@ function install_zeronet_blog {
|
|||
ZERONET_BLOG_PRIVATE_KEY=${blog_private_key//[[:blank:]]/}
|
||||
|
||||
if [ ! -d "$ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS" ]; then
|
||||
echo "Unable to find site directory: $$ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS"
|
||||
echo "Unable to find site directory: $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS"
|
||||
exit 7638
|
||||
fi
|
||||
|
||||
|
@ -52,6 +58,19 @@ function install_zeronet_blog {
|
|||
cp -r $ZERONET_DIR/ZeroBlog/* $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS
|
||||
python zeronet.py siteSign $ZERONET_BLOG_ADDRESS $ZERONET_BLOG_PRIVATE_KEY
|
||||
|
||||
# Add an avahi service
|
||||
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-blog.service
|
||||
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-blog.service
|
||||
echo '<service-group>' >> /tmp/zeronet-blog.service
|
||||
echo ' <name replace-wildcards="yes">%h ZeroNet Blog</name>' >> /tmp/zeronet-blog.service
|
||||
echo ' <service>' >> /tmp/zeronet-blog.service
|
||||
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-blog.service
|
||||
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-blog.service
|
||||
echo " <txt-record>$ZERONET_URL/$ZERONET_BLOG_ADDRESS</txt-record>" >> /tmp/zeronet-blog.service
|
||||
echo ' </service>' >> /tmp/zeronet-blog.service
|
||||
echo '</service-group>' >> /tmp/zeronet-blog.service
|
||||
sudo cp /tmp/zeronet-blog.service /etc/avahi/services/zeronet-blog.service
|
||||
|
||||
if ! grep -q "ZeroNet Blog address" /home/$MY_USERNAME/README; then
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Blog address: $ZERONET_BLOG_ADDRESS" >> /home/$MY_USERNAME/README
|
||||
|
@ -70,6 +89,11 @@ function install_zeronet_forum {
|
|||
return
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/avahi ]; then
|
||||
echo 'Avahi is not installed'
|
||||
exit 736
|
||||
fi
|
||||
|
||||
cd $ZERONET_DIR
|
||||
python zeronet.py --batch siteCreate 2> $ZERONET_DIR/forum.txt
|
||||
if [ ! -f $ZERONET_DIR/forum.txt ]; then
|
||||
|
@ -82,7 +106,7 @@ function install_zeronet_forum {
|
|||
ZERONET_FORUM_PRIVATE_KEY=${forum_private_key//[[:blank:]]/}
|
||||
|
||||
if [ ! -d "$ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS" ]; then
|
||||
echo "Unable to find site directory: $$ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS"
|
||||
echo "Unable to find site directory: $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS"
|
||||
exit 7638
|
||||
fi
|
||||
|
||||
|
@ -96,6 +120,19 @@ function install_zeronet_forum {
|
|||
cp -r $ZERONET_DIR/ZeroTalk/* $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS
|
||||
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY
|
||||
|
||||
# Add an avahi service
|
||||
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-forum.service
|
||||
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-forum.service
|
||||
echo '<service-group>' >> /tmp/zeronet-forum.service
|
||||
echo ' <name replace-wildcards="yes">%h ZeroNet Forum</name>' >> /tmp/zeronet-forum.service
|
||||
echo ' <service>' >> /tmp/zeronet-forum.service
|
||||
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-forum.service
|
||||
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-forum.service
|
||||
echo " <txt-record>$ZERONET_URL/$ZERONET_FORUM_ADDRESS</txt-record>" >> /tmp/zeronet-forum.service
|
||||
echo ' </service>' >> /tmp/zeronet-forum.service
|
||||
echo '</service-group>' >> /tmp/zeronet-forum.service
|
||||
sudo cp /tmp/zeronet-forum.service /etc/avahi/services/zeronet-forum.service
|
||||
|
||||
if ! grep -q "ZeroNet Forum address" /home/$MY_USERNAME/README; then
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo "ZeroNet Forum address: $ZERONET_FORUM_ADDRESS" >> /home/$MY_USERNAME/README
|
||||
|
|
Loading…
Reference in New Issue