diff --git a/src/freedombone b/src/freedombone
index 39d6044c..9408e7e7 100755
--- a/src/freedombone
+++ b/src/freedombone
@@ -433,6 +433,8 @@ ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet.git'
ZERONET_COMMIT='675bd462556c541d65e2d95f91f899146a373aad'
ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
ZERONET_BLOG_COMMIT='bbb0d6c36465fed2e6df71f1aab45fcc9c6ad609'
+ZERONET_MAIL_REPO='https://github.com/HelloZeroNet/ZeroMail'
+ZERONET_MAIL_COMMIT='955af09d643c72b02e4983d71eca5c0c93a6c131'
ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
ZERONET_FORUM_COMMIT='e2d2c9cb1cfbfef91b244935efb5c14c2ad95faa'
ZERONET_URL=http://127.0.0.1:43110
@@ -440,6 +442,7 @@ ZERONET_PORT=15441
TRACKER_PORT=6969
ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
+ZERONET_DEFAULT_MAIL_TAGLINE="Mail for the Mesh"
# https://github.com/ipfs/go-ipfs
IPFS_GO_REPO="github.com/ipfs/go-ipfs/cmd/ipfs"
@@ -910,6 +913,9 @@ function read_configuration {
if grep -q "ZERONET_BLOG_COMMIT" $CONFIGURATION_FILE; then
ZERONET_BLOG_COMMIT=$(grep "ZERONET_BLOG_COMMIT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
+ if grep -q "ZERONET_MAIL_COMMIT" $CONFIGURATION_FILE; then
+ ZERONET_MAIL_COMMIT=$(grep "ZERONET_MAIL_COMMIT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
+ fi
if grep -q "ZERONET_FORUM_COMMIT" $CONFIGURATION_FILE; then
ZERONET_FORUM_COMMIT=$(grep "ZERONET_FORUM_COMMIT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
@@ -1974,6 +1980,132 @@ function install_zeronet_blog {
echo 'install_zeronet_blog' >> $COMPLETION_FILE
}
+function install_zeronet_mail {
+ if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
+ return
+ fi
+
+ if [ -d /opt/zeronet/ZeroMail ]; then
+ if grep -q "ZeroNet Mail commit" $COMPLETION_FILE; then
+ CURRENT_ZERONET_MAIL_COMMIT=$(grep "ZeroNet Mail commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
+ if [[ "$CURRENT_ZERONET_MAIL_COMMIT" != "$ZERONET_MAIL_COMMIT" ]]; then
+ cd /opt/zeronet/ZeroMail
+ git stash
+ git checkout master
+ git pull
+ git checkout $ZERONET_MAIL_COMMIT -b $ZERONET_MAIL_COMMIT
+ sed -i "s/ZeroNet Mail commit.*/ZeroNet Mail commit:$ZERONET_MAIL_COMMIT/g" $COMPLETION_FILE
+ fi
+ else
+ echo "ZeroNet Mail commit:$ZERONET_MAIL_COMMIT" >> $COMPLETION_FILE
+ fi
+ fi
+
+ if grep -Fxq "install_zeronet_mail" $COMPLETION_FILE; then
+ return
+ fi
+
+ if [ ! -f /home/$MY_USERNAME/README ]; then
+ touch /home/$MY_USERNAME/README
+ fi
+
+ if grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
+ return
+ fi
+
+ if [ ! -d /etc/avahi ]; then
+ echo 'Avahi is not installed'
+ exit 736
+ fi
+
+ ZERONET_DEFAULT_MAIL_TITLE="${MY_USERNAME}'s Mail"
+
+ cd /opt/zeronet
+ python zeronet.py --batch siteCreate 2> /opt/zeronet/mail.txt
+ if [ ! -f /opt/zeronet/mail.txt ]; then
+ echo 'Unable to create mail'
+ exit 479
+ fi
+ mail_address=$(cat mail.txt | grep "Site address" | awk -F ':' '{print $2}')
+ mail_private_key=$(cat mail.txt | grep "Site private key" | awk -F ':' '{print $2}')
+ ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
+ ZERONET_MAIL_PRIVATE_KEY=${mail_private_key//[[:blank:]]/}
+
+ if [ ${#ZERONET_MAIL_ADDRESS} -lt 20 ]; then
+ echo $"Address: $ZERONET_MAIL_ADDRESS"
+ echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
+ echo $'Unable to create zeronet mail address'
+ exit 7358
+ fi
+
+ if [ ${#ZERONET_MAIL_PRIVATE_KEY} -lt 20 ]; then
+ echo $"Address: $ZERONET_MAIL_ADDRESS"
+ echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
+ echo $'Unable to create zeronet mail private key'
+ exit 1639
+ fi
+
+ if [ ! -d "/opt/zeronet/data/$ZERONET_MAIL_ADDRESS" ]; then
+ echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_MAIL_ADDRESS"
+ exit 7638
+ fi
+
+ git clone $ZERONET_MAIL_REPO ZeroMail
+ if [ ! -d /opt/zeronet/ZeroMail ]; then
+ echo 'ZeroMail repo could not be cloned'
+ exit 6739
+ fi
+ cd /opt/zeronet/ZeroMail
+ git checkout $ZERONET_MAIL_COMMIT -b $ZERONET_MAIL_COMMIT
+ if ! grep -q "ZeroNet Mail commit" $COMPLETION_FILE; then
+ echo "ZeroNet Mail commit:$ZERONET_MAIL_COMMIT" >> $COMPLETION_FILE
+ else
+ sed -i "s/ZeroNet Mail commit.*/ZeroNet Mail commit:$ZERONET_MAIL_COMMIT/g" $COMPLETION_FILE
+ fi
+
+ echo $"ZeroNet Mail address: $ZERONET_MAIL_ADDRESS"
+ echo $"ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY"
+ cp -r /opt/zeronet/ZeroMail/* /opt/zeronet/data/$ZERONET_MAIL_ADDRESS
+
+ if [ ! -d /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data ]; then
+ mkdir /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
+ fi
+ cp /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data-default/data.json /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
+ sed -i "s/MyZeroMail/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
+ sed -i "s/My ZeroMail./$ZERONET_DEFAULT_MAIL_TAGLINE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
+ sed -i "s/ZeroMail Demo/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
+ sed -i "s|
.*|$ZERONET_DEFAULT_MAIL_TAGLINE
|g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
+ sed -i "s/Mailging platform Demo/Mailging platform/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/content.json
+ python zeronet.py siteSign $ZERONET_MAIL_ADDRESS $ZERONET_MAIL_PRIVATE_KEY
+
+ # Add an avahi service
+ echo '' > /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ echo ' %h ZeroNet Mail' >> /tmp/zeronet-mail.service
+ echo ' ' >> /tmp/zeronet-mail.service
+ echo ' _zeronet._udp' >> /tmp/zeronet-mail.service
+ echo " $ZERONET_PORT" >> /tmp/zeronet-mail.service
+ echo " $ZERONET_URL/$ZERONET_MAIL_ADDRESS" >> /tmp/zeronet-mail.service
+ echo ' ' >> /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ cp /tmp/zeronet-mail.service /etc/avahi/services/zeronet-mail.service
+
+ if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
+ mkdir -p /home/$MY_USERNAME/.config/zeronet
+ chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
+ fi
+ echo "$ZERONET_URL/$ZERONET_MAIL_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/mymail
+
+ if ! grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
+ echo '' >> /home/$MY_USERNAME/README
+ echo "ZeroNet Mail address: $ZERONET_MAIL_ADDRESS" >> /home/$MY_USERNAME/README
+ echo "ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY" >> /home/$MY_USERNAME/README
+ fi
+
+ echo 'install_zeronet_mail' >> $COMPLETION_FILE
+}
+
function install_zeronet_forum {
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
return
@@ -8826,6 +8958,7 @@ install_zeronet
install_watchdog_script
configure_avahi
install_zeronet_blog
+install_zeronet_mail
install_zeronet_forum
#install_atheros_wifi
configure_firewall_for_cjdns
diff --git a/src/freedombone-meshweb b/src/freedombone-meshweb
index a874b9dc..be8c5a2a 100755
--- a/src/freedombone-meshweb
+++ b/src/freedombone-meshweb
@@ -16,6 +16,8 @@ PEERS_FILE=/tmp/meshwebstart
ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet'
ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
+ZERONET_MAIL_REPO='https://github.com/HelloZeroNet/ZeroMail'
+ZERONET_MAIL_COMMIT='955af09d643c72b02e4983d71eca5c0c93a6c131'
ZERONET_URL=http://127.0.0.1:43110
ZERONET_PORT=15441
TRACKER_PORT=6969
@@ -24,6 +26,7 @@ ZERONET_DIR=/home/$MY_USERNAME/zeronet
UPDATED="no"
ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
+ZERONET_DEFAULT_MAIL_TAGLINE="Mail for the Mesh"
IPFS_PORT=4001
@@ -191,6 +194,101 @@ function install_zeronet_blog {
echo $'Zeronet blog installed'
}
+function install_zeronet_mail {
+ if [ ! -f /home/$MY_USERNAME/README ]; then
+ touch /home/$MY_USERNAME/README
+ fi
+
+ if grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
+ return
+ fi
+
+ if [ ! -d /etc/avahi ]; then
+ echo 'Avahi is not installed'
+ exit 736
+ fi
+
+ ZERONET_DEFAULT_MAIL_TITLE="${MY_USERNAME}'s Mail"
+
+ cd /opt/zeronet
+ python zeronet.py --batch siteCreate 2> /opt/zeronet/mail.txt
+ if [ ! -f /opt/zeronet/mail.txt ]; then
+ echo 'Unable to create mail'
+ exit 479
+ fi
+ mail_address=$(cat mail.txt | grep "Site address" | awk -F ':' '{print $2}')
+ mail_private_key=$(cat mail.txt | grep "Site private key" | awk -F ':' '{print $2}')
+ ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
+ ZERONET_MAIL_PRIVATE_KEY=${mail_private_key//[[:blank:]]/}
+
+ if [ ${#ZERONET_MAIL_ADDRESS} -lt 20 ]; then
+ echo $"Address: $ZERONET_MAIL_ADDRESS"
+ echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
+ echo $'Unable to create zeronet mail address'
+ exit 7358
+ fi
+
+ if [ ${#ZERONET_MAIL_PRIVATE_KEY} -lt 20 ]; then
+ echo $"Address: $ZERONET_MAIL_ADDRESS"
+ echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
+ echo $'Unable to create zeronet mail private key'
+ exit 1639
+ fi
+
+ if [ ! -d "/opt/zeronet/data/$ZERONET_MAIL_ADDRESS" ]; then
+ echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_MAIL_ADDRESS"
+ exit 7638
+ fi
+
+ git clone $ZERONET_MAIL_REPO ZeroMail
+ if [ ! -d /opt/zeronet/ZeroMail ]; then
+ echo 'ZeroMail repo could not be cloned'
+ exit 6739
+ fi
+ cd /opt/zeronet/ZeroMail
+ git checkout $ZERONET_MAIL_COMMIT -b $ZERONET_MAIL_COMMIT
+
+ echo $"ZeroNet Mail address: $ZERONET_MAIL_ADDRESS"
+ echo $"ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY"
+ cp -r /opt/zeronet/ZeroMail/* /opt/zeronet/data/$ZERONET_MAIL_ADDRESS
+
+ if [ ! -d /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data ]; then
+ mkdir /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
+ fi
+ cp /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data-default/data.json /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
+ sed -i "s/MyZeroMail/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
+ sed -i "s/My ZeroMail./$ZERONET_DEFAULT_MAIL_TAGLINE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
+ sed -i "s/ZeroMail Demo/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
+ sed -i "s|.*|$ZERONET_DEFAULT_MAIL_TAGLINE
|g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
+ sed -i "s/Mailging platform Demo/Mailging platform/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/content.json
+ python zeronet.py siteSign $ZERONET_MAIL_ADDRESS $ZERONET_MAIL_PRIVATE_KEY
+
+ # Add an avahi service
+ echo '' > /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ echo ' %h ZeroNet Mail' >> /tmp/zeronet-mail.service
+ echo ' ' >> /tmp/zeronet-mail.service
+ echo ' _zeronet._udp' >> /tmp/zeronet-mail.service
+ echo " $ZERONET_PORT" >> /tmp/zeronet-mail.service
+ echo " $ZERONET_URL/$ZERONET_MAIL_ADDRESS" >> /tmp/zeronet-mail.service
+ echo ' ' >> /tmp/zeronet-mail.service
+ echo '' >> /tmp/zeronet-mail.service
+ cp /tmp/zeronet-mail.service /etc/avahi/services/zeronet-mail.service
+
+ if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
+ mkdir -p /home/$MY_USERNAME/.config/zeronet
+ chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
+ fi
+ echo "$ZERONET_URL/$ZERONET_MAIL_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/mymail
+
+ if ! grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
+ echo '' >> /home/$MY_USERNAME/README
+ echo "ZeroNet Mail address: $ZERONET_MAIL_ADDRESS" >> /home/$MY_USERNAME/README
+ echo "ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY" >> /home/$MY_USERNAME/README
+ fi
+}
+
function install_zeronet_forum {
if [ ! -f /home/$MY_USERNAME/README ]; then
touch /home/$MY_USERNAME/README
@@ -350,6 +448,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then
install_web_server
install_zeronet
install_zeronet_blog
+ install_zeronet_mail
install_zeronet_forum
install_ipfs
sudo batman start
diff --git a/src/zeronetavahi b/src/zeronetavahi
index 89a69f5c..2c929033 100755
--- a/src/zeronetavahi
+++ b/src/zeronetavahi
@@ -51,6 +51,7 @@ if [ ! -d $ZERONET_INSTALL ]; then
fi
BLOGS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-blogs
+MAIL_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-mail
FORUM_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-fora
TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users
ZERONET_INDEX=/home/$MY_USERNAME/mesh.html
@@ -61,6 +62,7 @@ IPFS_PORT=4001
function create_index {
if [ -f $ZERONET_INDEX ]; then
sed -i "s|.*My Blog.*|
My Blog|g" $ZERONET_INDEX
+ sed -i "s|.*My Mail.*| My Mail|g" $ZERONET_INDEX
sed -i "s|.*My Forum.*| My Forum|g" $ZERONET_INDEX
return
fi
@@ -76,6 +78,7 @@ function create_index {
echo '' >> $ZERONET_INDEX
echo '' >> $ZERONET_INDEX
echo " - My Blog
" >> $ZERONET_INDEX
+ echo " - My Mail
" >> $ZERONET_INDEX
echo " - My Forum
" >> $ZERONET_INDEX
echo " - File Share
" >> $ZERONET_INDEX
echo '
' >> $ZERONET_INDEX
@@ -84,6 +87,7 @@ function create_index {
echo '' >> $ZERONET_INDEX
echo '' >> $ZERONET_INDEX
echo " - Blogs
" >> $ZERONET_INDEX
+ echo " - Mail
" >> $ZERONET_INDEX
echo " - Fora
" >> $ZERONET_INDEX
echo " - Tox Users
" >> $ZERONET_INDEX
echo '
' >> $ZERONET_INDEX
@@ -194,6 +198,45 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
done < "$TEMPFILE"
echo '' >> $BLOGS_FILE.new
+
+# detect mail in the mesh
+if [ -f $MAIL_FILE.new ]; then
+ rm -f $MAIL_FILE.new
+fi
+
+cat $TEMPFILE_BASE | grep "ZeroNet Mail\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+
+state=0
+address=""
+peer=""
+echo '' >> $MAIL_FILE.new
+while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ mail_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ echo " - ${peer}
" >> $MAIL_FILE.new
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"ZeroNet Mail"* && $line == "= "* ]]; then
+ state=1
+ fi
+done < "$TEMPFILE"
+echo '
' >> $MAIL_FILE.new
+
+
# detect fora in the mesh
if [ -f $FORUM_FILE.new ]; then
rm -f $FORUM_FILE.new
@@ -297,9 +340,11 @@ fi
# make some html headers and footers
create_header $BLOGS_FILE "Blogs"
+create_header $MAIL_FILE "Mail"
create_header $FORUM_FILE "Fora"
create_header $TOX_USERS_FILE "Tox Users"
create_footer $BLOGS_FILE
+create_footer $MAIL_FILE
create_footer $FORUM_FILE
create_footer $TOX_USERS_FILE
@@ -313,6 +358,13 @@ if [ -d $ZERONET_USER_HOME ]; then
sudo chown zeronet:zeronet $BLOGS_FILE
fi
+# create a web page showing the available mail contacts
+cat ${MAIL_FILE}-header.html ${MAIL_FILE}.new ${MAIL_FILE}-footer.html > ${MAIL_FILE}.html
+rm -f ${MAIL_FILE}.new
+if [ -d $ZERONET_USER_HOME ]; then
+ sudo chown zeronet:zeronet $MAIL_FILE
+fi
+
# create a web page showing the available fora
cat ${FORUM_FILE}-header.html ${FORUM_FILE}.new ${FORUM_FILE}-footer.html > ${FORUM_FILE}.html
rm -f ${FORUM_FILE}.new