rsync push to humax stalling

Noting the comments of @ldf, I've had another go, based more closely on on @prpr's enhanced version.
  1. Caters for HD and HDR
  2. I've made the swapfile size configurable (the easy way)
  3. Separate default values for HD and HDR, 256MiB and 1024MiB respectively.
  4. Swapfile deleted at stop for HD
  5. Swapfile retained for HDR
  6. Swapfile deleted and recreated on start if configured size has changed
I've gone for 256 rather than 128 on the HD as I've often seen 160 used swap space (albeit on an HDR). As there's plenty of space on the HD3 partition on the HDR, it seemed sensible to have a biggish default.

I haven't tried it on a real HD, so it would be good if someone with an HD could give it a spin.

Feedback is welcome.
Code:
#!/bin/sh
########### /mod/etc/init.d/S00swapper ###########
set +x

# size of swapspace in MiB.  Configure as required
# Separate values for HD and HDR to allow different defaults
HDRswapsize=1024                # default 1024
HDswapsize=256                  # default 256

# Constants
HDRmnt='/mnt/hd3/'
HDmnt='/media/drive1/'
swapbasename='.swap0'
squote="'"

model="$(cat /etc/model)"
#model='HD' # fiddle for testing. normally commented out.
case "$model" in
    HDR)
        mnt="$HDRmnt"
        swapsize="$HDRswapsize"
        ;;
    HD)
        mnt="$HDmnt"
        swapsize="$HDswapsize"
        ;;
    *)
        echo "$squote$model$squote in /etc/model is neither HD nor HDR"
        exit 1
        ;;
esac
swapfile="$mnt$swapbasename"

case "$1" in
    start)
        if grep "$swapfile" /proc/swaps >/dev/null 2>&1 ; then
            echo "Swap file already enabled"
            exit 0
        fi
        actualsize=0
        [ -f $swapfile ] && actualsize=$(stat -t "$swapfile"|awk '{print $2/1024/1024}')
        if [ $actualsize -ne $swapsize ] ; then
            [ -f $swapfile ] && rm $swapfile
            dd if=/dev/zero of=$swapfile bs=1M count=$swapsize
            mkswap $swapfile
        fi
        swapon $swapfile
        echo "Enabled swap file."
        ;;
    stop)
        if grep "$swapfile" /proc/swaps >/dev/null 2>&1 ; then
            swapoff $swapfile
            echo "Disabled swap file."
            [ $model == HD ] && rm $swapfile && echo "Swap file deleted"
        else
            echo "Swap file was not enabled"
            exit 1
        fi
        ;;
    *)
        echo "Must use $squote$0 start$squote or $squote$0 stop$squote"
        exit 1
        ;;
esac

exit 0

Don't know what's happened to the indentation :(
edit: fixed
 
Last edited:
I'm looking at how to set swapsize via settings on the webif.

I've worked part of the story, nut I'm wondering if there is a how to available somewhere.

I'm not asking someone to write one, nut it would save me a bit of time not to have to re-invent the wheel.
 
Can't you take the existing settings add-ons as a template? undelete, for example? Somehow, installing undelete also adds a section to the WebIF settings (and removes it again if uninstalled).
 
Do you change all your WebIF settings frequently then? Why discourage somebody willing to help out?

it seems reasonable to me that a parameter such as this could be put under user control without having to hack files, regardless of how often the user might want to change it... if somebody is willing to do that (and swapper needs an upgrade anyway, to be compatible with HD-FOX). The size of a swap file is a compromise - much bigger than you need and it takes longer to initialise and may compete for disk resource; too small and you can't process big files (if you need to), so no one size fits all.

However, discussion of swapper ought to be in the swapper thread (or a separate thread with an appropriate title).
 
Back
Top