Timekpr Fedora 'Conversion'

Created by Savvas Radevic
Keywords:
fedora timekpr

Even though this is not a 'Fedora' project, I have seen that a number of people are interested in using Timekpr on Fedora distributions. In case anyone is interested. Here are the steps that I went though to make it 'work' on Fedora 14. These are for the stable 0.3.2 distribution. Note this is a hack and rather imperfect but I was impatient and did not want to edit the code itself. I am sure someone can make it 1000 X better -- especially the init.d script and probably it would not be too hard to write a script that
will automate the other steps I went through.

0. Download the stable 0.3.2 distribution and untar it. cd to 'stable', the directory it creates upon untarring.
1. In debian/install add a / after the work etc/xdg/autostart. It should look like etc/xdg/autostart/ when you are done
2. Run install.sh
3. Run debian/timekpr.postinst
4. Make /usr/bin/timekpr executable (if it is not already, wasn't for me).
5. Install the code listed below as /etc/init.d/timekpr ; this my simple attempt at a launch daemon.
6. Add S55timekpr as a softlink in /etc/rc.d/rcX.d for run levels 2,3,4,5 (i.e. cd /etc/rc.d/rc2.d; ln -s ../init.d/timekpr S55timekpr)
etc. and similarly put a K55timekpr in run levels 0,1,6.

You should now be ready to go. You can start the daemon with cd /etc/init.d ; ./timekpr start. Logout and log back in you should see the timekpr icon in the upper bar to the right. To set times for users. First su to root, then run /usr/bin/timekpr-gui. Note there is a link to this program in the Administrator pulldown menu but it does not launch for me since I do not have gksu installed.
Try ps aux | grep timekpr to see that both the daemon and the client are running.

----- cut here for start of /etc/init.d/timekpr --------
#! /bin/sh

### BEGIN INIT INFO
# Provides: timekpr
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Timekpr - Keep control of computer usage
# Description: This program will track and control the computer usage
# of your kids. You can limit their daily usage and
# configure periods when they cannot log in.
#
#
# ********WARNING*************
# Translation of debian/timekpr.init to Fedora format by a novice
# This is very stripted down version
#
### END INIT INFO

# Author: Savvas Radevic <vicedar@gmail.com>
# Butchered for Fedora by: Sanjay Govindjee <sanjay.govindjee@yahoo.com>

NAME=timekpr
DESC="computer usage control daemon"
DAEMON="/usr/bin/timekpr"
DAEMONPY="timekpr.py"
EXECSHELL="python"
PIDFILE=/var/run/timekpr.pid
SCRIPTNAME=/etc/init.d/timekpr
OPTIONS="&"

# Source function library
. /etc/rc.d/init.d/functions
# . /lib/lsb/init-functions

start() {
 [ -x $DAEMON ] || exit 5
 echo -n $"Starting $NAME: "
 if [ $UID -ne 0 ]; then
  RETVAL=1
  failure
 else
  daemon $DAEMON $OPTIONS
  REVTAL=$?
  ps aux | grep $DAEMONPY | grep $EXECSHELL | awk '{print $2}' > $PIDFILE
 fi;
 echo
 return $RETVAL
}

stop() {
 echo -n $"Stopping $NAME: "
 if [ $UID -ne 0 ]; then
  RETVAL=1
  failure
 else
  killproc -p $PIDFILE $DAEMON
  RETVAL=$?
  [ $RETVAL -eq 0 ] && rm -f $PIDFILE
 fi;
 echo
 return $RETVAL
}

restart() {
 stop
 start
}

case "$1" in
  start)
  $1
  RETVAL=$?
  ;;
  stop)
  $1
  RETVAL=$?
  ;;
  restart)
  $1
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $0 {start|stop|restart}"
  RETVAL=2
esac

exit $RETVAL
----- cut here for end of /etc/init.d/timekpr -------