Changeset 5541


Ignore:
Timestamp:
Jul 18, 2017, 9:22:18 AM (23 months ago)
Author:
hectorgh
Message:

fixing shutdown-lliurex to better support thin clients

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lliurex-shutdowner/trunk/fuentes/lliurex-shutdowner-common.install/usr/sbin/shutdown-lliurex

    r5538 r5541  
    55import time
    66
     7thinclient_cron_file="/etc/cron.d/lliurex-shutdowner-thinclients"
    78wait_time=1
     9
    810p=subprocess.Popen(["who"],shell=True,stdout=subprocess.PIPE).communicate()[0]
    9 ret=os.system("lliurex-version -t server")
     11is_server=os.system("lliurex-version -t server")
    1012is_thin=os.system("lliurex-version -x thin")
    1113
    12 thinclient_cron_file="/etc/cron.d/lliurex-shutdowner-thinclients"
    13 
    14 if ret==0:
    15         if is_thin!=0:
     14if is_server==0:
     15        if not os.path.exists(thinclient_cron_file):
    1616                wait_time=2
    1717
     
    1919shutdown_date="%s:%s"%(t.tm_hour,t.tm_min+wait_time)
    2020
    21 displays=set()
    2221
    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:
     22if 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]:
    3729                        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)
    4543
    4644
    47 if is_thin!=0:
     45if is_thin!=0 and not os.path.exists(thinclient_cron_file):
    4846        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 client
    53                         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 server
    57                         #Shutdown will be handled inside thin client
    58                         pass
    5947
     48if 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.