diff --git a/Documentation/setting/Screenshot from 2016-07-27 23:12:37.png b/Documentation/setting/Screenshot from 2016-07-27 23_12_37.png similarity index 100% rename from Documentation/setting/Screenshot from 2016-07-27 23:12:37.png rename to Documentation/setting/Screenshot from 2016-07-27 23_12_37.png diff --git a/Documentation/setting/Screenshot from 2016-08-01 18:07:59.png b/Documentation/setting/Screenshot from 2016-08-01 18_07_59.png similarity index 100% rename from Documentation/setting/Screenshot from 2016-08-01 18:07:59.png rename to Documentation/setting/Screenshot from 2016-08-01 18_07_59.png diff --git a/Prepare for Release/Release checklist~ b/Prepare for Release/Release checklist~ deleted file mode 100644 index 5532609..0000000 --- a/Prepare for Release/Release checklist~ +++ /dev/null @@ -1,19 +0,0 @@ -OPERATING SYSTEM LEVEL: - -1) disable SSH -> sudo raspi-config -> advanced -> disable SSH server -2) Check wifi password (AP mode) is "hydrosystem"-> sudo nano /etc/hostapd/hostapd.conf -4) check that the wifi account is deleted -> nano /etc/wpa_supplicant/wpa_supplicant.conf - -HYDROSYSTEM SW LEVEL: - -3) reset all data to default -> go to settings, scroll down, push reset button -5) check that the email send account are deleted -> go to hwdata.txt in database -6) check that the main mail account is deleted -> go to emailcred.txt in database -7) Hardware setting to be reduced to HUmid+Temp -> select it from hardwaresetting interface -8) remove data from sensors -> go to 'data' page and delete record data -9) remove all pictures -> go to 'images' and push deleteall -10) check port is set 5012-> go to networkmod.py and check around row 18, PUBLICPORT=5012 -11) check IP is set to 192.168.0.172 -> go to networkmod.py and check around row 18, IPADDRESS ='192.168.0.172' -13) AP wifi to Network switch time to 180 sec (3 minutes) -> go to networkmod.py and check around row 18, WAITTOCONNECT=180 - - diff --git a/bash/guide~ b/bash/guide~ deleted file mode 100644 index 8bf3504..0000000 --- a/bash/guide~ +++ /dev/null @@ -1,6 +0,0 @@ -use the following command to download the installation file: - -wget https://github.com/Hydrosys4/Master/blob/master/bash/install_hydrosys4.sh - -sudo chmod u+x install_hydrosys4.sh -sudo ./install_hydrosys4.sh diff --git a/bash/install_hydrosys4.sh b/bash/install_hydrosys4.sh index 24fef81..5922960 100755 --- a/bash/install_hydrosys4.sh +++ b/bash/install_hydrosys4.sh @@ -1,192 +1,67 @@ #!/bin/bash - - -#Debug enable next 3 lines -exec 5> install.txt -BASH_XTRACEFD="5" -set -x -# ------ end debug - - -function killpython() -{ - -sudo killall python3 - -} - - -function system_update_light() -{ - -# ---- system_update - -sudo apt-get -y update - -} - -function system_update() -{ - -# ---- remove unnecessary packages - -sudo apt-get remove --purge libreoffice-* -sudo apt-get remove --purge wolfram-engine - - -# ---- system_update - -sudo apt-get -y update -sudo apt-get -y upgrade - -} - -function system_update_UI() -{ - -while true; do - read -p "Do you wish to update the Raspbian system (y/n)?" yn - case $yn in - [Yy]* ) system_update; break;; - [Nn]* ) break;; - * ) echo "Please answer y or n.";; - esac -done - -} - -function install_dependencies() -{ - - -#--- start installing dependencies - -sudo apt-get -y install python3-dev || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo apt -y install python3-pip || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo pip3 install flask || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo pip3 install apscheduler || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo pip3 install pyserial || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo apt-get install python3-future - -#(for the webcam support) -sudo apt-get -y install fswebcam || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -#(for the image thumbnail support) -sudo apt-get -y install libjpeg-dev || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo apt install libopenjp2-7 -sudo pip3 install pillow || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -#(for external IP address, using DNS) -sudo apt-get -y install dnsutils || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -#(encryption) -sudo pip3 install pbkdf2 || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -#(web server) -sudo pip3 install tornado || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -#(GPIO) -sudo pip3 install RPi.GPIO -} - -function enable_I2C() -{ - -# --- Enable I2C and Spi : -# /boot/config.txt - -sed -i 's/\(^.*#dtparam=i2c_arm=on.*$\)/dtparam=i2c_arm=on/' /boot/config.txt -sed -i 's/\(^.*#dtparam=spi=on.*$\)/dtparam=spi=on/' /boot/config.txt -sed -i 's/\(^.*#dtparam=i2s=on.*$\)/dtparam=i2s=on/' /boot/config.txt - -# --- Add modules: -# /etc/modules -aconf="/etc/modules" - -sed -i '/i2c-bcm2708/d' $aconf -sed -i -e "\$ai2c-bcm2708" $aconf - -sed -i '/i2c-dev/d' $aconf -sed -i -e "\$ai2c-dev" $aconf - -sed -i '/i2c-bcm2835/d' $aconf -sed -i -e "\$ai2c-bcm2835" $aconf - -sed -i '/rtc-ds1307/d' $aconf -sed -i -e "\$artc-ds1307" $aconf - -sed -i '/bcm2835-v4l2/d' $aconf -sed -i -e "\$abcm2835-v4l2" $aconf - - -# --- install I2C tools -sudo apt-get -y install git build-essential python3-dev python3-smbus || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo apt-get -y install -y i2c-tools || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -} - - -# --- enable raspicam - -############# MISSING ############## - -function modify_RClocal() -{ - -# --- Real Time Clock (RTC) -# /etc/rc.local - -autostart="yes" -# copy the below lines between # START and #END to rc.local -tmpfile=$(mktemp) -sudo sed '/#START/,/#END/d' /etc/rc.local > "$tmpfile" && sudo mv "$tmpfile" /etc/rc.local -# Remove to growing plank lines. -sudo awk '!NF {if (++n <= 1) print; next}; {n=0;print}' /etc/rc.local > "$tmpfile" && sudo mv "$tmpfile" /etc/rc.local -if [ "$autostart" == "yes" ]; then - if ! grep -Fq '#START HYDROSYS4 SECTION' /etc/rc.local; then - sudo sed -i '/exit 0/d' /etc/rc.local - sudo bash -c "cat >> /etc/rc.local" << EOF -#START HYDROSYS4 SECTION -# iptables -sudo iptables-restore < /home/pi/iptables.rules - -# clock -echo "HYDROSYS4-set HW clock ****************************************" -echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device || true -hwclock -s || true - -echo "HYDROSYS4-start system ****************************************" -cd /home/pi/env/autonom/ -sudo python3 /home/pi/env/autonom/bentornado.py & - -#END HYDROSYS4 SECTION - -exit 0 -EOF - else - tmpfile=$(mktemp) - sudo sed '/#START/,/#END/d' /etc/rc.local > "$tmpfile" && sudo mv "$tmpfile" /etc/rc.local - # Remove to growing plank lines. - sudo awk '!NF {if (++n <= 1) print; next}; {n=0;print}' /etc/rc.local > "$tmpfile" && sudo mv "$tmpfile" /etc/rc.local - fi - +### +# TODO: OpenWeathermap +# TODO: install and uninstall +# TODO: More modules and sensors +### + +# Root/sudo check +if [ "$(id -u)" -ne 0 ]; then + echo ' --> ERROR ---------------- Please run as root or with sudo privileges ----------------' >&2 + exit 1 fi +# ------ End root/sudo check -sudo chown root:root /etc/rc.local -sudo chmod 755 /etc/rc.local -# end modification to RC.local - +function input_UI() { + IP="0" + PORT="" + killall python3 # Kill all processes with python3 that is running. + mkdir -p /usr/local/share/hydrosys4 # make sure installation directory is present + + echo "--> Welcome to Hydrosys4 install script. The following initial settings are required:" + while ! valid_ip $IP; do # IP part input + read -p "--> Enter desired IPv4 address (range 192.168.1.100-192.168.1.200) or accept suggested IPv4 address by pressing [ENTER]: " -e -i 192.168.1.172 IP + if valid_ip $IP; then stat='good'; + else stat='bad'; echo "--> Please enter a valid IPv4 address, ex. 192.168.1.172" + fi + done + echo "--> Setting $IP as IPv4 address" + + while [[ ! $PORT =~ ^[0-9]+$ ]]; do # PORT part input + read -p "--> Enter desired PORT number or accept suggested by pressing [ENTER]: " -e -i 5172 PORT + if [[ ! $PORT =~ ^[0-9]+$ ]]; then + echo "--> Please enter a valid PORT number, ex. 5172"; + fi + done + echo "--> Setting $PORT as port number" + + read -p "--> Enter desired WiFi AP name or accept suggested by pressing [ENTER]: " -e -i Hydrosys4 WiFiAPname # Local WiFi AP name and password setting + echo "--> Setting $WiFiAPname as WiFi AP name" + read -p "--> Enter desired WiFi AP password or accept suggested by pressing [ENTER]: " -e -i hydrosystem WiFiAPpsw + echo "--> Setting $WiFiAPpsw as WiFi password" + read -p "--> Do you wish to change hostname? (y,n): " -e -i y ChangeHostName + #echo " Confirmed Answer: "$ChangeHostName + if [ "$ChangeHostName" == "y" ]; then + read -p "--> Enter desired hostname or accept suggested by pressing [ENTER]: " -e -i hydrosys4-172 NewHostName + echo "--> Setting $NewHostName as hostname" + hostnamectl set-hostname $NewHostName # change the name in /etc/hostname + aconf="/etc/hosts" + cp /etc/hosts /usr/local/share/hydrosys4/hosts_hydrosys.backup + sed -i "s/127.0.1.1.*/127.0.1.1 "$NewHostName"/" $aconf # Update hosts main config file + fi + read -p "--> Do you wish to change default web page username and password? (y,n): " -e -i y changeDefaults + if [ "$changeDefaults" == "y" ]; then + $changeDefaults = "d" + read -p "--> Enter new login name or accept suggested by pressing [ENTER]: " -e -i admin newLogin + read -p "--> Enter new password or accept suggested by pressing [ENTER}: " -e -i default newPassword + echo "--> Setting $newLogin and $newPassword as your new login credentialts" + fi } - -### -- WIFI setup --- STANDARD - -function valid_ip() -{ +function valid_ip() { local ip=$1 local stat=1 - - if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then # -- WIFI setup --- STANDARD OIFS=$IFS IFS='.' ip=($ip) @@ -198,518 +73,474 @@ function valid_ip() return $stat } - -input_UI () -{ - -echo "Hello, following initial setting is requested:" - -# IP part input - -IP="0" -while ! valid_ip $IP; do - read -p "Local IP address (range 192.168.0.100-192.168.1.200), to confirm press [ENTER] or modify: " -e -i 192.168.1.172 IP - if valid_ip $IP; then stat='good'; - else stat='bad'; echo "WRONG FORMAT, please enter a valid value for IP address" - fi - -done - echo "Confirmed IP address: "$IP - -PORT="" -while [[ ! $PORT =~ ^[0-9]+$ ]]; do -read -p "Local PORT, to confirm press [ENTER] or modify: " -e -i 5172 PORT - if [[ ! $PORT =~ ^[0-9]+$ ]]; - then echo "WRONG FORMAT, please enter a valid value for PORT"; - fi -done - echo "Confirmed PORT: "$PORT - -# Local WiFi AP name and password setting - -read -p "System WiFi AP name, to confirm press [ENTER] or modify: " -e -i Hydrosys4 WiFiAPname -echo "Confirmed Name: "$WiFiAPname - -read -p "System WiFi AP password, to confirm press [ENTER] or modify: " -e -i hydrosystem WiFiAPpsw -echo "Confirmed Password: "$WiFiAPpsw - -read -p "Do you want to change hostname? (y,n): " -e -i y ChangeHostName -echo "Confirmed Answer: "$ChangeHostName - -if [ "$ChangeHostName" == "y" ]; then - read -p "System Hostname, to confirm press [ENTER] or modify: " -e -i hydrosys4-172 NewHostName - echo "Confirmed Hostname: "$NewHostName -fi - +function system_update_UI() { + while true; do + read -p "--> Do you wish to update and upgrade the Raspbian system (y/n)?" yn + case $yn in + [Yy]* ) system_update; echo "--> Running a full system update and upgrade"; break;; + [Nn]* ) system_update_light; echo "--> Only running system update to fetch the latest packages"; break;; + * ) echo "--> Please answer y or n.";; + esac + done } - -apply_newhostname () -{ - -# --- change system hostname -if [ "$ChangeHostName" == "y" ]; then - sudo hostnamectl set-hostname $NewHostName # change the name in /etc/hostname - - aconf="/etc/hosts" - # Update hostapd main config file - sudo sed -i "s/127.0.1.1.*/127.0.1.1 "$NewHostName"/" $aconf - -fi - +function system_update() { + while true; do + read -p "--> Do you want to uninstall LibreOffice and Wolfram Engine (if installed) as they are not necessary (y/n)? " yn + case $yn in + [Yy]* ) system_uninstall_pkgs; break;; + [Nn]* ) break;; + * ) "--> Please answer y or n.";; + esac + done + apt update && apt -y upgrade } - -ask_reboot () -{ - - -read -p "Do you want to reboot the system? (y,n): " -e -i y doreboot -echo "Confirmed Answer: "$doreboot - -if [ "$doreboot" == "y" ]; then - sudo reboot -fi - +function system_update_light() { + while true; do + read -p "--> Do you want to uninstall LibreOffice and Wolfram Engine (if installed) as they are not necessary (y/n)? " yn + case $yn in + [Yy]* ) system_uninstall_pkgs; break;; + [Nn]* ) break;; + * ) "--> Please answer y or n.";; + esac + done + apt -y update # ---- system_update only } - - - - - - -install_DHT22lib () -{ - -# --- installing the DHT22 Sensor libraries -sudo apt-get -y install build-essential python3-dev || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -# This is just going to install the lybrary present in local folder -aconf="/home/pi/env/autonom/libraries/DHT22/master.zip" -if [ -f $aconf ]; then - - cd /home/pi/env/autonom/libraries/DHT22 - unzip master.zip - cd Adafruit_Python_DHT-master - # setup1plus is file that make the DTH22 work with both RaspberryPi zero,1 and model 2,3 - sudo python3 setup1plus.py install - cd /home/pi - -fi +function system_uninstall_pkgs() { + UNWANTED="libreoffice-* wolfram-engine" # ---- remove unnecessary packages + for pkg in $UNWANTED; do + if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then + apt remove --purge $pkg + else + echo "--> ---------------- Unnecessary package $pkg not installed ----------------" + fi + done } - -install_SPIlib () -{ - - -# --- INSTALL SPI library: - -sudo apt-get -y install python3-dev || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} -sudo pip3 install spidev - +function install_dependencies() { + echo "--> Installing dependencies, APT packages" #--- start installing dependencies + INSTALL_APT="python3-dev python3-pip python3-future python3-smbus git build-essential i2c-tools fswebcam libjpeg-dev libopenjp2-7 dnsutils dnsmasq hostapd cmake libjpeg8-dev nginx" + for pkg in $INSTALL_APT; do + if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then + echo "--> ---------------- $pkg already installed ----------------" + else + apt -y install $pkg || { echo "--> APT ERROR: $pkg ---------------- Installation failed ----------------" && exit ;} + fi + done + + echo "--> Installing dependencies, PIP3 packages" + INSTALL_PIP="flask apscheduler pyserial pillow pbkdf2 tornado RPi.GPIO spidev" + for pkg in $INSTALL_PIP; do + if python3 -c "import sys, pkgutil; sys.exit(not pkgutil.find_loader('$pkg'))"; then + echo "--> *---------------- $pkg already installed ----------------*" + else + pip3 install $pkg || { echo "--> PIP3 ERROR: $pkg ---------------- Installation failed ----------------" && exit ;} + fi + done } - - - - -install_hydrosys4 () -{ -# --- INSTALL Hydrosys4 software -sudo apt-get -y install git || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - - -# check if file exist in local folder -aconf="/home/pi/env/autonom" -if [ -d $aconf ]; then # if the directory exist - cd /home/pi -else - cd /home/pi - sudo rm -r env - mkdir env - cd env - sudo rm -r autonom - git clone https://github.com/Hydrosys4/Master.git - sudo killall python3 - mv Master autonom - cd .. - -fi +function uninstall() { + REMOVE_APT="python3-dev python3-pip python3-future python3-smbus git build-essential i2c-tools fswebcam libjpeg-dev libopenjp2-7 dnsutils dnsmasq hostapd cmake libjpeg8-dev nginx" + REMOVE_PIP="flask apscheduler pyserial pillow pbkdf2 tornado RPi.GPIO spidev" + echo "--> Uninstalling APT and PIP3 packages" + echo "--> This will uninstall Hydrosys4 and all packages installed during installation including Nginx, Python 3 and Tornado, Flask aso." + while true; do + read -p "--> Would you like to KEEP all packages (y/n)?" yn + case $yn in + [Yy]* ) + echo "--> Keeping ALL packages, both APT and PIP3. Uninstall instruction: 'apt remove [package]' and 'pip3 uninstall [package]'." + echo "--> Installed APT packages: $REMOVE_APT" + echo "--> Installed PIP3 packages: $REMOVE_PIP" + echo "" + echo "--> Uninstalling and reverting Hydrosys4. Changes made to files will be reverted to version backed up when installing Hydrosys4." + echo "--> Reverting changes made to /etc/hosts. Moving backed up config file to /etc/hosts. Saving running file to ~/hosts_hydrosys.backup" + mv /etc/hosts ~/hosts_hydrosys.backup + mv /usr/local/share/hydrosys4/hosts_hydrosys.backup /etc/hosts + echo "--> Reverting changes made to default zone file. Moving backed up file to /etc/nginx/sites-enabled/default. Saving running file to ~/nginx_hydrosys.backup" + mv /etc/nginx/sites-enabled/default ~/nginx_hydrosys.backup + mv /usr/local/share/hydrosys4/nginx_hydrosys.backup /etc/nginx/sites-enabled/default + echo "--> Reverting changes made to rc.local. Moving backed up config file to /etc/rc.local. Saving running file to ~/rc_hydrosys.backup" + mv /etc/rc.local ~/rc_hydrosys.backup + mv /usr/local/share/hydrosys4/rc_hydrosys.backup /ect/rc.local + echo "--> Reverting changes made to /boot/config.txt. Moving backed up config file to /boot/config.txt. Saving running file to ~/boot_config_hydrosys.backup" + mv /boot/config.txt ~/boot_config_hydrosys.backup + mv /usr/local/share/hydrosys4/boot_config_hydrosys.backup /boot/config.txt + echo "--> Reverting changes made to /etc/modules. Moving backed up config file to /etc/modules. Saving running file to ~/etc_modules_hydrosys.backup" + mv /etc/modules ~/etc_modules_hydrosys.backup + mv /usr/local/share/hydrosys4/etc_modules_hydrosys.backup /etc/modules + echo "--> Reverting changes made to hostapd.conf. Moving backed up config file to /etc/hostapd/hostapd.conf. Saving running file to ~/hostapd_hydrosys.backup" + mv /etc/hostapd/hostapd.conf ~/hostapd_hydrosys.backup + mv /usr/local/share/hydrosys4/hostapd_hydrosys.backup /etc/hostapd/hostapd.conf + echo "--> Reverting changes made to dnsmasq.conf. Moving backed up config file to /etc/dnsmasq.conf. Saving running file to ~/dnsmasq_hydrosys.backup" + mv /etc/dnsmasq.conf ~/dnsmasq_hydrosys.backup + mv /usr/local/share/hydrosys4/dnsmasq_hydrosys.backup /etc/dnsmasq.conf + echo "--> Reverting changes made to dhcpcd.conf. Moving backed up config file to /etc/dhcpcd.conf. Saving running file to ~/dhcpcd_hydrosys.backup" + mv /etc/dhcpcd.conf ~/dhcpcd_hydrosys.backup + mv /usr/local/share/hydrosys4/dhcpcd_hydrosys.backup /etc/dhcpcd.conf + echo "--> Removing Hydrosys4 installation folder and configuration files." + rm -rf /usr/local/share/hydrosys4 + ask_reboot + break + ;; + [Nn]* ) + echo "--> Removing ALL packages, both APT and PIP3 including all configurations" + pip3 uninstall $REMOVE_PIP || { echo "--> PIP3 ERROR: ---------------- Uninstallation failed ----------------" && exit ;} + apt -y remove --purge $REMOVE_APT || { echo "--> APT ERROR: ---------------- Uninstallation failed ----------------" && exit ;} + apt autoremove + echo "--> Uninstalling and reverting Hydrosys4. Changes made to files will be reverted to version backed up when installing Hydrosys4." + echo "--> Reverting changes made to /etc/hosts. Moving backed up config file to /etc/hosts. Saving running file to ~/hosts_hydrosys.backup" + mv /etc/hosts ~/hosts_hydrosys.backup + mv /usr/local/share/hydrosys4/hosts_hydrosys.backup /etc/hosts + echo "--> Reverting changes made to default zone file. Moving backed up file to /etc/nginx/sites-enabled/default. Saving running file to ~/nginx_hydrosys.backup" + mv /etc/nginx/sites-enabled/default ~/nginx_hydrosys.backup + mv /usr/local/share/hydrosys4/nginx.default /etc/nginx/sites-enabled/default + echo "--> Reverting changes made to rc.local. Moving backed up config file to /etc/rc.local. Saving running file to ~/rc_hydrosys.backup" + mv /etc/rc.local ~/rc_hydrosys.backup + mv /usr/local/share/hydrosys4/rc_hydrosys.backup /ect/rc.local + echo "--> Reverting changes made to /boot/config.txt. Moving backed up config file to /boot/config.txt. Saving running file to ~/boot_config_hydrosys.backup" + mv /boot/config.txt ~/boot_config_hydrosys.backup + mv /usr/local/share/hydrosys4/boot_config_hydrosys.backup /boot/config.txt + echo "--> Reverting changes made to /etc/modules. Moving backed up config file to /etc/modules. Saving running file to ~/etc_modules_hydrosys.backup" + mv /etc/modules ~/etc_modules_hydrosys.backup + mv /usr/local/share/hydrosys4/etc_modules_hydrosys.backup /etc/modules + echo "--> Reverting changes made to hostapd.conf. Moving backed up config file to /etc/hostapd/hostapd.conf. Saving running file to ~/hostapd_hydrosys.backup" + mv /etc/hostapd/hostapd.conf ~/hostapd_hydrosys.backup + mv /usr/local/share/hydrosys4/hostapd_hydrosys.backup /etc/hostapd/hostapd.conf + echo "--> Reverting changes made to dnsmasq.conf. Moving backed up config file to /etc/dnsmasq.conf. Saving running file to ~/dnsmasq_hydrosys.backup" + mv /etc/dnsmasq.conf ~/dnsmasq_hydrosys.backup + mv /usr/local/share/hydrosys4/dnsmasq_hydrosys.backup /etc/dnsmasq.conf + echo "--> Reverting changes made to dhcpcd.conf. Moving backed up config file to /etc/dhcpcd.conf. Saving running file to ~/dhcpcd_hydrosys.backup" + mv /etc/dhcpcd.conf ~/dhcpcd_hydrosys.backup + mv /usr/local/share/hydrosys4/dhcpcd_hydrosys.backup /etc/dhcpcd.conf + echo "--> Removing Hydrosys4 installation folder and configuration files." + rm -rf /usr/local/share/hydrosys4 + break + ;; + * ) + echo "--> Please answer y or n." + ;; + esac + done } - - - - - -fn_hostapd () -{ - -sudo apt-get -y install hostapd || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -# unmask the service -sudo systemctl unmask hostapd.service - -# create hostapd.conf file -aconf="/etc/hostapd/hostapd.conf" -if [ -f $aconf ]; then - cp $aconf $aconf.1 - sudo rm $aconf - echo "remove file" -fi - - -sudo bash -c "cat >> $aconf" << EOF -# HERE-> {"name": "IPsetting", "LocalIPaddress": "$IP", "LocalPORT": "$PORT", "LocalAPSSID" : "$WiFiAPname"} -ieee80211n=1 -interface=wlan0 -ssid=$WiFiAPname -hw_mode=g -channel=6 -macaddr_acl=0 -auth_algs=1 -ignore_broadcast_ssid=0 -wpa=2 -wpa_passphrase=$WiFiAPpsw -wpa_key_mgmt=WPA-PSK -wpa_pairwise=TKIP -rsn_pairwise=CCMP -EOF - - -aconf="/etc/init.d/hostapd" -# Update hostapd main config file -sudo sed -i "s/\(^.*DAEMON_CONF=.*$\)/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" $aconf - -aconf="/etc/default/hostapd" -# Update hostapd main config file -sudo sed -i "s/\(^.*DAEMON_CONF=.*$\)/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" $aconf - -sudo systemctl enable hostapd.service - +function install_mjpegstr() { + aconf="/usr/local/share/hydrosys4/mjpg-streamer" # create hostapd.conf file + if [ -f $aconf ]; then + rm -rf /usr/local/share/hydrosys4/mjpg-streamer + fi + mkdir -p /usr/local/share/hydrosys4 + cd /usr/local/share/hydrosys4 + git clone https://github.com/jacksonliam/mjpg-streamer.git + cd mjpg-streamer/mjpg-streamer-experimental + make + make install } - -fn_dnsmasq () -{ - -sudo apt-get -y install dnsmasq || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - - -# edit /etc/dnsmasq.conf file -aconf="/etc/dnsmasq.conf" - -# delete rows between #START and #END -sed -i '/^#START HYDROSYS4 SECTION/,/^#END HYDROSYS4 SECTION/{/^#START HYDROSYS4 SECTION/!{/^#END HYDROSYS4 SECTION/!d}}' $aconf -sed -i '/#START HYDROSYS4 SECTION/d' $aconf -sed -i '/#END HYDROSYS4 SECTION/d' $aconf - -# calculation of the range starting from assigned IP address -IFS="." read -a a <<< $IP -IFS="." read -a b <<< 0.0.0.1 -IFS="." read -a c <<< 0.0.0.9 -IPSTART="$[a[0]].$[a[1]].$[a[2]].$[a[3]+b[3]]" -IPEND="$[a[0]].$[a[1]].$[a[2]].$[a[3]+c[3]]" -if [[ a[3] -gt 244 ]]; then -IPSTART="$[a[0]].$[a[1]].$[a[2]].$[a[3]-c[3]]" -IPEND="$[a[0]].$[a[1]].$[a[2]].$[a[3]-b[3]]" -fi - -echo $IPSTART $IPEND - - - -# ----- - - - -sudo bash -c "cat >> $aconf" << EOF -#START HYDROSYS4 SECTION -interface=wlan0 -dhcp-range=$IPSTART,$IPEND,12h -#no-resolv -#END HYDROSYS4 SECTION -EOF - -sudo systemctl enable dnsmasq.service - - +function install_hydrosys4() { + aconf="/usr/local/share/hydrosys4/env/autonom" # check if file exist in local folder + if [ -d $aconf ]; then # if the directory exist + rm -rf /usr/local/share/hydrosys4/env + else + mkdir -p /usr/local/share/hydrosys4/env # --- INSTALL Hydrosys4 software + cd /usr/local/share/hydrosys4/env + git clone https://github.com/Hydrosys4/Master.git + mv Master autonom + fi + if [ -f "changeDefaults" == "d" ]; then + bash -c "cat >> /usr/local/share/hydrosys4/env/autonom/database/logincred.txt" <<-EOF + {"name": "login", "password": "$newPassword", "username": "$newLogin"} + EOF + fi } - -fn_dhcpcd () -{ - -# edit /etc/dnsmasq.conf file -aconf="/etc/dhcpcd.conf" - -# delete rows between #START and #END -sed -i '/^#START HYDROSYS4 SECTION/,/^#END HYDROSYS4 SECTION/{/^#START HYDROSYS4 SECTION/!{/^#END HYDROSYS4 SECTION/!d}}' $aconf -sed -i '/#START HYDROSYS4 SECTION/d' $aconf -sed -i '/#END HYDROSYS4 SECTION/d' $aconf - - -sudo bash -c "cat >> $aconf" << EOF -#START HYDROSYS4 SECTION -profile static_wlan0 -static ip_address=$IP/24 -#static routers=192.168.1.1 -#static domain_name_servers=192.169.1.1 -# fallback to static profile on wlan0 -interface wlan0 -fallback static_wlan0 -#END HYDROSYS4 SECTION -EOF - - +function install_DHT22lib() { + aconf="/usr/local/share/hydrosys4/env/autonom/libraries/DHT22/master.zip" # This is just going to install the library present in local folder + if [ -f $aconf ]; then # --- installing the DHT22 Sensor libraries + cd /usr/local/share/hydrosys4/env/autonom/libraries/DHT22 + unzip master.zip + cd Adafruit_Python_DHT-master + python3 setup1plus.py install # setup1plus is file that make the DTH22 work with both RaspberryPi zero,1 and model 2,3 + fi } -fn_ifnames () -{ -# this is to preserve the network interfaces names, becasue staring from debian stretch (9) the ifnames have new rules -# edit /etc/dnsmasq.conf file -aconf="/boot/cmdline.txt" +function config_I2C() { + echo "--> Enabling I2C and SPI and adding modules" + aconf="/boot/config.txt" # --- Enable I2C and Spi: /boot/config.txt + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/boot_config_hydrosys.backup + fi + sed -i 's/\(^.*#dtparam=i2c_arm=on.*$\)/dtparam=i2c_arm=on/' $aconf + sed -i 's/\(^.*#dtparam=spi=on.*$\)/dtparam=spi=on/' $aconf + sed -i 's/\(^.*#dtparam=i2s=on.*$\)/dtparam=i2s=on/' $aconf -APPEND=' net.ifnames=0' -echo "$(cat $aconf)$APPEND" > $aconf - + aconf="/etc/modules" # --- Add modules: /etc/modules + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/etc_modules_hydrosys.backup + fi + sed -i '/i2c-bcm2708/d' $aconf + sed -i -e "\$ai2c-bcm2708" $aconf + sed -i '/i2c-dev/d' $aconf + sed -i -e "\$ai2c-dev" $aconf + sed -i '/i2c-bcm2835/d' $aconf + sed -i -e "\$ai2c-bcm2835" $aconf + sed -i '/rtc-ds1307/d' $aconf + sed -i -e "\$artc-ds1307" $aconf + sed -i '/bcm2835-v4l2/d' $aconf + sed -i -e "\$abcm2835-v4l2" $aconf } - - - - - - - - -install_mjpegstr () -{ -cd /home/pi - -sudo rm -r mjpg-streamer - -sudo apt-get -y install cmake libjpeg8-dev git - -sudo git clone https://github.com/jacksonliam/mjpg-streamer.git - -cd mjpg-streamer/mjpg-streamer-experimental - -sudo make - -sudo make install - -cd .. -cd .. - +function config_RClocal() { + echo "--> Modifying rc.local for autostart actions" + aconf="/etc/rc.local" + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/rc_hydrosys.backup + fi + autostart="yes" + tmpfile=$(mktemp) + sed '/#START/,/#END/d' /etc/rc.local > "$tmpfile" && mv "$tmpfile" /etc/rc.local # copy the below lines between #START and #END to rc.local + awk '!NF {if (++n <= 1) print; next}; {n=0;print}' /etc/rc.local > "$tmpfile" && mv "$tmpfile" /etc/rc.local # Remove to growing plank lines. + if [ "$autostart" == "yes" ]; then + if ! grep -Fq '#START HYDROSYS4 SECTION' /etc/rc.local; then # --- Real Time Clock (RTC) /etc/rc.local + sed -i '/exit 0/d' /etc/rc.local + bash -c "cat >> /etc/rc.local" <<-EOF + #START HYDROSYS4 SECTION + # iptables + sudo iptables-restore < /usr/local/share/hydrosys4/iptables.rules + + # clock + echo "HYDROSYS4-set HW clock ****************************************" + echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device || true + hwclock -s || true + + echo "HYDROSYS4-start system ****************************************" + cd /usr/local/share/hydrosys4/env/autonom/ + sudo python3 /usr/local/share/hydrosys4/env/autonom/bentornado.py & + #END HYDROSYS4 SECTION + exit 0 + EOF + else + tmpfile=$(mktemp) + sed '/#START/,/#END/d' /etc/rc.local > "$tmpfile" && mv "$tmpfile" /etc/rc.local + awk '!NF {if (++n <= 1) print; next}; {n=0;print}' /etc/rc.local > "$tmpfile" && mv "$tmpfile" /etc/rc.local # Remove to growing plank lines. + fi + fi + sudo chown root:root /etc/rc.local + sudo chmod 755 /etc/rc.local } - - -install_nginx () -{ -# this function is used -cd /home/pi - -sudo apt-get -y install nginx - -# create default file -aconf="/etc/nginx/sites-enabled/default" -if [ -f $aconf ]; then - cp $aconf /home/pi/$aconf.1 - sudo rm $aconf - echo "remove file" -fi - - -sudo bash -c "cat >> $aconf" << EOF -server { - # for a public HTTP server: - listen $PORT; - server_name localhost; - - access_log off; - error_log off; - - location / { - proxy_pass http://127.0.0.1:5020; - } - - location /stream { - rewrite ^/stream/(.*) /$1 break; - proxy_pass http://127.0.0.1:5022; - proxy_buffering off; - } - - location /favicon.ico { - alias /home/pi/env/autonom/static/favicon.ico; - } +function config_hostapd() { + echo "--> Adding network configuration for $WiFiAPname" + systemctl unmask hostapd.service # unmask the service + aconf="/etc/hostapd/hostapd.conf" # create hostapd.conf file + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/hostapd_hydrosys.backup + echo "--> Backed up /etc/hostapd/hostapd.conf to /usr/local/share/hydrosys4/hostapd_hydrosys.backup" + fi + bash -c "cat >> $aconf" <<-EOF + # HERE-> {"name": "IPsetting", "LocalIPaddress": "$IP", "LocalPORT": "$PORT", "LocalAPSSID" : "$WiFiAPname"} + ieee80211n=1 + interface=wlan0 + ssid=$WiFiAPname + hw_mode=g + channel=6 + macaddr_acl=0 + auth_algs=1 + ignore_broadcast_ssid=0 + wpa=2 + wpa_passphrase=$WiFiAPpsw + wpa_key_mgmt=WPA-PSK + wpa_pairwise=TKIP + rsn_pairwise=CCMP + EOF + aconf="/etc/init.d/hostapd" # Update hostapd main config file + sed -i "s/\(^.*DAEMON_CONF=.*$\)/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" $aconf + aconf="/etc/default/hostapd" # Update hostapd main config file + sed -i "s/\(^.*DAEMON_CONF=.*$\)/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" $aconf + systemctl enable hostapd.service } -EOF - -sudo service nginx start - -cd .. -cd .. +function config_dnsmasq() { + echo "--> Configuring DNS parameters" + aconf="/etc/dnsmasq.conf" # edit /etc/dnsmasq.conf file + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/dnsmasq_hydrosys.backup + fi + sed -i '/^#START HYDROSYS4 SECTION/,/^#END HYDROSYS4 SECTION/{/^#START HYDROSYS4 SECTION/!{/^#END HYDROSYS4 SECTION/!d}}' $aconf # delete rows between #START and #END + sed -i '/#START HYDROSYS4 SECTION/d' $aconf + sed -i '/#END HYDROSYS4 SECTION/d' $aconf + IFS="." read -a a <<< $IP # calculation of the range starting from assigned IP address + IFS="." read -a b <<< 0.0.0.1 + IFS="." read -a c <<< 0.0.0.9 + IPSTART="$[a[0]].$[a[1]].$[a[2]].$[a[3]+b[3]]" + IPEND="$[a[0]].$[a[1]].$[a[2]].$[a[3]+c[3]]" + if [[ a[3] -gt 244 ]]; then + IPSTART="$[a[0]].$[a[1]].$[a[2]].$[a[3]-c[3]]" + IPEND="$[a[0]].$[a[1]].$[a[2]].$[a[3]-b[3]]" + fi + echo $IPSTART $IPEND + bash -c "cat >> $aconf" <<-EOF + #START HYDROSYS4 SECTION + interface=wlan0 + dhcp-range=$IPSTART,$IPEND,12h + #no-resolv + #END HYDROSYS4 SECTION + EOF + systemctl enable dnsmasq.service + } + +function config_dhcpcd() { + echo "--> Configuring DHCP parameters" + aconf="/etc/dhcpcd.conf" # edit /etc/dnsmasq.conf file + if [ -f $aconf ]; then + cp $aconf /usr/local/share/hydrosys4/dhcpcd_hydrosys.backup + fi + sed -i '/^#START HYDROSYS4 SECTION/,/^#END HYDROSYS4 SECTION/{/^#START HYDROSYS4 SECTION/!{/^#END HYDROSYS4 SECTION/!d}}' $aconf # delete rows between #START and #END + sed -i '/#START HYDROSYS4 SECTION/d' $aconf + sed -i '/#END HYDROSYS4 SECTION/d' $aconf + bash -c "cat >> $aconf" <<-EOF + #START HYDROSYS4 SECTION + profile static_wlan0 + static ip_address=$IP/24 + #static routers=192.168.1.1 + #static domain_name_servers=192.169.1.1 + # fallback to static profile on wlan0 + interface wlan0 + fallback static_wlan0 + #END HYDROSYS4 SECTION + EOF } - -install_squid3 () -{ -# this function is NOT USED -cd /home/pi - -sudo apt-get install squid3 -y || { echo "ERROR --------------------------Installation failed ----------------" && exit ;} - -# add configuration to squid.conf, the file should already exist if installation is succesful -adir="/etc/squid3" -if [ -d $adir ]; then - aconf="/etc/squid3/squid.conf" -fi -adir="/etc/squid" -if [ -d $adir ]; then - aconf="/etc/squid/squid.conf" -fi - -if [ -f $aconf ]; then - cp $aconf $aconf.1 - sudo rm $aconf - echo "remove file" -fi - - - -sudo bash -c "cat >> $aconf" << EOF -# hydrosys4 configurations - -http_port $PORT accel defaultsite=hydrosys4 vhost - -acl Safe_ports port $PORT # unregistered ports - -acl videostream urlpath_regex \?action=stream - -cache_peer localhost parent 5020 0 no-query originserver name=server1 -cache_peer_access server1 deny videostream - -cache_peer localhost parent 5022 0 no-query originserver name=server2 -cache_peer_access server2 allow videostream -cache_peer_access server2 deny all - -http_access allow Safe_ports - -# default configurations - -# WELCOME TO SQUID 3.5.12 -acl SSL_ports port 443 -acl Safe_ports port 80 # http -acl Safe_ports port 21 # ftp -acl Safe_ports port 443 # https -acl Safe_ports port 70 # gopher -acl Safe_ports port 210 # wais -acl Safe_ports port 1025-65535 # unregistered ports -acl Safe_ports port 280 # http-mgmt -acl Safe_ports port 488 # gss-http -acl Safe_ports port 591 # filemaker -acl Safe_ports port 777 # multiling http -acl CONNECT method CONNECT -http_access deny !Safe_ports -http_access deny CONNECT !SSL_ports -http_access allow localhost manager -http_access deny manager -http_access allow localhost -http_access deny all -coredump_dir /var/spool/squid -refresh_pattern ^ftp: 1440 20% 10080 -refresh_pattern ^gopher: 1440 0% 1440 -refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 -refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880 -refresh_pattern . 0 20% 4320 -EOF - -sudo service squid3 start - -cd .. -cd .. - +function config_ifnames() { + aconf="/boot/cmdline.txt" # this is to preserve the network interfaces names, becasue staring from debian stretch (9) the ifnames have new rules + APPEND=' net.ifnames=0' + echo "$(cat $aconf)$APPEND" > $aconf } - - -edit_defaultnetworkdb () -{ - - -aconf="/home/pi/env/autonom/database/default/defnetwork.txt " - -# if file already exist then no action, otherwise create it -if [ -f $aconf ]; then - echo "network default file already exist" - else - sudo bash -c "cat >> $aconf" << EOF -{"name": "IPsetting", "LocalIPaddress": "192.168.0.172", "LocalPORT": "5012" , "LocalAPSSID" : "Hydrosys4"} -EOF - -fi - +function config_nginx() { + echo "--> Configuring Nginx server settings and default zone file" + aconf="/etc/nginx/sites-enabled/default" # create default file + if [ -f $aconf ]; then + mv $aconf /usr/local/share/hydrosys4/nginx_hydrosys.backup + echo "--> Backed up /etc/nginx/sites-enabled/default to /usr/local/share/hydrosys4/nginx_hydrosys.backup" + fi + bash -c "cat >> $aconf" <<-EOF + server { + # for a public HTTP server: + listen $PORT; + server_name localhost; + + access_log off; + error_log off; + + location / { + proxy_pass http://127.0.0.1:5020; + } + + location /stream { + rewrite ^/stream/(.*) /$1 break; + proxy_pass http://127.0.0.1:5022; + proxy_buffering off; + } + + location /favicon.ico { + alias /usr/local/share/hydrosys4/env/autonom/static/favicon.ico; + } + } + EOF + systemctl restart nginx } -edit_networkdb () -{ - - -aconf="/home/pi/env/autonom/database/network.txt " - -# if file already exist then delete it -if [ -f $aconf ]; then - sudo rm $aconf - echo "remove file" -fi - -sudo bash -c "cat >> $aconf" << EOF -{"name": "IPsetting", "LocalIPaddress": "$IP", "LocalPORT": "$PORT", "LocalAPSSID" : "$WiFiAPname"} -EOF - - +function config_defaultnetworkdb() { + aconf="/usr/local/share/hydrosys4/env/autonom/database/default/defnetwork.txt " + if [ -f $aconf ]; then # if file already exist then no action, otherwise create it + echo "--> Default network file already exist, no changes where made" + else + bash -c "cat >> $aconf" <<-EOF + {"name": "IPsetting", "LocalIPaddress": "192.168.0.172", "LocalPORT": "5012" , "LocalAPSSID" : "Hydrosys4"} + EOF + fi } +function config_iptables_ports() { + iptables -A INPUT -p tcp -s localhost --dport 5020 -j ACCEPT + iptables -A INPUT -p tcp -s localhost --dport 5022 -j ACCEPT + iptables -A INPUT -p tcp --dport 5020 -j DROP + iptables -A INPUT -p tcp --dport 5022 -j DROP + iptables-save > /usr/local/share/hydrosys4/iptables.rules + echo "--> installation finished!!!" +} -iptables_blockports () -{ -sudo iptables -A INPUT -p tcp -s localhost --dport 5020 -j ACCEPT -sudo iptables -A INPUT -p tcp -s localhost --dport 5022 -j ACCEPT -sudo iptables -A INPUT -p tcp --dport 5020 -j DROP -sudo iptables -A INPUT -p tcp --dport 5022 -j DROP +function ask_reboot() { + read -p "--> Do you want to reboot the system, required for all changes to be applied? (y,n): " -e -i y doreboot + echo " Confirmed Answer: "$doreboot + if [ "$doreboot" == "y" ]; then + reboot + fi +} -sudo iptables-save > /home/pi/iptables.rules +function show_help() { + cat <<-EOF + Usage: ${0##*/} [-i] [-u] [-h]... + Please use one of options given below to continue + -h|-help Display this help and exit + -i|-install Install Hydrosys4 + -u|-uninstall Completely remove Hydrosys4 and revert all changes + -d|-debug Log install or uninstall actions to debug_messages.log + EOF } - -# --- RUN the functions -killpython -input_UI -system_update_light -#system_update_UI -install_dependencies -enable_I2C -modify_RClocal -fn_hostapd -fn_dnsmasq -fn_dhcpcd -fn_ifnames -install_mjpegstr -#install_squid3 -install_nginx -install_hydrosys4 # this should be called before the DHT22 , SPI and BMP due to local library references -install_DHT22lib -install_SPIlib -edit_defaultnetworkdb -#edit_networkdb -iptables_blockports -apply_newhostname -echo "installation is finished!!! " -ask_reboot +while :; do + case $1 in + -h|-\?|--help) + show_help + exit 1 + ;; + -d|-debug|--debug) + exec 5> debug_messages.log + BASH_XTRACEFD="5" + set -x + ;; + -i|-install|--install) + input_UI + system_update_UI + install_dependencies + install_hydrosys4 # this should be called before the DHT22 due to local library references + install_mjpegstr + install_DHT22lib + config_I2C + config_RClocal + config_hostapd + config_dnsmasq + config_dhcpcd + config_ifnames + config_nginx + config_defaultnetworkdb + config_iptables_ports + ask_reboot + exit 1 + ;; + -u|-uninstall|--uninstall) + uninstall + exit 1 + ;; + --) # End of all options. + shift + break + ;; + -?*) + printf 'WARNING: Unknown option: %s\n\n' "$1" >&2 + show_help + exit 1 + ;; + *) + printf "ERROR: No option given, exiting\n\n" >&2 + show_help + exit 1 + ;; + esac + shift +done \ No newline at end of file diff --git a/changelog/change~ b/changelog/change~ deleted file mode 100644 index e1da0c3..0000000 --- a/changelog/change~ +++ /dev/null @@ -1,32 +0,0 @@ - -Change 49-> 50 - -upgrade to latest jessie lite - -the network interfaces are not editable in the file /etc/network/interfaces - -now it is required to use wpa_supplicant file starting from Weezy jessie. - -The wifi network modules should go and write on wpa_supplicant file - -introduced wpa_cli_mod - -Change 50->51 - -introducing the APscheduler 3.0 - -2016-09-20 -> release 51.01 - -fix the power pin enable/disable to support multithread - -fix the "hydropicture" folder issue in case folder is not present (Hardwaremod.py) - -introduced the bash file to autoinstall dependencies and program on jessie lite OS. (install_hydrosys4.sh) - - -2016-11-5 -> release 52 - -Introduce video function using the mjpeg-sreamer - - - diff --git a/database/default/defaddata.txt~ b/database/default/defaddata.txt~ deleted file mode 100644 index ddd50b0..0000000 --- a/database/default/defaddata.txt~ +++ /dev/null @@ -1,8 +0,0 @@ -{"1": "P1", "2": "P2", "3": "P3", "4": "P4", "4": "P5", "name": "listelements"} -{"1": "Monday", "2": "Tuesday", "3": "Wednesday", "4": "Thursday", "5": "Friday", "6": "Saturday", "7": "Sunday", "name": "listparam"} -{"1": "Time", "2": "Seconds", "3": "Temperature", "4": "Humidity", "name": "tableheaders"} -{"Friday": [["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Monday": [["14:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Saturday": [["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Sunday": [["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Thursday": [["14:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Tuesday": [["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Wednesday": [["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "name": "P1"} -{"Friday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Monday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Saturday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Sunday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Thursday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Tuesday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Wednesday": [["15:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "name": "P2"} -{"Friday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Monday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Saturday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Sunday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Thursday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Tuesday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "Wednesday": [["06:00", "30", "", ""], ["16:00", "30", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""], ["00:00", "0", "", ""]], "name": "P3"} -{"Friday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "", "1"], ["22:00", "30", "", "1"]], "Monday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "27", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Saturday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Sunday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Thursday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Tuesday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Wednesday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "name": "P4"} -{"Friday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "", "1"], ["22:00", "30", "", "1"]], "Monday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "27", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Saturday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Sunday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Thursday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Tuesday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "Wednesday": [["08:00", "30", "", "1"], ["12:00", "10", "", "1"], ["14:00", "10", "", "1"], ["18:00", "10", "27", "1"], ["22:00", "30", "27", "1"]], "name": "P5"} diff --git a/database/default/defhwdata.txt~ b/database/default/defhwdata.txt~ deleted file mode 100644 index c07f2d5..0000000 --- a/database/default/defhwdata.txt~ +++ /dev/null @@ -1,17 +0,0 @@ -{"IOtype": "input" ,"name": "tempsensor1", "unit" : "C", "measure":"Temperature", "controllercmd": "tempsensor", "pin": "4" , "usedfor" : "temperaturecontrol", "schedulingtype":"periodic", "time":"00:15:05"} -{"IOtype": "input" ,"name": "humidsensor", "unit" : "%", "measure":"Humidity", "controllercmd": "humidsensor", "pin": "4" , "usedfor" : "humiditycontrol", "schedulingtype":"periodic", "time":"00:15:03"} -{"IOtype": "input" ,"name": "pressuresensor", "unit" : "hPa", "measure":"Pressure", "controllercmd": "pressuresensor", "pin": "I2C" , "usedfor" : "Pressurecontrol", "schedulingtype":"periodic", "time":"00:15:01"} -{"IOtype": "input" ,"name": "hygropass", "unit" : "Volt", "measure":"Moisture", "controllercmd": "analogdigital", "pin": "SPI" , "usedfor" : "Moisturecontrol", "schedulingtype":"periodic", "time":"00:15:01" , "ADCchannel":"0" , "ADCpowerpin":"12" } -{"IOtype": "input" ,"name": "hygroampl", "unit" : "Volt", "measure":"Moisture", "controllercmd": "analogdigital", "pin": "SPI" , "usedfor" : "Moisturecontrol", "schedulingtype":"periodic", "time":"00:15:01" , "ADCchannel":"7" , "ADCpowerpin":"25" } -{"IOtype": "input" ,"name": "lightsensor", "unit" : "Lum", "measure":"Light", "controllercmd": "lightsensor", "pin": "I2C" , "usedfor" : "lightcontrol", "schedulingtype":"periodic", "time":"00:15:01"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "water1", "pin": "5", "usefor": "watercontrol", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "water2", "pin": "6", "usefor": "watercontrol", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "light1", "pin": "13", "time": "17:30" , "usefor": "lightcontrol", "measure": "Time", "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "doser1", "pin": "19", "usefor": "fertilizercontrol", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "doser2", "pin": "26", "usefor": "fertilizercontrol", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "empty1", "pin": "21", "usefor": "N/A", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "empty2", "pin": "20", "usefor": "N/A", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" , "controllercmd": "pulse", "logic": "neg", "name": "empty3", "pin": "16", "usefor": "N/A", "measure": "Time" , "unit" : "sec", "schedulingtype":"oneshot"} -{"IOtype": "output" ,"usefor": "mailcontrol", "mailaddress": "", "controllercmd": "mail+info+link","name": "mail1", "time": "10:00", "mailtitle": "Hydrosys today report", "measure" : "Mail" , "unit" : "pcs" , "schedulingtype":"oneshot"} -{"IOtype": "output" ,"usefor": "mailcontrol", "mailaddress": "", "controllercmd": "mail+info","name": "mail2", "time": "10:00", "mailtitle": "Hydrosys today report", "measure" : "Mail" , "unit" : "pcs" , "schedulingtype":"oneshot"} -{"IOtype": "output" ,"usefor": "photocontrol", "controllercmd": "photo", "name": "photo", "time": "09:30", "measure" : "Photo" , "unit" : "pcs", "schedulingtype":"oneshot"} diff --git a/database/default/defwtdata.txt~ b/database/default/defwtdata.txt~ deleted file mode 100644 index cfd3f88..0000000 --- a/database/default/defwtdata.txt~ +++ /dev/null @@ -1,2 +0,0 @@ -{"name": "listparam", "1":"jan","2":"feb","3":"mar","4":"apr","5":"may","6":"jun","7":"jul","8":"aug","9":"sep","10":"oct","11":"nov","12":"dec"} -{"element": "1", "jan": [1,0],"feb": [1,0],"mar": [1,1],"apr": [1,1],"may": [1,3],"jun": [1,3],"jul": [1,4],"aug": [1,2],"sep": [1,1],"oct": [1,0],"nov": [1,0],"dec": [1,0]}