Move to repo version of tahoe-lafs
For magic folder and maybe multiple introducers in future
This commit is contained in:
parent
644d51c8a8
commit
ccdf314253
|
@ -30,17 +30,21 @@
|
|||
|
||||
VARIANTS='mesh'
|
||||
|
||||
TAHOELAFS_REPO="https://github.com/tahoe-lafs/tahoe-lafs"
|
||||
TAHOELAFS_COMMIT='30b421d48b3d1dae2ef507bf27a1f3816300cd92'
|
||||
|
||||
TAHOELAFS_PORT=50213
|
||||
TAHOELAFS_WEB_PORT=3456
|
||||
TAHOELAFS_STORAGE_SPACE=1G
|
||||
TAHOELAFS_SHARED_DIR='Shared'
|
||||
TAHOE_COMMAND="cd /var/lib/tahoelafs && venv/bin/tahoe"
|
||||
|
||||
function reconfigure_tahoelafs {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [ -d /home/$USERNAME/.tahoe ]; then
|
||||
su -c 'tahoe stop' - $USERNAME
|
||||
su -c "$TAHOE_COMMAND stop" - $USERNAME
|
||||
rm -rf /home/$USERNAME/.tahoe
|
||||
fi
|
||||
|
||||
|
@ -48,7 +52,7 @@ function reconfigure_tahoelafs {
|
|||
rm -rf /home/$USERNAME/${TAHOELAFS_SHARED_DIR}
|
||||
fi
|
||||
|
||||
su -c 'tahoe create-node' - $USERNAME
|
||||
su -c "cd $TAHOE_COMMAND create-node" - $USERNAME
|
||||
|
||||
if [ ! -d /home/$USERNAME/.tahoe ]; then
|
||||
exit 63722
|
||||
|
@ -87,12 +91,13 @@ function reconfigure_tahoelafs {
|
|||
echo '[helper]' >> $TAHOELAFS_CONFIG
|
||||
echo 'enabled = false' >> $TAHOELAFS_CONFIG
|
||||
echo '' >> $TAHOELAFS_CONFIG
|
||||
echo '[drop_upload]' >> $TAHOELAFS_CONFIG
|
||||
echo '[magic_folder]' >> $TAHOELAFS_CONFIG
|
||||
echo 'enabled = true' >> $TAHOELAFS_CONFIG
|
||||
echo "local.directory = ~/${TAHOELAFS_SHARED_DIR}" >> $TAHOELAFS_CONFIG
|
||||
echo "local.directory = /home/${USERNAME}/${TAHOELAFS_SHARED_DIR}" >> $TAHOELAFS_CONFIG
|
||||
chown $USERNAME:$USERNAME $TAHOELAFS_CONFIG
|
||||
|
||||
su -c 'tahoe start' - $USERNAME
|
||||
su -c "$TAHOE_COMMAND start" - $USERNAME
|
||||
su -c "$TAHOE_COMMAND magic-folder create $HOSTNAME" - $USERNAME
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -131,8 +136,15 @@ function remove_tahoelafs {
|
|||
function_check save_firewall_settings
|
||||
save_firewall_settings
|
||||
|
||||
pip uninstall tahoe-lafs
|
||||
apt-get -y remove --purge tahoe-lafs
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [ -f /home/$USERNAME/.tahoe ]; then
|
||||
su -c "$TAHOE_COMMAND stop" - $USERNAME
|
||||
rm -rf /home/$USERNAME/.tahoe
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf /var/lib/tahoelafs
|
||||
|
||||
sed -i '/install_tahoelafs/d' $COMPLETION_FILE
|
||||
sed -i '/configure_firewall_for_tahoelafs/d' $COMPLETION_FILE
|
||||
|
@ -152,6 +164,7 @@ function configure_firewall_for_tahoelafs {
|
|||
|
||||
function tahoelafs_update_script {
|
||||
update_script_filename=$1
|
||||
update_script_type=$2
|
||||
|
||||
echo '#!/bin/bash' > $update_script_filename
|
||||
echo 'PEERS_FILE=$(mktemp /tmp/tahoelafs-peers.XXXXXX)' >> $update_script_filename
|
||||
|
@ -187,23 +200,44 @@ function tahoelafs_update_script {
|
|||
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 ' 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
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ' chown $USERNAME:$USERNAME /home/$USERNAME/.tahoe/tahoe.cfg' >> $update_script_filename
|
||||
echo ' su -c "tahoe 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 'done' >> $update_script_filename
|
||||
echo '' >> $update_script_filename
|
||||
|
||||
echo 'exit 0' >> $update_script_filename
|
||||
chmod +x $update_script_filename
|
||||
}
|
||||
|
||||
function mesh_install_tahoelafs {
|
||||
chroot "$rootdir" apt-get -y install python-pip tahoe-lafs
|
||||
chroot "$rootdir" pip install tahoe-lafs
|
||||
chroot "$rootdir" su -c 'tahoe create-client' - $MY_USERNAME
|
||||
if [ ! -d $rootdir/home/$MY_USERNAME/.tahoe ]; then
|
||||
exit 63722
|
||||
fi
|
||||
chroot "$rootdir" apt-get -y install build-essential python-pip python-dev
|
||||
chroot "$rootdir" apt-get -y install libffi-dev libssl-dev python-virtualenv
|
||||
|
||||
git clone $TAHOELAFS_REPO $rootdir/var/lib/tahoelafs
|
||||
cd $rootdir/var/lib/tahoelafs
|
||||
git checkout $TAHOELAFS_COMMIT -b $TAHOELAFS_COMMIT
|
||||
|
||||
cat <<EOF > $rootdir/root/install_tahoelafs
|
||||
cd /var/lib/tahoelafs
|
||||
virtualenv venv
|
||||
venv/bin/pip install --editable .
|
||||
EOF
|
||||
chroot "$rootdir" chmod +x /root/install_tahoelafs
|
||||
chroot "$rootdir" /root/install_tahoelafs
|
||||
chroot "$rootdir" rm /root/install_tahoelafs
|
||||
|
||||
tahoelafs_update_script $rootdir/usr/bin/update-tahoelafs
|
||||
|
||||
if ! grep -q "update-tahoelafs" $rootdir/etc/crontab; then
|
||||
|
@ -221,14 +255,19 @@ function install_tahoelafs {
|
|||
return
|
||||
fi
|
||||
|
||||
apt-get -y install python-pip tahoe-lafs
|
||||
pip install tahoe-lafs
|
||||
apt-get -y install build-essential python-pip python-dev libffi-dev libssl-dev python-virtualenv
|
||||
|
||||
git_clone $TAHOELAFS_REPO /var/lib/tahoelafs
|
||||
cd /var/lib/tahoelafs
|
||||
git checkout $TAHOELAFS_COMMIT -b $TAHOELAFS_COMMIT
|
||||
virtualenv venv
|
||||
venv/bin/pip install --editable .
|
||||
configure_firewall_for_tahoelafs
|
||||
reconfigure_tahoelafs
|
||||
tahoelafs_update_script /usr/bin/update-tahoelafs
|
||||
|
||||
function_check cron_add_mins
|
||||
cron_add_mins 1 '/usr/bin/update-tahoelafs 2> /dev/null'
|
||||
cron_add_mins 1 "/usr/bin/update-tahoelafs 2> /dev/null"
|
||||
|
||||
echo 'install_tahoelafs' >> $COMPLETION_FILE
|
||||
}
|
||||
|
|
|
@ -604,6 +604,7 @@ function mesh_client_startup_applications {
|
|||
|
||||
START_DESKTOP=$rootdir/home/$MY_USERNAME/mesh-desktop.sh
|
||||
FIRST_BOOT=/home/$MY_USERNAME/.first_boot
|
||||
TAHOE_COMMAND="cd /var/lib/tahoelafs && venv/bin/tahoe"
|
||||
echo '#!/bin/bash' > $START_DESKTOP
|
||||
echo "setxkbmap ${KEYBOARD_MAP}" > $START_DESKTOP
|
||||
echo 'dconf write /org/mate/caja/desktop/volumes-visible false' >> $START_DESKTOP
|
||||
|
@ -628,6 +629,7 @@ function mesh_client_startup_applications {
|
|||
|
||||
echo '' >> $START_DESKTOP
|
||||
echo "if [ ! -f $FIRST_BOOT ]; then" >> $START_DESKTOP
|
||||
echo " $TAHOE_COMMAND start" >> $START_DESKTOP
|
||||
echo ' exit 0' >> $START_DESKTOP
|
||||
echo 'fi' >> $START_DESKTOP
|
||||
echo '' >> $START_DESKTOP
|
||||
|
@ -652,6 +654,12 @@ function mesh_client_startup_applications {
|
|||
echo '' >> $START_DESKTOP
|
||||
echo 'toxid --setuser "$INITIAL_TOX_USERNAME"' >> $START_DESKTOP
|
||||
echo '' >> $START_DESKTOP
|
||||
echo "if [ -f /home/$MY_USERNAME/.tahoe/tahoe.cfg ]; then" >> $START_DESKTOP
|
||||
echo " sed -i 's|nickname =.*|nickname = \$INITIAL_TOX_USERNAME|g' /home/$MY_USERNAME/.tahoe/tahoe.cfg" >> $START_DESKTOP
|
||||
|
||||
echo " $TAHOE_COMMAND restart" >> $START_DESKTOP
|
||||
echo 'fi' >> $START_DESKTOP
|
||||
echo '' >> $START_DESKTOP
|
||||
echo "rm -f $FIRST_BOOT" >> $START_DESKTOP
|
||||
echo '' >> $START_DESKTOP
|
||||
echo 'exit 0' >> $START_DESKTOP
|
||||
|
|
|
@ -523,7 +523,7 @@ function show_desktop_icons {
|
|||
chown ${MY_USERNAME}:${MY_USERNAME} /home/$MY_USERNAME/*.sh
|
||||
|
||||
# link to Tahoe-LAFS Magic folder
|
||||
ln -s /home/${MY_USERNAME}/Desktop/${TAHOELAFS_SHARED_DIR} /home/${MY_USERNAME}/${TAHOELAFS_SHARED_DIR}
|
||||
#ln -s /home/${MY_USERNAME}/Desktop/${TAHOELAFS_SHARED_DIR} /home/${MY_USERNAME}/${TAHOELAFS_SHARED_DIR}
|
||||
|
||||
# restart caja
|
||||
killall caja
|
||||
|
|
Loading…
Reference in New Issue