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

Last change on this file since 5426 was 5426, checked in by hectorgh, 22 months ago

changing msg

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