Tob*_*ler 6 command-line mount unmounting truecrypt timeout
我正在通过命令行(即truecrypt file dir)安装一个 truecrypt 容器。有没有办法让 truecrypt 在 中的给定数量的不活动后自动卸载容器dir?
Truecrypt 无法做到这一点,但类似以下的内容可以完成您想要做的事情:
#!/bin/bash
TIMEOUT_PERIOD_IN_MINUTES=60
cd /
sleep ${TIMEOUT_PERIOD_IN_MINUTES}m
echo "$0: Proceeding with dismount in 5 minutes." > /dev/console
# or something else to notify user that the volume will be unmounted
sleep 4.5m
echo "$0: Proceeding with dismount in 30 seconds." > /dev/console
sleep 30s
sync; truecrypt $@
Run Code Online (Sandbox Code Playgroud)
这cd /是为了确保当前目录永远不会在已安装的 truecrypt 卷中,以防万一您在不同情况下调用它。
将其保存在某处,chmod +x并将其命名为truecrypt-auto-dismount,然后
truecrypt {mount-options}; truecrypt-auto-dismount {dismount-options}
我肯定会合并某种类型的通知,以便您有机会关闭打开的文件。lsof | grep /mnt/your-truecrypt-volume当然,您可以变得相当复杂,并尝试合并一个循环,该循环可以使用 SIGTERM 杀死您想要的所有列出的进程(如果它在某个时间范围内没有响应,则执行 SIGKILL) 。
| 归档时间: |
|
| 查看次数: |
1964 次 |
| 最近记录: |