Verified Commit 20bde6f9 authored by Silvio Rhatto's avatar Silvio Rhatto
Browse files

Feat: adds sync-from-remotes (Closes #19)

parent 55af2cf1
#!/usr/bin/env bash
#
# Sync Onionmine to remote servers.
#
# Copyright (C) 2022 Silvio Rhatto <rhatto@torproject.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License,
# or 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Parameters
BASENAME="`basename $0`"
DIRNAME="`dirname $0`"
source $DIRNAME/params
# Check
if [ -z "$REMOTE_HOSTS_RSYNC" ] || [ "$REMOTE_HOSTS_RSYNC" == 0 ]; then
echo "$BASENAME: please enable REMOTE_HOSTS_RSYNC at onionmine.conf"
exit 1
fi
# Check remotes
if [ -z "$REMOTE_HOSTS" ]; then
echo "$BASENAME: need to configure REMOTE_HOSTS parameter"
exit 1
fi
# Check base dir
if [ -z "$REMOTE_HOSTS_BASEDIR" ]; then
echo "$BASENAME: need to configure REMOTE_HOSTS_BASEDIR parameter"
exit 1
fi
# Iterate over all defined hosts
for host in $REMOTE_HOSTS; do
if [ ! -z "$REMOTE_HOSTS_RSYNC" ] && [ "$REMOTE_HOSTS_RSYNC" != 0 ]; then
# Sync the pools
$REMOTE_HOSTS_RSYNC_COMMAND $RSYNC_EXCLUDES $host:$REMOTE_HOSTS_BASEDIR/pools/ $BASEDIR/pools/
fi
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment