You are not logged in.
Pages: 1
Topic closed
Hey everybody,
I would like to learn shell scripting so I created a script to mount/unmount my truecrypt volume. This is what I have so far:
#!/bin/bash
case "$1" in
start)
truecrypt -k '' /dev/array/vault /home/<user>/vault
;;
stop)
truecrypt -d /home/<user>/vault
;;
*)
echo "usage: $0 (start|stop)"
esac
exit 0
Now I would like to add another feature. I want it to automatically unmount after 2 hours. I found the "at" command which should be able to do this.
I would need to do something like:
start)
truecrypt -k '' /dev/array/vault /home/<user>/vault
at -f "$1 stop" now + 2 hours
;;
However, running just " at -f "./vault.sh start" now + 2 minutes " fails:
warning: commands will be executed using /bin/sh
Cannot open input file ./vault.sh start: No such file or directory
If I can get this working I would like the "stop" code to remove any scheduled stop operations (for when I do it manually). Also, I would like to include a "keepalive" function that allows me to kill the scheduled stop task and reschedule it again to restart the countdown. This would allow me to keep the volume mounted if I want to use it for a longer period of time.
Is it possible to execute scripts + parameters with "at"? Can somebody help me to make this work?
Thanks a bunch!
P.S: Truecrypt also keeps asking me this:
Protect hidden volume (if any)? (y=Yes/n=No) [No]:
I would like to specify this in the command so that I don't have to hit enter every time. I've looked at the man page but found nothing helpfull. Anyone?
Offline
Make sure that vault.sh exists in the directory that you are executing it from. It may be better to refer to the whole file location rather than just './'. eg use " at -f "~/vault.sh start" now + 2 minutes " rather than just " at -f "./vault.sh start" now + 2 minutes ".
Providing thatyou are happy for TrueCrypt to accept the default answer for any questions it asks you can just pipe yes into it:
yes | truecrypt -k '' /dev/array/vault ~/vault
Yes will 'press enter' to any questions that TrueCrypt asks.
Last edited by gadget3000 (2011-07-14 16:46:01)
Offline
Hello!
You can execute scripts + parameters with "at" this way:
echo DISPLAY=:0 ./vault.sh start | at now + 2 minutes
It works!
Offline
Areopagite, please do not necrobump old threads
Neither of the users in this thread have even been on the forums in a year.
Feel free to open a new thread if you have a new question.
Closed.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Pages: 1
Topic closed