我想设置一个“计算机使用条款”消息在登录时弹出。如果用户点击“同意”,他们可以继续使用机器;如果他们单击“取消”,它将重新启动机器。这是我所拥有的:
#!/bin/bash
# This script is to set terms of use for this computer and force logged in guest to accept terms.
# If done correctly, it will restart the computer in the event that the terms are not accepted.
gmessage "This is a public terminal. Any use must be suitable for eyes of all ages. Failure to comply will result in your immediate removal from the property without any refund or discount." -center -title "Terms of Use" -default "Accept" -center -buttons "Accept":0,"Decline":1>/dev/null
case $? in
0)
gmessage "Enjoy our public terminal. :)" -center -title "Thank you for accepting the Terms of Use." -buttons "I will!":0;;
1)
(sudo reboot);;
esac
谁能帮我解决这个问题?在我将它放入“启动应用程序”列表之前,它一直按设计工作。我也chown root.root /path/to/script
做过chmod u+x /path/to/script
。我还编辑了 visudo 以包含该行%sudo ALL=NOPASSWD: /path/to/script
,但仍然没有。该脚本运行良好,可以正常弹出我的所有窗口,但是当有人拒绝使用条款时不会重新启动计算机,如果用户不接受这些条款则不会注销用户。我不再卡住了,我的老板正在逼我实施此修复修复已经实施(如果有人试图从我们的公共计算机终端打印一些图形成人材料,卡在打印机缓冲区中;一个小女孩稍后试图打印一些着色书页,我们勉强拦截了成人材料在他们被非成年人看到之前)。
完整的功能代码如下。
#!/bin/bash
# This script is to set terms of use for this computer and force logged in guest to accept terms.
# If done correctly, this script will log the user out in the event that the terms are not accepted.
gmessage -fg red -bg black " This is a public terminal. Any use must be suitable for eyes of all ages. Failure to comply will result in your immediate removal from the property without any refund or discount." -center -title "Terms of Use" -default "Accept" -center -buttons "Accept":0,"Decline":1>/dev/null
case $? in
0)
gmessage " Enjoy our public terminal. :)" -center -title "Thank you!" -buttons "I will!":2;;
1)
(killall -u super8guest);;
esac
case $? in
2)
gmessage "Click here when you are finished." -center -title "Cleanup" -buttons "Done":3;;
esac
case $? in
3)
(killall -u super8guest);;
esac
经过数小时的研究,这是我自己得出的答案。发在这里希望对遇到类似情况的朋友有所帮助。
如果有人对如何美化代码或如何使其更好地工作有任何想法,请不要犹豫,与我们分享。我还在学习。