Tiny Core Base > TCB Tips & Tricks

is there a way of logging of user activities in TC?

<< < (2/3) > >>

gerald_clark:
Read the bash manual, and look for HISTORY.

Rich:
Hi jamtat
It will take some work, and may get a little messy since you need to insert your script between the
calling mechanism and the application. Some applications are already started by a script. For example,
opera is the link  /usr/local/bin/opera  pointing to the script  /tmp/tcloop/opera10/usr/local/bin/opera.
If you delete the link and copy the script in its place, you could add the logging function to that script
and then add that script to your backup.

jamtat:

--- Quote from: gerald_clark on January 24, 2012, 10:58:34 PM ---Read the bash manual, and look for HISTORY.
--- End quote ---
I don't see how bash history applies since my users--if they're even capable of accomplishing this much--will be starting applications by clicking on icons located in wbar?

James

gerald_clark:
That's the first you have mentioned you are running X.
You could still use bash to start your applications.

jamtat:
Here's what I've come up with so far along the lines Rich has suggested. First, I create a directory in the home directory that will house the bash scripts; let's call it my-bin (/home/tc/my-bin). In that directory go the scripts--constructed as outlined above--for each of the programs I want to monitor. The next step is to replace the executables for the programs I want to monitor with the bash scripts I've created and that are located in /home/tc/my-bin. To do that, I edit bootlocal.sh.

As a concrete example of how I edit bootlocal.sh, let's say I've installed the Chromium browser and want to monitor when it is started and stopped. The first order of business is to find the name of the executable and its location. The real location of the executable is, of course, at /tmp/tcloop/chromium-browser/usr/local/bin/chromium-browser. But there's a symlink to that executable in /usr/local/bin, and that's where the system looks for the executable when the wbar icon for Chromium is clicked on. We've therefore got to get rid of that symlink and replace it with a symlink to the bash script we'll create in /home/tc/my-bin.

To get rid of the existing symlink we add a line to bootlocal.sh: rm /usr/local/bin/chromium-browser. Then, we create the script in /home/tc/my-bin: touch /home/tc/my-bin/chromium-browser. Somewhat in contrast to what Rich and I proposed above, the content of this new chromium-browser script (it has to have the same name as the original executable) should be as follows:
--- Code: ---#!/bin/sh
echo `date` Chromium started >> ~/LOGFILE &&
/tmp/tcloop/chromium-browser/usr/local/bin/chromium-browser &&
echo `date` Chromium stopped >> ~/LOGFILE
--- End code ---
Note that the executable the script calls is the one located in /tmp/tcloop, the one the original /usr/local/bin/chromium-browser file pointed to. Once that script is created and has had chmod +x done to it, we're ready for the final step.

The final step is to create a new symlink to the bash script we've created, a symlink that get's placed in /usr/local/bin every time the system boots--/usr/local/bin being where the system will be looking for the exectuable. That can be done by placing another entry in bootlocal.sh. So, after the line rm /usr/local/bin/chromium-browser, the line ln -s /mnt/sda1/home/tc/my-bin/chromium-browser /usr/local/bin/chromium-browser needs to be added. This scenario assumes, of course, that you have a persistent home directory for your TC installation (sda1 may need to be modified to suit your own particualr scenario). Now, when the system boots and when you click on the Chromium icon in wbar, the program starts normally and the time of its execution and shutdown get recorded in ~/LOGFILE.

This so far seems to me the most straightforward way to implement the solution suggested by Rich. It's still fairly convoluted but, owing to the non-standard design of TC, I'm not sure it could be further simplified. Additional input on this, anyone?

James

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version