|
|
|
@ -83,18 +83,37 @@ class ResourceRemounter:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def handle_resuming(self, statename):
|
|
|
|
|
"""
|
|
|
|
|
Handle PrepareForSleep statename(True) sleep, statename(False) resume
|
|
|
|
|
"""
|
|
|
|
|
resume = not bool(statename)
|
|
|
|
|
print("Restoring remote mounts for user %s" % self.dv.Get('ur_login'))
|
|
|
|
|
# waiting for the domain
|
|
|
|
|
for wait in [1, 2, 5, 10]:
|
|
|
|
|
try:
|
|
|
|
|
if self.check_server(True):
|
|
|
|
|
if resume:
|
|
|
|
|
# lazy umount domain user resources, and remote
|
|
|
|
|
for rpath in self.dv.Get('client.cl_client_user_mount_path'):
|
|
|
|
|
if rpath:
|
|
|
|
|
os.system("/bin/umount -l %s &>/dev/null"%rpath)
|
|
|
|
|
os.system("/bin/umount -l %s &>/dev/null"%"/var/calculate/remote")
|
|
|
|
|
|
|
|
|
|
# waiting for the domain
|
|
|
|
|
for wait in [1, 2, 5, 5, 10, 10, 15]:
|
|
|
|
|
try:
|
|
|
|
|
if self.check_server(True):
|
|
|
|
|
break
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
sleep(wait)
|
|
|
|
|
|
|
|
|
|
# wait for netmount
|
|
|
|
|
netmount_stopping = '/run/openrc/stopping/netmount'
|
|
|
|
|
for wait in range(0, 20):
|
|
|
|
|
if not path.exists(netmount_stopping):
|
|
|
|
|
break
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
sleep(wait)
|
|
|
|
|
# check and remount remote resources
|
|
|
|
|
self.remount_remote()
|
|
|
|
|
self.remount_user_resources()
|
|
|
|
|
sleep(1)
|
|
|
|
|
|
|
|
|
|
# check and remount remote resources
|
|
|
|
|
self.remount_remote()
|
|
|
|
|
self.remount_user_resources()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv):
|
|
|
|
@ -112,6 +131,13 @@ def main(argv):
|
|
|
|
|
dv.importData()
|
|
|
|
|
dv.flIniFile()
|
|
|
|
|
dv.Set('ur_login', namespace.user)
|
|
|
|
|
# pre-calculate values
|
|
|
|
|
for vn in ("ur_uid", "ur_gid",
|
|
|
|
|
"client.cl_client_user_mount_path",
|
|
|
|
|
"client.cl_client_user_mount_resource",
|
|
|
|
|
"client.cl_client_user_mount_host",
|
|
|
|
|
"client.cl_client_user_mount_name"):
|
|
|
|
|
dv.Get(vn)
|
|
|
|
|
if dv.Get('desktop.ur_domain_set') == 'off':
|
|
|
|
|
print("%s isn't a domain user" % namespace.user)
|
|
|
|
|
sys.exit(0)
|
|
|
|
@ -121,8 +147,8 @@ def main(argv):
|
|
|
|
|
|
|
|
|
|
rm = ResourceRemounter(dv)
|
|
|
|
|
bus.add_signal_receiver(rm.handle_resuming,
|
|
|
|
|
dbus_interface="org.freedesktop.UPower",
|
|
|
|
|
signal_name="NotifyResume")
|
|
|
|
|
dbus_interface="org.freedesktop.ConsoleKit.Manager",
|
|
|
|
|
signal_name="PrepareForSleep")
|
|
|
|
|
loop = gobject.MainLoop()
|
|
|
|
|
context = loop.get_context()
|
|
|
|
|
while True:
|
|
|
|
|