This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
argonone.install
52 lines (47 loc) · 1.56 KB
/
argonone.install
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
pre_install() {
echo "Checking Hardware Model..."
if grep "Raspberry Pi 3" /proc/device-tree/model ; then
echo "Building New Virtual Environment in /opt/argonone..."
python -m venv --clear /opt/argonone
/opt/argonone/bin/python3 -m pip install pysmbus RPi.GPIO
echo "Enabling i2C..."
BOOT_CFG="/boot/config.txt"
if [ -e "${BOOT_CFG}" ]; then
touch "${BOOT_CFG}"
fi
if ! grep "dtparam=i2c_arm=on" "${BOOT_CFG}" >/dev/null 2>&1 ; then
echo "dtparam=i2c_arm=on" >> "${BOOT_CFG}"
fi
if ! grep "dtparam=i2c-1=on" "${BOOT_CFG}" >/dev/null 2>&1 ; then
echo "dtparam=i2c-1=on" >> "${BOOT_CFG}"
fi
MODULE_CFG="/etc/modules-load.d/raspberrypi.conf"
if [ -e "${MODULE_CFG}" ]; then
touch "${MODULE_CFG}"
chmod 644 "${MODULE_CFG}"
fi
if ! grep "i2c-dev" "${MODULE_CFG}" >/dev/null 2>&1 ; then
echo "i2c-dev" >> "${MODULE_CFG}"
fi
if ! grep "i2c-bcm2835" "${MODULE_CFG}" >/dev/null 2>&1 ; then
echo "i2c-bcm2835" >> "${MODULE_CFG}"
fi
else
echo "Not a Raspberry Pi Model 3!"
/usr/bin/false
fi
}
post_install() {
echo "Please reboot before first use."
echo "Configuration file: /etc/argononed.conf"
echo "Enable power button and fan control service with: sudo systemctl enable argononed.service"
}
pre_remove() {
systemctl stop argononed.service
systemctl deactivate argononed.service
}
post_remove() {
echo "Removing Virtual Environment in /opt/argonone..."
rm -rf /opt/argonone
echo "Software removed. Please remember to disable I2C if not needed any more"
}