88# %
99# % DESCRIPTION
1010# % This script installs a mandatory PolicyKit policy that either prevents
11- # % the "user" or "lightdm" users from suspending the system,
12- # % prevents the "user" or "lightdm" users from restarting/ shutting down
13- # % the system or prevents both .
11+ # % the "user" or "lightdm" users from suspending the system or
12+ # % prevents the "user" or "lightdm" users from suspending, restarting or shutting down
13+ # % the system.
1414# %
1515# % It takes two optional parameters: whether to prevent suspending the system
16- # % and whether to prevent restart/shutdown.
16+ # % and whether to also prevent restart/shutdown.
1717# % 1. Use a boolean to decide whether or not to prevent the "user" from
1818# % suspending the system. A checked box prevents suspend and an
1919# % unchecked box allows it
20- # % 2. Use a boolean to decide whether or not to prevent the "user" from
20+ # % 2. Use a boolean to decide whether or not to also prevent the "user" from
2121# % restarting/shutting down the system. A checked box prevents
22- # % restart/shutdown and an unchecked box allows it
22+ # % restart/shutdown and an unchecked box allows it.
23+ # % Has no effect if input 1 is unchecked
2324# %
2425# ================================================================
2526# - IMPLEMENTATION
@@ -47,10 +48,10 @@ set -x
4748POLICY=" /etc/polkit-1/localauthority/90-mandatory.d/10-os2borgerpc-no-user-shutdown.pkla"
4849
4950if [ ! -d " $( dirname " $POLICY " ) " ]; then
50- mkdir " $( dirname " $POLICY " ) "
51+ mkdir -p " $( dirname " $POLICY " ) "
5152fi
5253
53- if [ " $1 " = " False" ] && [ " $2 " = " False " ] ; then
54+ if [ " $1 " = " False" ]; then
5455 rm -f " $POLICY "
5556elif [ " $1 " = " True" ] && [ " $2 " = " False" ]; then
5657 cat > " $POLICY " << END
@@ -61,15 +62,6 @@ ResultAny=no
6162ResultActive=no
6263ResultInactive=no
6364END
64- elif [ " $1 " = " False" ] && [ " $2 " = " True" ]; then
65- cat > " $POLICY " << END
66- [Restrict system shutdown]
67- Identity=unix-user:user;unix-user:lightdm
68- Action=org.freedesktop.login1.power-off*;org.freedesktop.login1.reboot*;org.freedesktop.login1.lock-sessions;org.freedesktop.login1.set-reboot*
69- ResultAny=no
70- ResultActive=no
71- ResultInactive=no
72- END
7365else
7466 cat > " $POLICY " << END
7567[Restrict system shutdown]
0 commit comments