Last change
on this file since 5541 was
5541,
checked in by hectorgh, 4 years ago
|
fixing shutdown-lliurex to better support thin clients
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[5407] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import subprocess |
---|
| 4 | import os |
---|
[5426] | 5 | import time |
---|
[5407] | 6 | |
---|
[5541] | 7 | thinclient_cron_file="/etc/cron.d/lliurex-shutdowner-thinclients" |
---|
[5426] | 8 | wait_time=1 |
---|
[5541] | 9 | |
---|
[5537] | 10 | p=subprocess.Popen(["who"],shell=True,stdout=subprocess.PIPE).communicate()[0] |
---|
[5541] | 11 | is_server=os.system("lliurex-version -t server") |
---|
[5537] | 12 | is_thin=os.system("lliurex-version -x thin") |
---|
[5407] | 13 | |
---|
[5541] | 14 | if is_server==0: |
---|
| 15 | if not os.path.exists(thinclient_cron_file): |
---|
[5537] | 16 | wait_time=2 |
---|
[5407] | 17 | |
---|
[5426] | 18 | t=time.localtime() |
---|
| 19 | shutdown_date="%s:%s"%(t.tm_hour,t.tm_min+wait_time) |
---|
| 20 | |
---|
| 21 | |
---|
[5541] | 22 | if is_thin!=0: |
---|
| 23 | displays=set() |
---|
| 24 | for item in p.strip("\n").split("\n"): |
---|
| 25 | |
---|
| 26 | x=item.split(" ") |
---|
| 27 | user=x[0] |
---|
| 28 | if "(" not in x[-1] or ")" not in x[-1] or ":" not in x[-1] or "." not in x[-1]: |
---|
[5538] | 29 | continue |
---|
[5541] | 30 | display=x[-1].lstrip("(").rstrip(")") |
---|
| 31 | |
---|
| 32 | if os.path.exists(thinclient_cron_file): |
---|
| 33 | if len(display.split(":")[0].split("."))<4: |
---|
| 34 | continue |
---|
| 35 | |
---|
| 36 | if display not in displays: |
---|
| 37 | displays.add(display) |
---|
| 38 | else: |
---|
| 39 | continue |
---|
| 40 | |
---|
| 41 | cmd="su -c 'DISPLAY=%s /usr/sbin/shutdown-lliurex-dialog %s' %s &"%(display,wait_time,user) |
---|
| 42 | os.system(cmd) |
---|
[5407] | 43 | |
---|
| 44 | |
---|
[5541] | 45 | if is_thin!=0 and not os.path.exists(thinclient_cron_file): |
---|
[5537] | 46 | os.system("/sbin/shutdown -h +%s"%wait_time) |
---|
[5407] | 47 | |
---|
[5541] | 48 | if is_thin==0 and not os.path.exists(thinclient_cron_file): |
---|
| 49 | time.sleep(60*wait_time) |
---|
| 50 | os.system("n4d-client -r -m shutdown -c ShutdownerClient") |
---|
Note: See
TracBrowser
for help on using the repository browser.