Merge remote-tracking branch 'git.kebler.net/master' into giskard
commit
6357528bb8
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
log=$HOME/.session/session.log
|
||||
&>> $log
|
||||
echo $USER $HOME
|
||||
echo "lightdm login setup $(date)"
|
||||
|
||||
# example commands to run when logging in, here binding some other directories for the user
|
||||
#echo "binding chromium browsers to .browsers"
|
||||
#/usr/bin/bindfs --map=sysadmin/$USER:@users/@$USER /opt/chromium/default $HOME/.browsers/default
|
||||
# bind alternate downloads directory
|
||||
#/usr/bin/bindfs --map=sysadmin/$USER:@users/@$USER /data/downloads $HOME/Downloads
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
log=$HOME/.session/session.log
|
||||
&>> $log
|
||||
echo $USER $HOME
|
||||
echo "lightdm logout cleanup $(date)"
|
||||
# example complimentary cleanup here unmounting those mounted in session_login
|
||||
#echo "un mounting chromium browsers from .browsers"
|
||||
#/bin/fusermount -u $HOME/.browsers/default
|
||||
#/bin/fusermount -u $HOME/Downloads
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
# run the session login script manually, used for debugging
|
||||
sudo -E HOME=$HOME USER=$USER ./session_login
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
# run the session logout script manually, used for debugging
|
||||
sudo -E HOME=$HOME USER=$USER /bin/bash session_logout
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[Seat:*]
|
||||
session-cleanup-script=/opt/scripts/lightdm-cleanup.sh
|
||||
session-setup-script=/opt/scripts/lightdm-setup.sh
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
function confirm()
|
||||
{
|
||||
echo -n "$@ "
|
||||
read -e answer
|
||||
for response in y Y yes YES Yes Sure sure SURE OK ok Ok
|
||||
do
|
||||
if [ "_$answer" == "_$response" ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Any answer other than the list above is considered a "no" answer
|
||||
return 1
|
||||
}
|
||||
|
||||
if [[ -d $HOME/.session ]]; then
|
||||
echo $HOME/.session folder already exists
|
||||
confirm "!overwrite??? (y/n)" || exit
|
||||
/bin/cp -r -f $HOME/.session/ $HOME/.session-saved/
|
||||
echo saved copy first to $HOME/.session-saved
|
||||
fi
|
||||
echo copying .session from $(pwd) to $HOME
|
||||
/bin/cp -r -f .session/ $HOME
|
||||
echo setting execute permissions
|
||||
chmod +x $HOME/.session/*
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
echo "cleanup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
|
||||
log=${HOME}/.session.log
|
||||
if [[ -e $HOME/.session_logout ]]; then su -c "/bin/bash $HOME/.session_logout 1>>${log} 2>>${log} || true" $USER; fi
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
echo "setup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
|
||||
log=${HOME}/.session.log
|
||||
if [[ -e $HOME/.session_login ]]; then su -c "/bin/bash $HOME/.session_login 1>>${log} 2>>${log} || true" $USER; fi
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
loginout_install() {
|
||||
module_load confirm
|
||||
module_load helpers
|
||||
|
||||
[[ ! $(systemctl list-units | grep lightdm) ]] && echo lightdm not running on this machine, aborting && return
|
||||
|
||||
SDIR=$(adirname "$0")
|
||||
|
||||
pushd $SDIR &> /dev/null || exit
|
||||
[[ ! -d /etc/lightdm/lightdm.conf.d ]] && mkdir -p /etc/lightdm/lightdm.conf.d
|
||||
echo copying 50-setup-cleanup.conf to /etc/lightdm/lightdm.conf.d
|
||||
sudo cp -f 50-setup-cleanup.conf /etc/lightdm/lightdm.conf.d
|
||||
|
||||
if [[ ! -d /opt/scripts ]]; then
|
||||
if [[ ! $(mkdir -p /opt/scripts) ]]; then
|
||||
_sudo="sudo"
|
||||
[[ $($_sudo mkdir -p /opt/scripts) ]] && echo can not make /opt/scripts, aborting && return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo copying lightdm-cleanup.sh and lightdm-setup.sh to /opt/scripts
|
||||
$_sudo cp -f lightdm-*.sh /opt/scripts
|
||||
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
_user=${1:-${USER}}
|
||||
confirm "add a user .session folder for $_user" && add_user_session $1
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add_user_session {
|
||||
|
||||
module_load confirm
|
||||
module_load helpers
|
||||
|
||||
SDIR=$(adirname "$0")
|
||||
# echo source directory: $SDIR
|
||||
|
||||
pushd $SDIR &> /dev/null || exit
|
||||
|
||||
_user=${1:-${USER}}
|
||||
|
||||
[[ ! $(user_exists $_user) ]] && echo user $_user does not exist, aborting && return
|
||||
_home=$(bash -c "cd ~$(printf %q $_user) && pwd")
|
||||
|
||||
echo making $_home/.session folder for $_user
|
||||
# mkdir $USER/.session
|
||||
|
||||
sudo -H -E -u "$_user" -s /bin/bash cpy.session.sh
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
|
||||
# confirm "do you want to install WidevineCDM for digital streaming rights?"
|
||||
# if [ $? -eq 0 ]; then
|
||||
# module_load widevine-install
|
||||
# widevine_install
|
||||
# fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
# if script was executed then call the function
|
||||
(return 0 2>/dev/null) || loginout_install $@
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
Lightdm (gdm) is the login manager for linux ubuntu and mint (by default)
|
||||
|
||||
If you need setup and cleanup that is ONLY done at lightdm login/logout then
|
||||
one can run a script to setup and cleanup the session by
|
||||
|
||||
running the loginout-install script, requires sudo
|
||||
|
||||
`module_load loginout-install; loginout_install <user>` # default is current user
|
||||
|
||||
after loading common scripts this will ask if you want to add the .session folder for the user
|
||||
|
||||
or if you just need to add a user .session folder afterward
|
||||
|
||||
`module_load loginout-install; add_user_session <user>`
|
||||
|
||||
|
||||
the script does this
|
||||
|
||||
in `/etc/lightdm/lightdm.conf.d` adds a file `50-setup-cleanup.conf`
|
||||
|
||||
```
|
||||
[Seat:*]
|
||||
session-cleanup-script=/opt/scripts/lightdm-cleanup.sh
|
||||
session-setup-script=/opt/scripts/lightdm-setup.sh
|
||||
```
|
||||
|
||||
in /opt/scripts put two files below and make sure they are +x executable
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#lightdm-setup.sh
|
||||
echo "setup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
|
||||
log=${HOME}/.session.log
|
||||
if [[ -e $HOME/.session_login ]]; then su -c "/bin/bash $HOME/.session_login 1>>${log} 2>>${log} || true" $USER; fi
|
||||
```
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#lightdm-cleanup.sh
|
||||
echo "cleanup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
|
||||
log=${HOME}/.session.log
|
||||
if [[ -e $HOME/.session_logout ]]; then su -c "/bin/bash $HOME/.session_logout 1>>${log} 2>>${log} || true" $USER; fi
|
||||
```
|
||||
|
||||
then in the user home puts
|
||||
`.session_login` and `.session_logout` files both executable
|
||||
in those you can do anything like bindfs and fusermount -u
|
||||
|
||||
make sure you restart lightdm or reboot
|
||||
`sdr lightdm`
|
Reference in New Issue