7
7
from linuxmusterLinuxclient7 import logging , constants , user , config , computer , environment , setup , shares
8
8
9
9
class Type (Enum ):
10
+ """
11
+ Enum containing all hook types
12
+ """
13
+
10
14
Boot = 0
15
+ """The onBoot hook
16
+ """
11
17
Shutdown = 1
18
+ """The on Shutdown hook
19
+ """
12
20
LoginAsRoot = 2
21
+ """The onLoginAsRoot hook
22
+ """
13
23
Login = 3
24
+ """The onLogin hook
25
+ """
14
26
SessionStarted = 4
27
+ """The onSession started hook
28
+ """
15
29
LogoutAsRoot = 5
16
30
LoginLogoutAsRoot = 6
17
31
@@ -30,6 +44,12 @@ class Type(Enum):
30
44
}
31
45
32
46
def runLocalHook (hookType ):
47
+ """
48
+ Run all scripts in a local hookdir
49
+
50
+ :param hookType: The type of hook to run
51
+ :type hookType: hooks.Type
52
+ """
33
53
logging .info ("=== Running local hook on{0} ===" .format (hookType .name ))
34
54
hookDir = _getLocalHookDir (hookType )
35
55
if os .path .exists (hookDir ):
@@ -41,6 +61,12 @@ def runLocalHook(hookType):
41
61
42
62
43
63
def runRemoteHook (hookType ):
64
+ """
65
+ Run hookscript from sysvol
66
+
67
+ :param hookType: The type of hook to run
68
+ :type hookType: hooks.Type
69
+ """
44
70
logging .info ("=== Running remote hook on{0} ===" .format (hookType .name ))
45
71
rc , hookScripts = _getRemoteHookScripts (hookType )
46
72
@@ -52,16 +78,33 @@ def runRemoteHook(hookType):
52
78
logging .info ("===> Finished running remote hook on{0} ===" .format (hookType .name ))
53
79
54
80
def runHook (hookType ):
81
+ """
82
+ Executes hooks.runLocalHook() and hooks.runRemoteHook()
83
+
84
+ :param hookType: The type of hook to run
85
+ :type hookType: hooks.Type
86
+ """
55
87
runLocalHook (hookType )
56
88
runRemoteHook (hookType )
57
89
58
90
def getLocalHookScript (hookType ):
59
- return "{0}/on{1}" . format ( constants . scriptDir , hookType . name )
91
+ """Get the path of a local hookscript
60
92
61
- def createSessionAutostartFile ():
62
- pass
93
+ :param hookType: The type of hook script to get the path for
94
+ :type hookType: hooks.Type
95
+ :return: The path
96
+ :rtype: str
97
+ """
98
+ return "{0}/on{1}" .format (constants .scriptDir ,hookType .name )
63
99
64
100
def shouldHooksBeExecuted (overrideUsername = None ):
101
+ """Check if hooks should be executed
102
+
103
+ :param overrideUsername: Override the username to check, defaults to None
104
+ :type overrideUsername: str, optional
105
+ :return: True if hooks should be executed, fale otherwise
106
+ :rtype: bool
107
+ """
65
108
# check if linuxmuster-linuxclient7 is setup
66
109
if not setup .isSetup ():
67
110
logging .info ("==== Linuxmuster-linuxclient7 is not setup, exiting ====" )
0 commit comments