AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 664434
Accepted
necromancini
necromancini
Asked: 2015-08-22 23:43:32 +0800 CST2015-08-22 23:43:32 +0800 CST 2015-08-22 23:43:32 +0800 CST

如何将 gxmessage 设置为在登录时运行,并使退出代码触发事件

  • 772

我想设置一个“计算机使用条款”消息在登录时弹出。如果用户点击“同意”,他们可以继续使用机器;如果他们单击“取消”,它将重新启动机器。这是我所拥有的:

#!/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
login
  • 1 1 个回答
  • 117 Views

1 个回答

  • Voted
  1. Best Answer
    necromancini
    2015-09-05T23:21:12+08:002015-09-05T23:21:12+08:00

    经过数小时的研究,这是我自己得出的答案。发在这里希望对遇到类似情况的朋友有所帮助。

    #!/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
    

    如果有人对如何美化代码或如何使其更好地工作有任何想法,请不要犹豫,与我们分享。我还在学习。

    • 1

相关问题

  • 在登录屏幕上自动选择用户

  • 在哪里可以找到适用于 Ubuntu 的 Novell NetWare 客户端?

  • gdm登录屏幕中的名称顺序存储在哪里?[复制]

  • xubuntu 中没有其他用户的面板

  • 登录失败并显示低图形然后崩溃?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve