1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00

Merge pull request #219 from iiab/master

sync from iiab/iiab
This commit is contained in:
A Holt 2019-02-14 09:27:59 -05:00 committed by GitHub
commit 2dee3b0a57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 208 additions and 41 deletions

View file

@ -1,10 +1,14 @@
# Internet-in-a-Box (IIAB) # Internet-in-a-Box (IIAB)
Welcome to the Git repository for Internet-in-a-Box (IIAB). Internet-in-a-Box (IIAB) is a small, inexpensive device which provides essential Internet resources (Wikipedia, OpenStreetMap, Khan Academy and others) without any Internet connection. Welcome to the GitHub repository for Internet-in-a-Box (IIAB). IIAB is a small and inexpensive device which provides essential Internet resources (Wikipedia, OpenStreetMap, Khan Academy and others) *usable even when offline!*.
You are encouraged to customize this local content hotspot or server with the best of the worlds Free Knowledge — to suit your own region, your school, your medical clinic, your library and/or for your very own family. Create the digital library needed by your school, your medical clinic, your region and/or your very own family — accessible with any nearby smartphone, tablet or laptop.
FYI this community product is enabled by professional volunteers working side-by-side with schools, clinics and libraries around the world. Thank you for being a part of our grassroots technology movement! Internet-in-a-Box provides you the tools to DIY (download and customize) a local content hotspot or server, with the very best of the Worlds Free Knowledge.
Schools can also choose among [30 powerful educational apps](http://wiki.laptop.org/go/IIAB/FAQ#What_services_.28IIAB_apps.29_are_suggested_during_installation.3F) for teachers and students, optionally with a complete LMS (learning management system).
FYI this community product is enabled by professional volunteers working side-by-side with schools, clinics and libraries around the world. *Thank you for being a part of our grassroots technology movement!*
## Installation ## Installation

View file

@ -27,4 +27,4 @@ You can monitor it with command::
See Also See Also
-------- --------
`Node-RED <../nodered/README.rst>`_ `Node-RED <../nodered#node-red-readme>`_

View file

@ -29,14 +29,21 @@
# nodejs_version_installed.stderr == "/bin/sh: 1: nodejs: not found" # nodejs_version_installed.stderr == "/bin/sh: 1: nodejs: not found"
# BOTH ABOVE (incl non-null stderr) are USED BELOW to confirm install is nec! # BOTH ABOVE (incl non-null stderr) are USED BELOW to confirm install is nec!
- name: "ENFORCE PRECONDITION: Stop installing (intentionally fail) IF an installed 'nodejs' version isn't {{ nodejs_version }}" #- name: "ENFORCE PRECONDITION: Stop installing (intentionally fail) IF an installed 'nodejs' version isn't {{ nodejs_version }}"
fail: # fail:
msg: > # msg: >
PLEASE REMOVE 'nodejs' VERSION {{ nodejs_version_installed.stdout }} AS # PLEASE REMOVE 'nodejs' VERSION {{ nodejs_version_installed.stdout }} AS
IT DOES NOT MATCH THE REQUIRED nodejs_version: {{ nodejs_version }} -- # IT DOES NOT MATCH THE REQUIRED nodejs_version: {{ nodejs_version }} --
as set in /opt/iiab/iiab/vars/default_vars.yml and/or # as set in /opt/iiab/iiab/vars/default_vars.yml and/or
/etc/iiab/local_vars.yml -- then re-run this IIAB installer. # /etc/iiab/local_vars.yml -- then re-run this IIAB installer.
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stderr == "" # when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stderr == ""
# BRUTAL but ensures consistency across OS's / distros like Raspbian Desktop & Ubermix that often include an older version of Node.js
- name: ASK apt/yum/dnf TO REMOVE PRE-EXISTING Node.js {{ nodejs_version_installed.stdout }} (IF IT'S NOT {{ nodejs_version }})
package:
name: nodejs
state: absent
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stdout != ""
- name: Warn if Node.js {{ nodejs_version}} already installed & might be updated - name: Warn if Node.js {{ nodejs_version}} already installed & might be updated
debug: debug:
@ -46,6 +53,15 @@
# 2. INSTALL Node.js USING nodesource.com # 2. INSTALL Node.js USING nodesource.com
# 2019-02-12: Should not be nec, as stanza below it should overwrite
# /etc/apt/sources.list.d/nodesource.list regardless!
#
#- name: Clear prior /etc/apt/sources.list.d/nodesource.list (permitting Node.js downgrade if nec)
# file:
# path: /etc/apt/sources.list.d/nodesource.list
# state: absent
# when: internet_available and is_debuntu
- name: Set up Node.js {{ nodejs_version }} apt sources (debuntu) - name: Set up Node.js {{ nodejs_version }} apt sources (debuntu)
shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version }} | bash - shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version }} | bash -
args: args:

View file

@ -20,11 +20,18 @@ Username: ``Admin``
Password: ``changeme`` Password: ``changeme``
To change this password, please see: `roles/nodered/defaults/main.yml <defaults/main.yml#L10-L25>`_
You can monitor the Node-RED service with command:: You can monitor the Node-RED service with command::
systemctl status node-red systemctl status nodered
Raspberry Pi Zero W Warning
---------------------------
Node.js applications like Asterisk/FreePBX, Node-RED and Sugarizer `won't work <https://nodered.org/docs/hardware/raspberrypi#swapping-sd-cards>`_ on Raspberry Pi Zero W (ARM6) if you installed Node.js while on RPi 3 or 3 B+ (ARM7). If necessary, run ``apt remove nodejs`` then ``cd /opt/iiab/iiab`` then `./runrole nodejs <https://github.com/iiab/iiab/blob/master/roles/nodejs/tasks/main.yml>`_ *on the Raspberry Pi Zero W itself* — before proceeding to install Asterisk/FreePBX, Node-RED and/or Sugarizer.
See Also See Also
-------- --------
`Mosquitto (MQTT) <../mosquitto/README.rst>`_ `Mosquitto (MQTT) <../mosquitto#mosquitto-readme>`_

View file

@ -5,11 +5,21 @@
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml # All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
nodered_web_path: nodered # http://box/nodered redirect to http://box:1880 nodered_web_path: nodered # http://box/nodered reverse proxies http://box:1880
nodered_user: Admin nodered_user: Admin
nodered_password: changeme nodered_password: changeme # REMOVE THIS PASSWORD REMINDER LINE AS NECESSARY
nodered_password_hash: $2b$08$oxgvoU9et3deSbXY8UNVTOWHSTQAyEASIal86RHVMqYQJhpPMNz7q nodered_password_hash: $2b$08$oxgvoU9et3deSbXY8UNVTOWHSTQAyEASIal86RHVMqYQJhpPMNz7q
# To generate a new password hash, run 'node-red-admin hash-pw' and enter the
# new password. Paste the resulting hash above. After Ansible runs, username # TO GENERATE A NEW PASSWORD HASH, run 'node-red-admin hash-pw' and enter
# and password hash will be placed in: /home/nodered/.node-red/settings.js # the new password. Paste the resulting hash as above, but into your own:
# /opt/iiab/iiab/vars/nodered/defaults/main.yml
#
# After IIAB's installer runs (or "cd /opt/iiab/iiab" then "./runrole nodered")
# username and password hash are stored in:
# /home/nodered/.node-red/settings.js
#
# Or...on Raspberry Pi they're stored in:
# /home/pi/.node-red/settings.js
#
# See http://nodered.org/docs/security.html for more detail.

View file

@ -1,32 +1,146 @@
# 2019-01-16: @jvonau's PR #1403 moved installation of Node.js (8.x for now) & # 2019-01-16: @jvonau's PR #1403 moved installation of Node.js (8.x for now) &
# npm to roles/nodejs/tasks/main.yml, triggered by roles/nodered/meta/main.yml # npm to roles/nodejs/tasks/main.yml, triggered by roles/nodered/meta/main.yml
- name: 'npm install node-red packages globally: node-red, node-red-admin, node-red-dashboard' # BRUTAL but ensures consistency across OS's / distros like Raspbian Desktop &
shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard # Ubermix that often include an older version of Node-RED. Brutal, as this
# removes customizations on graphical desktop OS's e.g. Raspbian Desktop's:
# 1. Node-RED's icon (Raspberry Menu in top-left -> Programming -> Node-RED)
# 2. scripts like {node-red-start, node-red-stop, node-red-log} in /usr/bin
# 3. other changes per /usr/bin/update-nodejs-and-nodered summarized at
# https://nodered.org/docs/hardware/raspberrypi for example low-memory
# flag --max_old_space_size=256 for unit file (we're using 128 on RPi)
# That we'll reconstitute below!
- name: ASK apt/yum/dnf TO REMOVE PRE-EXISTING 'nodered' (IF PREVIOUSLY INSTALLED BY OS PKG MANAGER)
package:
name: nodered
state: absent
when: nodered_install when: nodered_install
- name: Ensure Linux group 'nodered' exists # 2012-02-13: the 6 RPi stanzas below recreate Raspbian Desktop's Node-RED
# environment, inspired by:
# https://nodered.org/docs/hardware/raspberrypi
# https://github.com/node-red/raspbian-deb-package/blob/master/resources/update-nodejs-and-nodered
# https://github.com/iiab/iiab/pull/1497
- name: "Globally 'npm install' 3 Node-RED packages: node-red, node-red-admin, node-red-dashboard"
command: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard
#command: npm install -g --unsafe-perm node-red@latest node-red-admin@latest node-red-dashboard@latest
# Above "@latest" is recommended by https://nodered.org/docs/hardware/raspberrypi (SHOULD WE CONSIDER?)
when: nodered_install and internet_available
- name: "Globally 'npm install' 8 Node-RED learning examples for RPi: node-red-contrib-ibm-watson-iot, node-red-contrib-play-audio, node-red-node-ledborg, node-red-node-ping, node-red-node-pi-sense-hat, node-red-node-random, node-red-node-serialport, node-red-node-smooth"
command: npm install -g --unsafe-perm node-red-contrib-ibm-watson-iot node-red-contrib-play-audio node-red-node-ledborg node-red-node-ping node-red-node-pi-sense-hat node-red-node-random node-red-node-serialport node-red-node-smooth
when: nodered_install and internet_available and is_rpi
# TEST UNNEC ICON/MENU FILE PLACEMENT ON RASPIAN LITE TOO !
- name: 'Download/Install 4 useful items for RPi: Node-RED icon, start menu item, /etc/logrotate.d/nodered, tweaked "Pi cpu temperature.json"'
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
with_items:
- url: https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-icon.svg
dest: /usr/share/icons/hicolor/scalable/apps/node-red-icon.svg
- url: https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/Node-RED.desktop
dest: /usr/share/applications/Node-RED.desktop
- url: https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.rotate
dest: /etc/logrotate.d/nodered
- url: 'https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/Pi%20cpu%20temperature.json'
dest: '/usr/lib/node_modules/node-red-contrib-ibm-watson-iot/examples/Pi cpu temperature.json'
when: nodered_install and internet_available and is_rpi
#- name: Replace/Tweak "node-red-contrib-ibm-watson-iot/examples/Pi cpu temperature.json" (rpi)
# command: 'curl -sL -o /usr/lib/node_modules/node-red-contrib-ibm-watson-iot/examples/Pi\ cpu\ temperature.json https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/Pi%20cpu%20temperature.json'
# when: nodered_install and internet_available and is_rpi
- name: 'Download/Install 4 RPi executables to /usr/bin: node-red-start, node-red-stop, node-red-restart, node-red-log'
get_url:
url: "{{ item }}"
dest: /usr/bin
mode: a+x
with_items:
- https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start
- https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop
- https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-restart
- https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-log
when: nodered_install and internet_available and is_rpi
## To protect pre-installed packages within /usr/lib/node_modules in graphical
## desktop OS's like Raspbian Desktop & Ubermix, we now only install those that
## are missing -- among the 3+8 below. WARNING: THIS COULD POTENTIALLY LEAD TO
## INCOMPATIBILITIES, IF OS'S /usr/lib/node_modules/node-red GETS OUT OF DATE!
#
## /usr/lib/node_modules/node-red is PRE-INSTALLED by Raspbian Desktop, even if
## their package (42MB, 0.19.4) is a bit out of date compared to npm's (55MB,
## 0.19.5) as of 2019-02-12. Among others in /usr/lib/node_modules, pre-placed
## by Raspbian Desktop's apt package 'nodered':
## node-red-contrib-ibm-watson-iot, node-red-contrib-play-audio,
## node-red-node-ledborg, node-red-node-ping, node-red-node-pi-sense-hat
## node-red-node-random, node-red-node-serialport, node-red-node-smooth
#- name: Globally 'npm install' pkg 'node-red' if /usr/lib/node_modules/node-red missing (most OS's except for Raspbian Desktop)
# #command: npm install -g --unsafe-perm node-red
# command: npm install -g --unsafe-perm node-red@latest
# args:
# creates: /usr/lib/node_modules/node-red
# when: nodered_install and internet_available
#
## NOT pre-installed by Raspbian Desktop as of 2019-02-12...so we install this
## on most all OS's:
#- name: Globally 'npm install' pkg 'node-red-admin' if /usr/lib/node_modules/node-red-admin missing (most OS's)
# command: npm install -g --unsafe-perm node-red-admin
# args:
# creates: /usr/lib/node_modules/node-red-admin
# when: nodered_install and internet_available
#
## NOT pre-installed by Raspbian Desktop as of 2019-02-12...so we install this
## on most all OS's:
#- name: Globally 'npm install' pkg 'node-red-dashboard' if /usr/lib/node_modules/node-red-dashboard missing (most OS's)
# command: npm install -g --unsafe-perm node-red-dashboard
# args:
# creates: /usr/lib/node_modules/node-red-dashboard
# when: nodered_install and internet_available
- name: Create /home/pi/.node-red/ directory (rpi)
file:
path: /home/pi/.node-red
state: directory
owner: pi
group: pi
mode: 0775
when: nodered_install and is_rpi
- name: Install /home/pi/.node-red/settings.js from template, with authentication (rpi)
template:
backup: yes
src: settings.js.j2
dest: /home/pi/.node-red/settings.js
owner: pi
group: pi
mode: 0755
when: nodered_install and is_rpi
- name: Ensure Linux group 'nodered' exists (if not rpi)
group: group:
name: nodered name: nodered
state: present state: present
when: nodered_install when: nodered_install and not is_rpi
- name: Ensure Linux user 'nodered' exists and is added to group 'nodered' - name: Ensure Linux user 'nodered' exists and is added to group 'nodered' (if not rpi)
user: user:
name: nodered name: nodered
group: nodered group: nodered
when: nodered_install when: nodered_install and not is_rpi
- name: Create /home/nodered/.node-red/ directory - name: Ensure directory /home/nodered/.node-red/ exists (if not rpi)
file: file:
path: /home/nodered/.node-red path: /home/nodered/.node-red
state: directory state: directory
owner: nodered owner: nodered
group: nodered group: nodered
mode: 0775 mode: 0775
when: nodered_install when: nodered_install and not is_rpi
- name: Install /home/nodered/.node-red/settings.js from template, with authentication - name: Install /home/nodered/.node-red/settings.js from template, with authentication (if not rpi)
template: template:
backup: yes backup: yes
src: settings.js.j2 src: settings.js.j2
@ -34,13 +148,14 @@
owner: nodered owner: nodered
group: nodered group: nodered
mode: 0755 mode: 0755
when: nodered_install when: nodered_install and not is_rpi
- name: Install /etc/systemd/system/node-red.service systemd unit file from template
- name: Install /etc/systemd/system/nodered.service systemd unit file from template
template: template:
backup: yes backup: yes
src: node-red.service.j2 src: nodered.service.j2
dest: /etc/systemd/system/node-red.service dest: /etc/systemd/system/nodered.service
owner: root owner: root
group: root group: root
mode: 0666 mode: 0666
@ -84,22 +199,23 @@
state: restarted state: restarted
when: nodered_install when: nodered_install
- name: Enable & (Re)start 'node-red' systemd service (if nodered_enabled) - name: Enable & (Re)start 'nodered' systemd service (if nodered_enabled)
systemd: systemd:
daemon_reload: yes daemon_reload: yes
name: node-red name: nodered
enabled: yes enabled: yes
state: restarted state: restarted
when: nodered_enabled when: nodered_enabled
- name: Disable & Stop 'node-red' systemd service (if not nodered_enabled) - name: Disable & Stop 'nodered' systemd service (if not nodered_enabled)
systemd: systemd:
daemon_reload: yes daemon_reload: yes
name: node-red name: nodered
enabled: no enabled: no
state: stopped state: stopped
when: not nodered_enabled when: not nodered_enabled
- name: Add 'nodered' variable values to {{ iiab_ini_file }} - name: Add 'nodered' variable values to {{ iiab_ini_file }}
ini_file: ini_file:
path: "{{ iiab_ini_file }}" path: "{{ iiab_ini_file }}"
@ -110,7 +226,7 @@
- option: name - option: name
value: Node-RED value: Node-RED
- option: description - option: description
value: '"Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions."' value: '"Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions."'
- option: nodered_install - option: nodered_install
value: "{{ nodered_install }}" value: "{{ nodered_install }}"
- option: nodered_enabled - option: nodered_enabled

View file

@ -5,10 +5,12 @@ After=syslog.target network.target
[Service] [Service]
# Ansible template HAD: if is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 # Ansible template HAD: if is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17
# Ansible template HAD: if is_debuntu # Ansible template HAD: if is_debuntu
{% if is_rpi %}
ExecStart=/usr/bin/node-red-pi --max-old-space-size=128 -v ExecStart=/usr/bin/node-red-pi --max-old-space-size=128 -v
# Ansible template HAD: else {% else %}
# ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v # ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v
# Ansible template HAD: endif ExecStart=/usr/bin/node-red-pi -v
{% endif %}
Restart=on-failure Restart=on-failure
KillSignal=SIGINT KillSignal=SIGINT
@ -17,9 +19,15 @@ SyslogIdentifier=node-red
StandardOutput=syslog StandardOutput=syslog
# non-root user to run as # non-root user to run as
{% if is_rpi %}
WorkingDirectory=/home/pi/
User=pi
Group=pi
{% else %}
WorkingDirectory=/home/nodered/ WorkingDirectory=/home/nodered/
User=nodered User=nodered
Group=nodered Group=nodered
{% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -33,6 +33,11 @@ You can monitor the FreePBX service with command::
systemctl status freepbx systemctl status freepbx
Raspberry Pi Zero W Warning
---------------------------
Node.js applications like Asterisk/FreePBX, Node-RED and Sugarizer `won't work <https://nodered.org/docs/hardware/raspberrypi#swapping-sd-cards>`_ on Raspberry Pi Zero W (ARM6) if you installed Node.js while on RPi 3 or 3 B+ (ARM7). If necessary, run ``apt remove nodejs`` then ``cd /opt/iiab/iiab`` then `./runrole nodejs <https://github.com/iiab/iiab/blob/master/roles/nodejs/tasks/main.yml>`_ *on the Raspberry Pi Zero W itself* — before proceeding to install Asterisk/FreePBX, Node-RED and/or Sugarizer.
Attribution Attribution
----------- -----------

View file

@ -15,6 +15,7 @@ sugarizer_git_version: v1.1.0 # WAS: v1.0.1, master
sugarizer_server_dir_version: sugarizer-server-dev # WAS: sugarizer-server-1.0, sugarizer-server-master sugarizer_server_dir_version: sugarizer-server-dev # WAS: sugarizer-server-1.0, sugarizer-server-master
sugarizer_server_git_version: f27bf6acd56aba6d99116ef471ca713b0f0dfed3 # WAS: v1.0.1, master, dev sugarizer_server_git_version: f27bf6acd56aba6d99116ef471ca713b0f0dfed3 # WAS: v1.0.1, master, dev
# Above commit (githash f27bf6a... for iiab/iiab PR #1430 from 'dev' branch of # Above commit (githash f27bf6a... for iiab/iiab PR #1430 from 'dev' branch of
# https://github.com/llaske/sugarizer-server) well-tested Jan 29 - Feb 2 2019. # https://github.com/llaske/sugarizer-server) well-tested Jan 29 - Feb 12 2019.
# #
# PLEASE HELP MONITOR https://github.com/llaske/sugarizer-server/releases # PLEASE HELP MONITOR https://github.com/llaske/sugarizer-server/commits/dev
# AND https://github.com/llaske/sugarizer-server/releases