diff --git a/src/freedombone-app-rsync b/src/freedombone-app-rsync index 8b51f69a37bc2445d970c92454408b1931521df5..b03f3702e8f46de81e77974fa6a242b79df936e0 100755 --- a/src/freedombone-app-rsync +++ b/src/freedombone-app-rsync @@ -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 { diff --git a/webadmin/EN/settings_rsync.html b/webadmin/EN/settings_rsync.html index ce34d3a646c39cc22057b784e69e7587c6ce1e87..a81963938e7db4d0963365147bb2259bc0b5101c 100644 --- a/webadmin/EN/settings_rsync.html +++ b/webadmin/EN/settings_rsync.html @@ -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> diff --git a/webadmin/settings_rsync.php b/webadmin/settings_rsync.php index 33a40d273de8e89a6712944abd9a1abc4967e44f..29b28d1ae4b66d59c3398c83089fc7b4b0c95d75 100755 --- a/webadmin/settings_rsync.php +++ b/webadmin/settings_rsync.php @@ -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);