diff --git a/bin/cosmicpi-postinstall b/bin/cosmicpi-postinstall deleted file mode 100755 index e06ee95..0000000 --- a/bin/cosmicpi-postinstall +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -echo "--- Updating packages" -sudo apt --yes update -sudo apt --yes upgrade - -echo "--- Installing packages via apt" -sudo apt --yes install git htop mosquitto mosquitto-clients - -echo "--- Setting up services" -sudo systemctl daemon-reload -sudo systemctl enable cosmicpi-mqtt.service -sudo systemctl enable cosmicpi-dbcleaner.service -sudo systemctl enable cosmicpi-detector.service -sudo systemctl enable cosmicpi-ui.service - -echo "--- Finished setup! Rebooting now, when this is done your Cosmic Pi should start working ---" -echo "--- To connect go to the IP address assigned by your network to the CosmicPi device, or ---" -echo "--- cosmicpi.local if you have the correct type of browser. If you are operating in ---" -echo "--- stand-alone mode via the CosmicPi wifi network, go directly to 192.168.12.1 ---" -echo "--- Note that this Cosmic Pi will automatically publish all cosmic ray and associated ---" -echo "--- meta-data (position, accelerometer, magnetometer, temperature, humidity, pressure) ---" -echo "--- to the internet for anyone to use under a CC0 license (no rights reserved) ---" -echo "--- and placed in the public domain. For license details see: ---" -echo "--- https://creativecommons.org/share-your-work/public-domain/cc0/ ---" - - -# sleep 60 -# sudo reboot now diff --git a/setup.py b/setup.py index 83c4a38..5998d03 100644 --- a/setup.py +++ b/setup.py @@ -3,14 +3,60 @@ from setuptools.command.install import install import os -class PostInstall(install): +PREINSTALL = """ + # Check if OS has `apt` command + if [ "$(command -v apt)" != '' ]; then + echo "--- Updating packages" + sudo apt --yes update + sudo apt --yes upgrade + + echo "--- Installing packages general purpose packages" + sudo apt --yes install git \ + htop \ + mosquitto \ + mosquitto-clients + + echo "--- Installing Python packages" + sudo apt --yes install python-numpy \ + python-matplotlib \ + python-flask \ + python-configparser \ + python-serial \ + python-flask-restful + fi +""" + + +POSTINSTALL = """ + echo "--- Setting up services" + # Hope an OS uses systemd (not SysVinit or similar) + sudo systemctl daemon-reload + sudo systemctl enable cosmicpi-mqtt.service + sudo systemctl enable cosmicpi-dbcleaner.service + sudo systemctl enable cosmicpi-detector.service + sudo systemctl enable cosmicpi-ui.service + + echo "--- Finished setup! Rebooting now, when this is done your Cosmic Pi should start working ---" + echo "--- To connect go to the IP address assigned by your network to the CosmicPi device, or ---" + echo "--- cosmicpi.local if you have the correct type of browser. If you are operating in ---" + echo "--- stand-alone mode via the CosmicPi wifi network, go directly to 192.168.12.1 ---" + echo "--- Note that this Cosmic Pi will automatically publish all cosmic ray and associated ---" + echo "--- meta-data (position, accelerometer, magnetometer, temperature, humidity, pressure) ---" + echo "--- to the internet for anyone to use under a CC0 license (no rights reserved) ---" + echo "--- and placed in the public domain. For license details see: ---" + echo "--- https://creativecommons.org/share-your-work/public-domain/cc0/ ---" +""" + + +class PrePostInstall(install): def run(self): + os.system(PREINSTALL) install.run(self) - #os.system('cosmicpi-postinstall') + os.system(POSTINSTALL) setup(name='cosmicpi', - version='1.5.2', + version='1.5.3', description='UI for the CosmicPi cosmic ray detector', long_description='This software provides the user interface, temporary storage and connection to the internet storage for the detectors of the CosmicPi project. The Cosmic Pi project aims to build the world\'s largest open source distributed cosmic ray telescope. You too can be a part of the project, by becoming a Cosmic Pixel!', platforms=['noarch'], @@ -40,7 +86,12 @@ setup(name='cosmicpi', 'data_files/cosmicpi-detector.service', 'data_files/cosmicpi-dbcleaner.service', ]), - ('/etc', ['data_files/cosmicpi.config']), + ('/etc', [ + 'data_files/cosmicpi.config', + 'data_files/dhcpcd.conf', + 'data_files/dnsmasq.conf' + ] + ), ], install_requires=[ 'numpy', @@ -57,9 +108,8 @@ setup(name='cosmicpi', 'bin/cosmicpi-mqtt', 'bin/cosmicpi-rest', 'bin/cosmicpi-ui', - 'bin/cosmicpi-postinstall', ], cmdclass={ - 'install': PostInstall, + 'install': PrePostInstall, }, )