You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.6 KiB
77 lines
1.6 KiB
8 years ago
|
#!/bin/sh
|
||
|
#
|
||
|
# a workaround for the sucking date behavior of oscam
|
||
|
#
|
||
|
|
||
|
. /etc/init.d/globals
|
||
|
|
||
|
BNAME=${0##*/}
|
||
|
BINARY="/var/bin/$2"
|
||
|
FLAGFILE="/var/etc/.$2"
|
||
|
|
||
|
case "$1" in
|
||
|
"start")
|
||
|
DATE_TODAY=$(date +%Y%m%d%H%M)
|
||
|
if [ "${DATE_TODAY:0:8}" = "19700101" ]; then
|
||
|
# try to read date from flagfile
|
||
|
test -e $FLAGFILE && \
|
||
|
DATE_FLAG=$(date -r $FLAGFILE +%Y%m%d%H%M)
|
||
|
|
||
|
# try to read date from binary
|
||
|
DATE_OSCAM=$(strings $BINARY | grep -B1 "is smaller than the build date")
|
||
|
DATE_OSCAM=${DATE_OSCAM:0:11}
|
||
|
_m=$(echo $DATE_OSCAM | cut -d\ -f1)
|
||
|
_d=$(echo $DATE_OSCAM | cut -d\ -f2)
|
||
|
_y=$(echo $DATE_OSCAM | cut -d\ -f3)
|
||
|
|
||
|
c=0
|
||
|
for m in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
|
||
|
c=$(($c+1))
|
||
|
if [ "$m" = "$_m" ]; then
|
||
|
_m=$c
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
test ${#_m} -lt 2 && _m=0$_m
|
||
|
test ${#_d} -lt 2 && _d=0$_d
|
||
|
|
||
|
DATE_OSCAM=$_y$_m$_d
|
||
|
|
||
|
# try to read date from versionfile
|
||
|
DATE_IMAGE=$(cat /.version | grep "^version=" | cut -d= -f2)
|
||
|
DATE_IMAGE=${DATE_IMAGE:4}
|
||
|
|
||
|
c=0
|
||
|
for date in "$DATE_FLAG" "$DATE_OSCAM" "$DATE_IMAGE"; do
|
||
|
c=$(($c+1))
|
||
|
while [ ${#date} -lt 12 ]; do
|
||
|
date=$date"0"
|
||
|
done
|
||
|
test $c = 1 && DATE_FLAG=$date
|
||
|
test $c = 2 && DATE_OSCAM=$date
|
||
|
test $c = 3 && DATE_IMAGE=$date
|
||
|
done
|
||
|
|
||
|
SHOWINFO "manipulating date ... "
|
||
|
for date in "$DATE_FLAG" "$DATE_OSCAM" "$DATE_IMAGE"; do
|
||
|
echo $date;
|
||
|
done | sort -r -u | while read date; do
|
||
|
if date -s $date > /dev/null; then
|
||
|
SHOWINFO "done ($date)"
|
||
|
break
|
||
|
else
|
||
|
continue
|
||
|
fi
|
||
|
SHOWWARN "failed"
|
||
|
done
|
||
|
fi
|
||
|
;;
|
||
|
"stop")
|
||
|
test -e $FLAGFILE && touch $FLAGFILE
|
||
|
;;
|
||
|
*)
|
||
|
;;
|
||
|
esac
|
||
|
true
|