Update script only applies to mesh

This commit is contained in:
Bob Mottram 2016-08-29 11:28:49 +01:00
parent 5fe86e97e6
commit f3bf095e9f
1 changed files with 3 additions and 12 deletions

View File

@ -206,9 +206,9 @@ function configure_firewall_for_tahoelafs {
function tahoelafs_update_script { function tahoelafs_update_script {
update_script_filename=$1 update_script_filename=$1
update_script_type=$2
echo '#!/bin/bash' > $update_script_filename echo '#!/bin/bash' > $update_script_filename
echo 'TOX_USERNAME=$(toxid --showuser)' >> $update_script_filename
echo 'PEERS_FILE=$(mktemp /tmp/tahoelafs-peers.XXXXXX)' >> $update_script_filename echo 'PEERS_FILE=$(mktemp /tmp/tahoelafs-peers.XXXXXX)' >> $update_script_filename
echo -n 'avahi-browse -atl | grep "Workstation" | ' >> $update_script_filename echo -n 'avahi-browse -atl | grep "Workstation" | ' >> $update_script_filename
echo -n "awk -F ' ' '{print \$4}' " >> $update_script_filename echo -n "awk -F ' ' '{print \$4}' " >> $update_script_filename
@ -242,19 +242,10 @@ function tahoelafs_update_script {
echo ' if [ -f /home/$USERNAME/.tahoe/tahoe.cfg ]; then' >> $update_script_filename echo ' if [ -f /home/$USERNAME/.tahoe/tahoe.cfg ]; then' >> $update_script_filename
echo ' if ! grep -q "introducer.furl = ${furl}" /home/$USERNAME/.tahoe/tahoe.cfg; then' >> $update_script_filename echo ' if ! grep -q "introducer.furl = ${furl}" /home/$USERNAME/.tahoe/tahoe.cfg; then' >> $update_script_filename
echo ' sed -i "s|introducer.furl =.*|introducer.furl = ${furl}|g" /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename echo ' sed -i "s|introducer.furl =.*|introducer.furl = ${furl}|g" /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename
# change the nickname to the same as used by tox
if [ $update_script_type ]; then
if [[ $update_script_type == "mesh" ]]; then
echo ' TOX_USERNAME=$(toxid --showuser)' >> $update_script_filename
echo ' sed -i "s|nickname =.*|nickname = ${TOX_USERNAME}|g" /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename echo ' sed -i "s|nickname =.*|nickname = ${TOX_USERNAME}|g" /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename
fi
fi
echo ' chown $USERNAME:$USERNAME /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename echo ' chown $USERNAME:$USERNAME /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename
echo " su -c '$TAHOE_COMMAND restart' - \$USERNAME" >> $update_script_filename echo " su -c '$TAHOE_COMMAND restart' - \$USERNAME" >> $update_script_filename
echo ' fi' >> $update_script_filename echo ' fi' >> $update_script_filename
echo ' fi' >> $update_script_filename echo ' fi' >> $update_script_filename
echo 'done' >> $update_script_filename echo 'done' >> $update_script_filename
echo '' >> $update_script_filename echo '' >> $update_script_filename
@ -280,7 +271,7 @@ EOF
chroot "$rootdir" /root/install_tahoelafs chroot "$rootdir" /root/install_tahoelafs
chroot "$rootdir" rm /root/install_tahoelafs chroot "$rootdir" rm /root/install_tahoelafs
tahoelafs_update_script $rootdir/usr/bin/update-tahoelafs mesh tahoelafs_update_script $rootdir/usr/bin/update-tahoelafs
if ! grep -q "update-tahoelafs" $rootdir/etc/crontab; then if ! grep -q "update-tahoelafs" $rootdir/etc/crontab; then
echo "*/1 * * * * root /usr/bin/update-tahoelafs 2> /dev/null" >> $rootdir/etc/crontab echo "*/1 * * * * root /usr/bin/update-tahoelafs 2> /dev/null" >> $rootdir/etc/crontab