Changeset 5541
- Timestamp:
- Jul 18, 2017, 9:22:18 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-shutdowner/trunk/fuentes/lliurex-shutdowner-common.install/usr/sbin/shutdown-lliurex
r5538 r5541 5 5 import time 6 6 7 thinclient_cron_file="/etc/cron.d/lliurex-shutdowner-thinclients" 7 8 wait_time=1 9 8 10 p=subprocess.Popen(["who"],shell=True,stdout=subprocess.PIPE).communicate()[0] 9 ret=os.system("lliurex-version -t server")11 is_server=os.system("lliurex-version -t server") 10 12 is_thin=os.system("lliurex-version -x thin") 11 13 12 thinclient_cron_file="/etc/cron.d/lliurex-shutdowner-thinclients" 13 14 if ret==0: 15 if is_thin!=0: 14 if is_server==0: 15 if not os.path.exists(thinclient_cron_file): 16 16 wait_time=2 17 17 … … 19 19 shutdown_date="%s:%s"%(t.tm_hour,t.tm_min+wait_time) 20 20 21 displays=set()22 21 23 for item in p.strip("\n").split("\n"): 24 x=item.split(" ") 25 user=x[0] 26 if "(" not in x[-1] or ")" not in x[-1] or ":" not in x[-1] or "." not in x[-1]: 27 continue 28 display=x[-1].lstrip("(").rstrip(")") 29 30 # If thinclient_cron_file exists, this is being called from the server to show shutdown dialog 31 # to thin clients 32 # if this is being called from the server and thincron_file doesn't exist, then it means server 33 # will handle every dialog call 34 35 if is_thin==0 and os.path.exists(thincron_file): 36 if len(display.split(":")[0].split("."))<4: 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]: 37 29 continue 38 39 if display not in displays: 40 displays.add(display) 41 else: 42 continue 43 cmd="su -c 'DISPLAY=%s /usr/sbin/shutdown-lliurex-dialog %s' %s &"%(display,wait_time,user) 44 os.system(cmd) 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) 45 43 46 44 47 if is_thin!=0 :45 if is_thin!=0 and not os.path.exists(thinclient_cron_file): 48 46 os.system("/sbin/shutdown -h +%s"%wait_time) 49 else:50 if is_thin==0:51 if not os.path.exists(thincron_file):52 # this means this is being called inside thin client53 time.sleep(60*wait_time)54 os.system("n4d-client -r -m shutdown -c ShutdownerClient")55 else:56 #this means this is being called from the server57 #Shutdown will be handled inside thin client58 pass59 47 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 TracChangeset
for help on using the changeset viewer.