diff --git a/img/android-app/rsync.png b/img/android-app/rsync.png new file mode 100644 index 0000000000000000000000000000000000000000..77c66b089cf3c707e2d2ab80866910640be95014 Binary files /dev/null and b/img/android-app/rsync.png differ diff --git a/src/freedombone-app-rsync b/src/freedombone-app-rsync new file mode 100755 index 0000000000000000000000000000000000000000..2730bb787079fe6bc8f7651db19ef33a814dca0f --- /dev/null +++ b/src/freedombone-app-rsync @@ -0,0 +1,209 @@ +#!/bin/bash +# +# _____ _ _ +# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___ +# | __| _| -_| -_| . | . | | . | . | | -_| +# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___| +# +# Freedom in the Cloud +# +# License +# ======= +# +# Copyright (C) 2019 Bob Mottram <bob@freedombone.net> +# +# 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/>. + +VARIANTS='full full-vim' + +APP_CATEGORY=sync + +IN_DEFAULT_INSTALL=0 +INSTALLED_ON_DEFAULT_DOMAIN=1 +SHOW_ON_ABOUT=1 + +RSYNC_DATA=/var/lib/rsync + +# whether to show the domain name in the web UI +SHOW_DOMAIN_IN_WEBADMIN=1 +NOT_ON_API=0 + +# Whether to show on http://freedombone/home +NOT_ON_HOMEPAGE=1 + +RSYNC_DOMAIN_NAME= +RSYNC_CODE= +RSYNC_ONION_PORT=9951 +RSYNC_PORT=873 + +# These parameters are used by the FreedomBox mobile app and web UI +RSYNC_SHORT_DESCRIPTION=rsync daemon +RSYNC_DESCRIPTION=rsync daemon +RSYNC_MOBILE_APP_URL=https://f-droid.org/wiki/page/org.amoradi.syncopoli + +rsync_variables=(ONION_ONLY + RSYNC_CODE + DDNS_PROVIDER + MY_USERNAME) + +function change_default_domain_name_rsync { + new_default_domain_name="$1" + # If anything references DEFAULT_DOMAIN_NAME then change it here +} + +function logging_on_rsync { + echo -n '' +} + +function logging_off_rsync { + echo -n '' +} + +function remove_user_rsync { + remove_username="$1" +} + +function add_user_rsync { + new_username="$1" + new_user_password="$2" + + echo '0' +} + +function install_interactive_rsync { + if [ ! "$ONION_ONLY" ]; then + ONION_ONLY='no' + fi + + APP_INSTALLED=1 +} + +function change_password_rsync { + curr_username="$1" + new_user_password="$2" +} + +function reconfigure_rsync { + # This is used if you need to switch identity. Dump old keys and generate new ones + echo -n '' +} + +function configure_interactive_rsync { + echo -n '' +} + +function upgrade_rsync { + chown -R rsync:rsync "$RSYNC_DATA" +} + +function backup_local_rsync { + echo -n '' +} + +function restore_local_rsync { + echo -n '' +} + +function backup_remote_rsync { + echo -n '' +} + +function restore_remote_rsync { + echo -n '' +} + +function remove_rsync { + firewall_remove $RSYNC_PORT tcp + + if [ -f /etc/systemd/system/rsync.service ]; then + systemctl stop rsync + systemctl disable rsync + rm /etc/systemd/system/rsync.service + fi + userdel -r rsync + rm -rf "$RSYNC_DATA" + + remove_app rsync + remove_completion_param install_rsync + sed -i '/rsync/d' "$COMPLETION_FILE" +} + +function install_rsync { + $INSTALL_PACKAGES rsync + + increment_app_install_progress + + if [ ! -d "$RSYNC_DATA" ]; then + mkdir "$RSYNC_DATA" + fi + if [ ! -d /etc/rsync ]; then + mkdir /etc/rsync + fi + + { echo 'pid file = /var/run/rsyncd.pid'; + echo 'lock file = /var/run/rsync.lock'; + echo 'log file = /dev/null'; + echo "port = $RSYNC_PORT"; + echo ''; + echo '[files]'; + echo "path = $RSYNC_DATA"; + echo 'comment = RSYNC FILES'; + echo 'read only = true'; + echo 'timeout = 300'; } > /etc/rsync/rsyncd.conf + + increment_app_install_progress + + adduser --system --home="$RSYNC_DATA" --group rsync + + increment_app_install_progress + + chown -R rsync:rsync /etc/rsync + chown -R rsync:rsync "$RSYNC_DATA" + + increment_app_install_progress + + { echo '[Unit]'; + echo 'Description=rsync'; + echo 'After=syslog.target'; + echo 'After=network.target'; + echo "Documentation=$RSYNC_REPO"; + echo ''; + echo '[Service]'; + echo 'Type=simple'; + echo 'User=rsync'; + echo 'Group=rsync'; + echo "WorkingDirectory=$RSYNC_DATA"; + echo 'ExecStart=/usr/bin/rsync --config=/etc/rsync/rsyncd.conf --daemon'; + echo 'Environment=USER=rsync'; + echo 'Restart=always'; + echo 'StandardError=syslog'; + echo ''; + echo '[Install]'; + echo 'WantedBy=multi-user.target'; } > "/etc/systemd/system/rsync.service" + + increment_app_install_progress + + systemctl enable rsync + systemctl start rsync + + increment_app_install_progress + + firewall_add rsync $RSYNC_PORT tcp + + increment_app_install_progress + + APP_INSTALLED=1 +} + +# NOTE: deliberately there is no "exit 0"