Allow mesh client identity to be reset

This commit is contained in:
Bob Mottram 2016-07-21 22:43:40 +01:00
parent 70578c7749
commit d5e5d26d06
3 changed files with 481 additions and 342 deletions

View File

@ -574,7 +574,15 @@ function mesh_client_startup_applications {
echo 'Icon=qtox' >> $rootdir/home/$MY_USERNAME/Desktop/tox.desktop
echo 'StartupNotify=true' >> $rootdir/home/$MY_USERNAME/Desktop/tox.desktop
cp $rootdir/home/$MY_USERNAME/Desktop/tox.desktop $rootdir/home/$MY_USERNAME/.config/autostart/tox.desktop
echo '[Desktop Entry]' > $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'Name=New Identity' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'Type=Application' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'Comment=Create a new identity' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'TryExec=freedombone-mesh-reset' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'Exec=freedombone-mesh-reset' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
echo 'Icon=user-away' >> $rootdir/home/$MY_USERNAME/Desktop/new_identity.desktop
#cp $rootdir/home/$MY_USERNAME/Desktop/tox.desktop $rootdir/home/$MY_USERNAME/.config/autostart/tox.desktop
chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
}

View File

@ -48,6 +48,8 @@ TOX_NODES=
#)
MESH_INSTALL_DIR=/var/lib
MESH_INSTALL_COMPLETED=/root/.mesh_setup_completed
MESH_INSTALL_SETUP=/root/.initial_mesh_setup
function set_hostname {
DEFAULT_DOMAIN_NAME="$1"
@ -72,6 +74,9 @@ function change_avahi_name {
echo "New avahi name for this peer is P$PEER_ID"
toilet "mesh-$PEER_ID"
echo $"avahi name changed to P${PEER_ID}.local" >> $INSTALL_LOG
if [ -f $MESH_INSTALL_COMPLETED ]; then
systemctl restart avahi-daemon
fi
}
function regenerate_ssh_host_keys {
@ -83,6 +88,10 @@ function regenerate_ssh_host_keys {
awk '$5 > 2000' /etc/ssh/moduli > ~/moduli
mv ~/moduli /etc/ssh/moduli
echo $'ssh small moduli removed' >> $INSTALL_LOG
if [ -f $MESH_INSTALL_COMPLETED ]; then
systemctl restart ssh
fi
}
function configure_zeronet {
@ -90,7 +99,25 @@ function configure_zeronet {
echo $"zeronet daemon updated to P${PEER_ID}.local" >> $INSTALL_LOG
}
function remove_zeronet_blog {
blog_address=$(cat $MESH_INSTALL_DIR/zeronet/blog.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_BLOG_ADDRESS=${blog_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/*.json
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/data/*
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/post/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/post
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS
fi
}
function configure_zeronet_blog {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_blog
fi
echo $'Updating ZeroNet Blog' >> $INSTALL_LOG
ZERONET_DEFAULT_BLOG_TITLE="${MY_USERNAME}'s Blog"
@ -100,8 +127,8 @@ function configure_zeronet_blog {
echo $'Unable to create ZeroNet blog' >> $INSTALL_LOG
exit 7386
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}')
blog_address=$(cat $MESH_INSTALL_DIR/zeronet/blog.txt | grep "Site address" | awk -F ':' '{print $2}')
blog_private_key=$(cat $MESH_INSTALL_DIR/zeronet/blog.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_BLOG_ADDRESS=${blog_address//[[:blank:]]/}
ZERONET_BLOG_PRIVATE_KEY=${blog_private_key//[[:blank:]]/}
@ -168,7 +195,24 @@ function configure_zeronet_blog {
echo $'Update of ZeroNet Blog completed' >> $INSTALL_LOG
}
function remove_zeronet_mail {
mail_address=$(cat $MESH_INSTALL_DIR/zeronet/mail.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/*.json
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/users/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/users
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS
fi
}
function configure_zeronet_mail {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_mail
fi
echo $'Updating ZeroNet Mail' >> $INSTALL_LOG
ZERONET_DEFAULT_MAIL_TITLE="${MY_USERNAME}'s Mail"
@ -178,8 +222,8 @@ function configure_zeronet_mail {
echo $'Unable to create ZeroNet mail' >> $INSTALL_LOG
exit 72574
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}')
mail_address=$(cat $MESH_INSTALL_DIR/zeronet/mail.txt | grep "Site address" | awk -F ':' '{print $2}')
mail_private_key=$(cat $MESH_INSTALL_DIR/zeronet/mail.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
ZERONET_MAIL_PRIVATE_KEY=${mail_private_key//[[:blank:]]/}
@ -246,7 +290,23 @@ function configure_zeronet_mail {
echo $'Update of ZeroNet Mail completed' >> $INSTALL_LOG
}
function remove_zeronet_forum {
forum_address=$(cat $MESH_INSTALL_DIR/zeronet/forum.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_FORUM_ADDRESS=${forum_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/users/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/users
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/*
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/*.json
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS
fi
}
function configure_zeronet_forum {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_forum
fi
echo $'Updating ZeroNet Forum' >> $INSTALL_LOG
ZERONET_DEFAULT_FORUM_TITLE="${MY_USERNAME}'s Forum"
@ -256,8 +316,8 @@ function configure_zeronet_forum {
echo $'Unable to create ZeroNet forum' >> $INSTALL_LOG
exit 47962
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}')
forum_address=$(cat $MESH_INSTALL_DIR/zeronet/forum.txt | grep "Site address" | awk -F ':' '{print $2}')
forum_private_key=$(cat $MESH_INSTALL_DIR/zeronet/forum.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_FORUM_ADDRESS=${forum_address//[[:blank:]]/}
ZERONET_FORUM_PRIVATE_KEY=${forum_private_key//[[:blank:]]/}
@ -319,7 +379,19 @@ function configure_zeronet_forum {
echo $'Update of ZeroNet Forum completed' >> $INSTALL_LOG
}
function remove_zeronet_id {
zeroid_address=$(cat $MESH_INSTALL_DIR/zeronet/zeroid.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_ID_ADDRESS=${zeroid_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS
fi
}
function configure_zeronet_id {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_id
fi
echo $'Updating ZeroID' >> $INSTALL_LOG
cd $MESH_INSTALL_DIR/zeronet
@ -328,8 +400,8 @@ function configure_zeronet_id {
echo $'Unable to create ZeroID' >> $INSTALL_LOG
exit 47962
fi
zeroid_address=$(cat zeroid.txt | grep "Site address" | awk -F ':' '{print $2}')
zeroid_private_key=$(cat zeroid.txt | grep "Site private key" | awk -F ':' '{print $2}')
zeroid_address=$(cat $MESH_INSTALL_DIR/zeronet/zeroid.txt | grep "Site address" | awk -F ':' '{print $2}')
zeroid_private_key=$(cat $MESH_INSTALL_DIR/zeronet/zeroid.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_ID_ADDRESS=${zeroid_address//[[:blank:]]/}
ZERONET_ID_PRIVATE_KEY=${zeroid_private_key//[[:blank:]]/}
@ -450,7 +522,16 @@ function enable_batman_daemon {
systemctl daemon-reload
}
if [ -f /root/.initial_mesh_setup ]; then
# whether to reset the identity
if [ $2 ]; then
if [[ "$2" == $"new"* ]]; then
if [ ! -f $MESH_INSTALL_SETUP ]; then
touch $MESH_INSTALL_SETUP
fi
fi
fi
if [ -f $MESH_INSTALL_SETUP ]; then
if [ $1 ]; then
MY_USERNAME=$1
fi
@ -476,9 +557,9 @@ if [ -f /root/.initial_mesh_setup ]; then
disable_password_logins
disable_screen_lock
rm /root/.initial_mesh_setup
rm $MESH_INSTALL_SETUP
systemctl disable mesh-setup.service
touch /root/.mesh_setup_completed
touch $MESH_INSTALL_COMPLETED
echo $'Mesh node setup complete. Rebooting...' >> $INSTALL_LOG
reboot
fi

50
src/freedombone-mesh-reset Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Resets the identity of a mesh user
#
# License
# =======
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-mesh-reset
export TEXTDOMAINDIR="/usr/share/locale"
dialog --title $"New Identity" \
--backtitle $"Freedombone Mesh" \
--defaultno \
--yesno $"\nDo you want to reset your identity? This will reset ALL data for this peer, and you will not be able to recover it." 8 60
sel=$?
case $sel in
0) sudo pkill qtox
sudo pkill firefox
sudo pkill iceweasel
sudo ${PROJECT_NAME}-image-mesh $USER new
sudo batman restart
dialog --title $"New Identity" \
--msgbox $"You now have a new identity" 6 40
;;
esac
exit 0