-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstaller.sh
executable file
·57 lines (44 loc) · 1.55 KB
/
installer.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#If script is executed as non-root user, reject
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
else
INSTALL_DIR="/usr/bin/pendrive-reminder"
#Copy auxiliar scripts
mkdir $INSTALL_DIR 2>/dev/null
cp -r aux_scripts/ $INSTALL_DIR
chmod +x $INSTALL_DIR/aux_scripts/*
#copy udev rules and recharge udev
cp udev-rules/* /etc/udev/rules.d/
udevadm control --reload-rules
#Copy env variables into a auxiliar file
echo "DISPLAY="$DISPLAY"" > $INSTALL_DIR/var
echo "LANG="$LANG"" >> $INSTALL_DIR/var
#Copy locale files
cp -r locale/* /usr/share/locale/
#Copy polkit rules
#If polkit version is >= 0.106
if test $(pkaction --version | cut -d " " -f 3 | cut -d "." -f 2) -ge 106
then
#copy rules file
cp polkit-rules/10-inhibit-shutdown.rules /usr/share/polkit-1/rules.d/
#copy dbus-client
cp -r dbus-client/ $INSTALL_DIR
chmod ugo+x $INSTALL_DIR/dbus-client/client.py
#If polkit version is < 0.106
else
#if polkit version is < 0.106 copy pkla file to a temporal directory
cp polkit-rules/50-inhibit-shutdown.pkla $INSTALL_DIR
#Add cron task to remove shutdown lock after forced shutdown or reboot
(crontab -l 2>/dev/null; echo "@reboot $INSTALL_DIR/aux_scripts/check_shutforced.sh") | crontab -
fi
#check linux distribution
distro=$(grep '^ID=' /etc/os-release | cut -d = -f 2)
version=$(grep "VERSION_ID" /etc/os-release | cut -d "=" -f 2)
#if distribution is Ubuntu or Linux Mint, restart udev
if test "$distro" = "ubuntu" && test "$version" = "\"17.10\""
then
systemctl restart udev
fi
fi