install printer based on GPO
This commit is contained in:
parent
cc4010b1bb
commit
2fe52816e4
31 changed files with 3284 additions and 0 deletions
38
roles/lmn_printer/files/onLogout
Normal file
38
roles/lmn_printer/files/onLogout
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# DO NOT MODIFY THIS SCRIPT!
|
||||
# For custom scripts use the hookdirs
|
||||
# /etc/linuxmuster-linuxclient7/onLoginAsRoot.d
|
||||
# and /etc/linuxmuster-linuxclient7/onLogoutAsRoot.d
|
||||
|
||||
# This schript is called in root context when a user logs in or out
|
||||
try:
|
||||
import os, sys
|
||||
from linuxmusterLinuxclient7 import logging, hooks, constants, user, shares, printers, computer, realm
|
||||
|
||||
pamType = os.getenv("PAM_TYPE")
|
||||
pamUser = os.getenv("PAM_USER")
|
||||
#PAM_RHOST, PAM_RUSER, PAM_SERVICE, PAM_TTY, PAM_USER and PAM_TYPE
|
||||
logging.info("====== onLoginLogoutAsRoot started with PAM_TYPE={0} PAM_RHOST={1} PAM_RUSER={2} PAM_SERVICE={3} PAM_TTY={4} PAM_USER={5} ======".format(pamType, os.getenv("PAM_RHOST"), os.getenv("PAM_RUSER"), os.getenv("PAM_SERVICE"), os.getenv("PAM_TTY"), pamUser))
|
||||
|
||||
# check if whe should execute
|
||||
if not hooks.shouldHooksBeExecuted(pamUser):
|
||||
logging.info("======> onLoginLogoutAsRoot end ====")
|
||||
sys.exit(0)
|
||||
|
||||
elif pamType == "close_session":
|
||||
# cleanup
|
||||
printers.uninstallAllPrintersOfUser(pamUser)
|
||||
|
||||
logging.info("======> onLoginLogoutAsRoot end ======")
|
||||
|
||||
except Exception as e:
|
||||
try:
|
||||
logging.exception(e)
|
||||
except:
|
||||
print("A fatal error occured!")
|
||||
|
||||
# We need to catch all exceptions and return 0 in any case!
|
||||
# If we do not return 0, login will FAIL FOR EVERYONE!
|
||||
sys.exit(0)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue