source: lliurex-shutdowner/trunk/fuentes/lliurex-shutdowner-common.install/usr/sbin/shutdown-lliurex @ 5537

Last change on this file since 5537 was 5537, checked in by hectorgh, 3 years ago

trying to support thin clients as well

  • Property svn:executable set to *
File size: 912 bytes
Line 
1#!/usr/bin/env python
2
3import subprocess
4import os
5import time
6
7wait_time=1
8p=subprocess.Popen(["who"],shell=True,stdout=subprocess.PIPE).communicate()[0]
9ret=os.system("lliurex-version -t server")
10is_thin=os.system("lliurex-version -x thin")
11
12if ret==0:
13        if is_thin!=0:
14                wait_time=2
15
16t=time.localtime()
17shutdown_date="%s:%s"%(t.tm_hour,t.tm_min+wait_time)
18
19displays=set()
20
21for item in p.strip("\n").split("\n"):
22        x=item.split(" ")
23        user=x[0]
24        if "(" not in x[-1] or ")" not in x[-1] or ":" not in x[-1] or "." not in x[-1]:
25                continue
26        display=x[-1].lstrip("(").rstrip(")")
27        if display not in displays:
28                displays.add(display)
29        else:
30                continue
31        cmd="su -c 'DISPLAY=%s /usr/sbin/shutdown-lliurex-dialog %s' %s &"%(display,wait_time,user)
32        os.system(cmd)
33
34
35if is_thin!=0:
36        os.system("/sbin/shutdown -h +%s"%wait_time)
37else:
38        time.sleep(60*wait_time)
39        os.system("n4d-client -r -m shutdown -c ShutdownerClient")
40
Note: See TracBrowser for help on using the repository browser.