Skip to content
Snippets Groups Projects
Commit fb43680c authored by Bob Mottram's avatar Bob Mottram
Browse files

Clear rsync with mirror

parent 2b5fc2a9
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,16 @@ RSYNC_MOBILE_APP_URL=https://f-droid.org/wiki/page/org.amoradi.syncopoli
rsync_variables=(ONION_ONLY
MY_USERNAME)
function rsync_setting_clear {
if [ -f /etc/cron.daily/rsync_remote ]; then
rm /etc/cron.daily/rsync_remote
fi
if ! grep -q 'read only = false' /etc/rsync/rsyncd.conf; then
sed -i 's|read only =.*|read only = false|g' /etc/rsync/rsyncd.conf
systemctl restart rsync
fi
}
function rsync_setting_remote {
rsync_hostname="$1"
rsync_module="$2"
......@@ -71,17 +81,23 @@ function rsync_setting_remote {
systemctl restart rsync
fi
{ echo '#!/bin/bash';
echo "cd $RSYNC_DATA || exit 1";
echo "if torsocks rsync -aqrm --delete ${rsync_hostname}::${rsync_module} ${RSYNC_DATA}/; then";
echo " ${PROJECT_NAME}-notification -s 'rsync succeeded' -m 'Sync with ${rsync_hostname}::${rsync_module} succeeded'";
echo 'else';
echo " ${PROJECT_NAME}-notification -s 'rsync failed' -m 'Sync with ${rsync_hostname}::${rsync_module} failed'";
echo 'fi';
echo "chown -R rsync:rsync $RSYNC_DATA"; } > /etc/rsync/sync.sh
chmod +x /etc/rsync/sync.sh
chown rsync:rsync /etc/rsync/sync.sh
/etc/rsync/sync.sh &
if [[ "${rsync_hostname}" == *'.onion' ]]; then
{ echo '#!/bin/bash';
echo "cd $RSYNC_DATA || exit 1";
echo "if ! torsocks rsync -aqrm --delete ${rsync_hostname}::${rsync_module} ${RSYNC_DATA}/; then";
echo " ${PROJECT_NAME}-notification -s 'rsync failed' -m 'Sync with ${rsync_hostname}::${rsync_module} failed'";
echo 'fi';
echo "chown -R rsync:rsync $RSYNC_DATA"; } > /etc/cron.daily/rsync_remote
else
{ echo '#!/bin/bash';
echo "cd $RSYNC_DATA || exit 1";
echo "if ! rsync -aqrm --delete ${rsync_hostname}::${rsync_module} ${RSYNC_DATA}/; then";
echo " ${PROJECT_NAME}-notification -s 'rsync failed' -m 'Sync with ${rsync_hostname}::${rsync_module} failed'";
echo 'fi';
echo "chown -R rsync:rsync $RSYNC_DATA"; } > /etc/cron.daily/rsync_remote
fi
chmod +x /etc/cron.daily/rsync_remote
/etc/cron.daily/rsync_remote &
}
function change_default_domain_name_rsync {
......
......@@ -102,6 +102,8 @@
<p translate="yes">module</p>
<input type="text" name="rsync_module" translate="no" value="images">
<br><br>
<input type="submit" name="submitrsynccancel" translate="yes" value="Cancel" />
<input type="submit" name="submitrsynclear" translate="yes" value="Clear" />
<input type="submit" name="submitrsync" translate="yes" value="Continue" />
</form>
</p>
......
......@@ -43,6 +43,12 @@ if (isset($_POST['submitrsync'])) {
}
}
if (isset($_POST['submitrsyncclear'])) {
$settings_file = fopen(".appsettings.txt", "w") or die("Unable to write to appsettings file");
fwrite($settings_file, "rsync,clear");
fclose($settings_file);
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
echo fread($htmlfile,filesize("$output_filename"));
fclose($htmlfile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment