Improve installation script

This commit is contained in:
Darko Lukic 2018-04-22 18:21:07 +02:00
parent d71276133f
commit 31c07254c2
2 changed files with 56 additions and 35 deletions

View file

@ -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

View file

@ -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,
},
)