├── .gitignore ├── EmonPiFileSystem.md ├── common ├── emoncmsdbupdate.php ├── install_emoncms_service.sh ├── md5sum.py └── remove_emoncms_service.sh ├── components_available.json ├── defaults ├── apache2 │ ├── emoncms.conf │ └── emonsd.conf ├── emoncms │ ├── default.settings.php │ └── emonpi.settings.ini ├── etc │ ├── cron.daily │ │ └── logrotate │ ├── cron.hourly │ │ └── log2ram │ ├── fstab │ ├── logrotate.d │ │ ├── 00_defaults │ │ ├── emoncms │ │ ├── emoncms-non-emonsd │ │ ├── emonhub │ │ └── logrotate │ └── rc.local └── readme.md ├── docs ├── developer.md ├── digital-ocean-install.md ├── download.md ├── index.rst ├── install-scripts.md ├── install.md └── rpi-install.md ├── emonupload2.py ├── firmware_available.json ├── install ├── .gitignore ├── apache.sh ├── docker.sh ├── emoncms_core.sh ├── emoncms_emonpi_modules.sh ├── emoncms_modules.sh ├── emonhub.sh ├── emonhub_gateway.config.ini ├── emonpilcd.sh ├── emonsd.config.ini ├── emonsd.sh ├── firmware.sh ├── init.sh ├── init_resize.sh ├── load_config.sh ├── main.sh ├── mosquitto.sh ├── mysql.sh ├── network.sh ├── non_emonsd.sh ├── php.sh └── redis.sh ├── module.json ├── other ├── factoryreset ├── i2cdetect.py ├── stable_release.sh └── switch_git_urls_to_ssh.sh ├── readme.md ├── safe-update ├── sudoers.d ├── emoncms-filesystem ├── emoncms-rebootbutton ├── emonhub-sudoers └── wifi-sudoers └── update ├── atmega_firmware_upload.sh ├── avrdude.conf ├── emoncms.sh ├── emonhub.sh ├── emonsd.sh ├── firstbootupdate ├── get_firmware_download_url.py ├── load_config.sh ├── main.sh ├── readme.md ├── service-runner-update.sh ├── update_all_components.sh └── update_component.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/settings.json 2 | -------------------------------------------------------------------------------- /EmonPiFileSystem.md: -------------------------------------------------------------------------------- 1 | ## EmonCMS file system 2 | 3 | | | | | 4 | -- | -- | -- 5 | EMONCMS_WWW | /var/www/emoncms | location of the core package and of the main modules (admin, dashboards, config) 6 | EMONCMS_DATADIR | /var/opt/emoncms | timeseries database directories 7 | EMONCMS_DIR | /opt/emoncms | location of symlinked modules (postprocess, sync) and of uploaded tar.gz archives when importing a backup 8 | OPENENERGYMONITOR_DIR | /opt/openenergymonitor | location of EmonScripts, emonhub and of created backup archives 9 | EMONCMS_LOG_LOCATION | /var/log/emoncms | log location for emoncms logs
emoncms.log is main emoncms log, managed with the EmonLogger PHP class 10 | 11 | 12 | ### main dependencies 13 | | | | | 14 | -- | -- | -- 15 | web server | Apache2 | 16 | relational databases | mysql or maria | 17 | key:value database | redis-server | data buffering for timeseries and backgroud processing for service-runner 18 | message broker | mosquitto | 19 | data engine language |php with extensions | pear (for pecl needs)
mysql
gd dev, common
mbstring
redis
mosquitto (https://github.com/mgdm/Mosquitto-PHP)
curl 20 | 21 | 22 | ### EmonCMS systemd services 23 | 24 |

all systemd services have to be symlinked in /etc/systemd/system

25 | 26 | ``` 27 | emoncms_mqtt.service -> /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.service 28 | emonhub.service -> /opt/openenergymonitor/emonhub/service/emonhub.service 29 | feedwriter.service -> /var/www/emoncms/scripts/services/feedwriter/feedwriter.service 30 | service-runner.service -> /var/www/emoncms/scripts/services/service-runner/service-runner.service 31 | ``` 32 | MariaDB and Redis services are in lib/systemd/system, but they are compiled... 33 | ``` 34 | mysqld.service -> /lib/systemd/system/mariadb.service 35 | mysql.service -> /lib/systemd/system/mariadb.service 36 | redis.service -> /lib/systemd/system/redis-server.service 37 | ``` 38 | 39 | phpmqtt input (PHP)|listen to payloads published to the mosquitto broker on topic emon 40 | --|-- 41 | scriptpath | EMONCMS_WWW/scripts/services/emoncms_mqtt/emoncms_mqtt.php 42 | Servicepath | EMONCMS_WWW/scripts/services/emoncms_mqtt/emoncms_mqtt.service 43 | globals | $log , $mysqli, $redis, $user, $feed_settings, $mqtt_server $mqttsettings, $mqtt_client,
$feed, $input, $process 44 | non globals | $connected, $subscribed, $last_retry, $last_heartbeat, $count 45 | log | uses emoncms main log file
`journalctl -f -u emoncms_mqtt` 46 | specific conf file | no 47 | 48 | feedwriter (PHP)|writes input data from redis-buffer to disk in order to feed the timeseries database 49 | --|-- 50 | scriptpath | EMONCMS_WWW/scripts/feedwriter.php 51 | Servicepath | EMONCMS_WWW/scripts/services/feedwriter/feedwriter.service 52 | globals | $log, $feed_settings, $mysqli, $redis
$user, $feed 53 | log | uses emoncms main log file
`journalctl -f -u feedwriter` 54 | specific conf file | no 55 | 56 | Service-runner (Python)|trigger background workers from modules (update, backup, sync, postprocess) 57 | --|-- 58 | scriptpath | EMONCMS_WWW/scripts/services/service-runner/service-runner.py 59 | Servicepath | EMONCMS_WWW/scripts/services/service-runner/service-runner.service 60 | log | uses systemd log file
`journalctl -f -u service-runner` 61 | specific conf file | no 62 | 63 | emonhub (Python)| listen on serial port or ethernet and publish to mosquitto broker topic emon 64 | --|-- 65 | scriptpath | OPENENERGYMONITOR_DIR/emonhub/src/emonhub.py 66 | Servicepath | OPENENERGYMONITOR_DIR/service/emonhub.service 67 | log | log file is in /var/log/emonhub
`journalctl -u emonhub -n 30 –no-pager` 68 | specific conf file | /etc/emonhub/emonhub.conf
/etc/emonhub/emonhub.env 69 | 70 | emonPiLCD (Python)| manages the emonpi LCD screen 71 | --|-- 72 | scriptpath | OPENENERGYMONITOR_DIR/emonpi/lcd/emonPiLCD.py 73 | Servicepath | OPENENERGYMONITOR_DIR/emonpi/lcd/emonPiLCD.service 74 | log | log file is in /var/log/emonpilcd
`journalctl -u emonPiLCD` 75 | specific conf file | no 76 | 77 | ### EmonCMS modules 78 | 79 | admin| module integrated into the core package - does not have its own git repo 80 | --|-- 81 | place | EMONCMS_WWW/Modules/admin 82 | globals | $mysqli,$session,$route,$updatelogin,$allow_emonpi_admin, $redis, $openenergymonitor_dir, $admin_show_update, $path
$log, $log_location, $log_enabled, $log_level 83 | background workers | none 84 | log | uses emoncms main log file 85 | specific conf file | no 86 | 87 | config|web interface to supervise and configure emonhub 88 | --|-- 89 | place | EMONCMS_WWW/Modules/config 90 | globals | $route, $session, $redis, $homedir 91 | non globals | $emonhub_config_file, $emonhub_logfile, $restart_log
Also in model : $logfile, $config_file, $restart_log_name 92 | background workers | restart.sh 93 | log | /var/log/emoncms/emonhub-restart.log 94 | specific conf file | no 95 | 96 | dashboard|Dashboard Module 97 | --|-- 98 | place | EMONCMS_WWW/Modules/dashboard 99 | globals | $mysqli, $session, $route, $path 100 | background workers | no 101 | log | no 102 | specific conf file | no 103 | 104 | graph|main graph module with averaging on the fly 105 | --|-- 106 | place | EMONCMS_WWW/Modules/graph 107 | globals | $session,$route,$mysqli,$redis, $path 108 | background workers | no 109 | log | no 110 | specific conf file | no 111 | 112 | backup|import/export all timeseries+mysql database 113 | --|-- 114 | place | EMONCMS_DIR/modules/backup 115 | globals | $route, $session, $path, $redis, $linked_modules_dir, $log_location 116 | background workers | emoncms-import.sh
emoncms-export.sh
emoncms-copy.sh ?
service-runner bash file why ? All things related to service-runner are in controller 117 | log | EMONCMS_LOG_LOCATION/exportbackup.log
EMONCMS_LOG_LOCATION/importbackup.log 118 | specific conf file | config.cfg which has to be set up during installation 119 | 120 | sync|connect to distant EmonCMS machines to retrieve feeds
IOT flavoured alternative to backup 121 | --|-- 122 | place | EMONCMS_DIR/modules/sync 123 | globals | $linked_modules_dir,$path,$session,$route
$mysqli,$redis,$user,$feed_settings,$log_location
$log in model 124 | background workers | emoncms-sync.sh launching sync_run.php in CLI 125 | log | EMONCMS_LOG_LOCATION/sync.log
also uses emoncms main log file 126 | specific conf file | no 127 | 128 | postprocess|postprocess feeds - calculation module 129 | --|-- 130 | place |EMONCMS_DIR/modules/postprocess 131 | globals | $linked_modules_dir,$session,$route,$mysqli,$redis,$feed_settings, $log_location 132 | background workers | postprocess.sh launching postprocess_run.php in CLI
Postprocess_run.php scans the redis postprocessqueue and start process functions 133 | log | EMONCMS_LOG_LOCATION/postprocess.log 134 | specific conf file | no 135 | -------------------------------------------------------------------------------- /common/emoncmsdbupdate.php: -------------------------------------------------------------------------------- 1 | 1): 10 | file_name = str(sys.argv[1]) 11 | else: 12 | file_name = 0 13 | 14 | # Open,close, read file and calculate MD5 on its contents 15 | if (file_name != 0): 16 | with open(file_name) as file_to_check: 17 | # read contents of the file 18 | data = file_to_check.read() 19 | # pipe contents of the file through 20 | md5_returned = hashlib.md5(data).hexdigest() 21 | else: 22 | md5_returned = 0 23 | 24 | print(md5_returned) 25 | -------------------------------------------------------------------------------- /common/remove_emoncms_service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | service=$1 4 | 5 | if [ -f /etc/init.d/$service ]; then 6 | echo "removing initd $service service" 7 | sudo /etc/init.d/$service stop 8 | sudo rm /etc/init.d/$service 9 | fi 10 | 11 | if [ -L /lib/systemd/system/$service.service ] || [ -f /lib/systemd/system/$service.service ]; then 12 | echo "Removing $service.service" 13 | sudo systemctl stop $service.service 14 | sudo systemctl disable $service.service 15 | sudo rm /lib/systemd/system/$service.service 16 | sudo systemctl daemon-reload 17 | fi 18 | 19 | # if the service still exists in /etc then remove it 20 | if [ -L /etc/systemd/system/$service.service ] || [ -f /etc/systemd/system/$service.service ]; then 21 | echo "Removing $service.service from /etc/systemd/system" 22 | sudo rm /etc/systemd/system/$service.service 23 | fi 24 | -------------------------------------------------------------------------------- /components_available.json: -------------------------------------------------------------------------------- 1 | { 2 | "emoncms":{ 3 | "name":"Emoncms Core", 4 | "url":"https://github.com/emoncms/emoncms.git" 5 | }, 6 | "app":{ 7 | "name":"App", 8 | "url":"https://github.com/emoncms/app.git" 9 | }, 10 | "config":{ 11 | "name":"EmonHub Config", 12 | "url":"https://github.com/emoncms/config.git" 13 | }, 14 | "dashboard":{ 15 | "name":"Dashboard", 16 | "url":"https://github.com/emoncms/dashboard.git" 17 | }, 18 | "device":{ 19 | "name":"Device", 20 | "url":"https://github.com/emoncms/device.git" 21 | }, 22 | "graph":{ 23 | "name":"Graph", 24 | "url":"https://github.com/emoncms/graph.git" 25 | }, 26 | "setup":{ 27 | "name":"Network Setup", 28 | "url":"https://github.com/emoncms/setup.git" 29 | }, 30 | "wifi":{ 31 | "name":"WiFi", 32 | "url":"https://github.com/emoncms/wifi.git" 33 | }, 34 | "backup":{ 35 | "name":"Backup", 36 | "url":"https://github.com/emoncms/backup.git" 37 | }, 38 | "demandshaper":{ 39 | "name":"DemandShaper", 40 | "url":"https://github.com/emoncms/demandshaper.git" 41 | }, 42 | "postprocess":{ 43 | "name":"Postprocess", 44 | "url":"https://github.com/emoncms/postprocess.git" 45 | }, 46 | "sync":{ 47 | "name":"Sync", 48 | "url":"https://github.com/emoncms/sync.git" 49 | }, 50 | "usefulscripts":{ 51 | "name":"Usefulscripts", 52 | "url":"https://github.com/emoncms/usefulscripts.git" 53 | }, 54 | "EmonScripts":{ 55 | "name":"EmonScripts", 56 | "url":"https://github.com/openenergymonitor/EmonScripts.git" 57 | }, 58 | "RFM2Pi":{ 59 | "name":"RFM2Pi", 60 | "url":"https://github.com/openenergymonitor/RFM2Pi" 61 | }, 62 | "avrdude-rpi":{ 63 | "name":"Avrdude-rpi", 64 | "url":"https://github.com/openenergymonitor/avrdude-rpi.git" 65 | }, 66 | "emonhub":{ 67 | "name":"Emonhub", 68 | "url":"https://github.com/openenergymonitor/emonhub.git" 69 | }, 70 | "emonpi":{ 71 | "name":"EmonPi", 72 | "url":"https://github.com/openenergymonitor/emonpi.git" 73 | }, 74 | "dynamic":{ 75 | "name":"Dynamic", 76 | "url":"https://github.com/emoncms/dynamic.git" 77 | }, 78 | "mhep":{ 79 | "name":"MyHomeEnergyPlanner", 80 | "url":"https://github.com/emoncms/myhomenergyplanner.git" 81 | }, 82 | "find":{ 83 | "name":"Find", 84 | "url":"https://github.com/emoncms/find.git" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /defaults/apache2/emoncms.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerName localhost 3 | ServerAdmin webmaster@localhost 4 | DocumentRoot /var/www/emoncms 5 | 6 | # Virtual Host specific error log 7 | ErrorLog /var/log/emoncms/apache2-error.log 8 | # Access log disabled 9 | # CustomLog /var/log/emoncms/apache2-access.log combined 10 | 11 | 12 | Options FollowSymLinks 13 | AllowOverride All 14 | DirectoryIndex index.php 15 | Require all granted 16 | 17 | 18 | -------------------------------------------------------------------------------- /defaults/apache2/emonsd.conf: -------------------------------------------------------------------------------- 1 | # ServerName 2 | ServerName localhost 3 | 4 | # Default apache2 error log 5 | ErrorLog /var/log/emoncms/apache2-error.log 6 | -------------------------------------------------------------------------------- /defaults/emoncms/default.settings.php: -------------------------------------------------------------------------------- 1 | 'localhost', 16 | 'port' => 6379, 17 | 'auth' => '', 18 | 'prefix' => ''); 19 | 20 | 21 | //3 #### MQTT 22 | // The 'subscriber' topic format is rx/* - where * is the emoncms input node number. 23 | // The 'publisher' topic format is user selectable from the 'Publish to MQTT' input process, for example power/solar 24 | $mqtt_enabled = true; // Activate MQTT by changing to true 25 | $mqtt_server = array( 'host' => 'localhost', 26 | 'port' => 1883, 27 | 'user' => 'emonpi', 28 | 'password' => 'emonpimqtt2016', 29 | 'basetopic'=> 'emon', 30 | 'client_id' => 'emoncms' 31 | ); 32 | 33 | 34 | //4 #### Engine settings 35 | $feed_settings = array( 36 | // Supported engines. Uncommented engines will not be available for user to create a new feed using it. Existing feeds with a hidden engine still work. 37 | // Place a ',' as the first character on all uncommented engines lines but first. 38 | // If using emoncms in low-write mode, ensure that PHPFIWA is disabled by removing the leading //, from the PHPFIWA entry 39 | 'engines_hidden'=>array( 40 | Engine::MYSQL, // 0 Mysql traditional 41 | //Engine::MYSQLMEMORY, // 8 Mysql with MEMORY tables on RAM. All data is lost on shutdown 42 | //Engine::PHPTIMESERIES, // 2 43 | //Engine::PHPFINA, // 5 44 | Engine::PHPFIWA, // 6 PHPFIWA disabled for compatibility with Low-write mode 45 | Engine::CASSANDRA // 10 Apache Cassandra disabled by default for emonpi, enable if you wish to use 46 | ), 47 | 48 | // Redis Low-write mode 49 | 'redisbuffer'=>array( 50 | 'enabled' => true // If enabled is true, requires redis enabled and feedwriter service running 51 | ,'sleep' => 60 // Number of seconds to wait before write buffer to disk - user selectable option 52 | ), 53 | 54 | 'csvdownloadlimit_mb' => 25, // Max csv download size in MB 55 | 56 | // Engines working folder. Default is /var/lib/phpfiwa,phpfina,phptimeseries 57 | // On windows or shared hosting you will likely need to specify a different data directory-- 58 | // Make sure that emoncms has write permission's to the datadirectory folders 59 | 'phpfiwa'=>array( 60 | 'datadir' => '/var/opt/emoncms/phpfiwa/' 61 | ), 62 | 'phpfina'=>array( 63 | 'datadir' => '/var/opt/emoncms/phpfina/' 64 | ), 65 | 'phptimeseries'=>array( 66 | 'datadir' => '/var/opt/emoncms/phptimeseries/' 67 | ), 68 | 'cassandra'=>array( 69 | 'keyspace' => 'emoncms' 70 | ) 71 | ); 72 | 73 | $emoncms_dir = "EMONCMS_DIR"; 74 | $openenergymonitor_dir = "OPENENERGYMONITOR_DIR"; 75 | 76 | // Max number of allowed different inputs per user. For limiting garbage rf data 77 | $max_node_id_limit = 32; 78 | 79 | 80 | //5 #### User Interface settings 81 | // gettext translations are found under each Module's locale directory 82 | $default_language = 'en_GB'; 83 | 84 | // Theme location (folder located under Theme/, and must have the same structure as the basic one) 85 | $theme = "basic"; 86 | // Theme colour options: "standard", "blue", "sun" 87 | $themecolor = "blue"; 88 | 89 | // Favicon filenme in Theme/$theme 90 | $favicon = "favicon_emonpi.png"; 91 | 92 | // Use full screen width 93 | $fullwidth = true; 94 | 95 | // Main menu collapses on lower screen widths 96 | $menucollapses = false; 97 | 98 | // Enable multi user emoncms. 99 | // If set to false, emoncms will automatically remove the register form and 100 | // ability to create further users after the first user has been created 101 | $enable_multi_user = false; 102 | 103 | // Enable remember me feature 104 | $enable_rememberme = true; 105 | 106 | // Allow user to reset his password 107 | $enable_password_reset = false; 108 | 109 | // Email address to email proccessed input values 110 | $default_emailto = 'root@localhost'; 111 | 112 | // (OPTIONAL) Email SMTP, used for password reset or other email functions 113 | $smtp_email_settings = array( 114 | 'host'=>"smtp.gmail.com", 115 | 'port'=>"465", // 25, 465, 587 116 | 'from'=>array('noreply@emoncms.org' => 'EmonCMS'), 117 | // comment lines below that dont apply 118 | 'encryption'=>"ssl", // ssl, tls 119 | 'username'=>"yourusername@gmail.com", 120 | 'password'=>"yourpassword" 121 | ); 122 | 123 | // Default controller and action if none are specified and user is anonymous 124 | $default_controller = "user"; 125 | $default_action = "login"; 126 | 127 | // Default controller and action if none are specified and user is logged in 128 | $default_controller_auth = "feed"; 129 | $default_action_auth = "list"; 130 | 131 | // Public profile functionality 132 | // Allows http://yourdomain.com/[username]/[dash alias] or ?id=[dash id] 133 | // Alternative to http://yourdomain.com/dashboard/view?id=[dash id] 134 | // Add optional '&embed=1' in the end to remove header and footer 135 | $public_profile_enabled = true; 136 | $public_profile_controller = "dashboard"; 137 | $public_profile_action = "view"; 138 | 139 | // Default feed viewer: "vis/auto?feedid=" or "graph/" - requires module https://github.com/emoncms/graph 140 | $feedviewpath = "graph/"; 141 | 142 | 143 | //6 #### Other settings 144 | // Log file configuration 145 | $log_enabled = true; 146 | $log_location = '/var/log/emoncms'; 147 | // Log Level: 1=INFO, 2=WARN, 3=ERROR 148 | $log_level = 2; 149 | 150 | // If installed on Emonpi, allow admin menu tools 151 | $allow_emonpi_admin = true; 152 | 153 | //experimental feature for virtual feeds average, default is true, set to false to activate average agregation with all data points, will be slower 154 | $data_sampling = false; 155 | 156 | // Show all fatal PHP errors 157 | $display_errors = true; 158 | 159 | // CSV export options for the number of decimal_places, decimal_place_separator and field_separator 160 | // The thousands separator is not used (specified as "nothing") 161 | // NOTE: don't make $csv_decimal_place_separator == $csv_field_separator 162 | // Adjust as appropriate for your location 163 | // number of decimal places 164 | $csv_decimal_places = 2; 165 | 166 | // decimal place separator 167 | $csv_decimal_place_separator = "."; 168 | 169 | // field separator 170 | $csv_field_separator = ","; 171 | 172 | // set true on docker installations 173 | $allow_config_env_vars = false; 174 | 175 | // Dont change - developer updates this when the config format changes 176 | $config_file_version = "10"; 177 | 178 | // Set to true to run database update without logging in 179 | // URL Example: http://localhost/emoncms/admin/db 180 | $updatelogin = false; 181 | 182 | // Applicaton name 183 | $appname = "emoncms"; 184 | -------------------------------------------------------------------------------- /defaults/emoncms/emonpi.settings.ini: -------------------------------------------------------------------------------- 1 | emoncms_dir = "EMONCMS_DIR" 2 | openenergymonitor_dir = "OPENENERGYMONITOR_DIR" 3 | 4 | [sql] 5 | server = "127.0.0.1" 6 | database = "emoncms" 7 | username = "emoncms" 8 | password = "emonpiemoncmsmysql2016" 9 | ; Skip database setup test - set to false once database has been setup. 10 | dbtest = true 11 | 12 | [redis] 13 | enabled = true 14 | prefix = '' 15 | 16 | [mqtt] 17 | enabled = true 18 | user = 'emonpi' 19 | password = 'emonpimqtt2016' 20 | 21 | [feed] 22 | engines_hidden = [0,6,10] 23 | redisbuffer[enabled] = true 24 | redisbuffer[sleep] = 300 25 | phpfina[datadir] = 'EMONCMS_DATADIR/phpfina/' 26 | phptimeseries[datadir] = 'EMONCMS_DATADIR/phptimeseries/' 27 | 28 | [interface] 29 | enable_admin_ui = true 30 | feedviewpath = "graph/" 31 | favicon = "favicon_emonpi.png" 32 | 33 | [log] 34 | ; Log Level: 1=INFO, 2=WARN, 3=ERROR 35 | level = 2 36 | -------------------------------------------------------------------------------- /defaults/etc/cron.daily/logrotate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # test -x /usr/sbin/logrotate || exit 0 4 | # /usr/sbin/logrotate /etc/logrotate.conf 5 | 6 | # logrotate now triggered by log2ram 7 | # see /etc/cron.hourly/log2ram 8 | -------------------------------------------------------------------------------- /defaults/etc/cron.hourly/log2ram: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | test -x /usr/sbin/logrotate || exit 0 4 | # /usr/sbin/logrotate -v -s /var/log/logrotate/logrotate.status /etc/logrotate.conf 2>&1 | tee /var/log/logrotate/logrotate.log 5 | /usr/sbin/logrotate -v -s /var/log/logrotate/logrotate.status /etc/logrotate.conf >> /var/log/logrotate/logrotate.log 2>&1 6 | 7 | systemctl reload log2ram 8 | 9 | -------------------------------------------------------------------------------- /defaults/etc/fstab: -------------------------------------------------------------------------------- 1 | proc /proc proc defaults 0 0 2 | /dev/mmcblk0p1 /boot/firmware vfat defaults 0 2 3 | /dev/mmcblk0p2 / ext4 defaults,noatime,nodiratime 0 1 4 | /dev/mmcblk0p3 /var/opt/emoncms ext2 defaults,noatime,nodiratime 0 2 5 | # a swapfile is not a swap partition, no line here 6 | # use dphys-swapfile swap[on|off] for that 7 | 8 | tmpfs /tmp tmpfs nodev,nosuid,size=30M,mode=1777 0 0 9 | tmpfs /var/tmp tmpfs nodev,nosuid,size=128M,mode=1777 0 0 10 | tmpfs /var/lib/php/sessions tmpfs nodev,nosuid,size=1M,mode=1777 0 0 11 | 12 | -------------------------------------------------------------------------------- /defaults/etc/logrotate.d/00_defaults: -------------------------------------------------------------------------------- 1 | maxsize 250k -------------------------------------------------------------------------------- /defaults/etc/logrotate.d/emoncms: -------------------------------------------------------------------------------- 1 | /var/log/emoncms/*.log { 2 | maxsize 3M 3 | compress 4 | olddir /var/log.old/emoncms 5 | createolddir 775 root root 6 | renamecopy 7 | } 8 | -------------------------------------------------------------------------------- /defaults/etc/logrotate.d/emoncms-non-emonsd: -------------------------------------------------------------------------------- 1 | /var/log/emoncms/*.log { 2 | rotate 7 3 | daily 4 | compress 5 | copytruncate 6 | size 3M 7 | nocreate 8 | missingok 9 | notifempty 10 | delaycompress 11 | } 12 | -------------------------------------------------------------------------------- /defaults/etc/logrotate.d/emonhub: -------------------------------------------------------------------------------- 1 | /var/log/emonhub/emonhub.log { 2 | maxsize 3M 3 | compress 4 | olddir /var/log.old/emonhub 5 | createolddir 775 root root 6 | renamecopy 7 | } 8 | -------------------------------------------------------------------------------- /defaults/etc/logrotate.d/logrotate: -------------------------------------------------------------------------------- 1 | /var/log/logrotate/*.log { 2 | rotate 7 3 | daily 4 | compress 5 | nocreate 6 | missingok 7 | notifempty 8 | delaycompress 9 | } -------------------------------------------------------------------------------- /defaults/etc/rc.local: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # rc.local 4 | # 5 | # This script is executed at the end of each multiuser runlevel. 6 | # Make sure that the script will "exit 0" on success or any other 7 | # value on error. 8 | # 9 | # In order to enable or disable this script just change the execution 10 | # bits. 11 | # 12 | # By default this script does nothing. 13 | 14 | # Print the IP address 15 | _IP=$(hostname -I) || true 16 | if [ "$_IP" ]; then 17 | printf "My IP address is %s\n" "$_IP" 18 | fi 19 | 20 | # Update emonpi on first boot if applicable 21 | # su pi -c '/opt/openenergymonitor/EmonScripts/update/firstbootupdate' 22 | 23 | # Available here for backwards compatibility with old images 24 | # Newer images will start the access point from the wifi-check cron task 25 | if [ ! -d /opt/emoncms/modules/network ]; then 26 | if [ -f /opt/openenergymonitor/emonpi/wifiAP/startAP.sh ]; then 27 | # Start wifi AP if applicable 28 | /opt/openenergymonitor/emonpi/wifiAP/startAP.sh >> /var/log/wifiAP.log 29 | fi 30 | else 31 | if [ -f /opt/emoncms/modules/network/scripts/wifi-check ]; then 32 | /opt/emoncms/modules/network/scripts/wifi-check 33 | fi 34 | fi 35 | 36 | exit 0 37 | 38 | -------------------------------------------------------------------------------- /defaults/readme.md: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------- 2 | # Welcome to your emonPi/emonBase 3 | # -------------------------------------------------------------- 4 | 5 | This image was built using the EmonScripts installation scripts: 6 | https://github.com/openenergymonitor/EmonScripts 7 | 8 | You can find the emonSD software stack installed in the following primary locations: 9 | 10 | # /opt/openenergymonitor 11 | Contains software installed from github.com/openenergymonitor. 12 | Including: EmonScripts, emonpi, emonhub, RFM2Pi & avrdude 13 | 14 | # /opt/emoncms/modules 15 | Contains symlinked emoncms modules installed from github.com/emoncms 16 | Including: demandshaper, sync, backup, postprocess, usefulscripts 17 | 18 | # /var/www/emoncms 19 | Contains the emoncms web application and modules installed directly 20 | 21 | # /var/opt/emoncms 22 | Contains emoncms feed data, including PHPFina & PHPTimeSeries 23 | -------------------------------------------------------------------------------- /docs/developer.md: -------------------------------------------------------------------------------- 1 | # Developer Notes on EmonScripts 2 | 3 | These notes are to explain why certain things have been done as they are done! 4 | 5 | ## Creating the SD Image 6 | 7 | The SD Image is created primarily for user of the emonPi. 8 | 9 | 1\. Before creating a stable release of `EmonScripts`, update the `main.sh` file with the new image name 10 | 11 | [sudo touch /boot/emonSD-DDMMMYY](https://github.com/openenergymonitor/EmonScripts/blob/a7c03955f8e2450cdedbaac34e9410188d3eb818/install/main.sh#L102) 12 | 13 | 2\. Run `EmonScripts` with defaults. 14 | 15 | 3\. After running the EmonScripts, reboot. 16 | 17 | 4\. Set WiFi country code via `raspi-config` 18 | 19 | ```shell 20 | sudo raspi-config 21 | ``` 22 | 23 | 5\. Prepare wifiAP 24 | 25 | ```shell 26 | sudo systemctl disable hostapd.service 27 | sudo wifiAP start 28 | sudo reboot 29 | ``` 30 | 31 | 6\. Remove emoncms logs. `emonpiupdate.log` will be present, remove to ensure emonpifirstupdate runs next time. 32 | 33 | ```shell 34 | sudo rm /var/log/emoncms/emonpiupdate.log 35 | sudo rm /var/log/emoncms/emonupdate.log 36 | sudo rm /var/log/emoncms/emoncms.log 37 | ``` 38 | 39 | 7\. Disable SSH 40 | 41 | ```shell 42 | sudo update-rc.d ssh disable 43 | sudo invoke-rc.d ssh stop 44 | sudo dpkg-reconfigure openssh-server 45 | ``` 46 | 47 | 8\. Check that emonpiupdate.log has been removed before creating image. 48 | 49 | 9\. Update the Image name `emonSD-DDMMMYY` file on boot partition and in safe-update list on master branch. 50 | 51 | 10\. Create image 52 | 53 | ```shell 54 | sudo dd if=/dev/sdb of=emonSD-17Oct19.img bs=4M 55 | ``` 56 | 57 | ## Logs, `journald` and `logrotate` 58 | 59 | ### Why is it important 60 | 61 | It was suspected that the writing of the logs was having an impact on the life of the SD Card. Several mechanisms were put in place to reduce that write load, primarily the use of placing the log folder into RAM as opposed to disc. each write is then to a RAM file not an SD Card file. It was subsequently acknowledged that having a persistent form of logs was benificial so `log2ram` was introduced. With this brought a need to ensure `logrotate` worked for all logs and worked correctly. Finally, `journald` must also write to RAM. 62 | 63 | ### Principle - use drop-in files 64 | 65 | Adding to the standard configuration file is **always** a bad idea. As we do for other configuration changes, add in a drop-in to the `conf.d` folder and add the command to read it. From the `systemd` man (but they all say the same); 66 | 67 | ```shell 68 | When packages need to customize the configuration, they can install configuration snippets in /usr/lib/systemd/*.conf.d/ or /usr/local/lib/systemd/*.conf.d/. The main configuration file is read before any of the configuration directories, and has the lowest precedence; 69 | ``` 70 | 71 | In the Emonscripts folder `opt/openenergymonitor/EmonScripts/defaults/etc/logrotate` are a number of drop in files that are linked to from the `/etc/logrotate.d/` folder. If they need updating the update process replaces these files so logrotate will pick them up automatically. 72 | 73 | ### Changes to logrotate package 74 | 75 | A number of changes to the logrotate package have required the config files to be updated. 76 | 77 | `logrotate` should alos be run hourly by updating the `systemd` `timer`. 78 | 79 | ### `journald` changes 80 | 81 | TL:DR - by default in Bullseye `journald` writes to disk. To stop this delete the `/var/log/journal` file and it reverts to writing the log to RAM. 82 | 83 | There was an issue with `journald` - by default it is set to `auto` but a `/var/log/journal` folder is created somewhere along the line on first boot, so the journal is saved to disk. 84 | 85 | this question provides some insight. [Stackoverflow Question](https://unix.stackexchange.com/questions/513212/journald-storage-persistent-just-disk-or-ram-disk) 86 | 87 | You can see what files are in use using this command: 88 | 89 | ```shell 90 | journalctl --unit=systemd-journald --boot 0 --output cat 91 | ``` 92 | 93 | There may be some advantage to saving the `journal` files as they do contain some good info on occasions, however, `ForwardToSyslog=yes` is enabled by default and we preserve this. 94 | 95 | By default `journald` will use 10% of the available space. 96 | -------------------------------------------------------------------------------- /docs/digital-ocean-install.md: -------------------------------------------------------------------------------- 1 | # Installation on a DigitalOcean droplet 2 | 3 | **Note:** For a single user with moderate use, a small VM on a cloud service is likely plenty of performance for an emoncms installation. For applications with a large number of users and feeds the performance of emoncms will depend a lot on how the cloud provider implements storage. Networked disk drives will result in slow performance due to the network latency associated with the way the emoncms feed engines are implemented. VM's on machines with local storage should provide much better performance. 4 | 5 | 1. Click on 'Create' to create a new cloud server 6 | 1. Select Ubuntu, standard $5/month, region e.g London then Create Droplet 7 | 1. DigitalOcean email root login details, ssh in using these credentials. 8 | 1. Change root password 9 | 1. Follow [Initial Server Setup with Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04) 10 | 11 | ```shell 12 | adduser oem 13 | usermod -aG sudo oem 14 | ufw allow OpenSSH 15 | ufw enable 16 | ``` 17 | 18 | logout of root and login with oem. 19 | 20 | 1. Disable root login: 21 | 22 | ```shell 23 | sudo nano /etc/ssh/sshd_config 24 | PermitRootLogin no 25 | sudo service ssh restart 26 | ``` 27 | 28 | 1. Allow created user to run sudo without password. 29 | 30 | ```shell 31 | sudo visudo 32 | ``` 33 | 34 | Add to end of visudo file: 35 | 36 | ```shell 37 | oem ALL=(ALL) NOPASSWD:ALL 38 | ``` 39 | 40 | Save and exit. 41 | 42 | 1. Start the script 43 | 44 | ```shell 45 | wget https://raw.githubusercontent.com/openenergymonitor/EmonScripts/master/install/init.sh 46 | chmod +x init.sh 47 | ./init.sh 48 | ``` 49 | 50 | 1. Modify config.ini for non emonSD installation. 51 | 52 | Disable emonhub installation 53 | 54 | ```shell 55 | install_emonhub=false 56 | ``` 57 | 58 | Disable firmware, emonpilcd, emonsd, wifiap installation 59 | 60 | ```shell 61 | install_firmware=false 62 | install_emonpilcd=false 63 | install_emonsd=false 64 | install_wifiap=false 65 | Set user as applicable and set emonSD_pi_env=0 66 | ``` 67 | 68 | ```shell 69 | user=oem 70 | hostname=emonpi 71 | emonSD_pi_env=0 72 | ``` 73 | 74 | Comment out config, wifi and setup module: 75 | 76 | ```shell 77 | #emoncms_emonpi_modules[config]=stable 78 | #emoncms_emonpi_modules[wifi]=stable 79 | #emoncms_emonpi_modules[setup]=stable 80 | ``` 81 | 82 | 1. Run main installation script: 83 | 84 | ```shell 85 | ./main.sh 86 | ``` 87 | 88 | 1. Allow access to port 80 in firewall: 89 | 90 | ```shell 91 | sudo ufw allow 80/tcp 92 | ``` 93 | -------------------------------------------------------------------------------- /docs/download.md: -------------------------------------------------------------------------------- 1 | # emonSD Download 2 | 3 | emonSD is a pre-built SD card image for the Raspberry Pi to function as an OpenEnergyMonitor emonPi / emonBase. The image is available for download below or if you need a new SD card we also offer industrial grade SD cards with the image pre-loaded [in the shop](https://shop.openenergymonitor.com/emonsd-industrial-pre-loaded-sd-card/). 4 | 5 | --- 6 | 7 |
8 | emonSD-01Feb24 9 | 10 | **Download (1.4 GB):** [UK Server](https://openenergymonitor.org/files/emonSD-01Feb24.zip) 11 | 12 | (eligible for updates) 13 | ``` 14 | (.zip) MD5: b64503d08704d1605a7ea23745f0a6fc 15 | ``` 16 | 17 | **Credentials** 18 | 19 | - **Local Emoncms:** username `emonsd`, password `emonsd` 20 | - **SSH:** username: `pi`, password: `emonsd` (default - please change) 21 | - **WiFi Access Point:** SSID: `emonpi`, Password: `emonpi2016` 22 | - **MQTT:** username: `emonpi`, password: `emonpimqtt2016` 23 | - **MySQL:** username: `emoncms`, password: `emonpiemoncmsmysql2016` 24 | 25 | *SSH access disabled by default. Long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition.* 26 | 27 | **Build** 28 | 29 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 30 | - Based on Raspberry Pi OS Lite (32-bit Bookworm), 2023-12-11 31 | - Compatible with Raspberry Pi 3, 3B+, 4 & Pi Zero2 32 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 33 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 34 | 35 | **Kernel** 36 | ``` 37 | $ uname -a 38 | Linux emonpi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux 39 | ``` 40 | 41 | **File System** 42 | ``` 43 | $ df -h 44 | Filesystem Size Used Avail Use% Mounted on 45 | udev 661M 0 661M 0% /dev 46 | tmpfs 185M 4.3M 181M 3% /run 47 | /dev/mmcblk0p2 4.4G 3.0G 1.3G 71% / 48 | tmpfs 925M 0 925M 0% /dev/shm 49 | tmpfs 5.0M 16K 5.0M 1% /run/lock 50 | tmpfs 30M 28K 30M 1% /tmp 51 | tmpfs 1.0M 0 1.0M 0% /var/lib/php/sessions 52 | tmpfs 128M 0 128M 0% /var/tmp 53 | /dev/mmcblk0p1 510M 93M 418M 19% /boot/firmware 54 | /dev/mmcblk0p3 9.7G 19K 9.2G 1% /var/opt/emoncms 55 | log2ram 50M 824K 50M 2% /var/log 56 | tmpfs 185M 0 185M 0% /run/user/1000 57 | ``` 58 | 59 | **Emoncms** 60 | 61 | ``` 62 | Server Information 63 | ----------------------- 64 | 65 | Services 66 | emonhub : Active Running 67 | emoncms_mqtt : Active Running 68 | feedwriter : Active Running - sleep 300s 0 feed points pending write 69 | service-runner : Active Running 70 | emonPiLCD : Active Running 71 | redis-server : Active Running 72 | mosquitto : Active Running 73 | demandshaper : Not found or not installed 74 | Emoncms 75 | Version : low-write 11.4.11 76 | Git : 77 | URL : https://github.com/emoncms/emoncms.git 78 | Branch : * stable 79 | Describe : 11.4.11 80 | Components : Emoncms Core v11.4.11 | App v2.8.1 | EmonHub Config v2.1.5 | Dashboard v2.3.3 | Device v2.2.3 | Graph v2.2.3 | Network Setup v1.0.5 | Backup v2.3.3 | Network v3.1.2 | Postprocess v2.4.7 | Sync v2.1.5 | Usefulscripts v2.3.11 | EmonScripts v1.7.10 | RFM2Pi v1.4.2 | Avrdude-rpi v1.0.3 | EmonPiLCD v2.0.1 | Emonhub v2.6.5 81 | 82 | Server 83 | CPU : Cortex-A72 | 1 Threads(s) | - Sockets(s) | 108.00MIPS | 84 | OS : Linux 6.1.0-rpi8-rpi-v8 85 | Host : emonpi | emonpi | (192.168.42.1) 86 | Date : 2024-02-01 15:59:51 UTC 87 | Uptime : 15:59:51 up 20 min, 1 user, load average: 0.03, 0.04, 0.04 88 | 89 | Memory 90 | RAM : Used: 14.09% 91 | Total : 1.8 GB 92 | Used : 260.43 MB 93 | Free : 1.55 GB 94 | Swap : Used: 0.00% 95 | Total : 100 MB 96 | Used : 0 B 97 | Free : 100 MB 98 | 99 | Disk 100 | : - / : Used: 66.84% 101 | Total : 4.39 GB 102 | Used : 2.94 GB 103 | Free : 1.24 GB 104 | Read Load : n/a 105 | Write Load : n/a 106 | Load Time : n/a 107 | /boot/firmware : Used: 18.07% 108 | Total : 509.99 MB 109 | Used : 92.17 MB 110 | Free : 417.83 MB 111 | Read Load : n/a 112 | Write Load : n/a 113 | Load Time : n/a 114 | /var/opt/emoncms : Used: 0.00% 115 | Total : 9.68 GB 116 | Used : 19 KB 117 | Free : 9.19 GB 118 | Read Load : n/a 119 | Write Load : n/a 120 | Load Time : n/a 121 | /var/log : Used: 1.63% 122 | Total : 50 MB 123 | Used : 836 KB 124 | Free : 49.18 MB 125 | Read Load : n/a 126 | Write Load : n/a 127 | Load Time : n/a 128 | 129 | HTTP 130 | Server : Apache/2.4.57 (Raspbian) HTTP/1.1 CGI/1.1 80 131 | 132 | MySQL 133 | Version : 10.11.3-MariaDB-1+rpi1 134 | Host : 127.0.0.1 (127.0.0.1) 135 | Date : 2024-02-01 15:59:51 (UTC 00:00‌​) 136 | Stats : Uptime: 1232 Threads: 6 Questions: 281 Slow queries: 0 Opens: 46 Open tables: 39 Queries per second avg: 0.228 137 | 138 | Redis 139 | Version : 140 | Redis Server : 7.0.11 141 | PHP Redis : 6.0.3-dev 142 | Host : localhost:6379 143 | Size : 52 keys (1.01M) 144 | Uptime : 0 days 145 | 146 | MQTT Server 147 | Version : Mosquitto 2.0.11 148 | Host : localhost:1883 (127.0.0.1) 149 | 150 | PHP 151 | Version : 8.1.27 (Zend Version 4.1.27) 152 | Run user : User: www-data Group: www-data video Script Owner: pi 153 | Modules : apache2handler calendar Core ctype curl date exif FFI fileinfo filter ftp gd gettext hash iconv json libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 8.1.27openssl pcre PDO pdo_mysql Phar posix readline redis v6.0.3-devReflection session shmop sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer Zend OPcache zlib 154 | Pi 155 | Model : Raspberry Pi Model N/A Rev - () 156 | Serial num. : - CPU Temperature : 39.43°C 157 | GPU Temperature : N/A (to show GPU temp execute this command from the console "sudo usermod -G video www-data" ) 158 | emonpiRelease : emonSD-01Feb24 159 | File-system : read-write 160 | 161 | Client Information 162 | ----------------------- 163 | 164 | HTTP 165 | Browser : Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0 166 | Language : en-GB,en;q=0.5 167 | 168 | Window 169 | Size : 1856 x 968 170 | 171 | Screen 172 | Resolution : 1920 x 1080 173 | ``` 174 | 175 |
176 | 177 |
178 | emonSD-20Nov23 179 | 180 | --- 181 | 182 | **Download standard emonPi1 / emonBase image (1.3 GB):** [UK Server](https://openenergymonitor.org/files/emonSD-20Nov23.zip)
(MD5: ed9ecc0d8930d7f7422890e462b3020c) 183 | 184 | --- 185 | 186 | *Download emonPi2 version (1.3 GB): [UK Server](https://openenergymonitor.org/files/emonSD-20Nov23-emonpi2.zip)
(MD5: 164899034638325952572dbe68f3285e)
Includes emonPi2 compatible emonhub.conf and one wire temperature sensing on GPIO17 is enabled. Download the emonPi1/emonBase image for existing installations.* 187 | 188 | --- 189 | 190 | (eligible for updates) 191 | 192 | **Credentials** 193 | 194 | - **SSH:** username: `pi`, password: `emonsd` (default - please change) 195 | - **WiFi Access Point:** SSID: `emonpi`, Password: `emonpi2016` 196 | - **MQTT:** username: `emonpi`, password: `emonpimqtt2016` 197 | - **MySQL:** username: `emoncms`, password: `emonpiemoncmsmysql2016` 198 | 199 | *SSH access disabled by default. Long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition.* 200 | 201 | **Build** 202 | 203 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 204 | - Based on Debian Raspberry Pi OS (64-bit) Legacy Lite, 2023-05-03 205 | - Compatible with Raspberry Pi 3, 3B+, 4 & Pi Zero2 206 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 207 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 208 | 209 | **Kernel** 210 | ``` 211 | $ uname -a 212 | Linux emonpi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux 213 | 214 | ``` 215 | **File System** 216 | ``` 217 | $ df -h 218 | Filesystem Size Used Avail Use% Mounted on 219 | /dev/root 5.7G 2.5G 3.0G 46% / 220 | devtmpfs 667M 0 667M 0% /dev 221 | tmpfs 925M 0 925M 0% /dev/shm 222 | tmpfs 370M 5.8M 365M 2% /run 223 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 224 | tmpfs 30M 0 30M 0% /tmp 225 | tmpfs 1.0M 0 1.0M 0% /var/lib/php/sessions 226 | tmpfs 1.0M 0 1.0M 0% /var/tmp 227 | /dev/mmcblk0p1 255M 51M 205M 20% /boot 228 | /dev/mmcblk0p3 8.7G 23K 8.3G 1% /var/opt/emoncms 229 | log2ram 50M 3.0M 47M 6% /var/log 230 | tmpfs 185M 0 185M 0% /run/user/1000 231 | ``` 232 | **Emoncms** 233 | 234 | ``` 235 | Server Information 236 | ----------------------- 237 | 238 | Services 239 | emonhub : Active Running 240 | emoncms_mqtt : Active Running 241 | feedwriter : Active Running - sleep 300s 0 feed points pending write 242 | service-runner : Active Running 243 | emonPiLCD : Active Running 244 | redis-server : Active Running 245 | mosquitto : Active Running 246 | demandshaper : Not found or not installed 247 | Emoncms 248 | Version : low-write 11.4.2 249 | Git : 250 | URL : https://github.com/emoncms/emoncms.git 251 | Branch : * stable 252 | Describe : 11.4.2 253 | Components : Emoncms Core v11.4.2 | App v2.7.9 | EmonHub Config v2.1.5 | Dashboard v2.3.3 | Device v2.2.3 | Graph v2.2.3 | Network Setup v1.0.2 | WiFi v2.1.1 | Backup v2.3.3 | Postprocess v2.4.7 | Sync v2.1.5 | Usefulscripts v2.3.11 | EmonScripts v1.6.25 | RFM2Pi v1.4.2 | Avrdude-rpi v1.0.3 | Emonhub v2.6.2 | EmonPi v3.0.2 254 | 255 | Server 256 | CPU : 1 Threads(s) | 4 Core(s) | 1 Sockets(s) | Cortex-A72 | 108.00MIPS | 257 | OS : Linux 6.1.21-v8+ 258 | Host : emonpi | emonpi | (10.0.206.98) 259 | Date : 2023-11-21 13:46:54 UTC 260 | Uptime : 13:46:54 up 5 min, 1 user, load average: 0.10, 0.13, 0.07 261 | 262 | Memory 263 | RAM : Used: 12.57% 264 | Total : 1.81 GB 265 | Used : 232.36 MB 266 | Free : 1.58 GB 267 | Swap : Used: 0.00% 268 | Total : 100 MB 269 | Used : 0 B 270 | Free : 100 MB 271 | 272 | Disk 273 | : - / : Used: 43.43% 274 | Total : 5.62 GB 275 | Used : 2.44 GB 276 | Free : 2.92 GB 277 | Read Load : 336.44 KB/s 278 | Write Load : 0 B/s 279 | Load Time : 0 mins 280 | /boot : Used: 19.77% 281 | Total : 254.99 MB 282 | Used : 50.42 MB 283 | Free : 204.57 MB 284 | Read Load : 0 B/s 285 | Write Load : 0 B/s 286 | Load Time : 0 mins 287 | /var/opt/emoncms : Used: 0.00% 288 | Total : 8.69 GB 289 | Used : 23 KB 290 | Free : 8.25 GB 291 | Read Load : 0 B/s 292 | Write Load : 113.78 B/s 293 | Load Time : 0 mins 294 | /var/log : Used: 6.01% 295 | Total : 50 MB 296 | Used : 3 MB 297 | Free : 47 MB 298 | Read Load : n/a 299 | Write Load : n/a 300 | Load Time : n/a 301 | 302 | HTTP 303 | Server : Apache/2.4.56 (Raspbian) HTTP/1.1 CGI/1.1 80 304 | 305 | MySQL 306 | Version : 10.5.21-MariaDB-0+deb11u1 307 | Host : 127.0.0.1 (127.0.0.1) 308 | Date : 2023-11-21 13:46:53 (UTC 00:00‌​) 309 | Stats : Uptime: 2768 Threads: 7 Questions: 170 Slow queries: 0 Opens: 45 Open tables: 38 Queries per second avg: 0.061 310 | 311 | Redis 312 | Version : 313 | Redis Server : 6.0.16 314 | PHP Redis : 6.0.3-dev 315 | Host : localhost:6379 316 | Size : 73 keys (722.77K) 317 | Uptime : 0 days 318 | 319 | MQTT Server 320 | Version : Mosquitto 2.0.11 321 | Host : localhost:1883 (127.0.0.1) 322 | 323 | PHP 324 | Version : 8.1.25 (Zend Version 4.1.25) 325 | Run user : User: www-data Group: www-data video Script Owner: pi 326 | Modules : apache2handler calendar Core ctype curl date exif FFI fileinfo filter ftp gd gettext hash iconv json libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 8.1.25openssl pcre PDO pdo_mysql Phar posix readline redis v6.0.3-devReflection session shmop sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer Zend OPcache zlib 327 | Pi 328 | Model : Raspberry Pi 4 Model B Rev 1.5 - 2GB (Sony UK) 329 | Serial num. : 100000003F81AAAB 330 | CPU Temperature : 36.51°C 331 | GPU Temperature : N/A (to show GPU temp execute this command from the console "sudo usermod -G video www-data" ) 332 | emonpiRelease : emonSD-20Nov23 333 | File-system : read-write 334 | 335 | Client Information 336 | ----------------------- 337 | 338 | HTTP 339 | Browser : Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0 340 | Language : en-GB,en;q=0.5 341 | 342 | Window 343 | Size : 1848 x 938 344 | 345 | Screen 346 | Resolution : 1920 x 1080 347 | ``` 348 |
349 | 350 |
351 | emonSD-10Nov22 352 |
353 | 354 | 355 | **Download (1.0 GB):** [UK Server](https://openenergymonitor.org/files/emonSD-10Nov22_16gb.zip) 356 | 357 | (eligible for updates) 358 | ``` 359 | (.zip) MD5: 271d8d502e822e3703500a5762519c1d 360 | ``` 361 | 362 | **Credentials** 363 | 364 | - **SSH:** username: `pi`, password: `emonsd` (default - please change) 365 | - **WiFi Access Point:** SSID: `emonsd`, Password: `emonsd2022` 366 | - **MQTT:** username: `emonpi`, password: `emonpimqtt2016` 367 | - **MySQL:** username: `emoncms`, password: `emonpiemoncmsmysql2016` 368 | 369 | *SSH access disabled by default. Long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition.* 370 | 371 | **Build** 372 | 373 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 374 | - Based on Debian Raspberry Pi OS (32-bit) Lite, 2021-03-04 375 | - Compatible with Raspberry Pi 2, 3, 3B+, 4 & Pi Zero 376 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 377 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 378 | 379 | **Kernel** 380 | ``` 381 | $ uname -a 382 | Linux emonpi 5.15.76-v7l+ #1597 SMP Fri Nov 4 12:14:58 GMT 2022 armv7l GNU/Linux 383 | 384 | ``` 385 | **File System** 386 | ``` 387 | $ df -h 388 | Filesystem Size Used Avail Use% Mounted on 389 | /dev/root 5.8G 2.4G 3.2G 43% / 390 | devtmpfs 776M 0 776M 0% /dev 391 | tmpfs 937M 0 937M 0% /dev/shm 392 | tmpfs 375M 9.2M 366M 3% /run 393 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 394 | tmpfs 30M 0 30M 0% /tmp 395 | tmpfs 1.0M 0 1.0M 0% /var/lib/php/sessions 396 | tmpfs 1.0M 0 1.0M 0% /var/tmp 397 | /dev/mmcblk0p1 255M 50M 206M 20% /boot 398 | /dev/mmcblk0p3 9.7G 19K 9.2G 1% /var/opt/emoncms 399 | log2ram 50M 3.4M 47M 7% /var/log 400 | tmpfs 188M 0 188M 0% /run/user/1000 401 | ``` 402 | **Emoncms** 403 | 404 | ``` 405 | Server Information 406 | ----------------------- 407 | 408 | Services 409 | emonhub : Active Running 410 | emoncms_mqtt : Active Running 411 | feedwriter : Active Running - sleep 300s 0 feed points pending write 412 | service-runner : Active Running 413 | redis-server : Active Running 414 | mosquitto : Active Running 415 | emonPiLCD : Failed loaded failed failed 416 | demandshaper : Not found or not installed 417 | Emoncms 418 | Version : low-write 11.2.8 419 | Git : 420 | URL : https://github.com/emoncms/emoncms.git 421 | Branch : * stable 422 | Describe : 11.2.8 423 | Components : Emoncms Core v11.2.8 | App v2.6.8 | EmonHub Config v2.1.5 | Dashboard v2.3.3 | Device v2.2.1 | Graph v2.2.3 | Network Setup v1.0.2 | WiFi v2.1.1 | Backup v2.3.2 | Postprocess v2.2.7 | Sync v2.1.4 | Usefulscripts v2.3.10 | EmonScripts v1.5.10 | RFM2Pi v1.4.1 | Avrdude-rpi v1.0.1 | Emonhub v2.5.2 | EmonPi v2.9.5 424 | 425 | Server 426 | CPU : 1 Threads(s) | 4 Core(s) | 1 Sockets(s) | Cortex-A72 | 324.00MIPS | 427 | OS : Linux 5.15.76-v7l+ 428 | Host : emonpi | emonpi | (10.0.206.190) 429 | Date : 2022-11-29 15:55:08 UTC 430 | Uptime : 15:55:08 up 13 min, 1 user, load average: 0.33, 0.26, 0.19 431 | 432 | Memory 433 | RAM : Used: 10.18% 434 | Total : 1.83 GB 435 | Used : 190.7 MB 436 | Free : 1.64 GB 437 | Swap : Used: 0.00% 438 | Total : 100 MB 439 | Used : 0 B 440 | Free : 100 MB 441 | 442 | Disk 443 | : - / : Used: 39.88% 444 | Total : 5.78 GB 445 | Used : 2.3 GB 446 | Free : 3.16 GB 447 | Read Load : n/a 448 | Write Load : n/a 449 | Load Time : n/a 450 | /boot : Used: 19.52% 451 | Total : 254.99 MB 452 | Used : 49.78 MB 453 | Free : 205.21 MB 454 | Read Load : n/a 455 | Write Load : n/a 456 | Load Time : n/a 457 | /var/opt/emoncms : Used: 0.00% 458 | Total : 9.61 GB 459 | Used : 19 KB 460 | Free : 9.12 GB 461 | Read Load : n/a 462 | Write Load : n/a 463 | Load Time : n/a 464 | /var/log : Used: 6.64% 465 | Total : 50 MB 466 | Used : 3.32 MB 467 | Free : 46.68 MB 468 | Read Load : n/a 469 | Write Load : n/a 470 | Load Time : n/a 471 | 472 | HTTP 473 | Server : Apache/2.4.54 (Raspbian) HTTP/1.1 CGI/1.1 80 474 | 475 | MySQL 476 | Version : 10.5.15-MariaDB-0+deb11u1 477 | Host : 127.0.0.1 (127.0.0.1) 478 | Date : 2022-11-29 15:55:08 (UTC 00:00‌​) 479 | Stats : Uptime: 2266 Threads: 5 Questions: 137 Slow queries: 0 Opens: 47 Open tables: 39 Queries per second avg: 0.060 480 | 481 | Redis 482 | Version : 483 | Redis Server : 6.0.16 484 | PHP Redis : 6.0.0-dev 485 | Host : localhost:6379 486 | Size : 34 keys (701.23K) 487 | Uptime : 0 days 488 | 489 | MQTT Server 490 | Version : Mosquitto 2.0.11 491 | Host : localhost:1883 (127.0.0.1) 492 | 493 | PHP 494 | Version : 8.1.12 (Zend Version 4.1.12) 495 | Run user : User: www-data Group: www-data video Script Owner: pi 496 | Modules : apache2handler calendar Core ctype curl date dom v20031129exif FFI fileinfo filter ftp gd gettext hash iconv json libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 8.1.12openssl pcre PDO pdo_mysql Phar posix readline redis v6.0.0-devReflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zlib 497 | Pi 498 | Model : Raspberry Pi 4 Model B Rev 1.5 - 2GB (Sony UK) 499 | Serial num. : 10000000014CB367 500 | CPU Temperature : 39.43°C 501 | GPU Temperature : N/A (to show GPU temp execute this command from the console "sudo usermod -G video www-data" ) 502 | emonpiRelease : emonSD-10Nov22 503 | File-system : read-write 504 | 505 | Client Information 506 | ----------------------- 507 | 508 | HTTP 509 | Browser : Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:107.0) Gecko/20100101 Firefox/107.0 510 | Language : en-GB,en;q=0.5 511 | 512 | Window 513 | Size : 1848 x 939 514 | 515 | Screen 516 | Resolution : 1920 x 1080 517 | ``` 518 |
519 | 520 |
521 | emonSD-21Jul21 522 |
523 | 524 | **Download (1.8 GB):** [UK Server](https://openenergymonitor.org/files/emonSD-21Jul21.zip) 525 | 526 | (eligible for updates) 527 | ``` 528 | (.zip) MD5: 1bf5988a61ae363768362dcfdb6b0190 529 | ``` 530 | 531 | - **SSH Credentials:** username: pi, password: emonpi2016 (default - please change) 532 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 533 | - Based on Debian Raspberry Pi OS (32-bit) Lite, 2021-03-04 534 | - Compatible with Raspberry Pi 2, 3, 3B+, 4 & Pi Zero 535 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 536 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 537 | - [SSH access disabled by default](https://community.openenergymonitor.org/t/emonpi-ssh-disabled-by-default/8847), long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition. 538 | 539 | **Kernel** 540 | ``` 541 | $ uname -a 542 | Linux emonpi 5.10.17-v7+ #1421 SMP Thu May 27 13:59:01 BST 2021 armv7l GNU/Linux 543 | 544 | $ sudo /opt/vc/bin/vcgencmd version 545 | May 27 2021 14:04:13 546 | Copyright (c) 2012 Broadcom 547 | version 7d9a298cda813f747b51fe17e1e417e7bf5ca94d (clean) (release) (start) 548 | 549 | ``` 550 | **File System** 551 | ``` 552 | $ df -h 553 | Filesystem Size Used Avail Use% Mounted on 554 | /dev/root 4.1G 2.1G 1.9G 52% / 555 | devtmpfs 430M 0 430M 0% /dev 556 | tmpfs 463M 0 463M 0% /dev/shm 557 | tmpfs 463M 47M 416M 11% /run 558 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 559 | tmpfs 463M 0 463M 0% /sys/fs/cgroup 560 | tmpfs 30M 0 30M 0% /tmp 561 | tmpfs 1.0M 0 1.0M 0% /var/tmp 562 | tmpfs 1.0M 4.0K 1020K 1% /var/lib/php/sessions 563 | /dev/mmcblk0p3 9.9G 1.8G 7.6G 20% /var/opt/emoncms 564 | /dev/mmcblk0p1 253M 48M 205M 19% /boot 565 | log2ram 50M 4.2M 46M 9% /var/log 566 | tmpfs 93M 0 93M 0% /run/user/1000 567 | 568 | ``` 569 | **Emoncms** 570 | 571 | ``` 572 | Server Information 573 | ----------------------- 574 | 575 | Services 576 | emonhub : Active Running 577 | emoncms_mqtt : Active Running 578 | feedwriter : Active Running - sleep 300s 0 feed points pending write 579 | service-runner : Active Running 580 | emonPiLCD : Failed Failed 581 | redis-server : Active Running 582 | mosquitto : Active Running 583 | demandshaper : Active Running 584 | Emoncms 585 | Version : low-write 10.8.1 586 | Git : 587 | URL : https://github.com/emoncms/emoncms.git 588 | Branch : * stable 589 | Describe : 10.8.1 590 | Components : Emoncms Core v10.8.1 | App v2.3.2 | EmonHub Config v2.1.1 | Dashboard v2.1.5 | Device v2.1.2 | Graph v2.1.1 | Network Setup v1.0.2 | WiFi v2.1.0 | Backup v2.3.2 | DemandShaper v2.2.2 | Postprocess v2.2.2 | Sync v2.1.1 | Usefulscripts v2.3.7 | EmonScripts v1.3.9 | RFM2Pi v1.4.1 | Avrdude-rpi v1.0.0 | Emonhub v2.3.1 | EmonPi v2.9.4 591 | 592 | Server 593 | OS : Linux 5.10.17-v7+ 594 | Host : emonpi | emonpi | (192.168.1.120) 595 | Date : 2021-09-21 17:51:13 BST 596 | Uptime : 17:51:13 up 54 days, 18:53, 1 user, load average: 0.61, 0.48, 0.48 597 | 598 | Memory 599 | RAM : Used: 20.02% 600 | Total : 924.21 MB 601 | Used : 185 MB 602 | Free : 739.21 MB 603 | Swap : Used: 0.00% 604 | Total : 100 MB 605 | Used : 0 B 606 | Free : 100 MB 607 | Write Load Period 608 | Disk 609 | / : Used: 49.40% 610 | Total : 4.07 GB 611 | Used : 2.01 GB 612 | Free : 1.86 GB 613 | Write Load : 814.53 B/s (26 days 20 hours 33 mins) 614 | /var/opt/emoncms : Used: 18.06% 615 | Total : 9.84 GB 616 | Used : 1.78 GB 617 | Free : 7.56 GB 618 | Write Load : 295.85 B/s (26 days 20 hours 33 mins) 619 | /boot : Used: 18.90% 620 | Total : 252.05 MB 621 | Used : 47.65 MB 622 | Free : 204.4 MB 623 | Write Load : 0.01 B/s (26 days 20 hours 33 mins) 624 | /var/log : Used: 8.30% 625 | Total : 50 MB 626 | Used : 4.15 MB 627 | Free : 45.85 MB 628 | Write Load : n/a 629 | 630 | HTTP 631 | Server : Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80 632 | 633 | MySQL 634 | Version : 5.5.5-10.3.29-MariaDB-0+deb10u1 635 | Host : 127.0.0.1 (127.0.0.1) 636 | Date : 2021-09-21 17:51:13 (UTC 01:00‌​) 637 | Stats : Uptime: 4733656 Threads: 12 Questions: 281610 Slow queries: 0 Opens: 60 Flush tables: 1 Open tables: 53 Queries per second avg: 0.059 638 | 639 | Redis 640 | Version : 641 | Redis Server : 5.0.3 642 | PHP Redis : 5.3.4 643 | Host : localhost:6379 644 | Size : 408 keys (787.93K) 645 | Uptime : 54 days 646 | MQTT Server 647 | Version : Mosquitto 1.5.7 648 | Host : localhost:1883 (127.0.0.1) 649 | 650 | PHP 651 | Version : 7.3.29-1~deb10u1 (Zend Version 3.3.29) 652 | Modules : apache2handlercalendar Core ctype curl date dom v20031129exif fileinfo filter ftp gd gettext hash iconv json v1.7.0libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $openssl pcre PDO pdo_mysql Phar posix readline redis v5.3.4Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zlib 653 | Pi 654 | Model : Raspberry Pi 3 Model B Rev 1.2 - 1GB (Sony UK) 655 | Serial num. : B6918B05 656 | CPU Temperature : 49.39°C 657 | GPU Temperature : 48.3°C 658 | emonpiRelease : emonSD-21Jul21 659 | File-system : read-write 660 | 661 | Client Information 662 | ----------------------- 663 | 664 | HTTP 665 | Browser : Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0 666 | Language : en-GB,en;q=0.5 667 | 668 | Window 669 | Size : 1836 x 898 670 | 671 | Screen 672 | Resolution : 1920 x 1080 673 | 674 | ``` 675 |
676 | 677 |
678 | emonSD-08May21 679 | 680 | **Download (1.7 GB)** 681 | 682 | - [UK Server](https://openenergymonitor.org/files/emonSD-08May21.zip) 683 | 684 | (eligible for updates) 685 | ``` 686 | (.zip) MD5: 82e2ba6a281db539dc1e814b96b4b37b 687 | ``` 688 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 689 | - Based on Debian Raspberry Pi OS (32-bit) Lite, 2021-03-04 690 | - Compatible with Raspberry Pi 3, 3B+ & 4 691 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 692 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 693 | - [SSH access disabled by default](https://community.openenergymonitor.org/t/emonpi-ssh-disabled-by-default/8847), long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition. 694 | 695 |
696 | 697 | 698 |
699 | emonSD-24Jul20 700 | 701 | **Download (1.4 GB)** 702 | 703 | - [UK Server](https://openenergymonitor.org/files/emonSD-24Jul20.img.zip) 704 | 705 | (eligible for updates) 706 | ``` 707 | (.img) MD5: 1db713787a1f3469fc3a1027767fd607 708 | (.zip) MD5: a160f746595872d30b735ab17e8a0b1c 709 | ``` 710 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 711 | - Based on Debian Raspberry Pi OS (32-bit) Lite, 2020-05-27 712 | - Compatible with Raspberry Pi 3, 3B+ & 4 713 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 714 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 715 | - [SSH access disabled by default](https://community.openenergymonitor.org/t/emonpi-ssh-disabled-by-default/8847), long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition. 716 | 717 | **Kernel** 718 | ``` 719 | $ uname -a 720 | Linux emonpi 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux 721 | 722 | $ sudo /opt/vc/bin/vcgencmd version 723 | Aug 6 2020 16:22:25 724 | Copyright (c) 2012 Broadcom 725 | version af3edc2de473197cdfe1ff5a8ff2d34095d5b336 (clean) (release) (start) 726 | ``` 727 | **File System** 728 | ``` 729 | $ df -h 730 | Filesystem Size Used Avail Use% Mounted on 731 | /dev/root 4.1G 2.0G 1.9G 52% / 732 | devtmpfs 299M 0 299M 0% /dev 733 | tmpfs 428M 0 428M 0% /dev/shm 734 | tmpfs 428M 5.9M 422M 2% /run 735 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 736 | tmpfs 428M 0 428M 0% /sys/fs/cgroup 737 | tmpfs 1.0M 12K 1012K 2% /var/lib/php/sessions 738 | tmpfs 1.0M 0 1.0M 0% /var/tmp 739 | tmpfs 30M 16K 30M 1% /tmp 740 | /dev/mmcblk0p1 253M 54M 199M 22% /boot 741 | /dev/mmcblk0p3 10G 5.3M 9.5G 1% /var/opt/emoncms 742 | log2ram 50M 2.1M 48M 5% /var/log 743 | tmpfs 86M 0 86M 0% /run/user/1000 744 | ``` 745 | **Emoncms** 746 | 747 | ``` 748 | Server Information 749 | ----------------------- 750 | 751 | Services 752 | emonhub : Active Running 753 | emoncms_mqtt : Active Running 754 | feedwriter : Active Running - sleep 300s 533 feed points pending write 755 | service-runner : Active Running 756 | emonPiLCD : Active Running 757 | redis-server : Active Running 758 | mosquitto : Active Running 759 | demandshaper : Activating Auto-restart 760 | 761 | Emoncms 762 | Version : low-write 10.2.5 763 | Modules : Administration | App v2.1.6 | Backup v2.2.4 | EmonHub Config v2.0.5 | Dashboard v2.0.8 | DemandShaper v1.2.6 | Device v2.0.6 | EventProcesses | Feed | Graph v2.0.9 | Input | Postprocess v2.1.4 | CoreProcess | Schedule | Network Setup v1.0.0 | sync | Time | User | Visualisation | WiFi v2.0.3 764 | Git : 765 | URL : https://github.com/emoncms/emoncms.git 766 | Branch : * stable 767 | Describe : 10.2.5 768 | 769 | Server 770 | OS : Linux 5.4.51-v7l+ 771 | Host : emonpi | emonpi | (192.168.1.64) 772 | Date : 2020-08-24 14:07:33 BST 773 | Uptime : 14:07:33 up 51 min, 1 user, load average: 0.19, 0.12, 0.21 774 | 775 | Memory 776 | RAM : Used: 21.84% 777 | Total : 855.19 MB 778 | Used : 186.82 MB 779 | Free : 668.38 MB 780 | Swap : Used: 0.75% 781 | Total : 100 MB 782 | Used : 768 KB 783 | Free : 99.25 MB 784 | Write Load Period 785 | Disk 786 | / : Used: 49.08% 787 | Total : 4.06 GB 788 | Used : 1.99 GB 789 | Free : 1.87 GB 790 | Write Load : 63.14 B/s (33 mins) 791 | /boot : Used: 21.15% 792 | Total : 252.05 MB 793 | Used : 53.32 MB 794 | Free : 198.73 MB 795 | Write Load : 0 B/s (33 mins) 796 | /var/opt/emoncms : Used: 8.13% 797 | Total : 9.84 GB 798 | Used : 819.75 MB 799 | Free : 8.54 GB 800 | Write Load : 360.51 B/s (33 mins) 801 | /var/log : Used: 4.04% 802 | Total : 50 MB 803 | Used : 2.02 MB 804 | Free : 47.98 MB 805 | Write Load : n/a 806 | 807 | HTTP 808 | Server : Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80 809 | 810 | MySQL 811 | Version : 5.5.5-10.3.23-MariaDB-0+deb10u1 812 | Host : localhost:6379 (127.0.0.1) 813 | Date : 2020-08-24 14:07:33 (UTC 01:00‌​) 814 | Stats : Uptime: 2895 Threads: 12 Questions: 4079 Slow queries: 0 Opens: 57 Flush tables: 1 Open tables: 51 Queries per second avg: 1.408 815 | 816 | Redis 817 | Version : 818 | Redis Server : 5.0.3 819 | PHP Redis : 5.3.1 820 | Host : localhost:6379 821 | Size : 514 keys (849.12K) 822 | Uptime : 4 days 823 | MQTT Server 824 | Version : Mosquitto 1.5.7 825 | Host : localhost:1883 (127.0.0.1) 826 | 827 | PHP 828 | Version : 7.3.19-1~deb10u1 (Zend Version 3.3.19) 829 | Modules : apache2handlercalendar Core ctype curl date dom v20031129exif fileinfo filter ftp gd gettext hash iconv json v1.7.0libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $openssl pcre PDO pdo_mysql Phar posix readline redis v5.3.1Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zlib 830 | Pi 831 | Model : Raspberry Pi 4 Model B Rev 1.1 - 1GB (Sony UK) 832 | Serial num. : 10000000EA26C808 833 | CPU Temperature : 49.17°C 834 | GPU Temperature : 49.0°C 835 | emonpiRelease : emonSD-24Jul20 836 | File-system : read-write 837 | 838 | ``` 839 |
840 | 841 | 842 |
843 | emonSD-17Oct19 844 | 845 | [Forum Thread](https://community.openenergymonitor.org/t/emonsd-17oct19-release/12231) 846 | 847 | **Download (1.1 GB)** 848 | 849 | - [UK Server](http://files.openenergymonitor.org/emonSD-17Oct19.img.zip) 850 | - [Canada Server](https://distanthost.com/oem/emonSD-17Oct19.img.zip) 851 | 852 | (eligible for updates) 853 | ``` 854 | (.img) MD5: a7d12ac6b589ae0d470c4a6f1ce38414 855 | (.zip) MD5: 52ecf81c2ad4afbd9da42a6e703b5c59 856 | ``` 857 | - Built using EmonScripts emoncms installation script, see
[https://github.com/openenergymonitor/EmonScripts](https://github.com/openenergymonitor/EmonScripts). 858 | - Based on Debian Raspbian Buster minimal 859 | - Compatible with Raspberry Pi 3, 3B+ & 4 860 | - Emoncms data is logged to low-write ext2 partition mounted in `/var/opt/emoncms` 861 | - Log partition `/var/log` mounted as tmpfs using log2ram, now persistent after reboot 862 | - [SSH access disabled by default](https://community.openenergymonitor.org/t/emonpi-ssh-disabled-by-default/8847), long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition. 863 | 864 | \* To use this image on Pi2 remove the following lines from `/boot/config.txt`: 865 | 866 | ``` 867 | arm_freq=1200 868 | arm_freq_min=600 869 | ``` 870 | 871 | **Kernel** 872 | ``` 873 | $ uname -a 874 | Linux emonpi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux 875 | 876 | $ sudo /opt/vc/bin/vcgencmd version 877 | Sep 24 2019 17:37:47 878 | Copyright (c) 2012 Broadcom 879 | version 6820edeee4ef3891b95fc01cf02a7abd7ca52f17 (clean) (release) (start_cd) 880 | ``` 881 | **File System** 882 | ``` 883 | $ df -h 884 | Filesystem Size Used Avail Use% Mounted on 885 | /dev/root 4.0G 1.9G 2.0G 49% / 886 | devtmpfs 484M 0 484M 0% /dev 887 | tmpfs 488M 0 488M 0% /dev/shm 888 | tmpfs 488M 6.6M 482M 2% /run 889 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 890 | tmpfs 488M 0 488M 0% /sys/fs/cgroup 891 | tmpfs 1.0M 4.0K 1020K 1% /var/lib/php/sessions 892 | tmpfs 1.0M 0 1.0M 0% /var/tmp 893 | tmpfs 30M 16K 30M 1% /tmp 894 | /dev/mmcblk0p3 10G 5.3M 9.5G 1% /var/opt/emoncms 895 | /dev/mmcblk0p1 253M 52M 201M 21% /boot 896 | log2ram 50M 2.1M 48M 5% /var/log 897 | tmpfs 98M 0 98M 0% /run/user/1000 898 | 899 | ``` 900 | **Emoncms** 901 | 902 | ``` 903 | Server Information 904 | ----------------------- 905 | 906 | Emoncms 907 | Version : low-write 10.1.9 908 | Modules : Administration | App v2.0.7 | Backup v2.1.4 | EmonHub Config v2.0.4 | Dashboard v2.0.5 | DemandShaper v1.0.2 | Device v2.0.2 | EventProcesses | Feed | Graph v2.0.5 | Input | Postprocess v2.1.1 | CoreProcess | Schedule | Network Setup v1.0.0 | sync | Time | User | Visualisation | WiFi v2.0.2 909 | Git : 910 | URL : https://github.com/emoncms/emoncms.git 911 | Branch : * stable 912 | Describe : 10.1.9 913 | 914 | Server 915 | OS : Linux 4.19.75-v7+ 916 | Host : emonpi | emonpi | (192.168.0.109) 917 | Date : 2019-10-17 13:10:53 BST 918 | Uptime : 13:10:53 up 15 min, 1 user, load average: 0.10, 0.11, 0.09 919 | 920 | Memory 921 | RAM : Used: 19.37% 922 | Total : 975.62 MB 923 | Used : 188.99 MB 924 | Free : 786.63 MB 925 | Swap : Used: 0.00% 926 | Total : 100 MB 927 | Used : 0 B 928 | Free : 100 MB 929 | 930 | Disk 931 | / : Used: 46.42% 932 | Total : 3.92 GB 933 | Used : 1.82 GB 934 | Free : 1.91 GB 935 | Write Load : n/a 936 | /var/opt/emoncms : Used: 0.05% 937 | Total : 9.98 GB 938 | Used : 5.27 MB 939 | Free : 9.47 GB 940 | Write Load : n/a 941 | /boot : Used: 20.55% 942 | Total : 252.05 MB 943 | Used : 51.79 MB 944 | Free : 200.26 MB 945 | Write Load : n/a 946 | /var/log : Used: 4.20% 947 | Total : 50 MB 948 | Used : 2.1 MB 949 | Free : 47.9 MB 950 | Write Load : n/a 951 | 952 | HTTP 953 | Server : Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80 954 | 955 | MySQL 956 | Version : 5.5.5-10.3.17-MariaDB-0+deb10u1 957 | Host : localhost:6379 (127.0.0.1) 958 | Date : 2019-10-17 13:10:52 (UTC 01:00‌​) 959 | Stats : Uptime: 899 Threads: 14 Questions: 1757 Slow queries: 0 Opens: 70 Flush tables: 1 Open tables: 36 Queries per second avg: 1.954 960 | 961 | Redis 962 | Version : 963 | Redis Server : 5.0.3 964 | PHP Redis : 5.0.2 965 | Host : localhost:6379 966 | Size : 114 keys (810.42K) 967 | Uptime : 0 days 968 | MQTT Server 969 | Version : Mosquitto 1.5.7 970 | Host : localhost:1883 (127.0.0.1) 971 | 972 | PHP 973 | Version : 7.3.9-1~deb10u1 (Zend Version 3.3.9) 974 | Modules : apache2handler | calendar v7.3.9-1~deb10u1 | Core v7.3.9-1~deb10u1 | ctype v7.3.9-1~deb10u1 | curl v7.3.9-1~deb10u1 | date v7.3.9-1~deb10u1 | dom v20031129 | exif v7.3.9-1~deb10u1 | fileinfo v7.3.9-1~deb10u1 | filter v7.3.9-1~deb10u1 | ftp v7.3.9-1~deb10u1 | gd v7.3.9-1~deb10u1 | gettext v7.3.9-1~deb10u1 | hash v7.3.9-1~deb10u1 | iconv v7.3.9-1~deb10u1 | json v1.7.0 | libxml v7.3.9-1~deb10u1 | mbstring v7.3.9-1~deb10u1 | mosquitto v0.4.0 | mysqli v7.3.9-1~deb10u1 | mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $ | openssl v7.3.9-1~deb10u1 | pcre v7.3.9-1~deb10u1 | PDO v7.3.9-1~deb10u1 | pdo_mysql v7.3.9-1~deb10u1 | Phar v7.3.9-1~deb10u1 | posix v7.3.9-1~deb10u1 | readline v7.3.9-1~deb10u1 | redis v5.0.2 | Reflection v7.3.9-1~deb10u1 | session v7.3.9-1~deb10u1 | shmop v7.3.9-1~deb10u1 | SimpleXML v7.3.9-1~deb10u1 | sockets v7.3.9-1~deb10u1 | sodium v7.3.9-1~deb10u1 | SPL v7.3.9-1~deb10u1 | standard v7.3.9-1~deb10u1 | sysvmsg v7.3.9-1~deb10u1 | sysvsem v7.3.9-1~deb10u1 | sysvshm v7.3.9-1~deb10u1 | tokenizer v7.3.9-1~deb10u1 | wddx v7.3.9-1~deb10u1 | xml v7.3.9-1~deb10u1 | xmlreader v7.3.9-1~deb10u1 | xmlwriter v7.3.9-1~deb10u1 | xsl v7.3.9-1~deb10u1 | Zend OPcache v7.3.9-1~deb10u1 | zlib v7.3.9-1~deb10u1 975 | 976 | Pi 977 | Model : Raspberry Pi 3 Model B+ Rev 1.3 - 1GB (Sony UK) 978 | Serial num. : 78A9D9F 979 | Temperature : 48.31°C - 47.8°C 980 | emonpiRelease : emonSD-17Oct19 981 | File-system : read-write 982 | ``` 983 |
984 | 985 |
986 | emonSD-30Oct18 987 | 988 | **Download (1.2GB)** 989 | 990 | - [UK Server](http://files.openenergymonitor.org/emonSD-30Oct18.zip) 991 | - [Canada Server](http://distanthost.com/oem/emonSD-30Oct18.zip) 992 | 993 | Following the [release of emonSD-24Jul20](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170), this version is no longer eligible for updates. For more details see the [release notes](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170). 994 | 995 | ``` 996 | (.img) MD5: eb24460efcd8af7bc568415002581649 997 | (.zip) MD5: 0c6cbfc59403ba536ad7c0120bb687e5 998 | ``` 999 | 1000 | - Based on Debian Raspbian Stretch minimal 1001 | - Compatible with Raspberry Pi 3 & 3B+ (minor change required for Pi2*) 1002 | - [No longer use read-only root file system](https://community.openenergymonitor.org/t/new-emonsd-dropping-read-only-root-filesystem-requirement/8293) 1003 | - Emoncms data is logged to low-write ext2 partition mounted in `~/data` 1004 | - Log partition `/var/log` mounted as tmpfs, non-persistent between boots 1005 | - [SSH access disabled by default](https://community.openenergymonitor.org/t/emonpi-ssh-disabled-by-default/8847), long press emonPi LCD push button for 5s to enable. Or create file `/boot/ssh` in FAT partition. 1006 | - OpenHAB & NodeRED removed, can easily be installed via apt-get 1007 | 1008 | \* To use this image on Pi2 remove the following lines from `/boot/config.txt` : 1009 | 1010 | ``` 1011 | arm_freq=1200 1012 | arm_freq_min=600 1013 | ``` 1014 | 1015 | **Kernel** 1016 | ``` 1017 | $ uname -a 1018 | Linux emonpi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux 1019 | $ sudo /opt/vc/bin/vcgencmd version 1020 | Sep 21 2018 15:44:25 1021 | Copyright (c) 2012 Broadcom 1022 | version 07f57128b8491ffdefcdfd13f7b4961b3006d9a9 (clean) (release) 1023 | ``` 1024 | **File System** 1025 | ``` 1026 | $ df -h 1027 | Filesystem Size Used Avail Use% Mounted on 1028 | /dev/root 3.9G 1.6G 2.2G 42% / 1029 | devtmpfs 484M 0 484M 0% /dev 1030 | tmpfs 489M 0 489M 0% /dev/shm 1031 | tmpfs 489M 13M 476M 3% /run 1032 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 1033 | tmpfs 489M 0 489M 0% /sys/fs/cgroup 1034 | tmpfs 1.0M 0 1.0M 0% /var/tmp 1035 | tmpfs 50M 1004K 50M 2% /var/log 1036 | tmpfs 30M 0 30M 0% /tmp 1037 | /dev/mmcblk0p1 43M 22M 21M 52% /boot 1038 | /dev/mmcblk0p3 3.3G 113M 3.0G 4% /home/pi/data 1039 | tmpfs 98M 0 98M 0% /run/user/1000 1040 | ``` 1041 | **Emoncms** 1042 | 1043 | ``` 1044 |
Server Information
1045 | 
1046 | | | | |
1047 | | --- | --- | --- |
1048 | |Emoncms|Version|low-write 9.9.3
1049 | ||Modules|Administration : App v1.2.0 : Backup v1.1.5 : EmonHub Config v1.0.0 : Dashboard v1.3.1 : Device v1.1.1 : EventProcesses : Feed : Graph v1.2.1 : Input : Postprocess v1.0.0 : CoreProcess : Schedule : Network Setup v1.0.0 : sync : Time : User : Visualisation : WiFi v1.3.0
1050 | ||Git URL|https://github.com/emoncms/emoncms.git
1051 | ||Git Branch|* stable
1052 | ||Buffer|loading...
1053 | ||Writer|Daemon is running with sleep 60s
1054 | |Server|OS|Linux 4.14.71-v7+
1055 | ||Host|emonpi emonpi (192.168.86.36)
1056 | ||Date|2018-10-30 01:34:56 UTC
1057 | ||Uptime| 01:34:56 up 27 min,  1 user,  load average: 1.75, 1.59, 1.34
1058 | |HTTP|Server|Apache/2.4.25 (Raspbian) HTTP/1.1 CGI/1.1 80
1059 | |MySQL|Version|5.5.5-10.1.23-MariaDB-9+deb9u1
1060 | ||Host|127.0.0.1 (127.0.0.1)
1061 | ||Date|2018-10-30 01:34:56 (UTC 00:00‌)
1062 | ||Stats|Uptime: 1667  Threads: 3  Questions: 68  Slow queries: 0  Opens: 23  Flush tables: 1  Open tables: 17  Queries per second avg: 0.040
1063 | |Redis|Version|3.2.6
1064 | ||Host|localhost:6379 (127.0.0.1)
1065 | ||Size|44 keys  (840.02K)
1066 | ||Uptime|0 days
1067 | |MQTT Server|Version|Mosquitto 1.4.10
1068 | ||Host|localhost:1883 (127.0.0.1)
1069 | |Pi|Model|Raspberry Pi 3 Model B Rev 1.2 - 1 GB (Stadium)
1070 | ||SoC|Broadcom BCM2835
1071 | ||Serial num.|68D8124E
1072 | ||Temperature|CPU: 49.39°C - GPU: 49.4'C
1073 | ||Release|emonSD-30Oct18
1074 | ||File-system|Current: read-write - Set root file-system temporarily to read-write, (default read-only) 
1075 | |Memory|RAM|Used: 15.91% Total: 976.74 MB Used: 155.45 MB Free: 821.29 MB
1076 | ||Swap|Used: 0.00% Total: 100 MB Used: 0 B Free: 100 MB
1077 | |Disk|Mount|Stats
1078 | ||/|Used: 39.77% Total: 3.81 GB Used: 1.52 GB Free: 2.12 GB
1079 | ||/boot|Used: 51.69% Total: 42.52 MB Used: 21.98 MB Free: 20.54 MB
1080 | ||/home/pi/data|Used: 3.43% Total: 3.21 GB Used: 112.78 MB Free: 2.93 GB
1081 | |PHP|Version|7.0.30-0+deb9u1 (Zend Version 3.0.0)
1082 | ||Modules|apache2handler : calendar v7.0.30-0+deb9u1 : Core v7.0.30-0+deb9u1 : ctype v7.0.30-0+deb9u1 : curl v7.0.30-0+deb9u1 : date v7.0.30-0+deb9u1 : dom v20031129 : exif v7.0.30-0+deb9u1 : fileinfo v1.0.5 : filter v7.0.30-0+deb9u1 : ftp v7.0.30-0+deb9u1 : gd v7.0.30-0+deb9u1 : gettext v7.0.30-0+deb9u1 : hash v1.0 : iconv v7.0.30-0+deb9u1 : igbinary v2.0.1 : json v1.4.0 : libxml v7.0.30-0+deb9u1 : mbstring v7.0.30-0+deb9u1 : mcrypt v7.0.30-0+deb9u1 : mosquitto v0.4.0 : mysqli v7.0.30-0+deb9u1 : mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ : openssl v7.0.30-0+deb9u1 : pcre v7.0.30-0+deb9u1 : PDO v7.0.30-0+deb9u1 : pdo_mysql v7.0.30-0+deb9u1 : Phar v2.0.2 : posix v7.0.30-0+deb9u1 : readline v7.0.30-0+deb9u1 : redis v4.1.1 : Reflection v7.0.30-0+deb9u1 : session v7.0.30-0+deb9u1 : shmop v7.0.30-0+deb9u1 : SimpleXML v7.0.30-0+deb9u1 : sockets v7.0.30-0+deb9u1 : SPL v7.0.30-0+deb9u1 : standard v7.0.30-0+deb9u1 : sysvmsg v7.0.30-0+deb9u1 : sysvsem v7.0.30-0+deb9u1 : sysvshm v7.0.30-0+deb9u1 : tokenizer v7.0.30-0+deb9u1 : wddx v7.0.30-0+deb9u1 : xml v7.0.30-0+deb9u1 : xmlreader v7.0.30-0+deb9u1 : xmlwriter v7.0.30-0+deb9u1 : xsl v7.0.30-0+deb9u1 : Zend OPcache v7.0.30-0+deb9u1 : zlib v7.0.30-0+deb9u1
1083 | 
1084 | ``` 1085 | 1086 | **Known Issues** 1087 | 1088 | - Current bug in rpi-gpio 0.6.4 causes LCD push button to stop working, a solution is to continue using 0.6.3 `pip install RPi.GPIO==0.6.3`. [Open issue](https://github.com/RPi-Distro/python-gpiozero/issues/687). 1089 | - Mosquitto 1.4.10 is included in this release, this is a downgrade from 1.4.14 included in the previous image (emonSD-26Oct17). This is because 1.4.10 is the current stable Stretch apt release. A newer version can be manually installed if required https://mosquitto.org/download/ 1090 |
1091 | 1092 |
1093 | emonSD-26Oct17 1094 | 1095 | [Download (1.4GB)](http://files.openenergymonitor.org/emonSD-26Oct17.img.zip) 1096 | 1097 | Following the [release of emonSD-24Jul20](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170), this version is no longer eligible for updates. For more details see the [release notes](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170). 1098 | 1099 | ``` 1100 | (.img) MD5: 88f8ff9a5f7bc0e9b07012895a5cdd95 1101 | (.zip) MD5: 6726564f379d0127052e8c30a3ffa534 1102 | ``` 1103 | New changes compared with previous release, [SD-card-build.md](https://github.com/openenergymonitor/emonpi/blob/master/docs/SD-card-build.md) has been updated: 1104 | 1105 | - Based on Debian Raspbian Jessie minimal, updated to latest packages, kernel and firmware. Includes patch for [KRACK WPA vulnerability](https://www.krackattacks.com/): 1106 | - Compatible with Raspberry Pi 2/3 (not zero or 3B+) 1107 | 1108 | ``` 1109 | $ uname -a 1110 | Linux emonpi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux 1111 | $ sudo /opt/vc/bin/vcgencmd version 1112 | Jul 3 2017 14:17:30 1113 | version 4139c62f14cafdb7d918a3eaa0dbd68cf434e0d8 (tainted) (release) 1114 | ``` 1115 | - Automatic NTP time update: see [forum thread](https://community.openenergymonitor.org/t/emontx-communication-with-rpi/3659/2) and [changes](https://github.com/openenergymonitor/emonpi/commit/0081b6d4724cb2a1445adc22eef777fd1aa3797c). 1116 | - Fix random seed: improved HTTPS / SSH security. See [forum thread](https://community.openenergymonitor.org/t/random-seed/3637). 1117 | - Use `dtoverlay=pi3-miniuart-bt` instead of `dtoverlay=pi3-disable-bt` in `/boot/config.txt` 1118 | This re-maps RasPi3 bluetooth to software serial`/dev/ttyS0` instead of disabling it. 1119 | 1120 | **File System** 1121 | 1122 | *4GB min SD card (8GB+ recommended). If SD card is larger than 4GB, expand `data` partition with `sudo emonSDexpand`* 1123 | 1124 | ``` 1125 | $ df -h 1126 | Filesystem Size Used Avail Use% Mounted on 1127 | /dev/root 3.4G 2.0G 1.2G 63% / 1128 | devtmpfs 481M 0 481M 0% /dev 1129 | tmpfs 486M 0 486M 0% /dev/shm 1130 | tmpfs 486M 6.6M 479M 2% /run 1131 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 1132 | tmpfs 486M 0 486M 0% /sys/fs/cgroup 1133 | tmpfs 40M 6.1M 34M 16% /var/lib/openhab 1134 | tmpfs 1.0M 4.0K 1020K 1% /var/lib/dhcpcd5 1135 | /dev/mmcblk0p1 60M 22M 39M 37% /boot 1136 | tmpfs 1.0M 0 1.0M 0% /var/lib/dhcp 1137 | tmpfs 50M 480K 50M 1% /var/log 1138 | tmpfs 30M 152K 30M 1% /tmp 1139 | /dev/mmcblk0p3 3.5G 39M 1000M 2% /home/pi/data 1140 | ``` 1141 | **Emoncms Server Information** 1142 | 1143 | ``` 1144 | Emoncms Version low-write 9.8.10 | 2017.08.17 1145 | Modules Administration | App v1.0.0 | Backup v1.0.0 | EmonHub Config v1.0.0 | Dashboard v1.1.1 | EventProcesses | Feed | Graph v1.0.0 | Input | postprocess | CoreProcess | Schedule | setup | Time | User | Visualisation | WiFi v1.0.0 1146 | Buffer 0 feed points pending write 1147 | Writer Daemon is running with sleep 60s 1148 | Server OS Linux 4.9.35-v7+ 1149 | Host emonpi emonpi (127.0.1.1) 1150 | Date 2017-10-27 16:04:08 UTC 1151 | Uptime 16:04:08 up 6 min, 1 user, load average: 0.09, 0.17, 0.09 1152 | HTTP Server Apache/2.4.10 (Raspbian) HTTP/1.1 CGI/1.1 80 1153 | Database Version MySQL 5.5.57-0+deb8u1 1154 | Host localhost (127.0.0.1) 1155 | Date 2017-10-27 16:04:08 (UTC 00:00‌) 1156 | Stats Uptime: 82668 Threads: 3 Questions: 196 Slow queries: 0 Opens: 59 Flush tables: 1 Open tables: 51 Queries per second avg: 0.002 1157 | Redis Version 2.8.17 1158 | Host localhost:6379 (127.0.0.1) 1159 | Size 13 keys (473.56K)Flush 1160 | Uptime 0 days 1161 | MQTT Version 1.4.14 1162 | Host localhost:1883 (127.0.0.1) 1163 | Pi CPU Temp 40.78°CShutdownReboot 1164 | Release emonSD-26Oct17 1165 | File-system Set root file-system temporarily to read-write, (default read-only)Read-Write Read-Only 1166 | Memory RAM 1167 | Used 25.03% 1168 | Total: 970.93 MB Used: 242.99 MB Free: 727.94 MB 1169 | Disk Mount Stats 1170 | / 1171 | Used 59.18% 1172 | Total: 3.33 GB Used: 1.97 GB Free: 1.2 GB 1173 | /boot 1174 | Used 36.32% 1175 | Total: 59.95 MB Used: 21.77 MB Free: 38.17 MB 1176 | /home/pi/data 1177 | Used 1.09% 1178 | Total: 3.46 GB Used: 38.69 MB Free: 3.25 GB 1179 | PHP Version 5.6.30-0+deb8u1 (Zend Version 2.6.0) 1180 | Modules apache2handler | bcmath | bz2 | calendar | Core v5.6.30-0+deb8u1 | ctype | curl | date v5.6.30-0+deb8u1 | dba | dio v0.0.4RC4 | dom v20031129 | ereg | exif v1.4 | fileinfo v1.0.5 | filter v0.11.0 | ftp | gettext | hash v1.0 | iconv | json v1.3.6 | libxml | mbstring | mcrypt | mhash | mosquitto v0.3.0 | mysql v1.0 | mysqli v0.1 | openssl | pcre | PDO v1.0.4dev | pdo_mysql v1.0.2 | Phar v2.0.2 | posix | readline v5.6.30-0+deb8u1 | redis v2.2.7 | Reflection | session | shmop | SimpleXML v0.1 | soap | sockets | SPL v0.2 | standard v5.6.30-0+deb8u1 | sysvmsg | sysvsem | sysvshm | tokenizer v0.1 | wddx | xml | xmlreader v0.1 | xmlwriter v0.1 | Zend OPcache v7.0.6-devFE | zip v1.12.5 | zlib v2.0 | 1181 | ``` 1182 |
1183 | 1184 |
1185 | emonSD-07Nov16 1186 | 1187 | **RELEASE** 1188 | 1189 | [Download (824MB)](http://files.openenergymonitor.org/emonSD-07Nov16.zip) | [Mirror 1 (Canada)](http://www.distanthost.com/oem/emonSD-07Nov16.zip) 1190 | 1191 | Following the [release of emonSD-24Jul20](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170), this version is no longer eligible for updates. For more details see the [release notes](https://community.openenergymonitor.org/t/emonsd-24jul20-release/15170). 1192 | 1193 | [Forum Discussion](https://community.openenergymonitor.org/t/emonsd-07nov16-beta/2137?u=glyn.hudson) 1194 | 1195 | ``` 1196 | (.img) MD5: cf8537e90ffd98ffb5838fbe3c878d4d 1197 | (.zip) MD5: 3961e96cf2e1ab46d750d0a0cae72a2e 1198 | ``` 1199 | 1200 | **File System** 1201 | 1202 | *4GB min SD card (8GB+ recommended). If SD card is larger than 4GB, expand `data` partition with `sudo emonSDexpand`* 1203 | ``` 1204 | Filesystem Size Used Avail Use% Mounted on 1205 | /dev/root 3.4G 2.1G 1.2G 64% / 1206 | devtmpfs 483M 0 483M 0% /dev 1207 | tmpfs 487M 0 487M 0% /dev/shm 1208 | tmpfs 487M 6.6M 480M 2% /run 1209 | tmpfs 5.0M 4.0K 5.0M 1% /run/lock 1210 | tmpfs 487M 0 487M 0% /sys/fs/cgroup 1211 | tmpfs 40M 3.8M 37M 10% /var/lib/openhab 1212 | tmpfs 1.0M 4.0K 1020K 1% /var/lib/dhcpcd5 1213 | tmpfs 1.0M 0 1.0M 0% /var/lib/dhcp 1214 | tmpfs 50M 328K 50M 1% /var/log 1215 | tmpfs 30M 52K 30M 1% /tmp 1216 | /dev/mmcblk0p1 60M 21M 40M 35% /boot 1217 | /dev/mmcblk0p3 194M 37M 147M 21% /home/pi/data 1218 | ``` 1219 | 1220 | **Linux** 1221 | * Update Linux kernal to at least 4.4.26-v7+ to get latest security & raspi firmware fixes (e.g. Dirty Cow) (dist-upgrade) [forum topic](https://community.openenergymonitor.org/t/dirty-cow-vulnerability/2010/2) 1222 | * `$ apt-get clean all` (free up unused packages, approx 700Mb) 1223 | 1224 | **Emoncms** 1225 | * Latest Emoncms (currently V9.7.7) 1226 | * New graph module 1227 | * Lots of dashboard fixes and improvements 1228 | 1229 | **emonPi** 1230 | * Remove personal GitHub credentials 1231 | * Fix Mosquitto MQTT server hanging after V1.4.10 update [forum thread](https://community.openenergymonitor.org/t/mqtt-log-files/1597/6) 1232 | * [Add bash prompt RW indicator](https://community.openenergymonitor.org/t/increase-emonsd-pre-built-sd-card-to-8gb-min/1730/12?u=glyn.hudson), add to ` /etc/bash.bashrc` 1233 | * Install [emonUpload](https://github.com/openenergymonitor/emonupload) to enable easier user emonTx, emonTH firmware updates 1234 | * Updated [motd](https://github.com/openenergymonitor/emonpi/blob/master/motd) 1235 | * [PlatformIO](https://platformio.org) installed for on-device firmware compiling & updating. [See blog post](https://blog.openenergymonitor.org/2016/06/platformio/). 1236 | 1237 | **nodeRED** 1238 | * Add weather underground nodeRED node + [flow example](https://github.com/openenergymonitor/oem_node-red) 1239 | 1240 | **OpenHAB** 1241 | * Update to Java 8 - fix my.openhab connection issue [forum thread](https://community.openenergymonitor.org/t/openhab-problems-connecting-through-myopenhab-with-java-8/1232) 1242 | * [Disable OpenHAB Jetty server request logs](https://github.com/openenergymonitor/oem_openHab/blob/master/Readme.md#disable-request-log). Stop filling up /var/log partition. 1243 | 1244 | **Emoncms Server Info** 1245 | 1246 | ``` 1247 | Server Information 1248 | Emoncms Version low-write 9.7.7 | 2016.10.29 1249 | Modules app, config, dashboard, graph, wifi 1250 | Buffer 0 feed points pending write 1251 | Writer Daemon is running with sleep 60s 1252 | Server OS Linux 4.4.26-v7+ 1253 | Host emonpi emonpi (127.0.1.1) 1254 | Date 2016-11-01 00:52:38 UTC 1255 | Uptime 00:52:38 up 5 min, 1 user, load average: 0.76, 0.65, 0.31 1256 | HTTP Server Apache/2.4.10 (Raspbian) HTTP/1.1 CGI/1.1 80 1257 | Database Version MySQL 5.5.52-0+deb8u1 1258 | Host localhost (127.0.0.1) 1259 | Date 2016-11-01 00:52:38 (UTC 00:00‌) 1260 | Stats Uptime: 5583 Threads: 3 Questions: 1699 Slow queries: 0 Opens: 61 Flush tables: 1 Open tables: 50 Queries per second avg: 0.304 1261 | Redis Version 2.8.17 1262 | Host localhost:6379 (127.0.0.1) 1263 | Size 0 keys (471.91K)Flush 1264 | Uptime 0 days 1265 | MQTT Version 1.4.10 1266 | Host localhost:1883 (127.0.0.1) 1267 | Pi CPU Temp 41.86°CShutdownReboot 1268 | Release emonSD-07Nov16 1269 | Memory RAM 1270 | Used 25.23% 1271 | Total: 973.11 MB Used: 245.53 MB Free: 727.58 MB 1272 | Disk Mount Stats 1273 | / 1274 | Used 60.45% 1275 | Total: 3.33 GB Used: 2.01 GB Free: 1.16 GB 1276 | /boot 1277 | Used 34.67% 1278 | Total: 59.95 MB Used: 20.78 MB Free: 39.16 MB 1279 | /home/pi/data 1280 | Used 19.04% 1281 | Total: 193.66 MB Used: 36.87 MB Free: 146.8 MB 1282 | PHP Version 5.6.27-0+deb8u1 (Zend Version 2.6.0) 1283 | Modules Core date ereg libxml openssl pcre zlib bcmath bz2 calendar ctype dba dom hash fileinfo filter ftp gettext SPL iconv mbstring session posix Reflection standard shmop SimpleXML soap sockets Phar exif sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter zip apache2handler PDO curl dio json mcrypt mosquitto mysql mysqli pdo_mysql readline redis mhash Zend OPcache 1284 | ``` 1285 | 1286 | By default emonSD has a number of services running. If you don't want to use them, they can be disabled with: 1287 | 1288 | ``` 1289 | pi@emonpi:~ $ sudo systemctl disable openhab.service 1290 | pi@emonpi:~ $ sudo systemctl disable nodered.service 1291 | pi@emonpi:~ $ sudo systemctl disable emonPiLCD.service 1292 | pi@emonpi:~ $ sudo systemctl disable apache2.service 1293 | ``` 1294 |
1295 | 1296 |
1297 | emonSD-03May16 1298 | 1299 | [Download (1.7GB)](http://files.openenergymonitor.org/emonSD-03May16.img.zip) | [UK Mirror 1](http://217.9.195.227/files/emonSD-03May16.img.zip) | [Forum Discussion](https://community.openenergymonitor.org/t/emonsd-03may16-release/145) 1300 | 1301 | ``` 1302 | MD5 Checksum (zip): d102aff6dafd89d2e4d3209eee964251 1303 | MD5 Checksum (.img): 08557bda1c12daa76ab94bef0c04f3fd 1304 | ``` 1305 | 1306 | * Based on RASPBIAN JESSIE LITE (2015-11-21) `SSH user,pass:pi,emonpi2016` 1307 | * Linux Kernal 4.1.19-v7+ 1308 | * RasPi Firmware & packages updated to support Raspberry Pi3 & onboard Wifi ([RasPi3 BT disabled](https://blog.openenergymonitor.org/2016/03/raspberry-pi-3/)) 1309 | * Tested to work on RasPi 3, 2 Model B+, B, A and even [Pi zero](https://community.openenergymonitor.org/t/emonsd-03may16-release/145/66)! 1310 | * Emoncms V9.5.1 | 2016.04.28 [stable branch](https://github.com/emoncms/emoncms/tree/stable) 1311 | * emonHub [emon-pi variant](https://github.com/openenergymonitor/emonhub) - now default HTTPS to Emoncms.org 1312 | * [MQTT LightWave RF OOK](https://github.com/openenergymonitor/lightwaverf-pi) 1313 | * [NodeRED 13.4 - with custom OEM setup](https://github.com/openenergymonitor/oem_node-red) *port:1880* `user,pass:emonpi,emonpi2016` 1314 | * [OpenHab 1.8.2 - with custom OEM setup](https://github.com/openenergymonitor/oem_openhab) *port:8080* `user,pass:pi,emonpi2016` 1315 | * Mosquitto MQTT server V1.4.8 with authentication *port:1883* `user,pass:emonpi,emonpimqtt2016` 1316 | * MYSQL `username: emoncms, password:emonpiemoncmsmysql2016` port 3306 (not open externally) 1317 | * [GSM 3G USB modem support](https://guide.openenergymonitor.org/setup/connect/#5-connect-via-3g-gsm-optional) 1318 | 1319 | New Changes 1320 | [forum discussion](https://openenergymonitor.org/emon/node/12566) 1321 | * Append `gpu_mem=16` to `/boot/config.txt` to give us more RAM at expense of GPU 1322 | * Symlink `fstab` in emonpi repo to `/etc/fstab` to allow updating 1323 | * Reduce garbage in /var/log/messages but to Raspbian bug 1324 | * Fix log rotate to includue all log files to ensure /var/log does not fill up 1325 | * RasPi3 SSHD fix 1326 | * Fix language pack support (install gettext & locales), language setting in 'Account' now works out the box 1327 | * Fix node-RED flows to survive update cycle 1328 | * Trim SD card (allow 60mB of unallocated partition) to fit on all (or majority) of 4GB SD cards, shop pre-built SD cards included with emonPi / emonBase will be 8GB with ~/data partition expanded accordingly. 1329 | * Generate new SSH keys 1330 | 1331 | By default emonSD has a number of services running, if you don't want to use these they can be disabled with: 1332 | 1333 | ``` 1334 | pi@emonpi:~ $ sudo systemctl disable openhab.service 1335 | pi@emonpi:~ $ sudo systemctl disable nodered.service 1336 | pi@emonpi:~ $ sudo systemctl disable emonPiLCD.service 1337 | pi@emonpi:~ $ sudo systemctl disable apache2.service 1338 | ``` 1339 |
1340 | 1341 |
1342 | emonSD-17Jun15 1343 | 1344 | [Download](http://files.openenergymonitor.org/emonSD-17Jun2015.img.zip) | [Forum Thread](https://openenergymonitor.org/emon/node/10729) 1345 | 1346 | * **Shipped on all emonPi's Jun15-March16** 1347 | * Emoncms V8  1348 | * 2015-05-05 version of Raspbian  1349 | * Mosquitto MQTT with no authentication (port closed) **** 1350 |
1351 | 1352 | 1353 |
1354 | emonpi-28may2015 1355 | 1356 | * First emonPi release 1357 | * Emoncms V8 1358 | * Shipped with first batch of Kickstarter backer units  1359 | * Shipped on emonpi's May15-June15 1360 | 1361 |
1362 | 1363 | --- 1364 | 1365 | ## Writing the image to an SD card 1366 | 1367 | **Option 1:** We recommend using [balenaEtcher](https://www.etcher.io/) to flash the image to an SD card. See [forum discussion](https://community.openenergymonitor.org/t/using-etcher-tool-to-flash-emonsd-image-to-sd-card/1773). 1368 | 1369 | **Option 2:** [Use the Raspberry Pi Imager](https://www.raspberrypi.com/software/). Select 'Use custom: Select a custom.img from your computer' and then select the emonSD image that you have just downloaded. There is no need to unzip the image first, just use the .zip file directly. **WARNING: the user name must not be changed; it must be "pi"**. 1370 | 1371 | ## Before bootup SSH & WiFi configuration 1372 | 1373 | **Before booting up the Raspberry Pi** you may want to enable SSH and pre-configure your WiFi details on the image first. SSH provides command line access to the RaspberryPi. If you are not sure if you need this, leave it disabled for now, it can be enabled later. 1374 | 1375 | Plug the SD card into your computer again and wait for the SD card partitions to load. On Linux you should see three partitions: boot, rootfs and a larger data volume. On Windows you may only see the boot partition. 1376 | 1377 | **To enable SSH:** Open the boot partition and add an empty file called `ssh`. 1378 | 1379 | Safely dismount the SD card and insert in the Raspberry Pi. 1380 | 1381 | **First boot update:** If connected to the internet by Ethernet (or pre-configured WiFi), a fresh emonSD will run a full system update. It's best not to interrupt this process. Leave about 10 min before switching off or rebooting. See `/var/log/emoncms/update.log` if you want to view the update log to check if it's finished. 1382 | 1383 | **WiFi Access Point:** If the SD card is booted without ethernet connected or WiFi configured it will create a WiFi access point to allow scanning for a local network and configuration via the web user interface `IP address: 192.168.42.1`. The first boot update is not performed in this case and we suggest updating via the emoncms admin interfacer at a convenient time once the system is up and running. 1384 | 1385 | *** 1386 | 1387 | ## Identify Image Version 1388 | 1389 | The Image version can be identified in three ways: 1390 | 1391 | **emonPi systems:** - View emonPi LCD at startup or press the LCD button the scroll through the pages until `emonSD-XX` is displayed. 1392 | 1393 | **All systems: Emoncms admin interface** - view the emonSD version in the local Emoncms admin interface. 1394 | 1395 | **All systems: Look for a file in /boot partition** for a file called `emonSD-XXX` in the FAT /boot partition: 1396 | 1397 | ```$ sudo ls /boot | grep emonSD``` 1398 | 1399 | 1400 | 1401 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | emonSD 2 | ====== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | Download pre-built image 8 | Build with EmonScripts 9 | Raspberry Pi preparation 10 | Digital Ocean VM preparation 11 | -------------------------------------------------------------------------------- /docs/install-scripts.md: -------------------------------------------------------------------------------- 1 | # Individual Install Scripts 2 | 3 | All these links, link to the `stable` branch. 4 | 5 | The installation process is broken out into separate scripts that can be run individually. 6 | 7 | **[init.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/init.sh)** Launches the full installation script, first downloading the EmonScripts repository that contains the rest of the installation scripts. All output sent to screen also stored in the user's home directory `~/init.sh.log`. 8 | 9 | **[main.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/main.sh)** Loads the configuration file and runs the individual installation scripts as applicable. All output sent to screen also stored in the user's home directory `~/main.sh.log`. 10 | 11 | --- 12 | 13 | **[apache.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/apache.sh)** Apache configuration, mod rewrite and apache logging. 14 | 15 | **[mysql.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/mysql.sh)** Removal of test databases, creation of emoncms database and emoncms mysql user. 16 | 17 | **[php.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/php.sh)** PHP packages installation and configuration 18 | 19 | **[redis.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/redis.sh)** Installs redis and configures the redis configuration file: turning off redis database persistance. 20 | 21 | **[mosquitto.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/mosquitto.sh)** Installation and configuration of mosquitto MQTT server, used for emoncms MQTT interface with emonhub and smart control e.g: demandshaper module. 22 | 23 | --- 24 | 25 | **[emoncms_core.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emoncms_core.sh)** Installation of emoncms core, data directories and emoncms core services. 26 | 27 | **[emoncms_modules.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emoncms_modules.sh)** Installation of emoncms optional modules listed in config.ini e.g: Graphs, Dashboards, Apps & Backup 28 | 29 | **[emonhub.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emonhub.sh)** Emonhub is used in the OpenEnergyMonitor system to read data received over serial from either the EmonPi board or the RFM12/69Pi adapter board then forward the data to emonCMS in a decoded ready-to-use form 30 | 31 | **[firmware.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/firmware.sh)** Requirements for firmware upload to directly connected emonPi hardware or rfm69pi adapter board. 32 | 33 | **[emonpilcd.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emonpilcd.sh)** Support for emonPi LCD. 34 | 35 | **[wifiap.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/wifiap.sh)** RaspberryPi 3B+ WIFI Access Point support. 36 | 37 | **[emonsd.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emonsd.sh)** RaspberryPi specific configuration e.g: logging, default SSH password and hostname. 38 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # EmonCMS Install Scripts 2 | 3 | ## Introduction 4 | 5 | The [EmonScripts build scripts](https://github.com/openenergymonitor/EmonScripts/) can be used to build a fully fledged emonCMS installation on debian based operating systems, including: installation of LAMP server and related packages, redis, MQTT, emonCMS core, emonCMS modules, and if applicable, emonhub & RaspberryPi support for serial port, and WiFi access point. 6 | 7 | We use EmonScripts to build the pre-built emonSD SD card image for the Raspberry Pi. If you prefer to build your own or customise the installation using EmonScripts directly is a good approach. 8 | 9 | The installation process is carried out by a series of scripts that install each required component. These can be explored here: [https://github.com/openenergymonitor/EmonScripts/tree/master/install](https://github.com/openenergymonitor/EmonScripts/tree/master/install). 10 | 11 | It is **strongly recommended** that you dedicate a single device (NUC/VM/Pi) to emoncms. Using it alongside other software can prove problematic. 12 | 13 | **Before starting,** please review the EmonScripts issue list for any new issues that might affect your build. We try to list new issues and notes from recent builds there that might be useful or required to complete a successful build: [https://github.com/openenergymonitor/EmonScripts/issues](https://github.com/openenergymonitor/EmonScripts/issues). 14 | 15 | ## Building Your Own - Base OS Preparation 16 | 17 | ### RaspberryPi 18 | 19 | To install on a RaspberryPi, a number of tasks are first required. Please follow [these instructions first](rpi-install.md). 20 | 21 | ### Ubuntu 22 | 23 | For Ubuntu, post base OS install, run this command so the user does not need a password for `sudo`. 24 | 25 | ```shell 26 | sudo echo $USER' ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/$USER && sudo chmod 0440 /etc/sudoers.d/$USER 27 | ``` 28 | 29 | ### Digital Ocean Droplet 30 | 31 | For installation on a Digital Ocean Droplet, follow [these instructions](digital-ocean-install.md). 32 | 33 | ## Install the EmonCMS Installation Scripts 34 | 35 | Pull the script from GitHub (note if you wish to pull the script from `master` change the path). If you **want** to install the master branch 36 | 37 | ```shell 38 | wget https://raw.githubusercontent.com/openenergymonitor/EmonScripts/stable/install/init.sh 39 | chmod +x init.sh && ./init.sh 40 | ``` 41 | 42 | The `init` script automatically calls the `main` script. At this point you will be offered the option to configure the installation process. 43 | 44 | Output from `init.sh` is displayed on screen and also stored in the user's home directory `~/init.sh.log`. Output from `main.sh` is also displayed on screen and stored in the user's home directory `~/main.sh.log`. 45 | 46 | If you are on a RaspberryPi or EmonPi you can usually just proceed. 47 | 48 | Be patient, the install process takes some time. 49 | 50 | ### Ubuntu 51 | 52 | For Ubuntu, once the script starts and asks if you "would like to review the build script before starting?" Answer y(es) 53 | The installation must be configured before proceeding... 54 | 55 | ## Configure install 56 | 57 | The default configuration is specifically for the RaspberryPi platform and Raspbian Buster image. To run the installation on a different distribution, you may need to change the configuration to reflect the target environment, e.g. set `emonSD_pi_env=0` 58 | 59 | To edit the configuration (standard file paths): 60 | 61 | ```shell 62 | cd /opt/openenergymonitor/EmonScripts/install/ 63 | nano config.ini 64 | ``` 65 | ### Ubuntu 66 | 67 | Change the following: 68 | ``` 69 | user=[YOUR_UBUNTU_USERNAME] 70 | emonSD_pi_env=0 71 | 72 | install_emonhub=false 73 | 74 | install_emoncms_emonpi_modules=false 75 | install_firmware=false 76 | install_emonpilcd=false 77 | install_emonsd=false 78 | install_wifiap=false 79 | ``` 80 | Comment out the following: 81 | ``` 82 | #emoncms_emonpi_modules[config]=stable 83 | #emoncms_emonpi_modules[wifi]=stable 84 | #emoncms_emonpi_modules[setup]=stable 85 | ``` 86 | To restart the installation: 87 | 88 | ```shell 89 | ./main.sh 90 | ``` 91 | 92 | See explanation and settings in the installation configuration file here: [config.ini](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/emonsd.config.ini) 93 | 94 | ## Run Scripts Individually 95 | 96 | It is possible to run the [scripts individually](https://github.com/openenergymonitor/EmonScripts/blob/stable/docs/install-scripts.md) for a single part of the stack. These are not guaranteed to be a complete solution (some folders may not be created for instance). 97 | 98 | ## Post Install - Settings 99 | 100 | If you have used EmonCMS before, you may need to edit the settings to suit your local setup. This is now an `ini` file called `settings.ini` in `/var/www/emoncms/`. 101 | 102 | ## Post Install - First Use 103 | 104 | To access EmonCMS go to the IP of your machine, in your browser. This [Guide](https://guide.openenergymonitor.org/setup/connect/) will help you set your system up. 105 | 106 | At the initial user screen, you need to select **Register** and create a user - this will be the admin user. 107 | 108 | If you are migrating from an old system, export your data from the old system and import the data to the new system (after registering a user). This will require you to login as the original user. 109 | 110 | ## Standard Setup Filepaths 111 | 112 | | Role | Location | 113 | | :------------- | :----------- | 114 | | Install location for code from OpenEnergyMonitor GitHub repository such as EmonScripts | `/opt/openenergymonitor` | 115 | | Install location for modules symlinked to www | `/opt/emoncms` | 116 | | Main code location | `/var/www/emoncms` | 117 | | Log file location | `/var/log/emoncms` | 118 | | Data directory | `/var/opt/emoncms` | 119 | -------------------------------------------------------------------------------- /docs/rpi-install.md: -------------------------------------------------------------------------------- 1 | # EmonScripts: SD Card Preparation for RaspberryPi 2 | 3 | 1\. Start by following the first part of this nice guide by Pimoroni: [Setting up a Headless Pi](https://learn.pimoroni.com/article/setting-up-a-headless-pi) to flash the base OS Image. Choose the Lite 32-bit image. Set a username (`pi`) & password, Enable SSH, and add your WiFi credentials if required. **Do not insert into the Pi**. 4 | 5 | 2\. Eject the SD Card from computer and reinsert. On Windows open 'Disk Management' and look for the SDCard. At the end there will be a large area of unallocated space. Right Click on that and select `New Simple Volume`. What you select here does not matter, but do not format it (waste of time!). Eject card and insert into the Pi. Let the Pi do it's first boot (be patient it reboots several times). 6 | 7 | 3\. Once it has booted SSH into the Pi. e.g. `ssh pi@192.168.1.100` (password: your password)` or use PuTTY. 8 | 9 | 4\. You now need to delete the partition you created. It was there to prevent the Pi expanding the `rootfs` on first boot. You cannot easily shrink `rootfs`! You will then create a new partition at the end of the card and then increase `rootfs` to fill the remaining space. Follow the following instructions: 10 | 11 | 5\. Delete additional partition 12 | 13 | ```shell 14 | sudo parted /dev/mmcblk0 rm 3 15 | ``` 16 | 17 | 6\. Create a new partition at the end - you specify the **start** point and the partition filles to the end of the card. The **example** 20G figure is the **start** point for the data partition and can vary depending on size of card of course. For testing make it small so the mkfs doesn't take an age!! You will get an error message in red - ignore it. 18 | 19 | Create partition starting at XX and filling to the end. 20 | 21 | ```shell 22 | echo "5G, +" | sudo sfdisk --force -N 3 /dev/mmcblk0 23 | ``` 24 | 25 | 7\. Expand the root partition in the space available. Again an error message - ignore it! 26 | 27 | ```shell 28 | echo ", +" | sudo sfdisk --force -N 2 /dev/mmcblk0 29 | ``` 30 | 31 | 8\. Run partprobe 32 | 33 | ```shell 34 | sudo partprobe 35 | ``` 36 | 37 | 9\. Resize the rootfs 38 | 39 | ```shell 40 | sudo resize2fs /dev/mmcblk0p2 41 | ``` 42 | 43 | 10\. Format the new partition. We set the blocksize here to be 1024 bytes instead of the default 4096 bytes. A lower block size results in significant write load reduction when using an application like emoncms that only makes small but frequent and across many files updates to disk. Ext2 is choosen because it supports multiple linux user ownership options which are needed for the mysql data folder. Ext2 is non-journaling which reduces the write load a little although it may make data recovery harder vs Ext4, The data disk size is small however and the downtime from running fsck is perhaps less critical. 44 | 45 | ```shell 46 | sudo mkfs.ext2 -b 1024 /dev/mmcblk0p3 47 | ``` 48 | 49 | 11\. Pull down the fstab as before (change `stable` to `master` if you want the master branch) 50 | 51 | ```shell 52 | wget https://raw.githubusercontent.com/openenergymonitor/EmonScripts/stable/defaults/etc/fstab 53 | ``` 54 | 55 | 12\. Then 56 | 57 | ```shell 58 | sudo mv fstab /etc/fstab && sudo reboot now 59 | ``` 60 | 61 | After the rebbot it should look like this (roughly, your sizes may vary). 62 | 63 | ```shell 64 | pi@emonsdtestZ:~ $ df -h 65 | Filesystem Size Used Avail Use% Mounted on 66 | udev 661M 0 661M 0% /dev 67 | tmpfs 185M 1.2M 184M 1% /run 68 | /dev/mmcblk0p2 4.4G 1.7G 2.6G 39% / 69 | tmpfs 925M 0 925M 0% /dev/shm 70 | tmpfs 5.0M 16K 5.0M 1% /run/lock 71 | tmpfs 30M 0 30M 0% /tmp 72 | tmpfs 1.0M 0 1.0M 0% /var/lib/php/sessions 73 | tmpfs 1.0M 0 1.0M 0% /var/tmp 74 | /dev/mmcblk0p1 510M 93M 418M 19% /boot 75 | /dev/mmcblk0p3 9.7G 14K 9.2G 1% /var/opt/emoncms 76 | tmpfs 185M 0 185M 0% /run/user/1000 77 | ``` 78 | 79 | Note post EmonScripts steps listed in the [RaspberryPi OS 32bit Lite install (10th Nov 2022) PROCESS UPDATE issue](https://github.com/openenergymonitor/EmonScripts/issues/148). 80 | -------------------------------------------------------------------------------- /emonupload2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # This script is used to upload pre-compiled firmware to OpenEnergyMonitor hardware 4 | # It is designed to be ran from the command line and is an alternative to using the Emoncms firmware upload tool 5 | 6 | import sys 7 | import json 8 | import subprocess 9 | import os.path 10 | import urllib.request 11 | 12 | # Load firmware list from firmware_available.json 13 | with open("firmware_available.json") as jsonFile: 14 | firmware_available = json.load(jsonFile) 15 | jsonFile.close() 16 | 17 | # -------------------------------------------------------------------------------------------- 18 | # 1) Hardware selection 19 | # -------------------------------------------------------------------------------------------- 20 | 21 | # Create list of hardware 22 | hardware_list = [] 23 | for key in firmware_available: 24 | hardware = firmware_available[key]['hardware'] 25 | if not hardware in hardware_list: 26 | hardware_list.append(hardware) 27 | 28 | # Print list of hardware 29 | print ("Select hardware:") 30 | for idx, key in enumerate(hardware_list): 31 | print (" "+str(int(idx)+1)+". "+key) 32 | 33 | # Select hardware 34 | x = int(input("Enter number:"))-1 35 | # Check if valid 36 | try: 37 | selected_hardware = hardware_list[x] 38 | except IndexError: 39 | sys.exit(0) 40 | 41 | # -------------------------------------------------------------------------------------------- 42 | # 2) Firmware selection 43 | # -------------------------------------------------------------------------------------------- 44 | 45 | # Print list of firmware for selected hardware 46 | print("\nSelect firmware:") 47 | keys = [] 48 | idx = 0 49 | for key in firmware_available: 50 | if firmware_available[key]['hardware'] == selected_hardware: 51 | if firmware_available[key]['radio_format'] != "jeelib_native": 52 | idx += 1 53 | 54 | # Easier to read radio format 55 | radio_format_string = "" 56 | if firmware_available[key]['radio_format'] == 'lowpowerlabs': 57 | radio_format_string = " (Standard LowPowerLabs)" 58 | elif firmware_available[key]['radio_format'] == 'jeelib_classic': 59 | radio_format_string = " (Compatibility)" 60 | 61 | print (str(idx)+". "+key.ljust(40)+firmware_available[key]['version'].ljust(10)+radio_format_string) 62 | keys.append(key) 63 | 64 | # Select firmware 65 | x = int(input("Enter number:"))-1 66 | # Check if valid 67 | try: 68 | selected_firmware = keys[x] 69 | except IndexError: 70 | sys.exit(0) 71 | 72 | # Print selected firmware 73 | print("\nSelected firmware: "+str(selected_firmware)+"\n") 74 | 75 | # -------------------------------------------------------------------------------------------- 76 | # 3) Download and upload firmware 77 | # -------------------------------------------------------------------------------------------- 78 | 79 | # Check if /dev/ttyUSB0,1,2,3 exists 80 | print ("Checking for serial port...") 81 | for i in range(0,4): 82 | serial_port = "/dev/ttyUSB"+str(i) 83 | print("- checking: "+serial_port) 84 | if os.path.exists(serial_port): 85 | break 86 | else: 87 | serial_port = None 88 | 89 | # Exit if no serial port found 90 | if serial_port == None: 91 | print("Error: No serial port found") 92 | sys.exit(0) 93 | 94 | # Get firmware details & convert to object 95 | f = type('obj', (object,), firmware_available[selected_firmware])() 96 | 97 | # File name of downloaded firmware 98 | download_filename = selected_firmware + "_" + f.radio_format + "_v" + f.version + ".hex" 99 | 100 | # Download using python 101 | urllib.request.urlretrieve(f.download_url, download_filename) 102 | 103 | # Check if firmware downloaded 104 | if not os.path.isfile(download_filename): 105 | print("Error: Firmware download failed") 106 | 107 | # Upload firmware 108 | cmd = ' avrdude -Cupdate/avrdude.conf -v -p' + f.core + ' -carduino -D -P' + str(serial_port) + ' -b' + str(f.baud) + ' -Uflash:w:' + download_filename 109 | print(cmd) 110 | subprocess.call(cmd, shell=True) 111 | 112 | # cleanup 113 | os.remove(download_filename) -------------------------------------------------------------------------------- /firmware_available.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "emonTx5_DB_6CT_1phase_LPL":{ 4 | "hardware":"emonTx5", 5 | "core":"avr128db48", 6 | "radio_format":"lowpowerlabs", 7 | "version":"2.1.0", 8 | "date":"14 May 2024", 9 | "baud":115200, 10 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_6CT_1phase_LPL_v2_1_0.ino.hex", 11 | "description":"emonTx5 DB single phase, 6 channel firmware, pulse on analog" 12 | }, 13 | 14 | "emonTx5_DB_6CT_3phase_LPL":{ 15 | "hardware":"emonTx5", 16 | "core":"avr128db48", 17 | "radio_format":"lowpowerlabs", 18 | "version":"2.1.0", 19 | "date":"14 May 2024", 20 | "baud":115200, 21 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_6CT_3phase_LPL_v2_1_0.ino.hex", 22 | "description":"emonTx5 DB three phase, 6 channel firmware, pulse on analog" 23 | }, 24 | 25 | "emonTx5_DB_6CT_N_American_split_phase_LPL":{ 26 | "hardware":"emonTx5", 27 | "core":"avr128db48", 28 | "radio_format":"lowpowerlabs", 29 | "version":"2.1.0", 30 | "date":"21 Nov 2024", 31 | "baud":115200, 32 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_6CT_N_American_split_phase_LPL_v2_1_0.ino.hex", 33 | "description":"emonTx5 DB N.American split phase, 6 channel firmware, pulse on analog" 34 | }, 35 | 36 | "emonTx5_DB_12CT_1phase_LPL":{ 37 | "hardware":"emonTx5", 38 | "core":"avr128db48", 39 | "radio_format":"lowpowerlabs", 40 | "version":"1.2.0", 41 | "date":"17 May 2024", 42 | "baud":115200, 43 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_12CT_1phase_LPL_v1_2_0.ino.hex", 44 | "description":"emonTx5 DB single phase, 12 channel firmware" 45 | }, 46 | 47 | "emonTx5_DB_12CT_3phase_LPL":{ 48 | "hardware":"emonTx5", 49 | "core":"avr128db48", 50 | "radio_format":"lowpowerlabs", 51 | "version":"1.2.0", 52 | "date":"17 May 2024", 53 | "baud":115200, 54 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_12CT_3phase_LPL_v1_2_0.ino.hex", 55 | "description":"emonTx5 DB three phase, 12 channel firmware" 56 | }, 57 | 58 | "emonTx5_DB_12CT_N_American_split_phase_LPL":{ 59 | "hardware":"emonTx5", 60 | "core":"avr128db48", 61 | "radio_format":"lowpowerlabs", 62 | "version":"1.2.0", 63 | "date":"21 Nov 2024", 64 | "baud":115200, 65 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_DB_12CT_N_American_split_phase_LPL_v1_2_0.ino.hex", 66 | "description":"emonTx5 DB N.American split phase, 12 channel firmware" 67 | }, 68 | 69 | "emonTx5_CM_6CT_temperature_LPL":{ 70 | "hardware":"emonTx5", 71 | "core":"avr128db48", 72 | "radio_format":"lowpowerlabs", 73 | "version":"1.6.2", 74 | "date":"29 May 2024", 75 | "baud":115200, 76 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_CM_6CT_temperature_LPL_v1_6_2.ino.hex", 77 | "description":"emonTx5 CM single phase, 6 channel firmware with temperature sensing support. Pulse on analog. Can be used without an emonVs voltage sensor (current only)" 78 | }, 79 | 80 | "emonTx5_CM_6CT_temperature_digital_LPL":{ 81 | "hardware":"emonTx5", 82 | "core":"avr128db48", 83 | "radio_format":"lowpowerlabs", 84 | "version":"1.6.3", 85 | "date":"29 Aug 2024", 86 | "baud":115200, 87 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx5/emonTx5_CM_6CT_temperature_digital_LPL_v1_6_3.ino.hex", 88 | "description":"emonTx5 CM single phase, 6 channel firmware with temperature sensing support. Digital input on analog (e.g for use with DHW sensor). Can be used without an emonVs voltage sensor (current only)" 89 | }, 90 | 91 | "emonPi2_DB_6CT_1phase":{ 92 | "hardware":"emonPi2", 93 | "core":"avr128db48", 94 | "radio_format":"lowpowerlabs", 95 | "version":"2.1.0", 96 | "date":"14 May 2024", 97 | "baud":115200, 98 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_6CT_1phase_v2_1_0.ino.hex", 99 | "description":"emonPi2 DB single phase, 6 channel firmware, pulse on analog", 100 | "autoreset":"-pi2" 101 | }, 102 | 103 | "emonPi2_DB_6CT_3phase":{ 104 | "hardware":"emonPi2", 105 | "core":"avr128db48", 106 | "radio_format":"lowpowerlabs", 107 | "version":"2.1.0", 108 | "date":"14 May 2024", 109 | "baud":115200, 110 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_6CT_3phase_v2_1_0.ino.hex", 111 | "description":"emonPi2 DB three phase, 6 channel firmware, pulse on analog", 112 | "autoreset":"-pi2" 113 | }, 114 | 115 | "emonPi2_DB_6CT_N_American_split_phase":{ 116 | "hardware":"emonPi2", 117 | "core":"avr128db48", 118 | "radio_format":"lowpowerlabs", 119 | "version":"2.1.0", 120 | "date":"21 Nov 2024", 121 | "baud":115200, 122 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_6CT_N_American_split_phase_v2_1_0.ino.hex", 123 | "description":"emonPi2 DB N.American split phase, 6 channel firmware, pulse on analog", 124 | "autoreset":"-pi2" 125 | }, 126 | 127 | "emonPi2_DB_12CT_1phase_LPL":{ 128 | "hardware":"emonPi2", 129 | "core":"avr128db48", 130 | "radio_format":"lowpowerlabs", 131 | "version":"1.2.0", 132 | "date":"17 May 2024", 133 | "baud":115200, 134 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_12CT_1phase_LPL_v1_2_0.ino.hex", 135 | "description":"emonPi2 DB single phase, 12 channel firmware", 136 | "autoreset":"-pi2" 137 | }, 138 | 139 | "emonPi2_DB_12CT_3phase_LPL":{ 140 | "hardware":"emonPi2", 141 | "core":"avr128db48", 142 | "radio_format":"lowpowerlabs", 143 | "version":"1.2.0", 144 | "date":"17 May 2024", 145 | "baud":115200, 146 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_12CT_3phase_LPL_v1_2_0.ino.hex", 147 | "description":"emonPi2 DB three phase, 12 channel firmware", 148 | "autoreset":"-pi2" 149 | }, 150 | 151 | "emonPi2_DB_12CT_N_American_split_phase_LPL":{ 152 | "hardware":"emonPi2", 153 | "core":"avr128db48", 154 | "radio_format":"lowpowerlabs", 155 | "version":"1.2.0", 156 | "date":"21 Nov 2024", 157 | "baud":115200, 158 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_12CT_N_American_split_phase_LPL_v1_2_0.ino.hex", 159 | "description":"emonPi2 DB N.American split phase, 12 channel firmware", 160 | "autoreset":"-pi2" 161 | }, 162 | 163 | "emonPi2_CM_6CT":{ 164 | "hardware":"emonPi2", 165 | "core":"avr128db48", 166 | "radio_format":"lowpowerlabs", 167 | "version":"1.6.2", 168 | "date":"29 May 2024", 169 | "baud":115200, 170 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_CM_6CT_v1_6_2.ino.hex", 171 | "description":"emonPi2 CM single phase, 6 channel firmware, pulse on analog. Can be used without an emonVs voltage sensor (current only)", 172 | "autoreset":"-pi2" 173 | }, 174 | 175 | "emonPi2_CM_6CT_digital":{ 176 | "hardware":"emonPi2", 177 | "core":"avr128db48", 178 | "radio_format":"lowpowerlabs", 179 | "version":"1.6.3", 180 | "date":"29 Aug 2024", 181 | "baud":115200, 182 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_CM_6CT_digital_v1_6_3.ino.hex", 183 | "description":"emonPi2 CM single phase, 6 channel firmware. Digital input on analog (e.g for use with DHW sensor). Can be used without an emonVs voltage sensor (current only)", 184 | "autoreset":"-pi2" 185 | }, 186 | 187 | "emonPi2_CM_6CT_analog":{ 188 | "hardware":"emonPi2", 189 | "core":"avr128db48", 190 | "radio_format":"lowpowerlabs", 191 | "version":"1.6.3", 192 | "date":"18 Sep 2024", 193 | "baud":115200, 194 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_CM_6CT_analog_v1_6_3.ino.hex", 195 | "description":"emonPi2 CM single phase, 6 channel firmware. Analog input. Can be used without an emonVs voltage sensor (current only)", 196 | "autoreset":"-pi2" 197 | }, 198 | 199 | "emonPi2_DB_6CT_3phase_analog":{ 200 | "hardware":"emonPi2", 201 | "core":"avr128db48", 202 | "radio_format":"lowpowerlabs", 203 | "version":"2.1.0", 204 | "date":"6 Feb 2025", 205 | "baud":115200, 206 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonPi2/emonPi2_DB_6CT_3phase_analog_v2_1_0.ino.hex", 207 | "description":"emonPi2 DB three phase, 6 channel firmware, Analog input", 208 | "autoreset":"-pi2" 209 | }, 210 | 211 | "emonTx4_DB_6CT_1phase_LPL":{ 212 | "hardware":"emonTx4", 213 | "core":"avr128db48", 214 | "radio_format":"lowpowerlabs", 215 | "version":"2.1.0", 216 | "date":"14 May 2024", 217 | "baud":115200, 218 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_6CT_1phase_LPL_v2_1_0.ino.hex", 219 | "description":"emonTx4 DB single phase, 6 channel firmware, pulse on RJ45 digital" 220 | }, 221 | 222 | "emonTx4_DB_6CT_3phase_LPL":{ 223 | "hardware":"emonTx4", 224 | "core":"avr128db48", 225 | "radio_format":"lowpowerlabs", 226 | "version":"2.1.0", 227 | "date":"14 May 2024", 228 | "baud":115200, 229 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_6CT_3phase_LPL_v2_1_0.ino.hex", 230 | "description":"emonTx4 DB three phase, 6 channel firmware, pulse on RJ45 digital" 231 | }, 232 | 233 | "emonTx4_DB_6CT_N_American_split_phase_LPL":{ 234 | "hardware":"emonTx4", 235 | "core":"avr128db48", 236 | "radio_format":"lowpowerlabs", 237 | "version":"2.1.0", 238 | "date":"21 Nov 2024", 239 | "baud":115200, 240 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_6CT_N_American_split_phase_LPL_v2_1_0.ino.hex", 241 | "description":"emonTx4 DB N.American split phase, 6 channel firmware, pulse on RJ45 digital" 242 | }, 243 | 244 | "emonTx4_DB_12CT_1phase_LPL":{ 245 | "hardware":"emonTx4", 246 | "core":"avr128db48", 247 | "radio_format":"lowpowerlabs", 248 | "version":"1.2.0", 249 | "date":"17 May 2024", 250 | "baud":115200, 251 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_12CT_1phase_LPL_v1_2_0.ino.hex", 252 | "description":"emonTx4 DB single phase, 12 channel firmware" 253 | }, 254 | 255 | "emonTx4_DB_12CT_3phase_LPL":{ 256 | "hardware":"emonTx4", 257 | "core":"avr128db48", 258 | "radio_format":"lowpowerlabs", 259 | "version":"1.2.0", 260 | "date":"17 May 2024", 261 | "baud":115200, 262 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_12CT_3phase_LPL_v1_2_0.ino.hex", 263 | "description":"emonTx4 DB three phase, 12 channel firmware" 264 | }, 265 | 266 | "emonTx4_DB_12CT_N_American_split_phase_LPL":{ 267 | "hardware":"emonTx4", 268 | "core":"avr128db48", 269 | "radio_format":"lowpowerlabs", 270 | "version":"1.2.0", 271 | "date":"21 Nov 2024", 272 | "baud":115200, 273 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_12CT_N_American_split_phase_LPL_v1_2_0.ino.hex", 274 | "description":"emonTx4 DB N.American split phase, 12 channel firmware" 275 | }, 276 | 277 | "emonTx4_CM_6CT_temperature_LPL":{ 278 | "hardware":"emonTx4", 279 | "core":"avr128db48", 280 | "radio_format":"lowpowerlabs", 281 | "version":"1.6.2", 282 | "date":"29 May 2024", 283 | "baud":115200, 284 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_CM_6CT_temperature_LPL_v1_6_2.ino.hex", 285 | "description":"emonTx4 CM single phase, 6 channel firmware with temperature sensing support. Pulse on RJ45 digital. Can be used without an emonVs voltage sensor (current only)" 286 | }, 287 | 288 | "emonTx4_DB_6CT_1phase_JeeLib_Classic":{ 289 | "hardware":"emonTx4", 290 | "core":"avr128db48", 291 | "radio_format":"jeelib_classic", 292 | "version":"2.1.0", 293 | "date":"14 May 2024", 294 | "baud":115200, 295 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_6CT_1phase_JeeLib_Classic_v2_1_0.ino.hex", 296 | "description":"emonTx4 DB single phase, 6 channel firmware, pulse on RJ45 digital" 297 | }, 298 | 299 | "emonTx4_DB_6CT_3phase_JeeLib_Classic":{ 300 | "hardware":"emonTx4", 301 | "core":"avr128db48", 302 | "radio_format":"jeelib_classic", 303 | "version":"2.1.0", 304 | "date":"14 May 2024", 305 | "baud":115200, 306 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_DB_6CT_3phase_JeeLib_Classic_v2_1_0.ino.hex", 307 | "description":"emonTx4 DB three phase, 6 channel firmware, pulse on RJ45 digital" 308 | }, 309 | 310 | "emonTx4_CM_6CT_temperature_JeeLib_Classic":{ 311 | "hardware":"emonTx4", 312 | "core":"avr128db48", 313 | "radio_format":"jeelib_classic", 314 | "version":"1.6.2", 315 | "date":"29 May 2024", 316 | "baud":115200, 317 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/avrdb_firmware/master/compiled/emonTx4/emonTx4_CM_6CT_temperature_JeeLib_Classic_v1_6_2.ino.hex", 318 | "description":"emonTx4 CM single phase, 6 channel firmware with temperature sensing support. Pulse on RJ45 digital. Can be used without an emonVs voltage sensor (current only)" 319 | }, 320 | 321 | "emonPi_CM_LPL":{ 322 | "hardware":"emonPi", 323 | "core":"ATMEGA328P", 324 | "radio_format":"lowpowerlabs", 325 | "version":"1.1.4", 326 | "date":"20 April 2023", 327 | "baud":115200, 328 | "download_url":"https://github.com/openenergymonitor/emonpi/releases/download/20-04-23/emonPi_CM_LPL_1_1_4.hex", 329 | "description":"emonPi continuous sampling firmware" 330 | }, 331 | 332 | "emonPi_CM_jeelib_native":{ 333 | "hardware":"emonPi", 334 | "core":"ATMEGA328P", 335 | "radio_format":"jeelib_native", 336 | "version":"1.1.4", 337 | "date":"20 April 2023", 338 | "baud":115200, 339 | "download_url":"https://github.com/openenergymonitor/emonpi/releases/download/20-04-23/emonPi_CM_jeelib_native_1_1_4.hex", 340 | "description":"emonPi continuous sampling firmware" 341 | }, 342 | 343 | "emonPi_DS_jeelib_classic":{ 344 | "hardware":"emonPi", 345 | "core":"ATMEGA328P", 346 | "radio_format":"jeelib_classic", 347 | "version":"2.9.3", 348 | "date":"5 Jan 2021", 349 | "baud":115200, 350 | "download_url":"https://github.com/openenergymonitor/emonpi/releases/download/2.9.3/firmware.hex", 351 | "description":"emonPi discrete sampling firmware" 352 | }, 353 | 354 | "emonTx34_CM_LPL":{ 355 | "hardware":"emonTx3", 356 | "core":"ATMEGA328P", 357 | "radio_format":"lowpowerlabs", 358 | "version":"2.4.0", 359 | "date":"16 Feb 2023", 360 | "baud":115200, 361 | "download_url":"https://github.com/openenergymonitor/emontx3/releases/download/tx3-16-02-23/emonTx34_CM_LPL_2_4.hex", 362 | "description":"emonTx v3.4 continuous sampling firmware" 363 | }, 364 | "emonTx34_CM_jeelib_classic":{ 365 | "hardware":"emonTx3", 366 | "core":"ATMEGA328P", 367 | "radio_format":"jeelib_classic", 368 | "version":"2.4.0", 369 | "date":"16 Feb 2023", 370 | "baud":115200, 371 | "download_url":"https://github.com/openenergymonitor/emontx3/releases/download/tx3-16-02-23/emonTx34_CM_jeelib_classic_2_4.hex", 372 | "description":"emonTx v3.4 continuous sampling firmware" 373 | }, 374 | "emonTx34_DS_jeelib_classic":{ 375 | "hardware":"emonTx3", 376 | "core":"ATMEGA328P", 377 | "radio_format":"jeelib_classic", 378 | "version":"3.4.0", 379 | "date":"16 Feb 2023", 380 | "baud":115200, 381 | "download_url":"https://github.com/openenergymonitor/emontx3/releases/download/tx3-16-02-23/emonTx34_DS_jeelib_classic_3_4.hex", 382 | "description":"emonTx v3.4 discrete sampling firmware" 383 | }, 384 | "emonTx_3Phase_PLL_LPL":{ 385 | "hardware":"emonTx3", 386 | "core":"ATMEGA328P", 387 | "radio_format":"lowpowerlabs", 388 | "version":"2.1", 389 | "date":"16 Feb 2023", 390 | "baud":115200, 391 | "download_url":"https://github.com/openenergymonitor/emontx3/releases/download/tx3-16-02-23/emonTx_3Phase_PLL_LPL_2_1.hex", 392 | "description":"emonTx 3 phase continuous sampling firmware" 393 | }, 394 | "emonTx_3Phase_PLL_jeelib_classic":{ 395 | "hardware":"emonTx3", 396 | "core":"ATMEGA328P", 397 | "radio_format":"jeelib_classic", 398 | "version":"2.1", 399 | "date":"16 Feb 2023", 400 | "baud":115200, 401 | "download_url":"https://github.com/openenergymonitor/emontx3/releases/download/tx3-16-02-23/emonTx_3Phase_PLL_jeelib_classic_2_1.hex", 402 | "description":"emonTx 3 phase continuous sampling firmware" 403 | }, 404 | "emonBase_rfm69pi_LPL":{ 405 | "hardware":"rfm69pi", 406 | "core":"ATMEGA328P", 407 | "radio_format":"lowpowerlabs", 408 | "version":"1.1.1", 409 | "date":"29 Mar 2023", 410 | "baud":38400, 411 | "download_url":"https://github.com/openenergymonitor/RFM2Pi/releases/download/29-03-23/emonBase_rfm69pi_LPL_v1_1_1.hex", 412 | "description":"emonBase RFM69Pi firmware" 413 | }, 414 | "emonBase_jeelib":{ 415 | "hardware":"rfm69pi", 416 | "core":"ATMEGA328P", 417 | "radio_format":"jeelib_classic", 418 | "version":"1.4.0", 419 | "date":"13 Jan 2017", 420 | "baud":38400, 421 | "download_url":"https://github.com/openenergymonitor/RFM2Pi/releases/download/1.4.0/firmware.hex", 422 | "description":"emonBase RFM69Pi firmware" 423 | }, 424 | "rfm12pi_jeelib":{ 425 | "hardware":"rfm12pi", 426 | "core":"ATMEGA328P", 427 | "radio_format":"jeelib_classic", 428 | "version":"RFM12_Demo_ATmega328", 429 | "date":"2 May 2015", 430 | "baud":38400, 431 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/RFM2Pi/master/firmware/RFM69CW_RF_Demo_ATmega328/RFM12_Demo_ATmega328.cpp.hex", 432 | "description":"emonBase RFM12Pi firmware" 433 | }, 434 | "emonTH2_LPL":{ 435 | "hardware":"emonTH2", 436 | "core":"ATMEGA328P", 437 | "radio_format":"lowpowerlabs", 438 | "version":"4.1.8", 439 | "date":"14 Apr 2025", 440 | "baud":115200, 441 | "download_url":"https://raw.githubusercontent.com/openenergymonitor/emonth2/refs/heads/master/firmware/emonth2_LPL_4_1_8.hex", 442 | "description":"emonTH2 LPL firmware" 443 | }, 444 | "emonTH2_jeelib_classic":{ 445 | "hardware":"emonTH2", 446 | "core":"ATMEGA328P", 447 | "radio_format":"jeelib_classic", 448 | "version":"4.1.7", 449 | "date":"05 Mar 2024", 450 | "baud":115200, 451 | "download_url":"https://github.com/openenergymonitor/emonth2/releases/download/4.1.7/emonth2_jeelib_classic.hex", 452 | "description":"emonTH2 JeeLib firmware" 453 | }, 454 | "JeeLink_rfm69pi_LPL":{ 455 | "hardware":"JeeLink", 456 | "core":"ATMEGA328P", 457 | "radio_format":"lowpowerlabs", 458 | "version":"1.1.1", 459 | "date":"29 Mar 2023", 460 | "baud":115200, 461 | "download_url":"https://github.com/openenergymonitor/RFM2Pi/releases/download/29-03-23/jeelink_rfm69pi_LPL_v1_1_1.hex", 462 | "description":"emonBase RFM69Pi firmware" 463 | }, 464 | "JeeLink_repeater":{ 465 | "hardware":"JeeLink", 466 | "core":"ATMEGA328P", 467 | "radio_format":"lowpowerlabs", 468 | "version":"1.0.0", 469 | "date":"06 Mar 2024", 470 | "baud":115200, 471 | "download_url":"https://github.com/openenergymonitor/RFM2Pi/releases/download/1.4.2/jeelink_repeater.hex", 472 | "description":"JeeLink emonBase LPL" 473 | } 474 | } 475 | -------------------------------------------------------------------------------- /install/.gitignore: -------------------------------------------------------------------------------- 1 | config.ini 2 | -------------------------------------------------------------------------------- /install/apache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Apache configuration" 6 | echo "-------------------------------------------------------------" 7 | sudo apt-get install -y apache2 gettext 8 | 9 | sudo chown $user /var/www 10 | 11 | # create emoncms www folder 12 | if [ ! -d $emoncms_www ]; then 13 | echo "-- create emoncms www folder for Apache" 14 | mkdir $emoncms_www 15 | else 16 | echo "-- emoncms www folder already installed" 17 | fi 18 | 19 | # Create emoncms logfolder 20 | if [ ! -d $emoncms_log_location ]; then 21 | echo "-- creating emoncms log folder" 22 | sudo mkdir $emoncms_log_location 23 | sudo chown $user $emoncms_log_location 24 | else 25 | echo "-- log folder already exists" 26 | fi 27 | 28 | sudo sed -i "s/^CustomLog/#CustomLog/" /etc/apache2/conf-available/other-vhosts-access-log.conf 29 | 30 | # Enable apache mod rewrite 31 | sudo a2enmod rewrite 32 | 33 | # Default apache2 configuration 34 | sudo cp $openenergymonitor_dir/EmonScripts/defaults/apache2/emonsd.conf /etc/apache2/conf-available/emonsd.conf 35 | sudo a2enconf emonsd.conf 36 | 37 | # Configure virtual host 38 | sudo cp $openenergymonitor_dir/EmonScripts/defaults/apache2/emoncms.conf /etc/apache2/sites-available/emoncms.conf 39 | sudo a2dissite 000-default.conf 40 | sudo a2ensite emoncms 41 | 42 | sudo systemctl restart apache2 43 | 44 | -------------------------------------------------------------------------------- /install/docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "-- Installing Docker" 4 | # Add Docker's official GPG key: 5 | sudo apt-get update 6 | sudo apt-get install -y ca-certificates curl gnupg 7 | sudo install -m 0755 -d /etc/apt/keyrings 8 | [ -f /etc/apt/keyrings/docker.gpg ] && sudo rm /etc/apt/keyrings/docker.gpg 9 | curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 10 | sudo chmod a+r /etc/apt/keyrings/docker.gpg 11 | 12 | # Set up Docker's APT repository: 13 | echo "-- set up docker's APT repository" 14 | 15 | echo \ 16 | "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian \ 17 | "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ 18 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 19 | sudo apt-get update 20 | 21 | echo "-- apt-get install docker & dependencies" 22 | sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 23 | 24 | echo "-- add docker to pi user group" 25 | sudo usermod -aG docker pi 26 | 27 | echo "-- disable docker.service for now" 28 | sudo systemctl disable --now docker.service 29 | -------------------------------------------------------------------------------- /install/emoncms_core.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Install Emoncms Core" 6 | echo "-------------------------------------------------------------" 7 | 8 | # Give user ownership over /var/www/ folder 9 | sudo chown $user /var/www 10 | 11 | # Install emoncms core repository with git 12 | if [ -f "$emoncms_www/version.json" ]; then 13 | echo "-- emoncms already installed" 14 | else 15 | cd /var/www && git clone -b $emoncms_core_branch ${git_repo[emoncms_core]} 16 | cd 17 | fi 18 | 19 | # Create emoncms logfolder 20 | if [ ! -d $emoncms_log_location ]; then 21 | echo "-- creating emoncms log folder" 22 | sudo mkdir $emoncms_log_location 23 | sudo chown $user $emoncms_log_location 24 | else 25 | echo "-- log folder already exists" 26 | fi 27 | 28 | # Create emoncms logfile 29 | if [ ! -f "$emoncms_log_location/emoncms.log" ]; then 30 | echo "-- creating emoncms log file" 31 | sudo touch "$emoncms_log_location/emoncms.log" 32 | sudo chmod 666 "$emoncms_log_location/emoncms.log" 33 | else 34 | echo "-- log file already exists" 35 | fi 36 | 37 | # Copy and install emonpi.settings.ini 38 | if [ ! -f $emoncms_www/settings.ini ]; then 39 | echo "-- installing default emoncms settings.ini" 40 | cp $openenergymonitor_dir/EmonScripts/defaults/emoncms/emonpi.settings.ini $emoncms_www/settings.ini 41 | sed -i "s~EMONCMS_DIR~$emoncms_dir~" $emoncms_www/settings.ini 42 | sed -i "s~OPENENERGYMONITOR_DIR~$openenergymonitor_dir~" $emoncms_www/settings.ini 43 | sed -i "s~EMONCMS_DATADIR~$emoncms_datadir~" $emoncms_www/settings.ini 44 | else 45 | echo "-- emoncms settings.ini already exists" 46 | fi 47 | 48 | if [ ! -d $emoncms_datadir ]; then 49 | sudo mkdir $emoncms_datadir 50 | fi 51 | 52 | # Create data directories for emoncms feed engines: 53 | for engine in "phpfina" "phpfiwa" "phptimeseries"; do 54 | if [ ! -d $emoncms_datadir/$engine ]; then 55 | echo "-- create $engine dir" 56 | sudo mkdir $emoncms_datadir/$engine 57 | sudo chown www-data:root $emoncms_datadir/$engine 58 | else 59 | echo "-- datadir $engine already exists" 60 | fi 61 | done 62 | 63 | if [ ! -d $emoncms_dir ] 64 | then 65 | sudo mkdir $emoncms_dir 66 | sudo chown $USER $emoncms_dir 67 | fi 68 | 69 | # Create a symlink to reference emoncms within the web root folder (review): 70 | if [ ! -d /var/www/html/emoncms ]; then 71 | echo "-- symlinking emoncms folder to /var/www/html/emoncms" 72 | sudo ln -s $emoncms_www /var/www/html/emoncms 73 | 74 | # Redirect (review) 75 | echo "-- creating redirect to $emoncms_www" 76 | echo "" > $emoncms_dir/index.php 77 | sudo mv $emoncms_dir/index.php /var/www/html/index.php 78 | sudo rm /var/www/html/index.html 79 | fi 80 | 81 | echo "-------------------------------------------------------------" 82 | echo "Install Emoncms Services" 83 | echo "-------------------------------------------------------------" 84 | 85 | if [ "$install_redis" = true ]; then 86 | # Install actual services, enable and start 87 | for service in "feedwriter" "service-runner"; do 88 | servicepath=$emoncms_www/scripts/services/$service/$service.service 89 | echo "-- installing $service to $servicepath" 90 | $openenergymonitor_dir/EmonScripts/common/install_emoncms_service.sh $servicepath $service 91 | done 92 | 93 | # Install service-runner drop-in if system user is different 94 | if [ "$user" != "pi" ]; then 95 | echo "-- installing service-runner drop-in User=$user" 96 | if [ ! -d /lib/systemd/system/service-runner.service.d ]; then 97 | sudo mkdir /lib/systemd/system/service-runner.service.d 98 | fi 99 | echo $'[Service]\nUser='$user > service-runner.conf 100 | sudo mv service-runner.conf /lib/systemd/system/service-runner.service.d/service-runner.conf 101 | 102 | echo "-- installing feedwriter drop-in User=$user" 103 | if [ ! -d /lib/systemd/system/feedwriter.service.d ]; then 104 | sudo mkdir /lib/systemd/system/feedwriter.service.d 105 | fi 106 | echo $'[Service]\nEnvironment="USER='$user'"' > feedwriter.conf 107 | sudo mv feedwriter.conf /lib/systemd/system/feedwriter.service.d/feedwriter.conf 108 | fi 109 | sudo systemctl daemon-reload 110 | sudo systemctl restart {feedwriter.service,service-runner.service} 111 | 112 | if [ "$install_mosquitto_client" = true ]; then 113 | servicepath=$emoncms_www/scripts/services/emoncms_mqtt/emoncms_mqtt.service 114 | echo "-- installing $service to $servicepath" 115 | $openenergymonitor_dir/EmonScripts/common/install_emoncms_service.sh $servicepath emoncms_mqtt 116 | 117 | if [ "$user" != "pi" ]; then 118 | echo "-- installing emoncms_mqtt drop-in User=$user" 119 | if [ ! -d /lib/systemd/system/emoncms_mqtt.service.d ]; then 120 | sudo mkdir /lib/systemd/system/emoncms_mqtt.service.d 121 | fi 122 | echo $'[Service]\nEnvironment="USER='$user'"' > emoncms_mqtt.conf 123 | sudo mv emoncms_mqtt.conf /lib/systemd/system/emoncms_mqtt.service.d/emoncms_mqtt.conf 124 | fi 125 | sudo systemctl daemon-reload 126 | sudo systemctl restart emoncms_mqtt.service 127 | fi 128 | fi 129 | 130 | echo 131 | 132 | if [ "$emonSD_pi_env" = "1" ]; then 133 | # Sudoers entry (review) 134 | sudo visudo -cf $openenergymonitor_dir/EmonScripts/sudoers.d/emoncms-rebootbutton && \ 135 | sudo cp $openenergymonitor_dir/EmonScripts/sudoers.d/emoncms-rebootbutton /etc/sudoers.d/ 136 | sudo chmod 0440 /etc/sudoers.d/emoncms-rebootbutton 137 | echo "-- emonPi emoncms admin reboot button sudoers updated" 138 | fi 139 | 140 | echo 141 | -------------------------------------------------------------------------------- /install/emoncms_emonpi_modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Install Emoncms EMONPi / EmonBase specific Modules" 6 | echo "-------------------------------------------------------------" 7 | # Review default branch: e.g stable 8 | cd $emoncms_www/Modules 9 | for module in ${!emoncms_emonpi_modules[@]}; do 10 | branch=${emoncms_emonpi_modules[$module]} 11 | if [ ! -d $module ]; then 12 | echo "-- Installing module: $module" 13 | git clone -b $branch ${git_repo[$module]} 14 | else 15 | echo "-- Module $module already exists" 16 | fi 17 | done 18 | 19 | echo "-- Update Emoncms database" 20 | php $openenergymonitor_dir/EmonScripts/common/emoncmsdbupdate.php 21 | -------------------------------------------------------------------------------- /install/emoncms_modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Install Emoncms Core Modules" 6 | echo "-------------------------------------------------------------" 7 | # Review default branch: e.g stable 8 | cd $emoncms_www/Modules 9 | for module in ${!emoncms_modules[@]}; do 10 | branch=${emoncms_modules[$module]} 11 | if [ ! -d $module ]; then 12 | echo "-- Installing module: $module" 13 | git clone -b $branch ${git_repo[$module]} 14 | else 15 | echo "-- Module $module already exists" 16 | fi 17 | done 18 | 19 | if [ ! -d $emoncms_dir ] 20 | then 21 | sudo mkdir $emoncms_dir 22 | sudo chown $USER $emoncms_dir 23 | fi 24 | 25 | # Install emoncms modules that do not reside in /var/www/emoncms/Modules 26 | if [ ! -d $emoncms_dir/modules ]; then 27 | mkdir $emoncms_dir/modules 28 | fi 29 | 30 | cd $emoncms_dir/modules 31 | for module in ${!symlinked_emoncms_modules[@]}; do 32 | branch=${symlinked_emoncms_modules[$module]} 33 | if [ ! -d $module ]; then 34 | echo "-- Installing module: $module" 35 | git clone -b $branch ${git_repo[$module]} 36 | # If module contains emoncms UI folder, symlink to $emoncms_www/Modules 37 | if [ -d $emoncms_dir/modules/$module/$module-module ]; then 38 | echo "--- UI directory symlink" 39 | ln -s $emoncms_dir/modules/$module/$module-module $emoncms_www/Modules/$module 40 | fi 41 | # run module install script if present 42 | if [ -f $emoncms_dir/modules/$module/install.sh ]; then 43 | $emoncms_dir/modules/$module/install.sh $openenergymonitor_dir 44 | echo 45 | fi 46 | else 47 | echo "-- Module $module already exists" 48 | fi 49 | done 50 | 51 | echo "-- Update Emoncms database" 52 | php $openenergymonitor_dir/EmonScripts/common/emoncmsdbupdate.php 53 | -------------------------------------------------------------------------------- /install/emonhub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "emonHub install" 6 | echo "-------------------------------------------------------------" 7 | cd $openenergymonitor_dir 8 | 9 | if [ ! -d $openenergymonitor_dir/emonhub ]; then 10 | git clone -b $emonhub_branch ${git_repo[emonhub]} 11 | else 12 | echo "-- emonhub repository already installed" 13 | echo "-- emonhub running git pull:" 14 | git -C $openenergymonitor_dir/emonhub pull 15 | fi 16 | 17 | if [ -f $openenergymonitor_dir/emonhub/install.sh ]; then 18 | $openenergymonitor_dir/emonhub/install.sh $emonSD_pi_env $user 19 | else 20 | echo "-- ERROR: $openenergymonitor_dir/emonhub/install.sh script does not exist" 21 | fi 22 | 23 | # Sudoers entry (review!) 24 | sudo visudo -cf $openenergymonitor_dir/EmonScripts/sudoers.d/emonhub-sudoers && \ 25 | sudo cp $openenergymonitor_dir/EmonScripts/sudoers.d/emonhub-sudoers /etc/sudoers.d/ 26 | sudo chmod 0440 /etc/sudoers.d/emonhub-sudoers 27 | echo "-- emonhub service control sudoers entry installed" 28 | -------------------------------------------------------------------------------- /install/emonhub_gateway.config.ini: -------------------------------------------------------------------------------- 1 | # Edit this config file to suit your local environment if it is not a 2 | # vanilla Raspberry Pi. 3 | # 4 | # Main settings to look atif a non pi environment 5 | # user - Change user to reflect your OS user 6 | # emonSD_pi_env - Set emonSD_pi_env=0 if not a raspberrypi 7 | # install_redis - REDIS is required for feedwriter, service-runner and emoncms_mqtt services 8 | # locations - modify the install and data storage locations 9 | 10 | user=pi 11 | hostname=ehgateway 12 | emonSD_pi_env=1 13 | 14 | # Components enabled 15 | apt_get_upgrade_and_clean=true 16 | install_apache=false 17 | install_mysql=false 18 | install_php=false 19 | install_redis=false 20 | # To use mqtt but a different server, just set install_mosquitto_server=false 21 | # manually configure mqtt server settings in settings.ini 22 | install_mosquitto=false 23 | install_mosquitto_server=false 24 | install_mosquitto_client=false 25 | 26 | install_emoncms_core=false 27 | install_emoncms_modules=false 28 | 29 | # RaspberryPi emonSD applicable items - ignored if setting emonSD_pi_env=0 30 | # set to false if not needed 31 | 32 | # EmonHub: comment out line above "emoncms_emonpi_modules[config]=stable" if 33 | # you do not wish to have the emoncms emonhub config module installed 34 | install_emonhub=true 35 | 36 | install_emoncms_emonpi_modules=false 37 | install_firmware=false 38 | install_emonpilcd=false 39 | install_emonsd=true 40 | install_docker=false 41 | install_network=false 42 | 43 | openenergymonitor_dir=/opt/openenergymonitor 44 | emoncms_dir=/opt/emoncms 45 | 46 | emoncms_www=/var/www/emoncms 47 | emoncms_log_location=/var/log/emoncms 48 | emoncms_datadir=/var/opt/emoncms 49 | 50 | # usernames and passwords below are for default raspberrypi installation 51 | # these can all be changed to own preference 52 | 53 | # MySQL 54 | mysql_user=emoncms 55 | mysql_password=emonpiemoncmsmysql2016 56 | mysql_database=emoncms 57 | 58 | # MQTT - change settings.ini after install if server is not local 59 | mqtt_user=emonpi 60 | mqtt_password=emonpimqtt2016 61 | 62 | # Default branches 63 | emoncms_core_branch=stable 64 | emonhub_branch=stable 65 | log2ram_branch=rsync_mods 66 | 67 | # Core Modules installed in $emoncms_www/Modules 68 | # Configure branches as applicable 69 | declare -A emoncms_modules 70 | emoncms_modules[graph]=stable 71 | emoncms_modules[dashboard]=stable 72 | emoncms_modules[app]=stable 73 | emoncms_modules[device]=stable 74 | 75 | # Specific EmonPi / EmonBase Modules installed in $emoncms_www/Modules 76 | # Configure branches as applicable 77 | declare -A emoncms_emonpi_modules 78 | emoncms_emonpi_modules[config]=stable 79 | emoncms_emonpi_modules[setup]=stable 80 | 81 | # Modules installed in $emoncms_dir/modules 82 | # Configure branches as applicable 83 | declare -A symlinked_emoncms_modules 84 | # symlinked_emoncms_modules[demandshaper]=stable 85 | symlinked_emoncms_modules[sync]=stable 86 | symlinked_emoncms_modules[backup]=stable 87 | symlinked_emoncms_modules[usefulscripts]=stable 88 | symlinked_emoncms_modules[postprocess]=stable 89 | symlinked_emoncms_modules[network]=master 90 | 91 | ###################################################### 92 | ## Only change the repositories if you are a developer. 93 | # git repositories 94 | declare -A git_repo 95 | git_repo[emoncms_core]=https://github.com/emoncms/emoncms.git 96 | # main modules 97 | git_repo[config]=https://github.com/emoncms/config.git 98 | git_repo[graph]=https://github.com/emoncms/graph.git 99 | git_repo[dashboard]=https://github.com/emoncms/dashboard.git 100 | git_repo[app]=https://github.com/emoncms/app.git 101 | git_repo[device]=https://github.com/emoncms/device.git 102 | git_repo[setup]=https://github.com/emoncms/setup.git 103 | # symlinked modules 104 | # git_repo[demandshaper]=https://github.com/emoncms/demandshaper.git 105 | git_repo[sync]=https://github.com/emoncms/sync.git 106 | git_repo[backup]=https://github.com/emoncms/backup.git 107 | git_repo[usefulscripts]=https://github.com/emoncms/usefulscripts.git 108 | git_repo[postprocess]=https://github.com/emoncms/postprocess.git 109 | git_repo[network]=https://github.com/emoncms/network.git 110 | # emonhub 111 | git_repo[emonhub]=https://github.com/openenergymonitor/emonhub.git 112 | # emonpi/rpi specific tools 113 | git_repo[emonpi]=https://github.com/openenergymonitor/emonpi.git 114 | git_repo[log2ram]=https://github.com/openenergymonitor/log2ram.git 115 | git_repo[avrdude-rpi]=https://github.com/openenergymonitor/avrdude-rpi.git 116 | git_repo[RFM2Pi]=https://github.com/openenergymonitor/RFM2Pi 117 | -------------------------------------------------------------------------------- /install/emonpilcd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "emonPiLCD install" 6 | echo "-------------------------------------------------------------" 7 | cd $openenergymonitor_dir 8 | 9 | if [ ! -d $openenergymonitor_dir/emonPiLCD ]; then 10 | git clone -b $emonhub_branch ${git_repo[emonPiLCD]} 11 | else 12 | echo "-- emonPiLCD repository already installed" 13 | echo "-- emonPiLCD running git pull:" 14 | git -C $openenergymonitor_dir/emonPiLCD pull 15 | fi 16 | 17 | if [ -f $openenergymonitor_dir/emonPiLCD/install.sh ]; then 18 | $openenergymonitor_dir/emonPiLCD/install.sh 19 | else 20 | echo "-- ERROR: $openenergymonitor_dir/emonPiLCD/install.sh script does not exist" 21 | fi 22 | -------------------------------------------------------------------------------- /install/emonsd.config.ini: -------------------------------------------------------------------------------- 1 | # Edit this config file to suit your local environment if it is not a 2 | # vanilla Raspberry Pi. 3 | # 4 | # Main settings to look atif a non pi environment 5 | # user - Change user to reflect your OS user 6 | # emonSD_pi_env - Set emonSD_pi_env=0 if not a raspberrypi 7 | # install_redis - REDIS is required for feedwriter, service-runner and emoncms_mqtt services 8 | # locations - modify the install and data storage locations 9 | 10 | user=pi 11 | hostname=emonpi 12 | emonSD_pi_env=1 13 | 14 | # Components enabled 15 | apt_get_upgrade_and_clean=true 16 | install_apache=true 17 | install_mysql=true 18 | install_php=true 19 | install_redis=true 20 | # To use mqtt but a different server, just set install_mosquitto_server=false 21 | # manually configure mqtt server settings in settings.ini 22 | install_mosquitto=true 23 | install_mosquitto_server=true 24 | install_mosquitto_client=true 25 | 26 | install_emoncms_core=true 27 | install_emoncms_modules=true 28 | 29 | # RaspberryPi emonSD applicable items - ignored if setting emonSD_pi_env=0 30 | # set to false if not needed 31 | 32 | # EmonHub: comment out line above "emoncms_emonpi_modules[config]=stable" if 33 | # you do not wish to have the emoncms emonhub config module installed 34 | install_emonhub=true 35 | 36 | install_emoncms_emonpi_modules=true 37 | install_firmware=true 38 | install_emonpilcd=true 39 | install_emonsd=true 40 | install_docker=true 41 | install_network=true 42 | 43 | enable_onewire=true 44 | 45 | openenergymonitor_dir=/opt/openenergymonitor 46 | emoncms_dir=/opt/emoncms 47 | 48 | emoncms_www=/var/www/emoncms 49 | emoncms_log_location=/var/log/emoncms 50 | emoncms_datadir=/var/opt/emoncms 51 | 52 | # usernames and passwords below are for default raspberrypi installation 53 | # these can all be changed to own preference 54 | 55 | # MySQL 56 | mysql_user=emoncms 57 | mysql_password=emonpiemoncmsmysql2016 58 | mysql_database=emoncms 59 | 60 | # MQTT - change settings.ini after install if server is not local 61 | mqtt_user=emonpi 62 | mqtt_password=emonpimqtt2016 63 | 64 | # Default branches 65 | emoncms_core_branch=stable 66 | emonhub_branch=stable 67 | log2ram_branch=rsync_mods 68 | 69 | # Core Modules installed in $emoncms_www/Modules 70 | # Configure branches as applicable 71 | declare -A emoncms_modules 72 | emoncms_modules[graph]=stable 73 | emoncms_modules[dashboard]=stable 74 | emoncms_modules[app]=stable 75 | emoncms_modules[device]=stable 76 | 77 | # Specific EmonPi / EmonBase Modules installed in $emoncms_www/Modules 78 | # Configure branches as applicable 79 | declare -A emoncms_emonpi_modules 80 | emoncms_emonpi_modules[config]=stable 81 | emoncms_emonpi_modules[setup]=stable 82 | 83 | # Modules installed in $emoncms_dir/modules 84 | # Configure branches as applicable 85 | declare -A symlinked_emoncms_modules 86 | # symlinked_emoncms_modules[demandshaper]=stable 87 | symlinked_emoncms_modules[sync]=stable 88 | symlinked_emoncms_modules[backup]=stable 89 | symlinked_emoncms_modules[usefulscripts]=stable 90 | symlinked_emoncms_modules[postprocess]=stable 91 | symlinked_emoncms_modules[network]=master 92 | 93 | ###################################################### 94 | ## Only change the repositories if you are a developer. 95 | # git repositories 96 | declare -A git_repo 97 | git_repo[emoncms_core]=https://github.com/emoncms/emoncms.git 98 | # main modules 99 | git_repo[config]=https://github.com/emoncms/config.git 100 | git_repo[graph]=https://github.com/emoncms/graph.git 101 | git_repo[dashboard]=https://github.com/emoncms/dashboard.git 102 | git_repo[app]=https://github.com/emoncms/app.git 103 | git_repo[device]=https://github.com/emoncms/device.git 104 | git_repo[setup]=https://github.com/emoncms/setup.git 105 | # symlinked modules 106 | # git_repo[demandshaper]=https://github.com/emoncms/demandshaper.git 107 | git_repo[sync]=https://github.com/emoncms/sync.git 108 | git_repo[backup]=https://github.com/emoncms/backup.git 109 | git_repo[usefulscripts]=https://github.com/emoncms/usefulscripts.git 110 | git_repo[postprocess]=https://github.com/emoncms/postprocess.git 111 | git_repo[network]=https://github.com/emoncms/network.git 112 | # emonhub 113 | git_repo[emonhub]=https://github.com/openenergymonitor/emonhub.git 114 | # emonpi/rpi specific tools 115 | git_repo[emonpi]=https://github.com/openenergymonitor/emonpi.git 116 | git_repo[log2ram]=https://github.com/openenergymonitor/log2ram.git 117 | git_repo[avrdude-rpi]=https://github.com/openenergymonitor/avrdude-rpi.git 118 | git_repo[RFM2Pi]=https://github.com/openenergymonitor/RFM2Pi 119 | git_repo[emonPiLCD]=https://github.com/openenergymonitor/emonPiLCD 120 | -------------------------------------------------------------------------------- /install/emonsd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | # -------------------------------------------------------------------------------- 5 | # Install log2ram, so that logging is on RAM to reduce SD card wear. 6 | # Logs are written to disk every hour or at shutdown 7 | # log2ram forked from @pb66 repo here https://github.com/pb66/log2ram 8 | # -------------------------------------------------------------------------------- 9 | cd $openenergymonitor_dir 10 | 11 | echo "-- Installing log2ram" 12 | git clone -b $log2ram_branch ${git_repo[log2ram]} 13 | cd log2ram 14 | chmod +x install.sh && sudo ./install.sh 15 | cd .. 16 | rm -rf log2ram 17 | 18 | # -------------------------------------------------------------------------------- 19 | # Install custom logrotate 20 | # -------------------------------------------------------------------------------- 21 | echo "-- Installing custom logrotate" 22 | # logrotate log 23 | if [ ! -d /var/log/logrotate ]; then 24 | sudo mkdir /var/log/logrotate 25 | sudo chown -R root:adm /var/log/logrotate 26 | fi 27 | # custom logrotate config 28 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/00_defaults /etc/logrotate.d/00_defaults 29 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/emonhub /etc/logrotate.d/emonhub 30 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/emoncms /etc/logrotate.d/emoncms 31 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/logrotate /etc/logrotate.d/logrotate 32 | 33 | sudo chown root /etc/logrotate.d/00_defaults 34 | sudo chown root /etc/logrotate.d/emonhub 35 | sudo chown root /etc/logrotate.d/emoncms 36 | sudo chown root /etc/logrotate.d/logrotate 37 | 38 | # log2ram cron hourly entry 39 | echo "-- Setting up log2ram cron.hourly entry" 40 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/cron.hourly/log2ram /etc/cron.hourly/log2ram 41 | sudo chmod +x /etc/cron.hourly/log2ram 42 | # copy in commented out placeholder logrotate file 43 | echo "-- Setting up log2ram cron.daily entry" 44 | sudo cp $openenergymonitor_dir/EmonScripts/defaults/etc/cron.daily/logrotate /etc/cron.daily/logrotate 45 | 46 | if [ ! -d /var/log.old ]; then 47 | echo "-- Creating /var/log.old directory" 48 | sudo mkdir /var/log.old 49 | fi 50 | 51 | # -------------------------------------------------------------------------------- 52 | # UFW firewall 53 | # -------------------------------------------------------------------------------- 54 | # Review: reboot required before running: 55 | echo "-- Installing firewall" 56 | sudo apt-get install -y ufw 57 | # sudo ufw allow 80/tcp 58 | # sudo ufw allow 443/tcp (optional, HTTPS not present) 59 | # sudo ufw allow 22/tcp 60 | # sudo ufw allow 1883/tcp #(optional, Mosquitto) 61 | # sudo ufw enable 62 | 63 | boot_config=/boot/config.txt 64 | if [ -f /boot/firmware/config.txt ]; then 65 | boot_config=/boot/firmware/config.txt 66 | fi 67 | echo "-- boot config directory: $boot_config" 68 | 69 | # Underclock and memory tweak 70 | # change arm_freq to 1200 and gpu_mem to 16 71 | # more ram for general purpose, less for GPU 72 | # Removed see: https://github.com/openenergymonitor/EmonScripts/issues/83 73 | # sudo sed -i "s/^#arm_freq=800/arm_freq=1200\ngpu_mem=16/" /boot/config.txt 74 | 75 | 76 | # One wire temperature sensing support for emonPi v2 77 | # IMPORTANT: This will likely interfere with shutdown button on emonPi v1 78 | # It's best to disable onewire if using this image with an emonPi v1 79 | 80 | if [ "$enable_onewire" == true ]; then 81 | echo "-- Enabling one-wire, w1-gpio,gpiopin=17" 82 | sudo sed -i -n '/dtoverlay=w1-gpio/!p;$a dtoverlay=w1-gpio,gpiopin=17' $boot_config 83 | 84 | sudo modprobe w1-gpio 85 | sudo modprobe w1-therm 86 | else 87 | # Disable 1-Wire to prevent errors in logs 88 | echo "-- Disabling 1-Wire - will take effect on next reboot" 89 | sudo sed -i 's/dtoverlay=w1-gpio/#dtoverlay=w1-gpio/' $boot_config 90 | fi 91 | # 6 Sep 2019 decision to leave elevator setting as default 92 | # option to review in future: elevator=noop 93 | 94 | # Setup user group to enable reading GPU temperature (pi only) 95 | sudo usermod -a -G video www-data 96 | 97 | # Review automated install: Emoncms Language Support 98 | # sudo dpkg-reconfigure locales 99 | 100 | # emonSD rc.local includes wifiAP start and first boot update 101 | echo "-- Installing /etc/rc.local" 102 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/rc.local /etc/rc.local 103 | 104 | # emonSDexpand 105 | echo "-- Installing /usr/bin/emonSDexpand" 106 | sudo ln -sf $emoncms_dir/modules/usefulscripts/sdpart/sdpart_imagefile /usr/bin/emonSDexpand 107 | 108 | # -------------------------------------------------------------------------------- 109 | # Misc 110 | # -------------------------------------------------------------------------------- 111 | echo "-- Installing /home/pi/readme.md" 112 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/readme.md /home/pi/ 113 | 114 | # -------------------------------------------------------------------------------- 115 | 116 | # update checks for image type and only runs with a valid image name file in the boot partition 117 | # Update this value to the latest safe image version - this could be automated to pull from safe list 118 | emonsd_date=$(date +"%d%b%y") 119 | echo "-- creating version file: emonSD-$emonsd_date" 120 | 121 | sudo touch /boot/emonSD-$emonsd_date 122 | if [ -d /boot/firmware ]; then 123 | sudo cp /boot/emonSD-$emonsd_date /boot/firmware 124 | fi 125 | -------------------------------------------------------------------------------- /install/firmware.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | # -------------------------------------------------------------------------------- 5 | # Enable serial uploads with avrdude and autoreset 6 | # -------------------------------------------------------------------------------- 7 | cd $openenergymonitor_dir 8 | if [ ! -d $openenergymonitor_dir/avrdude-rpi ]; then 9 | echo "-- installing avrdude-rpi" 10 | git clone ${git_repo[avrdude-rpi]} 11 | $openenergymonitor_dir/avrdude-rpi/install 12 | else 13 | echo "-- avrdude-rpi already exists" 14 | fi 15 | 16 | cd $openenergymonitor_dir 17 | if [ ! -d $openenergymonitor_dir/RFM2Pi ]; then 18 | echo "-- installing RFM2Pi" 19 | git clone ${git_repo[RFM2Pi]} 20 | else 21 | echo "-- RFM2Pi already exists" 22 | fi 23 | -------------------------------------------------------------------------------- /install/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copy stdout and stderr to a log file in addition to the console 4 | # tee -a used in case script is run multiple times 5 | 6 | LOG_FILE=~/$(basename "$0").log 7 | exec > >(tee -a "${LOG_FILE}") 2>&1 8 | 9 | echo "Script output also stored in ${LOG_FILE}" 10 | echo -e "Started: $(date)\n" 11 | 12 | user=$USER 13 | openenergymonitor_dir=/opt/openenergymonitor 14 | emoncms_dir=/opt/emoncms 15 | 16 | sudo apt-get update -y 17 | sudo apt-get install -y git-core 18 | 19 | sudo mkdir $openenergymonitor_dir 20 | sudo chown $user $openenergymonitor_dir 21 | 22 | sudo mkdir $emoncms_dir 23 | sudo chown $user $emoncms_dir 24 | 25 | cd $openenergymonitor_dir 26 | 27 | echo "-- Installing EmonScripts" 28 | git clone https://github.com/openenergymonitor/EmonScripts.git 29 | cd $openenergymonitor_dir/EmonScripts 30 | git checkout stable 31 | 32 | echo "-- Running install/main.sh" 33 | cd $openenergymonitor_dir/EmonScripts/install 34 | ./main.sh 35 | cd 36 | 37 | rm init.sh 38 | 39 | echo -e "\nScript output also stored in ${LOG_FILE}" 40 | -------------------------------------------------------------------------------- /install/init_resize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Standard resize_init file modified by BPO as part of the EmonSD project 3 | # 26/06/2020 4 | # Modifications limit resize of rootfs to around 4GB and create an ext2 partition in remaining space 5 | 6 | #!/bin/sh 7 | 8 | reboot_pi () { 9 | umount /boot 10 | mount / -o remount,ro 11 | sync 12 | if [ "$NOOBS" = "1" ]; then 13 | if [ "$NEW_KERNEL" = "1" ]; then 14 | reboot -f "$BOOT_PART_NUM" 15 | else 16 | echo "$BOOT_PART_NUM" > "/sys/module/${BCM_MODULE}/parameters/reboot_part" 17 | fi 18 | fi 19 | echo b > /proc/sysrq-trigger 20 | sleep 5 21 | exit 0 22 | } 23 | 24 | check_commands () { 25 | if ! command -v whiptail > /dev/null; then 26 | echo "whiptail not found" 27 | sleep 5 28 | return 1 29 | fi 30 | for COMMAND in grep cut sed parted fdisk findmnt; do 31 | if ! command -v $COMMAND > /dev/null; then 32 | FAIL_REASON="$COMMAND not found" 33 | return 1 34 | fi 35 | done 36 | return 0 37 | } 38 | 39 | check_noobs () { 40 | if [ "$BOOT_PART_NUM" = "1" ]; then 41 | NOOBS=0 42 | else 43 | NOOBS=1 44 | fi 45 | } 46 | 47 | get_variables () { 48 | ROOT_PART_DEV=$(findmnt / -o source -n) 49 | ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3) 50 | ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4) 51 | ROOT_DEV="/dev/${ROOT_DEV_NAME}" 52 | ROOT_PART_NUM=$(cat "/sys/block/${ROOT_DEV_NAME}/${ROOT_PART_NAME}/partition") 53 | 54 | BOOT_PART_DEV=$(findmnt /boot -o source -n) 55 | BOOT_PART_NAME=$(echo "$BOOT_PART_DEV" | cut -d "/" -f 3) 56 | BOOT_DEV_NAME=$(echo /sys/block/*/"${BOOT_PART_NAME}" | cut -d "/" -f 4) 57 | BOOT_PART_NUM=$(cat "/sys/block/${BOOT_DEV_NAME}/${BOOT_PART_NAME}/partition") 58 | 59 | OLD_DISKID=$(fdisk -l "$ROOT_DEV" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p') 60 | 61 | check_noobs 62 | 63 | ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size") 64 | 65 | # Dev size divisible by 2048 66 | ROOT_DEV_SIZE2048=$((($ROOT_DEV_SIZE / 2048) * 2048 )) 67 | 68 | #EmonSD Fix end of Rootfs 69 | if [ $ROOT_DEV_SIZE -gt 14000000 ]; then 70 | #16GB card or above, assign last 10GB for data 71 | TARGET_END=$(($ROOT_DEV_SIZE2048 - 20971520 - 1 )) 72 | elif [ $ROOT_DEV_SIZE -gt 6000000 ]; then 73 | #8GB card, assign last 4GB for data 74 | TARGET_END=$(($ROOT_DEV_SIZE2048 - 7340032 - 1 )) 75 | else 76 | # Assign 2GB to rootfs 77 | TARGET_END=4098047 78 | fi 79 | 80 | #EmonSD set start of ext2 partition 81 | EXT2_START=$((TARGET_END + 1)) 82 | 83 | PARTITION_TABLE=$(parted -m "$ROOT_DEV" unit s print | tr -d 's') 84 | 85 | LAST_PART_NUM=$(echo "$PARTITION_TABLE" | tail -n 1 | cut -d ":" -f 1) 86 | 87 | ROOT_PART_LINE=$(echo "$PARTITION_TABLE" | grep -e "^${ROOT_PART_NUM}:") 88 | ROOT_PART_START=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 2) 89 | ROOT_PART_END=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 3) 90 | 91 | if [ "$NOOBS" = "1" ]; then 92 | EXT_PART_LINE=$(echo "$PARTITION_TABLE" | grep ":::;" | head -n 1) 93 | EXT_PART_NUM=$(echo "$EXT_PART_LINE" | cut -d ":" -f 1) 94 | EXT_PART_START=$(echo "$EXT_PART_LINE" | cut -d ":" -f 2) 95 | EXT_PART_END=$(echo "$EXT_PART_LINE" | cut -d ":" -f 3) 96 | fi 97 | } 98 | 99 | fix_partuuid() { 100 | mount -o remount,rw "$ROOT_PART_DEV" 101 | mount -o remount,rw "$BOOT_PART_DEV" 102 | DISKID="$(tr -dc 'a-f0-9' < /dev/hwrng | dd bs=1 count=8 2>/dev/null)" 103 | fdisk "$ROOT_DEV" > /dev/null < /proc/sys/kernel/sysrq 228 | 229 | if ! check_commands; then 230 | reboot_pi 231 | fi 232 | 233 | if main; then 234 | whiptail --infobox "Resized root filesystem. Rebooting in 5 seconds..." 20 60 235 | sleep 5 236 | else 237 | sleep 5 238 | whiptail --msgbox "Could not expand filesystem, please try raspi-config or rc_gui.\n${FAIL_REASON}" 20 60 239 | fi 240 | 241 | reboot_pi 242 | -------------------------------------------------------------------------------- /install/load_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Do not change these lines, they are used to auto detect the installation location 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | # usrdir=${DIR/\/EmonScripts\/install/} 5 | 6 | if [ -f config.ini ]; then 7 | source config.ini 8 | else 9 | echo "config.ini does not exist, please create from default e.g emonsd.config.ini" 10 | exit 0 11 | fi 12 | -------------------------------------------------------------------------------- /install/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -------------------------------------------------------------------------------- 3 | # RaspberryPi Strech Build Script 4 | # Emoncms, Emoncms Modules, EmonHub & dependencies 5 | # 6 | # Tested with: Raspbian Strech 7 | # Date: 19 March 2019 8 | # 9 | # Status: Work in Progress 10 | # -------------------------------------------------------------------------------- 11 | 12 | # Review splitting this up into seperate scripts 13 | # - emoncms installer 14 | # - emonhub installer 15 | # Format as documentation 16 | 17 | # Copy stdout and stderr to a log file in addition to the console 18 | # tee -a used in case script is run multiple times 19 | 20 | LOG_FILE=~/$(basename "$0").log 21 | exec > >(tee -a "${LOG_FILE}") 2>&1 22 | 23 | echo "Script output also stored in ${LOG_FILE}" 24 | echo -e "Started: $(date)\n" 25 | 26 | # fix interactive popup that keeps asking for service restart 27 | if [ -f /etc/needrestart/needrestart.conf ]; then 28 | sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf 29 | fi 30 | 31 | if [ ! -f config.ini ]; then 32 | cp emonsd.config.ini config.ini 33 | fi 34 | source load_config.sh 35 | 36 | echo "-------------------------------------------------------------" 37 | echo "EmonSD Install" 38 | echo "-------------------------------------------------------------" 39 | 40 | echo "Warning: The default configuration of this script applies" 41 | echo "significant modification to the underlying system!" 42 | echo "" 43 | read -p "Would you like to review the build script config before starting? (y/n) " start_confirm 44 | 45 | if [ "$start_confirm" != "n" ] && [ "$start_confirm" != "N" ]; then 46 | echo "" 47 | echo "You selected 'yes' to review config" 48 | echo "Please review config.ini and restart the build script to continue" 49 | echo "" 50 | echo " cd $openenergymonitor_dir/EmonScripts/install/" 51 | echo " nano config.ini" 52 | echo " ./main.sh" 53 | echo "" 54 | exit 0 55 | fi 56 | 57 | if [ "$apt_get_upgrade_and_clean" = true ]; then 58 | echo "apt-get update" 59 | sudo apt-get update -y 60 | echo "-------------------------------------------------------------" 61 | echo "apt-get upgrade" 62 | sudo apt-get upgrade -y 63 | echo "-------------------------------------------------------------" 64 | echo "apt-get dist-upgrade" 65 | sudo apt-get dist-upgrade -y 66 | echo "-------------------------------------------------------------" 67 | echo "apt-get clean" 68 | sudo apt-get clean 69 | 70 | # Needed on stock raspbian lite 19th March 2019 71 | sudo apt --fix-broken install 72 | 73 | echo "" 74 | echo "Important: Did you get a request to reboot your machine, if so we recommend you do this now." 75 | read -p "Would you like to exit installation to reboot your machine? (y/n) " reboot_confirm 76 | if [ "$reboot_confirm" != "n" ] && [ "$reboot_confirm" != "N" ]; then 77 | exit 0 78 | fi 79 | fi 80 | 81 | # Required to allow the webserver to use git commands. ref 82 | # https://community.openenergymonitor.org/t/ubuntu-22-04-lxc-install-issues-git/22189/1 83 | sudo git config --system --add safe.directory '*' 84 | 85 | # Required for emonpiLCD, wifi, rfm69pi firmware (review) 86 | if [ ! -d $openenergymonitor_dir/data ]; then mkdir $openenergymonitor_dir/data; fi 87 | 88 | echo "-------------------------------------------------------------" 89 | sudo apt-get install -y git build-essential python3-pip python3-dev 90 | 91 | # It's probably better to fix this by using python venv 92 | if [ -e /usr/lib/python3.11/EXTERNALLY-MANAGED ]; then 93 | sudo rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED 94 | echo "Removed pip3 external management warning." 95 | fi 96 | 97 | # Not 100% if this is needed (error with pip3 paho install on last build) 98 | if [ -e /usr/lib/python3.11/EXTERNALLY-MANAGED.orig ]; then 99 | sudo rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED.orig 100 | echo "Removed pip3 external management warning." 101 | fi 102 | 103 | 104 | echo "-------------------------------------------------------------" 105 | 106 | if [ "$install_apache" = true ]; then $openenergymonitor_dir/EmonScripts/install/apache.sh; fi 107 | if [ "$install_mysql" = true ]; then $openenergymonitor_dir/EmonScripts/install/mysql.sh; fi 108 | if [ "$install_php" = true ]; then $openenergymonitor_dir/EmonScripts/install/php.sh; fi 109 | if [ "$install_redis" = true ]; then $openenergymonitor_dir/EmonScripts/install/redis.sh; fi 110 | if [ "$install_mosquitto" = true ]; then $openenergymonitor_dir/EmonScripts/install/mosquitto.sh; fi 111 | if [ "$install_emoncms_core" = true ]; then $openenergymonitor_dir/EmonScripts/install/emoncms_core.sh; fi 112 | if [ "$install_emoncms_modules" = true ]; then $openenergymonitor_dir/EmonScripts/install/emoncms_modules.sh; fi 113 | 114 | if [ "$emonSD_pi_env" = "1" ]; then 115 | if [ "$install_emoncms_emonpi_modules" = true ]; then $openenergymonitor_dir/EmonScripts/install/emoncms_emonpi_modules.sh; fi 116 | if [ "$install_emonhub" = true ]; then $openenergymonitor_dir/EmonScripts/install/emonhub.sh; fi 117 | if [ "$install_firmware" = true ]; then $openenergymonitor_dir/EmonScripts/install/firmware.sh; fi 118 | if [ "$install_emonpilcd" = true ]; then $openenergymonitor_dir/EmonScripts/install/emonpilcd.sh; fi 119 | if [ "$install_docker" = true ]; then $openenergymonitor_dir/EmonScripts/install/docker.sh; fi 120 | if [ "$install_emonsd" = true ]; then $openenergymonitor_dir/EmonScripts/install/emonsd.sh; fi 121 | # Network must be run last 122 | if [ "$install_network" = true ]; then $openenergymonitor_dir/EmonScripts/install/network.sh; fi 123 | # Enable service-runner update 124 | else 125 | $openenergymonitor_dir/EmonScripts/install/non_emonsd.sh; 126 | fi 127 | 128 | echo -e "\nScript output also stored in ${LOG_FILE}" 129 | -------------------------------------------------------------------------------- /install/mosquitto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | if [ "$install_mosquitto_server" = true ]; then 5 | echo "-------------------------------------------------------------" 6 | echo "Mosquitto Server installation and configuration" 7 | echo "-------------------------------------------------------------" 8 | sudo apt-get install -y mosquitto 9 | sudo apt-get install -y libmosquitto-dev 10 | 11 | # Disable mosquitto persistance 12 | sudo sed -i "s/^persistence true/persistence false/" /etc/mosquitto/mosquitto.conf 13 | # append line: allow_anonymous false 14 | sudo sed -i -n '/allow_anonymous false/!p;$a allow_anonymous false' /etc/mosquitto/mosquitto.conf 15 | # append line: password_file /etc/mosquitto/passwd 16 | sudo sed -i -n '/password_file \/etc\/mosquitto\/passwd/!p;$a password_file \/etc\/mosquitto\/passwd' /etc/mosquitto/mosquitto.conf 17 | # append line: log_type error 18 | sudo sed -i -n '/log_type error/!p;$a log_type error' /etc/mosquitto/mosquitto.conf 19 | # append line: listener 1883 20 | sudo sed -i -n '/listener 1883/!p;$a listener 1883' /etc/mosquitto/mosquitto.conf 21 | 22 | # Create mosquitto password file 23 | sudo touch /etc/mosquitto/passwd 24 | sudo mosquitto_passwd -b /etc/mosquitto/passwd $mqtt_user $mqtt_password 25 | fi 26 | 27 | if [ "$install_mosquitto_client" = true ]; then 28 | echo "-------------------------------------------------------------" 29 | echo "Mosquitto Client installation and configuration" 30 | echo "-------------------------------------------------------------" 31 | sudo apt-get install -y libmosquitto-dev 32 | printf "\n" 33 | git clone https://github.com/openenergymonitor/Mosquitto-PHP 34 | cd Mosquitto-PHP/ 35 | phpize 36 | ./configure 37 | make 38 | sudo make install 39 | echo "-------------------------------------------------------------" 40 | # Add mosquitto to php mods available 41 | PHP_VER=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." ) 42 | printf "extension=mosquitto.so" | sudo tee /etc/php/$PHP_VER/mods-available/mosquitto.ini 1>&2 43 | sudo phpenmod mosquitto 44 | fi 45 | -------------------------------------------------------------------------------- /install/mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Setup the Mariadb server (MYSQL)" 6 | echo "-------------------------------------------------------------" 7 | sudo apt-get install -y mariadb-server mariadb-client 8 | 9 | # Secure mysql 10 | echo "-- Secure MYSQL" 11 | sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DELETE FROM mysql.user WHERE User=''; DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'; FLUSH PRIVILEGES;" 12 | # Create the emoncms database using utf8 character decoding: 13 | echo "-- Create $mysql_database database" 14 | sudo mysql -e "CREATE DATABASE $mysql_database DEFAULT CHARACTER SET utf8;" 15 | # Add emoncms database, set user permissions 16 | echo "-- Add user:$mysql_user and assign to database:$mysql_database" 17 | sudo mysql -e "CREATE USER '$mysql_user'@'localhost' IDENTIFIED BY '$mysql_password'; GRANT ALL ON $mysql_database.* TO '$mysql_user'@'localhost'; flush privileges;" 18 | -------------------------------------------------------------------------------- /install/network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Network install" 6 | echo "-------------------------------------------------------------" 7 | 8 | cd /opt/emoncms/modules/network 9 | sudo ./install.sh 10 | -------------------------------------------------------------------------------- /install/non_emonsd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | # -------------------------------------------------------------------------------- 5 | # Install custom logrotate 6 | # -------------------------------------------------------------------------------- 7 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/emoncms-non-emonsd /etc/logrotate.d/emoncms 8 | sudo chown root /etc/logrotate.d/emoncms 9 | sudo chmod 644 /opt/openenergymonitor/EmonScripts/defaults/etc/logrotate.d/emoncms-non-emonsd 10 | -------------------------------------------------------------------------------- /install/php.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Install PHP" 6 | echo "-------------------------------------------------------------" 7 | 8 | PHP_Ver="8.1" 9 | 10 | if grep -Fq "ARMv6" /proc/cpuinfo; then 11 | echo "-- ARMv6 architecture Use PHP8.0" 12 | PHP_Ver="8.0" 13 | 14 | else 15 | echo "-- not ARMv6 architecture OK to use PHP8.1" 16 | 17 | if [ "$emonSD_pi_env" = "1" ]; then 18 | curl https://packages.sury.org/php/apt.gpg | sudo tee /usr/share/keyrings/suryphp-archive-keyring.gpg >/dev/null 19 | echo "deb [signed-by=/usr/share/keyrings/suryphp-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/sury-php.list 20 | sudo apt update 21 | fi 22 | fi 23 | 24 | sudo apt-get install -y php$PHP_Ver 25 | 26 | # if [ "$install_apache" = true ]; then 27 | # sudo apt-get install -y libapache2-mod-php 28 | # fi 29 | 30 | if [ "$install_mysql" = true ]; then 31 | sudo apt-get install -y php$PHP_Ver-mysql 32 | fi 33 | 34 | sudo apt-get install -y php$PHP_Ver-gd php$PHP_Ver-curl php-pear php$PHP_Ver-dev php$PHP_Ver-common php$PHP_Ver-mbstring 35 | 36 | sudo pecl channel-update pecl.php.net 37 | 38 | -------------------------------------------------------------------------------- /install/redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Redis configuration" 6 | echo "-------------------------------------------------------------" 7 | sudo apt-get install -y redis-server 8 | 9 | if [ "$install_php" = true ]; then 10 | echo "-------------------------------------------------------------" 11 | printf "\n" 12 | git clone https://github.com/phpredis/phpredis 13 | cd phpredis 14 | phpize 15 | ./configure 16 | make 17 | sudo make install 18 | echo "-------------------------------------------------------------" 19 | PHP_VER=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." ) 20 | # Add redis to php mods available 21 | printf "extension=redis.so" | sudo tee /etc/php/$PHP_VER/mods-available/redis.ini 1>&2 22 | sudo phpenmod redis 23 | fi 24 | 25 | sudo pip3 install redis 26 | 27 | # Disable redis persistance 28 | sudo sed -i "s/^save 900 1/#save 900 1/" /etc/redis/redis.conf 29 | sudo sed -i "s/^save 300 1/#save 300 1/" /etc/redis/redis.conf 30 | sudo sed -i "s/^save 60 1/#save 60 1/" /etc/redis/redis.conf 31 | sudo systemctl restart redis-server 32 | -------------------------------------------------------------------------------- /module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "EmonScripts", 3 | "version" : "1.8.8", 4 | "location" : "/opt/openenergymonitor", 5 | "branches_available": ["stable","master"], 6 | "requires": [] 7 | } 8 | -------------------------------------------------------------------------------- /other/factoryreset: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $EUID -ne 0 ]]; then 4 | echo "This script must be run as root: sudo su" 5 | exit 1 6 | fi 7 | 8 | echo "emonPi Factory reset script" 9 | 10 | image_version=$(ls /boot | grep emonSD) 11 | 12 | if [[ "${image_version:0:6}" == "emonSD" ]] 13 | then 14 | echo "Image version: $image_version" 15 | else 16 | echo "Non OpenEnergyMonitor offical emonSD image, no gurantees this script will work :-/" 17 | read -p "Press any key to continue...or CTRL+C to exit " -n1 -s 18 | fi 19 | 20 | emoncms_datadir=/var/opt/emoncms 21 | 22 | sudo systemctl stop emonhub 23 | sudo systemctl stop emoncms_mqtt 24 | sudo systemctl stop feedwriter 25 | sudo systemctl stop service-runner 26 | # sudo systemctl stop redis-server 27 | # sudo systemctl stop mosquitto 28 | 29 | echo "deleting phpfina and phptimeseries data" 30 | sudo rm -rf /var/opt/emoncms/phpfina/* 31 | sudo rm -rf /var/opt/emoncms/phpfiwa/* 32 | sudo rm -rf /var/opt/emoncms/phptimeseries/* 33 | 34 | # Mysql 35 | echo "deleting mysql emoncms database" 36 | mysql -u emoncms -e "drop database emoncms" -pemonpiemoncmsmysql2016 37 | echo "creating new mysql emoncms database" 38 | mysql -u emoncms -e "create database emoncms" -pemonpiemoncmsmysql2016 39 | 40 | # Clear logs 41 | sudo rm -rf /var/log/emoncms/* 42 | 43 | sudo chmod 666 /etc/wpa_supplicant/wpa_supplicant.conf 44 | echo "clear WiFi config /etc/wpa_supplicant/wpa_supplicant.conf" 45 | echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" > /etc/wpa_supplicant/wpa_supplicant.conf 46 | echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf 47 | echo "country=GB" >> /etc/wpa_supplicant/wpa_supplicant.conf 48 | 49 | echo "remove git user credentials" 50 | sudo rm /home/pi/.gitconfig 51 | 52 | echo "Set default emonpi default git credentials" 53 | git config --global user.email "pi@emonpi.com" 54 | git config --global user.name "emonpi" 55 | 56 | echo "restore emonhub settings" 57 | cp /opt/openenergymonitor/emonhub/conf/emonpi.default.emonhub.conf /etc/emonhub/emonhub.conf 58 | sudo chmod 666 /etc/emonhub/emonhub.conf 59 | sed -i "s/loglevel = DEBUG/loglevel = WARNING/" /etc/emonhub/emonhub.conf 60 | 61 | echo "Clear bash history" 62 | history -c 63 | >~/.bash_history 64 | rm /home/pi/.bash_history 65 | 66 | echo "Clear and re-generate SSH keys" 67 | sudo rm /home/pi/.ssh/* 68 | sudo rm /etc/ssh/ssh_host_* 69 | sudo dpkg-reconfigure openssh-server 70 | 71 | echo "Clean up packages" 72 | sudo apt-get clean 73 | 74 | if [ "$VERSION" = "stretch" ]; then 75 | echo "Disabling SSH" 76 | sudo update-rc.d ssh disable 77 | sudo invoke-rc.d ssh stop 78 | sudo rm /boot/ssh 79 | fi 80 | -------------------------------------------------------------------------------- /other/i2cdetect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import smbus 3 | # Find LCD (alternative to i2cdetect) 4 | bus = smbus.SMBus(1) 5 | for address in ['0x27','0x3f','0x3c']: 6 | try: 7 | bus.read_byte(int(address,16)) 8 | break 9 | except Exception: 10 | address=False 11 | 12 | print(address) 13 | -------------------------------------------------------------------------------- /other/stable_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # sudo apt-get install jq 4 | 5 | M=$(pwd) 6 | 7 | if [ -d "$M/.git" ]; then 8 | 9 | 10 | if [ -f "$M/module.json" ]; then 11 | version=$(cat "$M/module.json" | jq -r '.version') 12 | elif [ -f "$M/version.json" ]; then 13 | version=$(cat "$M/version.json" | jq -r '.version') 14 | else 15 | echo "module or version file not found" 16 | exit 0 17 | fi 18 | 19 | changes=$(git -C $M diff-index HEAD --) 20 | if [ "$changes" = "" ]; then 21 | 22 | echo "Creating stable release for: $M $version" 23 | 24 | git -C $M fetch --all --prune 25 | 26 | git -C $M checkout stable 27 | 28 | git -C $M pull origin stable 29 | 30 | git -C $M merge origin/master 31 | 32 | git -C $M push origin stable 33 | 34 | git -C $M tag -a $version -m $version 35 | 36 | git -C $M push origin $version 37 | 38 | git -C $M checkout master 39 | 40 | git -C $M merge origin/stable 41 | 42 | git -C $M push origin master 43 | fi 44 | fi 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /other/switch_git_urls_to_ssh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source ../install/config.ini 5 | 6 | mode=$1 7 | 8 | for dir in "$emoncms_www" "$emoncms_www/Modules/*" "$emoncms_dir/modules/*" "$openenergymonitor_dir/*"; do 9 | for M in $dir; do 10 | if [ -d "$M/.git" ]; then 11 | url=$(git -C $M remote get-url origin) 12 | 13 | # 1. switch https:// to ssh 14 | if [ "$mode" = "ssh" ]; then 15 | ssh_url="${url/https:\/\/github.com\//git@github.com:}" 16 | git -C $M remote set-url origin $ssh_url 17 | echo $ssh_url 18 | fi 19 | 20 | # 2. switch https:// to ssh 21 | if [ "$mode" = "https" ]; then 22 | https_url="${url/git@github.com:/https:\/\/github.com\/}" 23 | git -C $M remote set-url origin $https_url 24 | echo $https_url 25 | fi 26 | fi 27 | done 28 | done 29 | 30 | 31 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Emoncms Stack Installer & Update scripts 2 | 3 | Including: emoncms core, emoncms modules, emonhub, apache2, mysql, redis, mqtt, dependencies and configuration. 4 | 5 | ## Install the Emoncms Stack 6 | 7 | To install the stack see:
8 | https://github.com/openenergymonitor/EmonScripts/blob/master/docs/install.md 9 | 10 | ## Update the Emoncms Stack 11 | 12 | Run the update via the Emoncms administration page, alternatively for command line level update see:
13 | https://github.com/openenergymonitor/EmonScripts/blob/master/update/readme.md 14 | 15 | ## Understand the EmonPi file System 16 | 17 | Before diving into these scripts, there are some things you need to know about architecture : main dependencies, systemd services, modules, structuring variables 18 | 19 | [read more about EmonPi File System](EmonPiFileSystem.md) 20 | -------------------------------------------------------------------------------- /safe-update: -------------------------------------------------------------------------------- 1 | emonSD-01Feb24 2 | emonSD-20Nov23 3 | emonSD-10Nov22 4 | emonSD-21Jul21 5 | emonSD-08May21 6 | emonSD-24Jul20 7 | emonSD-02Oct19 8 | emonSD-17Oct19 9 | -------------------------------------------------------------------------------- /sudoers.d/emoncms-filesystem: -------------------------------------------------------------------------------- 1 | www-data ALL=(ALL) NOPASSWD:/usr/bin/rpi-rw,/usr/bin/rpi-ro,/bin/mount 2 | -------------------------------------------------------------------------------- /sudoers.d/emoncms-rebootbutton: -------------------------------------------------------------------------------- 1 | www-data ALL=(ALL) NOPASSWD:/sbin/shutdown 2 | -------------------------------------------------------------------------------- /sudoers.d/emonhub-sudoers: -------------------------------------------------------------------------------- 1 | www-data ALL=(ALL) NOPASSWD:/bin/systemctl restart emonhub 2 | -------------------------------------------------------------------------------- /sudoers.d/wifi-sudoers: -------------------------------------------------------------------------------- 1 | www-data ALL=(ALL) NOPASSWD:/sbin/ifup wlan0 2 | www-data ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0 3 | www-data ALL=(ALL) NOPASSWD:/sbin/ifconfig wlan0 up 4 | www-data ALL=(ALL) NOPASSWD:/sbin/ifconfig wlan0 down 5 | www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 scan 6 | www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 scan_results 7 | www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure 8 | www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 reconfigure 9 | www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf 10 | www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf 11 | www-data ALL=(ALL) NOPASSWD:/usr/bin/tee /etc/wpa_supplicant/wpa_supplicant.conf 12 | www-data ALL=(ALL) NOPASSWD:/opt/openenergymonitor/emonpi/wifiAP/networklog.sh 13 | www-data ALL=(ALL) NOPASSWD:/opt/openenergymonitor/emonpi/wifiAP/stopAP.sh 14 | -------------------------------------------------------------------------------- /update/atmega_firmware_upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source load_config.sh 5 | 6 | if [ ! -d $openenergymonitor_dir/data/firmware ]; then 7 | mkdir $openenergymonitor_dir/data/firmware 8 | fi 9 | 10 | serial_port=$1 11 | firmware_key=$2 12 | 13 | if [ $serial_port == "none" ]; then 14 | echo "no serial port selected or available" 15 | exit 16 | fi 17 | 18 | if [ $firmware_key == "emonpi" ]; then 19 | firmware_key="emonPi_discrete_jeelib" 20 | fi 21 | 22 | # if custom, get baud_rate, core, autoreset and custom_firmware_filename 23 | if [ $firmware_key == "custom" ]; then 24 | custom_firmware_filename=$3 25 | baud_rate=$4 26 | core=$5 27 | autoreset=$6 28 | 29 | # Create upload folder if it does not exist 30 | if [ ! -d $openenergymonitor_dir/data/firmware/upload ]; then 31 | mkdir $openenergymonitor_dir/data/firmware/upload 32 | # change ownership of upload folder to www-data 33 | sudo chown -R www-data:www-data $openenergymonitor_dir/data/firmware/upload 34 | # this is the first time and so no fimware will have been uploaded 35 | echo "Looks like this is the first custom upload attempt." 36 | echo "Upload directory has now been created and permissions set." 37 | echo "Please upload firmware again to continue." 38 | exit 0 39 | fi 40 | 41 | hexfile=$openenergymonitor_dir/data/firmware/upload/$custom_firmware_filename 42 | # check if custom firmware file exists 43 | if [ ! -f $hexfile ]; then 44 | echo "Custom firmware file not found: $hexfile" 45 | exit 1 46 | fi 47 | 48 | echo "-------------------------------------------------------------" 49 | echo "Custom firmware selected: $custom_firmware_filename" 50 | echo "baud_rate: $baud_rate" 51 | echo "core: $core" 52 | echo "autoreset: $autoreset" 53 | echo "-------------------------------------------------------------" 54 | fi 55 | 56 | # If not custom download firmware from firmware list 57 | if [ $firmware_key != "custom" ]; then 58 | echo "-------------------------------------------------------------" 59 | echo "Firmware selected: $firmware_key" 60 | echo "-------------------------------------------------------------" 61 | result=$(./get_firmware_download_url.py $firmware_key) 62 | if [ "$result" != "firmware not found" ]; then 63 | result=($result) 64 | 65 | download_url=${result[0]} 66 | baud_rate=${result[1]} 67 | core=${result[3]} 68 | autoreset=${result[4]} 69 | 70 | hexfile=$openenergymonitor_dir/data/firmware/$firmware_key.hex 71 | 72 | echo "Downloading firmware from: " 73 | echo $download_url 74 | wget -q $download_url -O $hexfile 75 | 76 | echo 77 | echo "Downloaded file: " 78 | ls -lh $hexfile 79 | else 80 | echo "Firmware not found: $firmware_key" 81 | # exit 82 | exit 1 83 | fi 84 | fi 85 | 86 | if [ -f $hexfile ]; then 87 | 88 | state=$(systemctl show emonhub | grep ActiveState) 89 | 90 | if [ $state == "ActiveState=active" ]; then 91 | echo 92 | echo "EmonHub is running, stopping EmonHub" 93 | sudo systemctl stop emonhub 94 | emonhub_stopped_by_script=1 95 | else 96 | emonhub_stopped_by_script=0 97 | fi 98 | 99 | echo 100 | echo "Uploading $firmware_key on serial port $serial_port" 101 | 102 | for attempt in {1..1} 103 | do 104 | echo "Attempt $attempt..." 105 | echo 106 | echo "avrdude -Cavrdude.conf -v -p$core -carduino -D -P/dev/$serial_port -b$baud_rate -Uflash:w:$hexfile:i $autoreset" 107 | avrdude -Cavrdude.conf -v -p$core -carduino -D -P/dev/$serial_port -b$baud_rate -Uflash:w:$hexfile:i $autoreset 108 | 109 | # Find output logfile 110 | output_log_file=$( lsof -p $$ -a -d 1 -F n | awk '/^n/ {print substr($1, 2)}' ) 111 | # double check that it exists 112 | if [ -f $output_log_file ]; then 113 | # check for completion status 114 | not_in_sync=$(cat $output_log_file | grep "not in sync" | wc -l) 115 | flash_verified=$(cat $output_log_file | grep "flash verified" | wc -l) 116 | 117 | # if [ "$not_in_sync" == "0" ]; then 118 | if [ $flash_verified == "1" ]; then 119 | echo "SUCCESS: flash verified" 120 | break; 121 | else 122 | echo "ERROR: Not in sync" 123 | fi 124 | fi 125 | done 126 | 127 | if [ $emonhub_stopped_by_script == 1 ]; then 128 | echo 129 | echo "Restarting EmonHub" 130 | sudo systemctl start emonhub 131 | 132 | if [ "$serial_port" = "ttyAMA0" ]; then 133 | if [ "$(systemctl is-active emonPiLCD)" = "active" ]; then 134 | echo "emonPiLCD is running. Restarting in 5s..." 135 | sleep 5 136 | sudo systemctl restart emonPiLCD 137 | echo "emonPiLCD service has been restarted" 138 | fi 139 | fi 140 | fi 141 | 142 | else 143 | echo "Firmware download failed...check network connection" 144 | fi 145 | -------------------------------------------------------------------------------- /update/emoncms.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "Update Emoncms Core" 6 | echo "-------------------------------------------------------------" 7 | 8 | # Check emoncms directory 9 | if [ ! -d $emoncms_www ]; then 10 | echo "emoncms directory at $emoncms_www not found" 11 | exit 0 12 | fi 13 | 14 | # Use update_component script to update emoncms core 15 | ./update_component.sh /var/www/emoncms 16 | 17 | # This should be moved to an install/update script in the emoncms directory 18 | echo "-------------------------------------------------------------" 19 | echo "Update Emoncms Services" 20 | echo "-------------------------------------------------------------" 21 | for service in "emoncms_mqtt" "feedwriter" "service-runner"; do 22 | servicepath=$emoncms_www/scripts/services/$service/$service.service 23 | $openenergymonitor_dir/EmonScripts/common/install_emoncms_service.sh $servicepath $service 24 | done 25 | echo 26 | 27 | if [ -d /lib/systemd/system ]; then 28 | echo "Reloading systemctl deamon" 29 | sudo systemctl daemon-reload 30 | fi 31 | 32 | echo "Restarting Services..." 33 | 34 | for service in "feedwriter" "emoncms_mqtt" "emonhub"; do 35 | if [ -f /lib/systemd/system/$service.service ]; then 36 | echo "- sudo systemctl restart $service.service" 37 | sudo systemctl restart $service.service 38 | state=$(systemctl show $service | grep ActiveState) 39 | echo "--- $state ---" 40 | fi 41 | done 42 | 43 | if [ "$emonSD_pi_env" = "1" ]; then 44 | # Sudoers entry (review) 45 | sudo visudo -cf $openenergymonitor_dir/EmonScripts/sudoers.d/emoncms-rebootbutton && \ 46 | sudo cp $openenergymonitor_dir/EmonScripts/sudoers.d/emoncms-rebootbutton /etc/sudoers.d/ 47 | sudo chmod 0440 /etc/sudoers.d/emoncms-rebootbutton 48 | echo "emonPi emoncms admin reboot button sudoers updated" 49 | fi 50 | 51 | echo 52 | 53 | echo "-------------------------------------------------------------" 54 | echo "Update Emoncms Modules" 55 | echo "-------------------------------------------------------------" 56 | 57 | # Check emoncms directory 58 | if [ ! -d $emoncms_www ]; then 59 | echo "emoncms directory at $emoncms_www not found" 60 | exit 0 61 | fi 62 | 63 | # Update modules installed directly in the Modules folder 64 | for M in $emoncms_www/Modules/*; do 65 | ./update_component.sh $M 66 | done 67 | 68 | # Update modules installed in the $emoncms_dir/modules folder 69 | for M in $emoncms_dir/modules/*; do 70 | ./update_component.sh $M 71 | done 72 | 73 | # This should be moved to wifi module install.sh 74 | if [ -d $emoncms_www/Modules/wifi ]; then 75 | # wifi module sudoers entry 76 | sudo visudo -cf $openenergymonitor_dir/EmonScripts/sudoers.d/wifi-sudoers && \ 77 | sudo cp $openenergymonitor_dir/EmonScripts/sudoers.d/wifi-sudoers /etc/sudoers.d/ 78 | sudo chmod 0440 /etc/sudoers.d/wifi-sudoers 79 | echo "wifi sudoers entry updated" 80 | fi 81 | -------------------------------------------------------------------------------- /update/emonhub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | 4 | echo "-------------------------------------------------------------" 5 | echo "emonHub update" 6 | echo "-------------------------------------------------------------" 7 | 8 | boot_config=/boot/config.txt 9 | if [ -f /boot/firmware/config.txt ]; then 10 | boot_config=/boot/firmware/config.txt 11 | fi 12 | 13 | echo "Enabling SPI for RFM69SPI" 14 | sudo sed -i 's/#dtparam=spi=on/dtparam=spi=on/' $boot_config 15 | 16 | M=$openenergymonitor_dir/emonhub 17 | 18 | if [ -d "$M/.git" ]; then 19 | # emon-pi to stable migration 20 | branch=$(git -C $M branch | grep \* | cut -d ' ' -f2) 21 | if [ $branch == "emon-pi" ]; then 22 | branch="stable" 23 | echo "Migrating from emon-pi branch to $branch branch" 24 | fi 25 | 26 | ./update_component.sh $M $branch 27 | else 28 | echo "EmonHub not found" 29 | fi 30 | 31 | -------------------------------------------------------------------------------- /update/emonsd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source load_config.sh 3 | python_cmd=$1 4 | 5 | if [ ! -f /etc/logrotate.d/logrotate ]; then 6 | echo "-------------------------------------------------------------" 7 | echo "EmonPi Update logrotate" 8 | echo "-------------------------------------------------------------" 9 | sudo ln -sf $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/logrotate /etc/logrotate.d/logrotate 10 | sudo chown root /etc/logrotate.d/logrotate 11 | fi 12 | 13 | echo "-------------------------------------------------------------" 14 | echo "EmonPi LCD Update" 15 | echo "-------------------------------------------------------------" 16 | 17 | if [ -d $openenergymonitor_dir/emonPiLCD ]; then 18 | $openenergymonitor_dir/emonPiLCD/install.sh 19 | elif [ -f $openenergymonitor_dir/emonpi/lcd/install.sh ]; then 20 | $openenergymonitor_dir/emonpi/lcd/install.sh 21 | fi 22 | 23 | echo "Stopping emonPiLCD service" 24 | sudo systemctl stop emonPiLCD 25 | # echo "Display update message on LCD" 26 | # $python_cmd $openenergymonitor_dir/emonpi/lcd/./emonPiLCD_update.py 27 | -------------------------------------------------------------------------------- /update/firstbootupdate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to update new emonPi's to latest firmware and software the fist time they are booted up in the factory 4 | # Looks to see if /var/log/emoncms/emonpiupdate.log exists or LCD push button (GPIO 23) is pressed (high when pressed) 5 | 6 | # To rc.local before exit 0 add: 7 | # su pi -c '/opt/openenergymonitor/EmonScripts/update/firstbootupdate' 8 | 9 | # Check if update log file is empty if so then proceed to update 10 | 11 | # THIS SCRIPT IS NOW DISABLED 12 | echo "firstbootupdate script disabled" 13 | exit 1 14 | 15 | if [ -s /var/log/emoncms/update.log ]; then 16 | echo "Not first boot: /var/log/emoncms/update.log exists" 17 | exit 18 | fi 19 | 20 | if [ -f /boot/firstbootupdate ]; then 21 | echo "Not first boot: /boot/firstbootupdate exists" 22 | exit 23 | fi 24 | 25 | echo "First Boot Update.." 26 | sleep 5 27 | printf "Checking internet connectivity..,\n" 28 | WGET="/usr/bin/wget" 29 | $WGET -q --tries=20 --timeout=5 http://www.google.com -O /tmp/google.idx &> /dev/null 30 | if [ ! -s /tmp/google.idx ]; then 31 | echo "No Internet connection :-(" 32 | else 33 | echo "Internet connection detected running update.." 34 | connected=true 35 | fi 36 | 37 | if [ "$connected" = true ]; then 38 | /opt/openenergymonitor/EmonScripts/update/service-runner-update.sh all emonpi 2>&1 >> /var/log/emoncms/update.log 2>&1 39 | # set permissions on newly created logfile 40 | sudo chmod 666 /var/log/emoncms/update.log 41 | fi 42 | 43 | sudo touch /boot/firstbootupdate 44 | 45 | exit 46 | -------------------------------------------------------------------------------- /update/get_firmware_download_url.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import json 5 | 6 | import urllib.request, json 7 | with urllib.request.urlopen("https://raw.githubusercontent.com/openenergymonitor/EmonScripts/master/firmware_available.json") as url: 8 | firmware_available = json.load(url) 9 | 10 | if len(sys.argv)==2: 11 | firmware_key = sys.argv[1] 12 | if firmware_key in firmware_available: 13 | firmware = firmware_available[firmware_key] 14 | 15 | autoreset = "" 16 | if 'autoreset' in firmware: 17 | autoreset = str(firmware['autoreset']) 18 | 19 | print(firmware['download_url']+" "+str(firmware['baud'])+" "+str(firmware['version'])+" "+str(firmware['core'])+" "+autoreset) 20 | sys.exit(0) 21 | 22 | # Error 23 | print("firmware not found") 24 | -------------------------------------------------------------------------------- /update/load_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Do not change these lines, they are used to auto detect the installation location 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | # usrdir=${DIR/\/EmonScripts\/install/} 5 | 6 | if [ -f ../install/config.ini ]; then 7 | source ../install/config.ini 8 | else 9 | echo "config.ini does not exist, please create from default e.g emonsd.config.ini" 10 | exit 0 11 | fi 12 | -------------------------------------------------------------------------------- /update/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source load_config.sh 5 | 6 | # Check for emonHP image version 7 | # do not update these 8 | image_version=$(ls /boot | grep emonHP) 9 | if [ "$image_version" = "emonHP-20Nov23" ]; then 10 | echo "emonHP image 20Nov23 cannot be updated" 11 | exit 12 | fi 13 | 14 | 15 | echo "-------------------------------------------------------------" 16 | echo "Main Update Script" 17 | echo "-------------------------------------------------------------" 18 | 19 | 20 | type=$1 21 | firmware_key=$2 22 | serial_port=$3 23 | 24 | datestr=$(date) 25 | 26 | echo "Date:" $datestr 27 | echo "EUID: $EUID" 28 | echo "openenergymonitor_dir: $openenergymonitor_dir" 29 | echo "type: $type" 30 | echo "serial_port: $serial_port" 31 | echo "firmware: $firmware_key" 32 | 33 | if [ "$EUID" = "0" ] && [ "$user" != "root" ]; then 34 | # update is being ran mistakenly as root, switch to user 35 | echo "update running as root, switch to user" 36 | exit 0 37 | fi 38 | 39 | i2c_address=$(python3 $openenergymonitor_dir/EmonScripts/other/i2cdetect.py) 40 | 41 | if [ "$i2c_address" == "0x3c" ]; then 42 | hardware="EmonPi" # emonPi v2 43 | elif [ "$i2c_address" == "0x3f" ]; then 44 | hardware="EmonPi" # emonPi v1 45 | elif [ "$i2c_address" == "0x27" ]; then 46 | hardware="EmonPi" # emonPi v1 47 | else 48 | hardware="rfm2pi" 49 | fi 50 | 51 | echo "Hardware detected: $hardware" 52 | 53 | sudo apt-get install -y python3-pip 54 | pip3 install redis 55 | 56 | if [ "$emonSD_pi_env" = "1" ]; then 57 | 58 | if [ "$hardware" == "EmonPi" ]; then 59 | # Stop emonPi LCD servcice 60 | echo "Stopping emonPiLCD service" 61 | sudo systemctl stop emonPiLCD 62 | # Display update message on LCD 63 | # echo "Display update message on LCD" 64 | # $python_cmd $openenergymonitor_dir/emonpi/lcd/./emonPiLCD_update.py 65 | fi 66 | 67 | # Ensure logrotate configuration has correct permissions 68 | sudo chown root:$user $openenergymonitor_dir/EmonScripts/defaults/etc/logrotate.d/* 69 | 70 | fi 71 | 72 | if [ "$type" == "all" ] || [ "$type" == "emonhub" ]; then 73 | echo "Running apt-get update" 74 | sudo apt-get update 75 | fi 76 | 77 | # ----------------------------------------------------------------- 78 | 79 | if [ "$type" == "all" ]; then 80 | sudo rm -rf hardware/emonpi/emonpi2c/ 81 | 82 | for repo in "emonpi" "RFM2Pi" "huawei-hilink-status" "emonPiLCD"; do 83 | if [ -d $openenergymonitor_dir/$repo ]; then 84 | echo "git pull $openenergymonitor_dir/$repo" 85 | cd $openenergymonitor_dir/$repo 86 | git branch 87 | git status 88 | git fetch --all --prune 89 | git pull 90 | fi 91 | done 92 | fi 93 | cd $openenergymonitor_dir/EmonScripts/update 94 | 95 | # ----------------------------------------------------------------- 96 | 97 | if [ "$type" == "all" ] || [ "$type" == "emonhub" ]; then 98 | echo "Start emonhub update script:" 99 | $openenergymonitor_dir/EmonScripts/update/emonhub.sh 100 | echo 101 | fi 102 | 103 | # ----------------------------------------------------------------- 104 | 105 | if [ "$type" == "all" ] || [ "$type" == "emoncms" ]; then 106 | echo "Start emoncms update:" 107 | $openenergymonitor_dir/EmonScripts/update/emoncms.sh 108 | echo 109 | fi 110 | 111 | # ----------------------------------------------------------------- 112 | 113 | if [ "$type" == "all" ] && [ "$emonSD_pi_env" = "1" ]; then 114 | $openenergymonitor_dir/EmonScripts/update/emonsd.sh $python_cmd 115 | fi 116 | 117 | # ----------------------------------------------------------------- 118 | 119 | if [ "$type" == "firmware" ]; then 120 | if [ "$firmware_key" != "none" ]; then 121 | $openenergymonitor_dir/EmonScripts/update/atmega_firmware_upload.sh $serial_port $firmware_key 122 | fi 123 | fi 124 | 125 | # ----------------------------------------------------------------- 126 | 127 | if [ "$hardware" == "EmonPi" ]; then 128 | echo 129 | # Wait for update to finish 130 | echo "Starting emonPi LCD service.." 131 | sleep 5 132 | sudo systemctl restart emonPiLCD 133 | echo 134 | fi 135 | 136 | # ----------------------------------------------------------------- 137 | 138 | datestr=$(date) 139 | 140 | echo 141 | echo "-------------------------------------------------------------" 142 | echo "System update done: $datestr" # this text string is used by service runner to stop the log window polling, DO NOT CHANGE! 143 | echo "-------------------------------------------------------------" 144 | 145 | # ----------------------------------------------------------------- 146 | 147 | if [ "$type" == "all" ] || [ "$type" == "emoncms" ]; then 148 | echo "restarting service-runner" 149 | sudo systemctl restart service-runner.service 150 | fi 151 | -------------------------------------------------------------------------------- /update/readme.md: -------------------------------------------------------------------------------- 1 | # How to run scripts manually 2 | 3 | Current directory is EmonScripts/update 4 | 5 | ### Update Emoncms 6 | 7 | ./emoncms.sh IS_EMONSD 8 | ./emoncms.sh 0 9 | 10 | ### Update EmonHub 11 | 12 | ./emonhub.sh 13 | 14 | ### Update Firmware: EmonPi 15 | 16 | ./emonpi.sh 17 | 18 | ### Update Firmware: rfm69pi 19 | 20 | ./rfm69pi.sh 21 | 22 | ### Via main.sh 23 | 24 | ./main.sh UPDATE_TYPE FIRMWARE IMAGE_NAME 25 | ./main.sh all emonpi emonSD-30Oct18 26 | ./main.sh emoncms emonSD-30Oct18 27 | ./main.sh emonhub emonSD-30Oct18 28 | ./main.sh firmware emonpi emonSD-30Oct18 29 | 30 | ### Via service-runner-update.sh 31 | 32 | Current directory is EmonScripts. 33 | 34 | This script is triggered from emoncms via service-runner. 35 | 36 | ./service-runner-update.sh UPDATE_TYPE FIRMWARE 37 | ./service-runner-update.sh all emonpi 38 | 39 | # How do the automatic update process work in practise ? 40 | 41 | The automatic update process is managed from the admin module of emoncms. 42 | It consists of 2 main steps, launched by two different shell scripts located in the `/opt/openenergymonitor/EmonScripts` folder : 43 | 44 | 1) [update/service-runner-update.sh](service-runner-update.sh) 45 | 2) [update/main.sh](main.sh) 46 | 47 | ## step 1 : update/service-runner-update.sh 48 | 49 | - version check and comparison to labels stored in the safe-update file of the EmonScripts repository 50 | - pull the latest version of the EmonScripts repository 51 | - if version check is successful, goto step 2 52 | 53 | ## step 2 : update/main.sh 54 | 55 | ### emonPiLCD & al example 56 | 57 | - stop the emonPiLCD service 58 | - launch lcd/emonPiLCD_update.py from the emonpi repo (to display the "UPDATING..." message on the LCD) 59 | - pull the emonpi repo 60 | - run the update/emonpi.sh script of the EmonScripts repo, which runs the lcd/install.sh from the emonpi repo 61 | -------------------------------------------------------------------------------- /update/service-runner-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source load_config.sh 5 | 6 | type="all" 7 | if [ ! -z $1 ]; then 8 | type=$1 9 | fi 10 | 11 | firmware_key="emonPi_discrete_jeelib" 12 | if [ ! -z $2 ]; then 13 | firmware_key=$2 14 | fi 15 | 16 | serial_port="ttyAMA0" 17 | if [ ! -z $3 ]; then 18 | serial_port=$3 19 | fi 20 | 21 | # Clear log update file 22 | cat /dev/null > /var/log/emoncms/emonupdate.log 23 | 24 | # Find largest log file and remove 25 | varlog_available=$(df --output=avail /var/log | tail -n 1) 26 | if [ "$varlog_available" -lt "1024" ]; then 27 | largest_log_file=$(sudo find /var/log -type f -printf "%s\t%p\n" | sort -n | tail -1 | cut -f 2) 28 | sudo truncate -s 0 $largest_log_file 29 | echo "$largest_log_file truncated to make room for update log" 30 | fi 31 | 32 | echo "Starting update via service-runner-update.sh (v3.0) >" 33 | # Log the free space on each filesystem. 34 | df -h 35 | 36 | # ----------------------------------------------------------------- 37 | 38 | # Check emonSD version 39 | image_version=$(ls /boot | grep emonSD) 40 | 41 | if [ "$image_version" = "" ]; then 42 | echo "- Could not find emonSD version file" 43 | emonSD_pi_env=0 44 | else 45 | echo "- emonSD version: $image_version" 46 | valid=0 47 | 48 | retry=0 49 | while [ $retry -lt 5 ]; do 50 | safe_to_update=$(curl -s https://raw.githubusercontent.com/openenergymonitor/EmonScripts/master/safe-update) 51 | if [ "$safe_to_update" == "" ]; then 52 | echo " retry fetching safe-update list" 53 | retry=$((retry+1)) 54 | sleep 3 55 | else 56 | break 57 | fi 58 | done 59 | if [ "$safe_to_update" == "" ]; then 60 | echo "ERROR: Could not load safe-update list, please check network connection" 61 | exit 0 62 | fi 63 | 64 | echo "- supported images: "$safe_to_update 65 | 66 | while read -r image_name; do 67 | if [ "$image_version" == "$image_name" ]; then 68 | echo "- emonSD base image check passed...continue update" 69 | valid=1 70 | fi 71 | done <<< "$safe_to_update" 72 | 73 | if [ $valid == 0 ]; then 74 | echo "ERROR: emonSD base image old or undefined...update will not continue" 75 | echo "See latest verson: https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log" 76 | echo "Stopping update" 77 | exit 0 78 | fi 79 | fi 80 | 81 | # ----------------------------------------------------------------- 82 | 83 | # Pull in latest EmonScripts repo before then running updated update scripts 84 | echo "git pull $openenergymonitor_dir/EmonScripts" 85 | cd $openenergymonitor_dir/EmonScripts 86 | git branch 87 | git status 88 | git pull 89 | 90 | # Run update in main update script 91 | $openenergymonitor_dir/EmonScripts/update/main.sh $type $firmware_key $serial_port 92 | -------------------------------------------------------------------------------- /update/update_all_components.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source load_config.sh 5 | 6 | switch_branch=$1 7 | 8 | # Check emoncms directory 9 | if [ ! -d $emoncms_www ]; then 10 | echo "emoncms directory at $emoncms_www not found" 11 | exit 0 12 | fi 13 | 14 | # Emoncms core 15 | ./update_component.sh /var/www/emoncms $switch_branch 16 | 17 | # Update emoncms modules /var/www/emoncms/Modules 18 | for M in $emoncms_www/Modules/*; do 19 | ./update_component.sh $M $switch_branch 20 | done 21 | 22 | # Update emoncms modules /opt/emoncms/modules 23 | for M in $emoncms_dir/modules/*; do 24 | ./update_component.sh $M $switch_branch 25 | done 26 | 27 | # Update components in /opt/openenergymonitor 28 | for M in $openenergymonitor_dir/*; do 29 | ./update_component.sh $M $switch_branch 30 | done 31 | 32 | echo "- all components updated" 33 | -------------------------------------------------------------------------------- /update/update_component.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | cd $DIR 4 | source load_config.sh 5 | 6 | M=$1 7 | switch_branch=$2 8 | 9 | if [ -d "$M/.git" ]; then 10 | echo "Updating $M" 11 | 12 | branch=$(git -C $M branch | grep \* | cut -d ' ' -f2) 13 | echo "- current branch: $branch" 14 | #tags=$(git -C $M describe --tags) 15 | #echo "- git tags: $tags" 16 | 17 | if [ ! $switch_branch ]; then 18 | switch_branch=$branch 19 | fi 20 | 21 | changes=$(git -C $M diff-index -G. HEAD --) 22 | if [ "$changes" = "" ]; then 23 | echo "- local changes: no" 24 | result=$(git -C $M fetch --all --prune) 25 | echo "- git fetch: $result" 26 | result=$(git -C $M checkout $switch_branch) 27 | echo "- git checkout: $result" 28 | result=$(git -C $M pull --no-rebase) 29 | echo "- git pull: $result" 30 | 31 | # update mysql database 32 | result=$(php $openenergymonitor_dir/EmonScripts/common/emoncmsdbupdate.php) 33 | if [ ! $result = "[]" ]; then 34 | echo "- database update: $result" 35 | else 36 | echo "- database update: no changes" 37 | fi 38 | 39 | # run module install (& update) script if present 40 | if [ -f $M/install.sh ]; then 41 | echo "- running module install/update script (user=$user)" 42 | $M/install.sh $openenergymonitor_dir $user 43 | fi 44 | 45 | echo "- component updated" 46 | else 47 | echo "WARNING local changes in $M - Module not updated" 48 | result=$(git -C $M status) 49 | echo "- git status: $result" 50 | fi 51 | # else 52 | # echo "ERROR: not a git repository" 53 | fi 54 | --------------------------------------------------------------------------------