Я хотел установить сообщение «компьютерные условия использования», чтобы появиться при входе в систему. Если пользователь нажал «Согласен», они могли бы продолжать использовать машину; если они нажмут «Отменить», он перезагрузит машину. Вот что у меня было:
#!/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