Support for amnesia

This commit is contained in:
Bob Mottram 2016-07-22 09:39:21 +01:00
parent 1e626eb44d
commit 3f01621a23
2 changed files with 47 additions and 20 deletions

View File

@ -2016,7 +2016,7 @@ function show_result {
echo '' echo ''
} }
function read_configuration { function read_config {
if [ ! $CONFIGURATION_FILE ]; then if [ ! $CONFIGURATION_FILE ]; then
CONFIGURATION_FILE='freedombone.cfg' CONFIGURATION_FILE='freedombone.cfg'
fi fi
@ -2191,7 +2191,7 @@ function read_configuration {
fi fi
} }
read_configuration read_config
interactive_config interactive_config
show_result show_result
exit 0 exit 0

View File

@ -75,9 +75,6 @@ function change_avahi_name {
echo "New avahi name for this peer is P$PEER_ID" echo "New avahi name for this peer is P$PEER_ID"
toilet "mesh-$PEER_ID" toilet "mesh-$PEER_ID"
echo $"avahi name changed to P${PEER_ID}.local" >> $INSTALL_LOG 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 { function regenerate_ssh_host_keys {
@ -89,10 +86,6 @@ function regenerate_ssh_host_keys {
awk '$5 > 2000' /etc/ssh/moduli > ~/moduli awk '$5 > 2000' /etc/ssh/moduli > ~/moduli
mv ~/moduli /etc/ssh/moduli mv ~/moduli /etc/ssh/moduli
echo $'ssh small moduli removed' >> $INSTALL_LOG echo $'ssh small moduli removed' >> $INSTALL_LOG
if [ -f $MESH_INSTALL_COMPLETED ]; then
systemctl restart ssh
fi
} }
function configure_zeronet { function configure_zeronet {
@ -528,21 +521,29 @@ function enable_batman_daemon {
function mesh_amnesic { function mesh_amnesic {
if [ ! -f $MESH_AMNESIC ]; then if [ ! -f $MESH_AMNESIC ]; then
if [ -f /etc/systemd/system/amnesic.service ]; then
systemctl disable amnesic
fi
return return
fi fi
echo '#!/bin/bash' > /usr/bin/amnesic
echo '' >> /usr/bin/amnesic
echo 'MY_USERNAME=$1' >> /usr/bin/amnesic
echo -n "${PROJECT_NAME}-image-mesh " >> /usr/bin/amnesic
echo '$MY_USERNAME amnesic' >> /usr/bin/amnesic
echo '' >> /usr/bin/amnesic
echo 'exit 0' >> /usr/bin/amnesic
chmod +x /usr/bin/amnesic
if [ ! -f /etc/systemd/system/amnesic.service ]; then if [ ! -f /etc/systemd/system/amnesic.service ]; then
echo '[Unit]' > /etc/systemd/system/amnesic.service echo '[Unit]' > /etc/systemd/system/amnesic.service
echo 'Description=Amnesic Mesh' >> /etc/systemd/system/amnesic.service echo 'Description=Amnesic Mesh' >> /etc/systemd/system/amnesic.service
echo '' >> /etc/systemd/system/amnesic.service echo '' >> /etc/systemd/system/amnesic.service
echo '[Service]' >> /etc/systemd/system/amnesic.service echo '[Service]' >> /etc/systemd/system/amnesic.service
echo 'User=root' >> /etc/systemd/system/amnesic.service
echo 'Group=root' >> /etc/systemd/system/amnesic.service
echo 'Type=oneshot' >> /etc/systemd/system/amnesic.service echo 'Type=oneshot' >> /etc/systemd/system/amnesic.service
echo 'RemainAfterExit=true' >> /etc/systemd/system/amnesic.service echo 'RemainAfterExit=true' >> /etc/systemd/system/amnesic.service
echo 'ExecStart=/bin/true' >> /etc/systemd/system/amnesic.service echo 'ExecStart=/bin/true' >> /etc/systemd/system/amnesic.service
echo 'ExecStop=TODO' >> /etc/systemd/system/amnesic.service echo 'ExecStop=/usr/bin/amnesic' >> /etc/systemd/system/amnesic.service
echo '' >> /etc/systemd/system/amnesic.service echo '' >> /etc/systemd/system/amnesic.service
echo '[Install]' >> /etc/systemd/system/amnesic.service echo '[Install]' >> /etc/systemd/system/amnesic.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/amnesic.service echo 'WantedBy=multi-user.target' >> /etc/systemd/system/amnesic.service
@ -553,12 +554,31 @@ function mesh_amnesic {
systemctl start amnesic systemctl start amnesic
} }
function mesh_restart_daemons {
systemctl restart avahi-daemon
systemctl restart ssh
systemctl restart tox-bootstrapd
systemctl restart zeronet
echo $'Daemons restarted' >> $INSTALL_LOG
}
# whether to reset the identity # whether to reset the identity
set_new_identity=
if [ $2 ]; then if [ $2 ]; then
if [[ "$2" == $"new"* ]]; then if [[ "$2" == $"new"* ]]; then
if [ ! -f $MESH_INSTALL_SETUP ]; then if [ ! -f $MESH_INSTALL_SETUP ]; then
touch $MESH_INSTALL_SETUP touch $MESH_INSTALL_SETUP
fi fi
set_new_identity=1
fi
if [[ "$2" == $"amnesic"* ]]; then
if [ ! -f $MESH_AMNESIC ]; then
touch $MESH_AMNESIC
fi
if [ ! -f $MESH_INSTALL_SETUP ]; then
touch $MESH_INSTALL_SETUP
fi
set_new_identity=1
fi fi
fi fi
@ -567,8 +587,10 @@ if [ -f $MESH_INSTALL_SETUP ]; then
MY_USERNAME=$1 MY_USERNAME=$1
fi fi
if [ ! $set_new_identity ]; then
# sleep in order to allow other daemons to start up # sleep in order to allow other daemons to start up
sleep 15 sleep 15
fi
# clear the install log # clear the install log
if [ -f $INSTALL_LOG ]; then if [ -f $INSTALL_LOG ]; then
@ -589,11 +611,16 @@ if [ -f $MESH_INSTALL_SETUP ]; then
disable_screen_lock disable_screen_lock
mesh_amnesic mesh_amnesic
if [ ! -f $MESH_AMNESIC ]; then
rm $MESH_INSTALL_SETUP rm $MESH_INSTALL_SETUP
systemctl disable mesh-setup.service systemctl disable mesh-setup.service
fi
mesh_restart_daemons
if [ ! -f $MESH_INSTALL_COMPLETED ]; then
echo $'Mesh node setup complete' >> $INSTALL_LOG
touch $MESH_INSTALL_COMPLETED touch $MESH_INSTALL_COMPLETED
echo $'Mesh node setup complete. Rebooting...' >> $INSTALL_LOG fi
reboot
fi fi
exit 0 exit 0