From a40cdb837e8b796dc9bef2ed995b7a9bf523293d Mon Sep 17 00:00:00 2001 From: James Devine Date: Mon, 29 Jan 2018 21:58:25 +0100 Subject: [PATCH] two stage installer test run --- dhcpcd.conf | 22 +++++++++++++++++++++ normalrc.local | 20 +++++++++++++++++++ partialinstall.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++ rebootrc.local | 22 +++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 dhcpcd.conf create mode 100644 normalrc.local create mode 100644 partialinstall.sh create mode 100644 rebootrc.local diff --git a/dhcpcd.conf b/dhcpcd.conf new file mode 100644 index 0000000..32cee8a --- /dev/null +++ b/dhcpcd.conf @@ -0,0 +1,22 @@ +#interface wlan0 +# static ip_address=192.168.12.1/24 + +hostname +clientid +presistent +option rapid_commit +option domain_name_servers, domain_name, domain_search, host_name +option classless_static_routes +option interface_mtu +option ntp_servers +require dhcp_server_identifier + +slaac private + +profile static_wlan0 +static ip_address=192.168.12.1 +static routers=192.168.12.1 +static domain_name_servers=192.168.12.1 + +interface wlan0 +fallback static_wlan0 \ No newline at end of file diff --git a/normalrc.local b/normalrc.local new file mode 100644 index 0000000..7d39ed7 --- /dev/null +++ b/normalrc.local @@ -0,0 +1,20 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +# Print the IP address +_IP=$(hostname -I) || true +if [ "$_IP" ]; then + printf "My IP address is %s\n" "$_IP" +fi + +exit 0 diff --git a/partialinstall.sh b/partialinstall.sh new file mode 100644 index 0000000..556e891 --- /dev/null +++ b/partialinstall.sh @@ -0,0 +1,49 @@ +#!/bin/bash +echo "Sorry. This procedure isn't ready yet, We're working on it! " + +echo "--- Part 2: Updates and installation ---" +echo "--- Updating packages" +sudo apt --yes update +sudo apt --yes upgrade + +echo "--- Installing packages via apt" +# needed for the CosmicPi software +sudo apt --yes install git python-pip htop python-numpy python-matplotlib python-flask mosquitto mosquitto-clients + +echo "--- Installing python packages via pip" +sudo pip --no-cache-dir install pyserial configparser flask_googlemaps Flask-BasicAuth --extra-index-url https://www.piwheels.hostedpi.com/simple +#echo "we might need some more packages" + +echo "--- Getting executable path" +EXECPATH="`dirname \"$0\"`" # relative +EXECPATH="`( cd \"$EXECPATH\" && pwd )`" # absolutized and normalized +if [ -z "$EXECPATH" ] ; then + # error; for some reason, the path is not accessible + # to the script (e.g. permissions re-evaled after suid) + exit 1 # fail +fi +echo "$EXECPATH" +TOREPLACE="PATH_TO_EXECUTABLE" + +echo "--- Setting up systemd services" +sed -i -e "s+$TOREPLACE+$EXECPATH+g" install_files/CosmicPi-mqtt.service +sed -i -e "s+$TOREPLACE+$EXECPATH+g" install_files/CosmicPi-database_cleaner.service +sed -i -e "s+$TOREPLACE+$EXECPATH+g" install_files/CosmicPi-detector.service +sed -i -e "s+$TOREPLACE+$EXECPATH+g" install_files/CosmicPi-UI.service +sudo cp -f install_files/*.service /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable CosmicPi-mqtt.service +sudo systemctl enable CosmicPi-database_cleaner.service +sudo systemctl enable CosmicPi-detector.service +sudo systemctl enable CosmicPi-UI.service +#the ap was already done + +echo "--- changing static ip address to 192.168.12.1 ---" +cp -f dhcpcd.conf /etc/dhcpcd.conf + +echo"--- preventing this script from running next reboot ---" +cp -f normalrc.local /etc/rc.local + +echo "--- Finished setup! Rebooting now ---" +sleep 10 +sudo reboot now diff --git a/rebootrc.local b/rebootrc.local new file mode 100644 index 0000000..830cbb9 --- /dev/null +++ b/rebootrc.local @@ -0,0 +1,22 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +# Print the IP address +_IP=$(hostname -I) || true +if [ "$_IP" ]; then + printf "My IP address is %s\n" "$_IP" +fi + +sudo /home/cosmicpi/cosmicpi-rpi_V1.5/partialinstall.sh + +exit 0