forked from DeskPi-Team/deskpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-ubuntu-mate.sh
executable file
·80 lines (69 loc) · 2.94 KB
/
install-ubuntu-mate.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#
. /lib/lsb/init-functions
daemonname="deskpi"
tempmonscript=/usr/bin/pmwFanControl
deskpidaemon=/lib/systemd/system/$daemonname.service
safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service
# Thanks for muckypaws' help, solve the location problem.
installationfolder=/home/$SUDO_USER/deskpi
# install DeskPi stuff.
log_action_msg "DeskPi Fan control script installation Start."
# Create service file on system.
if [ -e $deskpidaemon ]; then
sudo rm -f $deskpidaemon
fi
# adding dtoverlay to enable dwc2 on host mode.
sudo sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt
sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt
# install PWM fan control daemon.
log_action_msg "DeskPi main control service loaded."
cd $installationfolder/drivers/c/
sudo cp -rf $installationfolder/drivers/c/pwmFanControl /usr/bin/pwmFanControl
sudo cp -rf $installationfolder/drivers/c/fanStop /usr/bin/fanStop
sudo cp -rf $installationfolder/deskpi-config /usr/bin/deskpi-config
sudo cp -rf $installationfolder/Deskpi-uninstall /usr/bin/Deskpi-uninstall
sudo chmod 755 /usr/bin/pwmFanControl
sudo chmod 755 /usr/bin/fanStop
sudo chmod 755 /usr/bin/deskpi-config
sudo chmod 755 /usr/bin/Deskpi-uninstall
# Build Fan Daemon
echo "[Unit]" > $deskpidaemon
echo "Description=DeskPi PWM Control Fan Service" >> $deskpidaemon
echo "After=multi-user.target" >> $deskpidaemon
echo "[Service]" >> $deskpidaemon
echo "Type=oneshot" >> $deskpidaemon
echo "RemainAfterExit=true" >> $deskpidaemon
echo "ExecStart=sudo /usr/bin/pwmFanControl &" >> $deskpidaemon
echo "[Install]" >> $deskpidaemon
echo "WantedBy=multi-user.target" >> $deskpidaemon
# send signal to MCU before system shuting down.
echo "[Unit]" > $safeshutdaemon
echo "Description=DeskPi Safeshutdown Service" >> $safeshutdaemon
echo "Conflicts=reboot.target" >> $safeshutdaemon
echo "Before=halt.target shutdown.target poweroff.target" >> $safeshutdaemon
echo "DefaultDependencies=no" >> $safeshutdaemon
echo "[Service]" >> $safeshutdaemon
echo "Type=oneshot" >> $safeshutdaemon
echo "ExecStart=/usr/bin/sudo /usr/bin/fanStop" >> $safeshutdaemon
echo "RemainAfterExit=yes" >> $safeshutdaemon
echo "[Install]" >> $safeshutdaemon
echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon
log_action_msg "DeskPi Service configuration finished."
sudo chown root:root $safeshutdaemon
sudo chmod 755 $safeshutdaemon
sudo chown root:root $deskpidaemon
sudo chmod 755 $deskpidaemon
log_action_msg "DeskPi Service Load module."
sudo systemctl daemon-reload
sudo systemctl enable $daemonname.service
sudo systemctl start $daemonname.service &
sudo systemctl enable $daemonname-safeshut.service
# Finished
log_success_msg "DeskPi PWM Fan Control and Safeshut Service installed successfully."
# greetings and require rebooting system to take effect.
log_action_msg "System will reboot in 5 seconds to take effect."
sudo sync
sleep 5
# sudo reboot
echo "Reboot system for changes to take effect"