wiki:ShepherdForWindows

Installing Cygwin and Shepherd for Windows

The Shepherd developers have not tested on Windows, but users have reported installing it successfully by following these steps.

Cygwin Installation

  1. Download setup.exe from the Cygwin site:
    http://www.cygwin.com/setup.exe
    
    For IE and Firefox: Save to "My Documents" -> "Downloads"

    For Chrome, this is the default.

  2. Execute the setup.exe that you downloaded, by typing Windows-R, and then:
    "%USERPROFILE%\My Documents\Downloads\setup.exe" -dq -R c:\cygwin -s http://mirror.aarnet.edu.au/pub/sourceware/cygwin -O -P perl -P make -P gcc4 -P wget
    
    The setup program will download and install some mandatory packages as well as the extra ones you listed. This will take about 10 minutes. At the end, it might show an error "cygutils.sh exit code 127", but this can be ignored. Or, the setup program might simply close.

  3. Copy the setup.exe to the cygwin directory for safe-keeping: Windows-R
    cmd /c copy "%USERPROFILE%\My Documents\Downloads\setup.exe" C:\Cygwin\usr\local\bin\
    
    If you ever need to install other packages, just drop to a cygwin terminal and run "setup".

  4. The Start menu should now have a new "Cygwin" program group with "Cygwin Terminal"

CPAN Module Installation

  1. Start the Cygwin Terminal: Start -> Cygwin -> Cygwin Terminal

  2. Install CPAN modules:
    cpan -i Module::Build CPAN::Meta::YAML ExtUtils::MakeMaker Date::Manip XML::Writer Lingua::EN::Numbers::Ordinate Lingua::Preferred Term::ProgressBar Unicode::String HTTP::Cache::Transparent HTML::TreeBuilder XML::Simple Sort::Versions Algorithm::Diff List::Compare Sort::Versions File::Slurp
    
    When prompted, select defaults by pressing "enter".

    This can take 20 minutes or more.

  3. Install XML::Twig
    cpan -i XML::Twig
    
    When prompted (5 times), select defaults by pressing "enter".

  4. Insatll XMLTV from Official Site

    Note: The version of XMLTV on CPAN is too old for shepherd.
    $ wget http://downloads.sourceforge.net/project/xmltv/xmltv/0.5.63/xmltv-0.5.63.tar.bz2
    $ tar -xjvf xmltv-0.5.63.tar.bz2
    $ cd xmltv-0.5.63
    $ perl Makefile.PL
    [select defaults]
    $ make
    $ make install
    

Shepherd Installation

  1. Start the Cygwin Terminal: Start -> Cygwin -> Cygwin Terminal

  2. Prepare the directory and download Shepherd
    $ mkdir -p .shepherd/applications/shepherd
    $ cd .shepherd/applications/shepherd
    $ wget www.whuffy.com/shepherd/shepherd
    
  3. Run shepherd, using fully-qualified path to pull in the modules:
    $ perl `pwd`/shepherd
    
    [ignore "Caught a die()" errors]

    Note that this creates a symlink ~/.shepherd/shepherd that we will use from now on.

    Choose appropriate location and channel details.

    Select "no" when asked for MythTV auto-configure.
    $ cd
    
  4. Disable mythtv module:
    $ ~/.shepherd/shepherd --disable Shepherd/MythTV.pm
    
  5. Check shepherd:
    ~/.shepherd/shepherd --check
    
  6. Grab data for the first time:
    ~/.shepherd/shepherd --noupdate
    

Make a Scheduled Task

  1. Launch Task Scheduler

    Start -> Control Panel -> Performance and Maintenance -> Scheduled Tasks

  2. Create a new "check" task using the wizard

    Add Scheduled Task -> Next -> Browse -> C:\cygwin\bin\mintty.exe

    Set Name: "Shepherd"

    Set Frequency: Daily

    -> Next

    Set Start time: 2am

    -> Next

    Enter your credentials

    -> Next

    Click on "Open advanced properties"

    Set Run:
    C:\cygwin\bin\mintty.exe --hold --exec /bin/sh -c 'PATH=$PATH:/usr/bin ~/.shepherd/shepherd --check"
    
    Clear "Start in"

    -> OK

    Enter your credentials

  3. Manually run the task

    Return to the scheduler.

    Right-click on the new task and select "run"

    Check that it runs correctly.

  4. Adjust the task to final state

    Right-click on the task to edit the properties

    On the "Settings" tab: stop if runs for more than 3 hours

    On the "Task" tab: remove both "--check" and "--hold" from the "Run" option so that it becomes:
    C:\cygwin\bin\mintty.exe --exec /bin/sh -c 'PATH=$PATH:/usr/bin ~/.shepherd/shepherd"
    
    To run in a hidden window, add "--window hide" as a parameter to mintty, such as:
    C:\cygwin\bin\mintty.exe --window hide --exec /bin/sh -c 'PATH=$PATH:/usr/bin ~/.shepherd/shepherd"
    
    To log all output to a file, redirect shepherd's output, such as:
    C:\cygwin\bin\mintty.exe --exec /bin/sh -c 'PATH=$PATH:/usr/bin ~/.shepherd/shepherd --check >~/shepherd-task.log 2>&1"
    
    Come back the next day and check the status of the scheduled task (might need to scroll to the right to see status) and the output of the log file shepherd-task.log.