-
Notifications
You must be signed in to change notification settings - Fork 17
/
install.sh
executable file
·38 lines (32 loc) · 1.23 KB
/
install.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
#!/usr/bin/env bash
#Check if script is being run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ ! $? = 0 ]; then
exit 1
else
apt-get install -y git whiptail #Installs packages which might be missing
PiSupplySwitchDir="Pi-Supply-Switch"
if [ -d "$PiSupplySwitchDir" ]; then
whiptail --title "Installation aborted" --msgbox "$PiSupplySwitchDir already exists, please remove it and restart the installation" 8 78
exit
else
git clone https://github.com/PiSupply/Pi-Supply-Switch.git
fi
mkdir /opt/piswitch
cp $PiSupplySwitchDir/softshut.py /opt/piswitch
if [ ! -f /opt/piswitch/softshut.py ]; then
whiptail --title "Installation aborted" --msgbox "There was a problem writing the softshut.py file" 8 78
exit
fi
cp $PiSupplySwitchDir/piswitch.service /etc/systemd/system
if [ ! -f /etc/systemd/system/piswitch.service ]; then
whiptail --title "Installation aborted" --msgbox "There was a problem writing the piswitch.service file" 8 78
exit
fi
systemctl enable /etc/systemd/system/piswitch.service
whiptail --title "Installation complete" --msgbox "Pi Switch installation complete. The system will power off." 8 78
poweroff
fi