Browse Source

Install zeronet on mesh peers

Bob Mottram 9 years ago
parent
commit
4bdf435933
1 changed files with 46 additions and 1 deletions
  1. 46
    1
      src/freedombone

+ 46
- 1
src/freedombone View File

@@ -400,6 +400,8 @@ TOX_NODE=
400 400
 #  '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
401 401
 #)
402 402
 
403
+ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet.git'
404
+
403 405
 function show_help {
404 406
   echo ''
405 407
   echo 'freedombone -c [configuration file]'
@@ -1583,6 +1585,43 @@ function mesh_cjdns_tools {
1583 1585
   echo 'mesh_cjdns_tools' >> $COMPLETION_FILE
1584 1586
 }
1585 1587
 
1588
+function install_zeronet {
1589
+  if grep -Fxq "install_zeronet" $COMPLETION_FILE; then
1590
+      return
1591
+  fi
1592
+  if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
1593
+      return
1594
+  fi
1595
+
1596
+  apt-get -y install python python-msgpack python-gevent python-pip
1597
+  pip install msgpack-python --upgrade
1598
+  
1599
+  adduser --home /opt/zeronet/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login zeronet
1600
+  git clone $ZERONET_REPO /opt/zeronet
1601
+  sudo chown -R zeronet:zeronet /opt/zeronet
1602
+
1603
+  echo '[Unit]' > /etc/systemd/system/zeronet.service
1604
+  echo 'Description=Zeronet Server' >> /etc/systemd/system/zeronet.service
1605
+  echo 'After=syslog.target' >> /etc/systemd/system/zeronet.service
1606
+  echo 'After=network.target' >> /etc/systemd/system/zeronet.service
1607
+  echo '[Service]' >> /etc/systemd/system/zeronet.service
1608
+  echo 'Type=simple' >> /etc/systemd/system/zeronet.service
1609
+  echo 'User=zeronet' >> /etc/systemd/system/zeronet.service
1610
+  echo 'Group=zeronet' >> /etc/systemd/system/zeronet.service
1611
+  echo 'WorkingDirectory=/opt/zeronet' >> /etc/systemd/system/zeronet.service
1612
+  echo 'ExecStart=/usr/bin/python zeronet.py' >> /etc/systemd/system/zeronet.service
1613
+  echo '' >> /etc/systemd/system/zeronet.service
1614
+  echo 'TimeoutSec=300' >> /etc/systemd/system/zeronet.service
1615
+  echo '' >> /etc/systemd/system/zeronet.service
1616
+  echo '[Install]' >> /etc/systemd/system/zeronet.service
1617
+  echo 'WantedBy=multi-user.target' >> /etc/systemd/system/zeronet.service
1618
+  
1619
+  systemctl enable zeronet.service
1620
+  systemctl start zeronet.service
1621
+  
1622
+  echo 'mesh_zeronet' >> $COMPLETION_FILE
1623
+}
1624
+
1586 1625
 function install_vpn_tunnel {
1587 1626
   if ! grep -q "repo.universe-factory.net" /etc/apt/sources.list; then
1588 1627
       echo 'deb http://repo.universe-factory.net/debian/ sid main' >> /etc/apt/sources.list
@@ -1790,6 +1829,9 @@ function mesh_babel {
1790 1829
   echo "ExecStop=$babel_script stop" >> /etc/systemd/system/babel.service
1791 1830
   echo 'RemainAfterExit=yes' >> /etc/systemd/system/babel.service
1792 1831
   echo '' >> /etc/systemd/system/babel.service
1832
+  echo '# Allow time for the server to start/stop' >> /etc/systemd/system/babel.service
1833
+  echo 'TimeoutSec=300' >> /etc/systemd/system/babel.service  
1834
+  echo '' >> /etc/systemd/system/babel.service
1793 1835
   echo '[Install]' >> /etc/systemd/system/babel.service
1794 1836
   echo 'WantedBy=multi-user.target' >> /etc/systemd/system/babel.service
1795 1837
   systemctl enable babel
@@ -1828,7 +1870,6 @@ function mesh_batman_bridge {
1828 1870
   echo '' >> $batman_script
1829 1871
   echo 'if [[ $1 == "start" ]]; then' >> $batman_script
1830 1872
   echo '    # install avahi' >> $batman_script
1831
-  echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd' >> $batman_script
1832 1873
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
1833 1874
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
1834 1875
   echo '    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
@@ -2006,6 +2047,9 @@ function mesh_batman_bridge {
2006 2047
   echo "ExecStop=$batman_script stop" >> /etc/systemd/system/batman.service
2007 2048
   echo 'RemainAfterExit=yes' >> /etc/systemd/system/batman.service
2008 2049
   echo '' >> /etc/systemd/system/batman.service
2050
+  echo '# Allow time for the server to start/stop' >> /etc/systemd/system/batman.service
2051
+  echo 'TimeoutSec=300' >> /etc/systemd/system/batman.service  
2052
+  echo '' >> /etc/systemd/system/batman.service
2009 2053
   echo '[Install]' >> /etc/systemd/system/batman.service
2010 2054
   echo 'WantedBy=multi-user.target' >> /etc/systemd/system/batman.service
2011 2055
   systemctl enable batman
@@ -10216,6 +10260,7 @@ check_hwrng
10216 10260
 search_for_attached_usb_drive
10217 10261
 regenerate_ssh_keys
10218 10262
 create_upgrade_script
10263
+install_zeronet
10219 10264
 configure_avahi
10220 10265
 install_atheros_wifi
10221 10266
 configure_firewall_for_cjdns