diff --git a/install.sh b/install.sh index b63860c8553c9903be2aa8f88bc02f0adc1e05fa..23f8c6649d54481ef5425f778d05ca1e15715293 100755 --- a/install.sh +++ b/install.sh @@ -1,8 +1,14 @@ #!/bin/bash +echo "=========== OhmPi installation script v1.0.0 ==========" + +echo "--------- Installing additional libraries via apt --------" + # ensure that the libatlas-base-dev library is installed sudo apt-get install -y libatlas-base-dev libopenblas-dev +echo "----------- Creating virtual python environment ----------" + # Create the virtual environment python3 -m venv ohmpy @@ -15,10 +21,14 @@ export CFLAGS=-fcommon # install all required packages in the virtual environment. pip install -r requirements.txt +echo "----------- Setting RPi parameters (I2C, GPIO, ...) --------" + # install a second i2c bus sudo apt-get install -y i2c-tools echo -e "[all]\ndtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=22,i2c_gpio_scl=23" | sudo tee -a /boot/config.txt +echo "-------------- Install local MQTT broker --------------" + # install local mqtt broker txtred='\e[0;31m' # Red txtgrn='\e[0;32m' # Green @@ -33,10 +43,15 @@ echo -e "\n${txtgrn}>>> Broker is installed. Starting now...${txtdef}" mosquitto -v echo -e "\n${txtgrn}>>> Updating configuration to allow anonymous remote connections and websockets...${txtdef}" -echo "listener 9001" | sudo tee -a /etc/mosquitto/mosquitto.conf echo "listener 1883" | sudo tee -a /etc/mosquitto/mosquitto.conf +echo "listener 9001" | sudo tee -a /etc/mosquitto/mosquitto.conf echo "protocol websockets" | sudo tee -a /etc/mosquitto/mosquitto.conf echo "socket_domain ipv4" | sudo tee -a /etc/mosquitto/mosquitto.conf echo "allow_anonymous true" | sudo tee -a /etc/mosquitto/mosquitto.conf echo -e "\n${txtgrn}>>> Current configuration stored in /etc/mosquitto/mosquitto.conf is displayed below${txtdef}" + cat /etc/mosquitto/mosquitto.conf + +echo "------------- Create config.py file -----------" + +python setup_config.py diff --git a/setup_config.py b/setup_config.py new file mode 100644 index 0000000000000000000000000000000000000000..c92871d43fe062481a4fc13e3c7853a458240433 --- /dev/null +++ b/setup_config.py @@ -0,0 +1,36 @@ + +print('This assistent helps you configure a basic system with a measurement board and from 0 to 4 mux of the same type. For more complex configuration with multiple mux of different types, please have a look in the configs/ folder.') + +mb = None +while True: + if mb in ['v2023', 'v2024']: + break + else: + mb = input('Choose a measurement boards: [v2023/v2024]: ') + +mux = None +while True: + if mux in ['v2023', 'v2024']: + break + else: + mux = input('Choose a mux boards: [v2023/v2024]: ') + +nb_mux = None +while True: + if nb_mux in ['0', '1', '2', '3', '4']: + break + else: + nb_mux = input('Number of multiplexers: [0, 1, 2, 3, 4]: ') + + +config = 'config_mb_' + mb[1:] + '_' + nb_mux + '_mux_' + mux[1:] + '.py' +print('Using this configuration: ' + config) + +import os +import shutil +if os.path.exists('configs/' + config): + shutil.copyfile('configs/' + config, 'ohmpi/config.py') +else: + print('configuration not found') + +