Timekpr Fedora 'Conversion'

Asked by Sanjay Govindjee

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 <email address hidden>
# Butchered for Fedora by: Sanjay Govindjee <email address hidden>

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 -------

Question information

Language:
English Edit question
Status:
Answered
For:
timekpr Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Savvas Radevic (medigeek) said :
#1

Thank you for your contribution. Laughed on the butchering line!
We might wake up one morning and decide on butchering timekpr ourselves for setup.py and better customisation parameters. :)
FAQ #1546: “Timekpr Fedora 'Conversion'”.

Revision history for this message
Frederick Koehler (fkoehleriv) said :
#2

Under Fedora 17, as root, created timekpr.service under /lib/systemd/system that contains the following:

[Unit]
Description=computer usage control daemon
After=syslog.target systemd-user-sessions.service

[Service]
EnvironmentFile=/etc/sysconfig/timekpr
ExecStart=/usr/bin/timekpr

[Install]
WantedBy=multi-user.target

Then launched it in the background with the following: systemctl start timekpr.service

Then configured it to launch automatically with the following: systemctl enable timekpr.service

This was from a naive understanding of systemd -- so welcoming improvements and YMMV.

Revision history for this message
Frederick Koehler (fkoehleriv) said :
#3

Additional update for F22...

Under the stable subdirectory go to the debian subdirectory. There edit the file timekpr.postinst. In that file, on the third line from the top, change "gfile='/etc/pam.d/gdm" to "gfile='/etc/pam.d/gdm-password". Fedora 22 does not have a file called /etc/pam.d/gdm. It looks like gdm functions have been split into a number of config files for password entry, pin, fingerprint, etc. The line that gets added to gdm-password likely needs to be included in all the gdm files. I only use a password to log in...so I only edited that file.

Can you help with this problem?

Provide an answer of your own, or ask Sanjay Govindjee for more information if necessary.

To post a message you must log in.