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

Last change on this file since 5407 was 5407, checked in by hectorgh, 2 years ago

adding new files

  • Property svn:executable set to *
File size: 627 bytes
Line 
1#!/usr/bin/env python
2
3import subprocess
4import os
5
6p=subprocess.Popen(["who | grep tty"],shell=True,stdout=subprocess.PIPE).communicate()[0]
7
8ret=os.system("lliurex-version -t server")
9wait_time=1
10if ret==0:
11        wait_time=3
12
13for item in p.strip("\n").split("\n"):
14        x=item.split(" ")
15        print x
16        user=x[0]
17        print user
18        if "(" not in x[-1] and ")" not in x[-1]:
19                continue
20        display=x[-1].lstrip("(").rstrip(")")
21        cmd="su -c 'zenity --info --text=\"System will shutdown in %s minutes, please save your files.\" --display %s\' %s &"%(wait_time,display,user)
22        print(cmd)
23        os.system(cmd)
24
25os.system("/sbin/shutdown -h +%s"%wait_time)
26
27
28
Note: See TracBrowser for help on using the repository browser.