forked from DeskPi-Team/deskpi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DeskPi-Team#61 from boschkundendienst/manjaro_arch
Manjaro arch
- Loading branch information
Showing
5 changed files
with
158 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,109 @@ | ||
#!/bin/bash | ||
# | ||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root or with sudo" | ||
exit | ||
fi | ||
|
||
# copy lib for functions used by deskpi-config | ||
# to /usr/local/lib | ||
if [ -f '/usr/local/lib/deskpi-log-functions' ] ; then | ||
echo "local functions lib already present" | ||
else | ||
echo "copying functions library to /usr/local/lib/deskpi-local.lib" | ||
cp ./log_functions.include '/usr/local/lib/deskpi-log-functions' | ||
fi | ||
# copy deskpi-config to usr local bin | ||
echo "copying deskpi-config to /usr/local/bin" | ||
cp ./deskpi-config /usr/local/bin/deskpi-config | ||
# make deskpi-config executable | ||
chmod +x /usr/local/bin/deskpi-config | ||
# copy uninstalls cript to local bin | ||
echo "copying uninstall-manjaro.sh to /usr/local/bin/Deskpi-uninstall" | ||
cp ./uninstall-manjaro.sh /usr/local/bin/Deskpi-uninstall | ||
chmod +x /usr/local/bin/Deskpi-uninstall | ||
|
||
echo "DeskPi Driver Installing..." | ||
if [ -d /tmp/deskpi ]; then | ||
sudo rm -rf /tmp/deskpi 2&>/dev/null | ||
rm -rf /tmp/deskpi 2&>/dev/null | ||
fi | ||
echo "Download the latest DeskPi Driver from GitHub..." | ||
cd /tmp && git clone https://github.com/DeskPi-Team/deskpi.git | ||
|
||
echo "DeskPi Driver Installation Start." | ||
deskpiv1=/lib/systemd/system/systemd-deskpi-safecutoffpower.service | ||
deskpi=/lib/systemd/system/deskpi.service | ||
safeshutdaemon=/lib/systemd/system/deskpi-safeshut.service | ||
driverfolder=/tmp/deskpi | ||
|
||
# delete deskpi-safecutoffpower.service file. | ||
if [ -e $deskpi ]; then | ||
sudo sh -c "rm -f $deskpi" | ||
sh -c "rm -f $deskpi" | ||
fi | ||
|
||
# adding dtoverlay to enable dwc2 on host mode. | ||
echo "Configure /boot/config.txt file and enable front USB2.0" | ||
sudo sed -i '/dtoverlay=dwc2*/d' /boot/config.txt | ||
sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/config.txt | ||
sudo sh -c "echo dwc2 > /etc/modules-load.d/raspberry.conf" | ||
sed -i '/dtoverlay=dwc2*/d' /boot/config.txt | ||
sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/config.txt | ||
sh -c "echo dwc2 > /etc/modules-load.d/raspberry.conf" | ||
|
||
sudo cp -rf $driverfolder/drivers/c/safecutoffpower64 /usr/bin/safecutoffpower64 | ||
sudo cp -rf $driverfolder/drivers/python/safecutoffpower.py /usr/bin/safecutoffpower.py | ||
sudo chmod 644 /usr/bin/safecutoffpower64 | ||
sudo chmod 644 /usr/bin/safecutoffpower.py | ||
cp -rf $driverfolder/drivers/python/safecutoffpower.py /usr/bin/safecutoffpower.py | ||
cp -rf $driverfolder/drivers/python/pwmControlFan.py /usr/bin/pwmControlFan.py | ||
chmod 644 /usr/bin/safecutoffpower.py | ||
chmod 644 /usr/bin/pwmControlFan.py | ||
|
||
# send cut off power signal to MCU before system shuting down. | ||
sudo echo "[Unit]" > $deskpi | ||
sudo echo "Description=DeskPi Safe Cut-off Power Service" >> $deskpi | ||
sudo echo "Conflicts=reboot.target" >> $deskpi | ||
sudo echo "DefaultDependencies=no" >> $deskpi | ||
sudo echo "" >> $deskpi | ||
sudo echo "[Service]" >> $deskpi | ||
sudo echo "Type=oneshot" >> $deskpi | ||
sudo echo "ExecStart=/usr/bin/sudo /usr/bin/safecutoffpower64" >> $deskpi | ||
sudo echo "# ExecStart=/usr/bin/sudo python3 /usr/bin/safecutoffpower.py" >> $deskpi | ||
sudo echo "RemainAfterExit=yes" >> $deskpi | ||
sudo echo "TimeoutStartSec=15" >> $deskpi | ||
sudo echo "" >> $deskpi | ||
sudo echo "[Install]" >> $deskpi | ||
sudo echo "WantedBy=halt.target shutdown.target poweroff.target final.target" >> $deskpi | ||
|
||
sudo chown root:root $deskpi | ||
sudo chmod 644 $deskpi | ||
|
||
sudo systemctl daemon-reload | ||
sudo systemctl enable systemd-deskpiv1-safecutoffpower.service | ||
echo "[Unit]" > $deskpi | ||
echo "Description=DeskPi Safe Cut-off Power Service" >> $deskpi | ||
echo "Conflicts=reboot.target" >> $deskpi | ||
echo "DefaultDependencies=no" >> $deskpi | ||
echo "" >> $deskpi | ||
echo "[Service]" >> $deskpi | ||
echo "#Type=oneshot" >> $deskpi | ||
echo "Type=simple" >> $deskpi | ||
echo "#ExecStart=/usr/bin//usr/bin/safecutoffpower64" >> $deskpi | ||
echo "ExecStart=/usr/bin/python3 /usr/bin/safecutoffpower.py" >> $deskpi | ||
echo "RemainAfterExit=true" >> $deskpi | ||
echo "TimeoutStartSec=15" >> $deskpi | ||
echo "" >> $deskpi | ||
echo "[Install]" >> $deskpi | ||
echo "WantedBy=halt.target shutdown.target poweroff.target final.target" >> $deskpi | ||
|
||
chown root:root $deskpi | ||
chmod 644 $deskpi | ||
|
||
# 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 "" >> $safeshutdaemon | ||
echo "[Service]" >> $safeshutdaemon | ||
echo 'Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/vc/bin"' | ||
echo "#Type=oneshot" >> $safeshutdaemon | ||
echo "Type=simple" >> $safeshutdaemon | ||
echo "ExecStart=/usr/bin/python3 /usr/bin/pwmControlFan.py" >> $safeshutdaemon | ||
echo "RemainAfterExit=true" >> $safeshutdaemon | ||
echo "TimeoutStartSec=15" >> $safeshutdaemon | ||
echo "" >> $safeshutdaemon | ||
echo "[Install]" >> $safeshutdaemon | ||
echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon | ||
|
||
chown root:root $safeshutdaemon | ||
chmod 644 $safeshutdaemon | ||
|
||
|
||
systemctl daemon-reload | ||
systemctl enable deskpi.service | ||
systemctl enable deskpi-safeshut.service | ||
|
||
# install rpi.gpio for fan control | ||
yes |sudo pacman -S python-pip | ||
sudo pip3 install pyserial | ||
# sudo pacman -S python python-pip base-devel | ||
pacman -S --noconfirm python-pip | ||
pip3 install pyserial | ||
# pacman -S python python-pip base-devel | ||
# env CFLAGS="-fcommon" pip install rpi.gpio | ||
|
||
sync | ||
sudo rm -rf /tmp/deskpi | ||
rm -rf /tmp/deskpi | ||
echo "DeskPi Driver installation successful, system will reboot in 5 seconds to take effect!" | ||
sleep 5 && sudo reboot | ||
#sleep 5 && reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# functions needed for deskpi-config | ||
# derived from https://www.apt-browse.org/browse/ubuntu/trusty/main/all/lsb-base/4.1+Debian11ubuntu6/file/lib/lsb/init-functions | ||
# | ||
#Copyright (c) 2002-08 Chris Lawrence | ||
#All rights reserved. | ||
# | ||
#Redistribution and use in source and binary forms, with or without | ||
#modification, are permitted provided that the following conditions | ||
#are met: | ||
#1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
#2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
#3. Neither the name of the author nor the names of other contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE | ||
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
log_action_msg_pre () { :; } | ||
log_action_msg_post () { :; } | ||
log_action_msg () { | ||
log_action_msg_pre "$@" | ||
echo "$@." || true | ||
log_action_msg_post "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
#!/bin/bash | ||
# uninstall deskpi script | ||
# | ||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root or with sudo" | ||
exit | ||
fi | ||
|
||
deskpi=/lib/systemd/system/systemd-deskpi-safecutoffpower.service | ||
deskpi=/lib/systemd/system/deskpi.service | ||
safeshutdaemon=/lib/systemd/system/deskpi-safeshut.service | ||
echo "DeskPi Driver Uninstalling..." | ||
echo "Configure /boot/config.txt" | ||
sudo sed -i '/dtoverlay=dwc2,dr_mode=host/d' /boot/config.txt | ||
echo "Stop and disable DeskPi services" | ||
sudo rm -f $deskpi 2&>/dev/null | ||
sudo rm -f /usr/bin/safecutoffpower* 2&>/dev/null | ||
sudo rm -rf /etc/modules-load.d/raspberry.conf 2&>/dev/null | ||
sed -i '/dtoverlay=dwc2,dr_mode=host/d' /boot/config.txt | ||
echo "Stop and disable DeskPi services" | ||
systemctl stop deskpi.service | ||
systemctl stop deskpi-safeshut.service | ||
systemctl daemon-reload | ||
rm -f "$deskpi" 2&>/dev/null | ||
rm -f "$safeshutdaemon" 2&>/dev/null | ||
rm -f /usr/bin/safecutoffpower* 2&>/dev/null | ||
rm -f /usr/bin/pwmControlFan* 2&>/dev/null | ||
rm -rf /etc/modules-load.d/raspberry.conf 2&>/dev/null | ||
# remove Uninstall script itself | ||
rm -f /usr/local/bin/Deskpi-uninstall | ||
# remove deskpi-config | ||
rm -f /usr/local/bin/deskpi-config | ||
# remove log functions | ||
rm -f '/usr/local/lib/deskpi-log-functions' | ||
echo "Uninstall DeskPi Driver Successfully." | ||
|