Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: bash-script: automatic upload of new files to archos/rockbox
From: Christian Folini (christian.folini_at_unifr.ch)
Date: 2002-09-21


Hi,

i do a lot of radio streaming. Since i do not want to bother with
copying the files to my archos, i wrote the following script
which might be of use for someone. I run it once a minute
as a cronjob and simply attach my archos to the computer
once a day for a certain time.

Christian

P.S. I am looking forward to file-management in 2.0, as the ability
to remove/delete a radiostream-file i have listened to would be
more fun. Including that, rockbox is a great project.

------
#! /bin/bash
# Put daily updated files on the archos Player
# christian.folini_at_unifr.ch
# This file is not exactly proper, but you can easily
# adapt it to your needs.

export TRUE=-1
export FALSE=0
export VERBOSE=$FALSE
export DEBUG=$FALSE
export LOCK=/tmp/archos-lock

function vprint {
        # print if verbose is set
        if [ $VERBOSE -eq $TRUE ]; then
                echo $1
        fi
}

function upload {
        wavp ~/data/beep.wav > /dev/null

        mount /mnt/archos
        vprint "archos mounted"

        cp -v /archive/mp3/rawstreams/*.mp3 /mnt/archos/actual
        vprint "all files copied."

        mv /archive/mp3/rawstreams/*.mp3 /archive/mp3/rawstreams/transferred
        vprint "all files on server moved to directory transferred."

        umount /mnt/archos
        vprint "archos unmounted"

        wavp ~/data/beep.wav > /dev/null
}

export FILES=`ls -1 /archive/mp3/rawstreams/*.mp3 2>/dev/null`
export ARCHOSMOUNT=`mount 2>&1 | grep "sda1"`
export ARCHOS=`/usr/sbin/lsusb -t 2>&1 | grep "Vendor 0x05ab Product 0x0060"`

        if [ ! "$FILES" ]; then
                vprint "No new files found. Aborting."
                exit
        fi
        if [ "$ARCHOSMOUNT" ]; then
                vprint "Archos already mounted. Aborting."
                exit
        fi
        if [ "$ARCHOS" ]; then
                vprint "Archos present."
                if [ -e $LOCK ]; then
                        vprint "Archos lockfile found. Aborting."
                        exit
                fi
                touch $LOCK
                upload
                rm $LOCK
        else
                vprint "Archos not present. Aborting."
        fi

exit

for opt in $@;
        do
        case $opt in
        "") echo "none.";;
        -d) export DEBUG=$TRUE;;
        -v) export VERBOSE=$TRUE;;
        esac
        done



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa