Добавлено восстановление точек монтирования при suspend

master3.3
Mike khiretskiy 11 years ago
parent ff53f288e5
commit 1542dd4b16

@ -271,13 +271,13 @@ class Client(commandServer, encrypt, Desktop):
p = process(mountCmd,"-t","cifs","-o",
"cache=loose,user=%s,uid=%d,gid=%d,noperm"%(userName,uid,gid),
"//%s/%s"%(host,res),rpath,
envdict={"PASSWD":userPwd})
envdict={"PASSWD":userPwd},stderr=STDOUT)
return p.success()
else:
p = process(mountCmd,"-t","cifs","-o",
"cache=loose,user=%s"%userName,
"//%s/%s"%(host,res),rpath,
envdict={"PASSWD":userPwd})
envdict={"PASSWD":userPwd},stderr=STDOUT)
return p.success()
def mountSleepRes(self,host,userName,userPwd,res,rpath,uid=None,gid=None):

@ -0,0 +1,92 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Copyright 2013 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import __future__
import gobject
import dbus
import dbus.mainloop.glib
from calculate.lib.datavars import DataVars, VariableError
from calculate.lib.utils.files import isMount, getRunCommands
from calculate.client.client import Client
from argparse import ArgumentParser
from time import sleep
class ResourceRemounter:
"""
Object contains one method for handle 'Resuming' dbus signal.
'handle_resuming' method checks and remounts user remote resources.
"""
def __init__(self,dv):
self.dv = dv
self.dv.defaultModule = 'client'
self.client = Client()
self.client.clVars = dv
def handle_resuming(self,statename):
print("Restoring remote mounts for user %s"%self.dv.Get('ur_login'))
# waiting for the domain
for wait in [1,2,5,10]:
if self.client.checkDomainServer(
self.dv.Get('cl_remote_host'),
self.dv.Get('os_net_domain')):
break
sleep(wait)
# check and remount remote resources
self.client.mountUserDomainRes(self.dv.Get('ur_login'),
self.dv.Get('desktop.ur_password'),
int(self.dv.Get('ur_uid')),
int(self.dv.Get('ur_gid')),
"unix","share","homes","ftp")
def main(argv):
# processing the user argument
argp = ArgumentParser(add_help=True)
argp.add_argument("user",help="tracked user",metavar="USER")
namespace = argp.parse_args(argv[1:])
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
# initialization calculate datavars and quitting on an error
try:
dv = DataVars()
dv.importData()
dv.flIniFile()
dv.Set('ur_login',namespace.user)
if dv.Get('desktop.ur_domain_set') == 'off':
print("%s isn't a domain user"%namespace.user)
sys.exit(0)
except VariableError as e:
sys.stderr.write(str(e)+'\n')
sys.exit(1)
rm = ResourceRemounter(dv)
bus.add_signal_receiver(rm.handle_resuming,dbus_interface="org.freedesktop.UPower",
signal_name = "NotifyResume")
loop = gobject.MainLoop()
context = loop.get_context()
while True:
# need for dbus processing
context.iteration(1)
sleep(1)
if __name__ == '__main__':
main(sys.argv)

@ -0,0 +1,25 @@
#! /bin/sh
# Copyright 2013 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
env-update
source /etc/profile
source /usr/share/calculate/xdm/functions
if [[ "${DOMAIN_USER}" == "on" ]]
then
/usr/sbin/cl-client-resume-remount ${USER} &
fi
exit 0

@ -0,0 +1,25 @@
#! /bin/sh
# Copyright 2013 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
env-update
source /etc/profile
source /usr/share/calculate/xdm/functions
if [[ "${DOMAIN_USER}" == "on" ]]
then
pkill -f "cl-client-resume-remount ${USER}"
fi
exit 0

@ -29,8 +29,13 @@ data_files = []
data_files += [('/etc/init.d', ['data/client'])]
data_files += [('/usr/sbin', ['data/logout'])]
data_files += [('/usr/sbin', ['data/cl-client-resume-remount'])]
data_files += [('/usr/share/calculate/xdm/login.d',
['data/login.d/10client'])] +\
[('/usr/share/calculate/xdm/login.d',
['data/login.d/15resume_remount'])] +\
[('/usr/share/calculate/xdm/logout.d',
['data/logout.d/15resume_remount'])] +\
[('/usr/share/calculate/xdm/logout.d',
['data/logout.d/10client'])] +\
[('/usr/share/calculate/xdm/',['data/wait_domain'])]
@ -73,6 +78,7 @@ class cl_install_data(install_data):
install_data.run(self)
data_file = [("/etc/init.d/client",0755),
("/usr/sbin/logout",0755),
("/usr/sbin/cl-client-resume-remount",0755),
("/usr/share/calculate/xdm/wait_domain",0755)]
fileNames = map(lambda x: os.path.split(x[0])[1], data_file)
listNames = map(lambda x: filter(lambda y: y, x[0].split("/")),

Loading…
Cancel
Save