pre_install() { echo "Checking Hardware Model..." if grep "Raspberry Pi 4" /proc/device-tree/model ; then echo "Building New Virtual Environment in /opt/argonone..." python -m venv --clear /opt/argonone env CFLAGS="-fcommon" /opt/argonone/bin/python3 -m pip install smbus 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-bcm2708" "${MODULE_CFG}" >/dev/null 2>&1 ; then echo "i2c-bcm2708" >> "${MODULE_CFG}" fi else echo "Not a Raspberry Pi Model 4!" /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" echo "If you want to: enable_uart=1" echo "Put it in /boot/config.txt and remove kgdboc=ttyAMA0,115200 in /boot/cmdline" echo "Thanks to thegeek1977 to help patching this" } 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" }