there's only one mistake i found... the find includes the start dir as well as first entry
here's a corrected version:
- Code: Select all
#!/usr/bin/bash
eval `grep 'RANDOM_MENUSHEETDIR=' /conf/config`
[ ! -d "$RANDOM_MENUSHEETDIR" ] && logger -t random_menusheetdir "No such dir: $RANDOM_MENUSHEETDIR" && exit
DIRS=($(find "$RANDOM_MENUSHEETDIR" -maxdepth 1 -type d))
[ ${#DIRS[@]} -eq 0 ] && logger -t random_menusheetdir "No menusheet dirs found" && exit
unset DIRS[0]
RND=$RANDOM
let "RND%=${#DIRS[@]}"
config_tool -c MENUSHEETDIR=${DIRS[RND]}
/osd/etc/init.d/S99menusheets restart
logger -t random_menusheetdir "Changed MENUSHEETDIR to ${DIRS[RND]}"
this really works.. make sure you have no starting whitespaces on any line.



