echo"This installer is meant to install the yubilock service for one user. Please specifiy for wich user you want to install xscreensaver-yubilock"
read -p 'Username: ' username
userid=`id -u "$username" 2>/dev/null`||(echo"$username is not a user on this system"&&exit1)
["$userid" -lt 1000]&&echo"User $username seems to be a systemuser (uid: $userid). Please specify a normal user."&&exit1
echo"Allowed yubikey serials can be set systemwide in ${install_dir}config.ini, or per user in \$HOME/.yubilock. Do you wish to add one or more for $username now?"
read -p "Add Yubikey serial? (Y/n) " add_serial
[ -z "$add_serial"]&&add_serial='yes'# if no input, assume yes
case${add_serial:0:1} in
y|Y|1)
add_serial='yes';;
* )
add_serial='no';;
esac
if["$add_serial"='yes'];then
if ! ykman -v >/dev/null 2>&1;then
echo"yubikey-manager doesn't seem to be installed. Do you want to install it? ('no' means you'll have to add your yubikey serial manually later)"
sed -i "s+^ExecStart=.*+ExecStart=${install_dir}venv/bin/python ${install_dir}xscreensaver_yubilock.py -v+g""/home/$username/.config/systemd/user/yubilock.service"
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user enable yubilock.service'
# su is used for systemctl user units because systemctl matches executing uid to unit owner uid. See:
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user reset-failed'
fi
echo"== xscreensaver-yubilock is installed! =="
echo"== to enable yubilock, please restart your device ==
exit0
# Due to loginctl not updating user groups, the user has to restart before the service can be started.
if["$use_systemd"='yes'];then
echo"Do you wish to start the daemon now? WARNING: If the specified yubikey is not plugged in, your machine will lock. Alternatively, you can start the service using 'sudo systemctl start yubilock.service' or wait for next login."
read -p "Start daemon? (y/N) " start_daemon
[ -z "$start_daemon"]&&start_daemon='no'# if no input, assume no
case${start_daemon:0:1} in
n|N|0)
;;
* )
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user start yubilock.service';;
userid=`id -u "$username" 2>/dev/null`||(echo"$username is not a user on this system"&&exit1)
["$userid" -lt 1000]&&echo"User $username seems to be a systemuser (uid: $userid). Please specify a normal user."&&exit1
echo"Allowed yubikey serials can be set in {$install_dir}config.ini. Do you wish to add one or more automaticaly now?"
echo"Allowed yubikey serials can be set systemwide in ${install_dir}config.ini, or per user in \$HOME/.yubilock. Do you wish to add one or more for $username now?"
read -p "Add Yubikey serial? (Y/n) " add_serial
[ -z "$add_serial"]&&add_serial='yes'# if no input, assume yes
case${add_serial:0:1} in
@ -30,7 +30,7 @@ case ${add_serial:0:1} in
@@ -30,7 +30,7 @@ case ${add_serial:0:1} in
esac
if["$add_serial"='yes'];then
if ! ykman -v >/dev/null 2>&1;then
echo"yubikey-manager doesn't seem to be installed. Do you want to install it? ('no' means you'll have to add your yubikey serial manually later"
echo"yubikey-manager doesn't seem to be installed. Do you want to install it? ('no' means you'll have to add your yubikey serial manually later)"
sed -i "s+^ExecStart=.*+ExecStart=${install_dir}venv/bin/python ${install_dir}xscreensaver_yubilock.py -v+g""/home/$username/.config/systemd/user/yubilock.service"
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user enable yubilock.service'
# su is used for systemctl user units because systemctl matches executing uid to unit owner uid. See:
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user reset-failed'
fi
echo"xscreensaver-yubilock is installed!"
echo"== xscreensaver-yubilock is installed! =="
echo"== to enable yubilock, please restart your device ==
exit0
# Due to loginctl not updating user groups, the user has to restart before the service can be started.
if["$use_systemd"='yes'];then
echo"Do you wish to start the daemon now? WARNING: If the specified yubikey is not plugged in, your machine will lock. Alternatively, you can start the service using 'sudo systemctl start yubilock.service' or wait for next login."
read -p "Start daemon? (y/N) " start_daemon
@ -140,7 +149,7 @@ if [ "$use_systemd" = 'yes' ]; then
@@ -140,7 +149,7 @@ if [ "$use_systemd" = 'yes' ]; then
n|N|0)
;;
* )
systemctl start yubilock.service;;
su "$username" -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user start yubilock.service';;