forked from sheagcraig/auto_logout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinstall
More file actions
executable file
·29 lines (23 loc) · 863 Bytes
/
postinstall
File metadata and controls
executable file
·29 lines (23 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# We have to be careful when editing the sudoers file. Syntax errors cause problems!
#STRING="ALL ALL=(root) NOPASSWD: /usr/bin/killall -9 loginwindow"
REBOOT="ALL ALL=(root) NOPASSWD: /sbin/reboot -q"
FVREBOOT="ALL ALL=(root) NOPASSWD: /usr/bin/fdesetup authrestart"
SHUTDOWN="ALL ALL=(root) NOPASSWD: /sbin/shutdown -h now"
if $(grep -q "$REBOOT" /etc/sudoers) && $(grep -q "$SHUTDOWN" /etc/sudoers) && $(grep -q "$FVREBOOT" /etc/sudoers); then
# Nothing to be done
exit 0
fi
# Make a working copy
cp /etc/sudoers /tmp/sudoers.tmp
# Echo in our changes
echo "$REBOOT" >> /tmp/sudoers.tmp
echo "$FVREBOOT" >> /tmp/sudoers.tmp
echo "$SHUTDOWN" >> /tmp/sudoers.tmp
# Validate the changes
visudo -cqsf /tmp/sudoers.tmp
# visudo exits 0 if the changes are syntactically correct
if [[ $? -eq 0 ]]; then
cp /tmp/sudoers.tmp /etc/sudoers
fi
exit 0