Questions tagged [hook]
46 questions
32
votes
3 answers
Can a bash script be hooked to a file?
I want a script to sleep unless a certain file is modifed/deleted (or a file created in a certain directory, or ...). Can this be achieved in some elegant way? The simplest thing that comes to my mind is a loop that sleeps for some time before…
Tobias Kienzler
- 9,184
- 13
- 65
- 106
18
votes
2 answers
Ssh login hook?
Is there a way to run a script/command every time a user connects using ssh? Can it be configured globally (i.e run the script when any user login)?
I came across this question on Identica, but there is no answer yet and would like to know it…
phunehehe
- 20,030
- 27
- 99
- 151
12
votes
3 answers
How can I run a command in bash after any change in $PWD?
zsh provides some nice hook functions, including chpwd for running a function after the user changes directories.
# zsh only
function greet() { echo 'hi'; }
chpwd_functions+=("greet")
cd .. # hi
pushd # hi
popd # hi
I'm trying to emulate that in…
Nathan Long
- 1,613
- 1
- 13
- 27
9
votes
3 answers
How to execute a script on gdm login automatically for all users?
What file should I modify to execute some instructions when any user logs in through gdm?
I tried /etc/bashrc but that is executed ony when starting bash (and each time an xterm is open). I'd like to execute something only once when the user logs…
Bogdan
- 271
- 2
- 6
8
votes
5 answers
How to run a command before download with apt-get?
How can I run a command before apt-get starts to download a package?
I know about the dpkg pre-invoke hook ( hook a script to apt-get ), but that seems to be run after the download.
$ apt-get update
Get: 11 http://security.debian.org/…
Arne Babenhauserheide
- 219
- 2
- 7
6
votes
2 answers
Encrypt hook in mkinitcpio.conf for full system encryption USB drive Arch install
I have installed Arch Linux on a USB drive with full system encryption using LUKS. The Arch wiki as usual walked me through almost everything. The only issue I ran into was using setting up the hooks in mkinitcpio. The Arch wiki says that for a USB…
StrongBad
- 5,151
- 9
- 47
- 73
5
votes
3 answers
Inspect IO operations on FreeBSD system
I would know is there any way to inspect/intercept IO operations on FreeBSD.
Like ktrace but if I don't know the process (which takes some big time for example).
Sergey Efimov
- 151
- 3
5
votes
4 answers
Run command when temperature exceeds threshold, without daemon
I need to run a specific command if my laptop gets too hot (for example, send a STOP signal to Firefox or Virtualbox in order to prevent my laptop from shutting down violently and damaging my hard disks).
I can easily write a program that loops…
user84207
- 871
- 2
- 14
- 19
4
votes
0 answers
How to run script when switching to specific (already logged in) user
There's plenty of info out there on how to run a script at login (add it to .xprofile etc.), but I'm looking for a solution that will run a script/command not just at login but also every time a particular user's session is activated/brought to the…
user629422
- 41
- 2
4
votes
1 answer
How to use debuild hooks (--signing-hook-foo etc)
The man page isn't clear on that.
How would I use a signing hook? Especially using the parameter without the config file.
What is the meaning of foo in the documentation? For example in --signing-hook-foo? Do I replace foo with my bash script? The…
Forivin
- 779
- 5
- 18
- 37
4
votes
2 answers
Falling to git checkout on non-found bash commands
When I type (in bash) a command which linux does not find, it usually does something like this:
$ x
x: command not found
but when I type a command which is not found but which is similar in some sense to other possible commands, the reply may look…
Bach
- 827
- 1
- 8
- 11
3
votes
1 answer
Set environment variable for all of tmux shells when gnome-sessions gets restarted
To solve this problem, I need to set the environment variable DBUS_SESSION_BUS_ADDRESS for all shells inside tmux every time I restart gnome without restarting tmux (this is often). How can I best solve this?
I cannot cleanly change another…
gerrit
- 3,457
- 6
- 25
- 41
3
votes
0 answers
Hooking sys_execve on Linux kernel 4.6 or higher
Kernels lower than 4.6 use assembly stubs to harden the hooking of critical system calls like fork, clone, exec etc. Particularly speaking for execve, the following snippet from Kernel-4.5 shows entry stub of execve:
ENTRY(stub_execve)
call …
Usman Riaz
- 31
- 2
3
votes
0 answers
Any way to specify process to call on Linux when OOM activates?
On my embedded system I'd like to record when the system OOM killer actives, e.g. by setting an env. variable in u-boot. Is there any way to specify a hook function to call on the OOM event?
SeanLabs
- 701
- 2
- 10
- 21
3
votes
2 answers
Dpkg env variable DPKG_HOOK_ACTION is not set in hook script
According to man dpkg I can use DPKG_HOOK_ACTION to get the current dpkg action being run in my dpkg hook script
--pre-invoke=command
--post-invoke=command
Set an invoke hook command to be run via “sh -c” before or after the dpkg run for the…
Flint
- 247
- 1
- 2
- 8