1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge pull request #814 from georgejhunt/sugar

Sugarizer v1.0 migration
This commit is contained in:
A Holt 2018-06-21 12:09:27 -04:00 committed by GitHub
commit 9383cca879
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 93 additions and 64 deletions

View file

@ -102,11 +102,11 @@
# when: elgg_enabled or rachel_enabled or owncloud_enabled or phpmyadmin_enabled or wordpress_enabled or iiab_menu_install # when: elgg_enabled or rachel_enabled or owncloud_enabled or phpmyadmin_enabled or wordpress_enabled or iiab_menu_install
# Commenting out MongoDB on a trial basis, for a more basic/lightweight Sugarizer, per https://github.com/iiab/iiab/pull/427 # Commenting out MongoDB on a trial basis, for a more basic/lightweight Sugarizer, per https://github.com/iiab/iiab/pull/427
# - name: Turn on mongodb if sugarizer enabled - name: Turn on mongodb if sugarizer enabled
# set_fact: set_fact:
# mongodb_install: True mongodb_install: True
# mongodb_enabled: True mongodb_enabled: True
# when: sugarizer_enabled when: sugarizer_enabled
# There might be other db's # There might be other db's
- name: Turn on PostgreSQL if Moodle or Pathagar enabled - name: Turn on PostgreSQL if Moodle or Pathagar enabled

View file

@ -17,7 +17,7 @@
- { path: '/library/dbdata/mongodb' } - { path: '/library/dbdata/mongodb' }
- { path: '/var/log/mongodb' } - { path: '/var/log/mongodb' }
- name: Create systemd files - name: Move required files
template: src={{ item.src }} template: src={{ item.src }}
dest={{ item.dest }} dest={{ item.dest }}
owner=root owner=root
@ -25,9 +25,7 @@
mode=0644 mode=0644
with_items: with_items:
- { src: 'mongodb.service' , dest: '/etc/systemd/system/' } - { src: 'mongodb.service' , dest: '/etc/systemd/system/' }
- { src: 'mongodb' , dest: '/etc/sysconfig/'}
- { src: 'mongod.conf' , dest: '/etc/mongod.conf'} - { src: 'mongod.conf' , dest: '/etc/mongod.conf'}
- { src: 'mongod.conf' , dest: '/etc/mongodb.conf'}
- name: enable services - name: enable services
service: name={{ item.name }} service: name={{ item.name }}
@ -45,20 +43,6 @@
- { name: mongodb } - { name: mongodb }
when: not mongodb_enabled when: not mongodb_enabled
# See https://github.com/iiab/iiab/issues/254 for other attempts to eliminate
# these 256MB files. Brute Force Idea: rm /var/lib/mongodb/journal/prealloc.*
- name: find /var/lib/mongodb/prealloc.* files to delete
find:
paths: /var/lib/mongodb/journal
patterns: prealloc.*
register: files_to_delete
- name: delete prealloc files
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"
- name: add mongodb to service list - name: add mongodb to service list
ini_file: dest="{{ service_filelist }}" ini_file: dest="{{ service_filelist }}"
section=mongodb section=mongodb

View file

@ -9,22 +9,22 @@ bind_ip = 127.0.0.1
port = 27018 port = 27018
# Fork server process (false by default) # Fork server process (false by default)
fork = true # fork = true
# Full path to pidfile (if not set, no pidfile is created) # Full path to pidfile (if not set, no pidfile is created)
pidfilepath = /var/run/mongodb/mongod.pid # pidfilepath = /var/run/mongodb/mongod.pid
# Log file to send write to instead of stdout - has to be a file, not directory # Log file to send write to instead of stdout - has to be a file, not directory
logpath = /var/log/mongodb/mongod.log logpath = /var/log/mongodb/mongod.log
# Alternative directory for UNIX domain sockets (defaults to /tmp) # Alternative directory for UNIX domain sockets (defaults to /tmp)
unixSocketPrefix = /var/run/mongodb # unixSocketPrefix = /var/run/mongodb
# Directory for datafiles (defaults to /data/db/) # Directory for datafiles (defaults to /data/db/)
dbpath = /library/dbdata/mongodb dbpath = /library/dbdata/mongodb
# Enable/Disable journaling (journaling is on by default for 64 bit) # Enable/Disable journaling (journaling is on by default for 64 bit)
#journal = true journal = true
#nojournal = true #nojournal = true
@ -37,7 +37,7 @@ dbpath = /library/dbdata/mongodb
#verbose = v #verbose = v
# Max number of simultaneous connections (1000000 by default) # Max number of simultaneous connections (1000000 by default)
#maxConns = 1000000 maxConns = 10000
# Log to system's syslog facility instead of file or stdout (false by default) # Log to system's syslog facility instead of file or stdout (false by default)
#syslog = true #syslog = true

View file

@ -1 +0,0 @@
OPTIONS=' -f /etc/mongod.conf '

View file

@ -3,12 +3,10 @@ Description=High-performance, schema-free document-oriented database
After=syslog.target network.target After=syslog.target network.target
[Service] [Service]
Type=forking Type=simple
User=mongodb User=mongodb
Group=mongodb Group=mongodb
PIDFile=/var/run/mongodb/mongod.pid ExecStart=/usr/bin/mongod -f /etc/mongod.conf
EnvironmentFile=/etc/sysconfig/mongodb
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1 +0,0 @@
OPTIONS=' -f /etc/mongod.conf '

View file

@ -57,6 +57,7 @@ services_externally_visible={{ services_externally_visible }}
calibre_port={{ calibre_port }} calibre_port={{ calibre_port }}
kiwix_port={{ kiwix_port }} kiwix_port={{ kiwix_port }}
kalite_server_port={{ kalite_server_port }} kalite_server_port={{ kalite_server_port }}
sugarizer_port={{ sugarizer_port }}
block_DNS={{ block_DNS }} block_DNS={{ block_DNS }}
captive_portal_enabled={{ captive_portal_enabled }} captive_portal_enabled={{ captive_portal_enabled }}
@ -89,6 +90,7 @@ if [ "$services_externally_visible" == "True" ]; then
$IPTABLES -A INPUT -p tcp --dport $kiwix_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $kiwix_port -m state --state NEW -i $wan -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport $kalite_server_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $kalite_server_port -m state --state NEW -i $wan -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport $calibre_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $calibre_port -m state --state NEW -i $wan -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport $sugarizer_port -m state --state NEW -i $wan -j ACCEPT
fi fi
if [ "$iiab_gateway_enabled" == "True" ]; then if [ "$iiab_gateway_enabled" == "True" ]; then

View file

@ -1,5 +1,6 @@
sugarizer_install: True sugarizer_install: True
sugarizer_enabled: False sugarizer_enabled: False
sugarizer_location: '{{ doc_root }}' sugarizer_location: /opt/iiab
sugarizer_version: 'sugarizer-0.9' sugarizer_version: 'sugarizer-1.0'
sugarizer_server_version: 'sugarizer-server-1.0'
npm_exists: False npm_exists: False

View file

@ -1,2 +1,2 @@
dependencies: dependencies:
# - { role: mongodb, tags: ['generic','mongodb'], when: sugarizer_install } - { role: mongodb, tags: ['generic','mongodb'], when: sugarizer_install }

View file

@ -1,3 +1,7 @@
- name: Wipe any previous sugarizer installation
shell: "rm -rf {{ doc_root }}/sugarizer*"
when: sugarizer_version == "sugarizer-1.0"
- name: Download latest stable Sugarizer from location we control - name: Download latest stable Sugarizer from location we control
get_url: get_url:
url: "{{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz" url: "{{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz"
@ -5,7 +9,7 @@
timeout: "{{ download_timeout }}" timeout: "{{ download_timeout }}"
when: internet_available when: internet_available
- name: Untar to /library/www/html/{{ sugarizer_version }} - name: Untar to {{ sugarizer_version }}
unarchive: unarchive:
src: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz" src: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz"
dest: "{{ sugarizer_location }}" dest: "{{ sugarizer_location }}"
@ -13,12 +17,35 @@
# command: tar xzf {{ downloads_dir }}/{{ sugarizer_version }}.tar.gz -C {{ sugarizer_location }} # command: tar xzf {{ downloads_dir }}/{{ sugarizer_version }}.tar.gz -C {{ sugarizer_location }}
# creates="{{ sugarizer_location }}/{{ sugarizer_version }}/index.html" # creates="{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
- name: Download latest stable Server from location we control
get_url:
url: "{{ iiab_download_url }}/{{ sugarizer_server_version }}.tar.gz"
dest: "{{ downloads_dir }}/{{ sugarizer_server_version }}.tar.gz"
timeout: "{{ download_timeout }}"
when: internet_available
- name: Untar to /{{ sugarizer_version }}
unarchive:
src: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz"
dest: "{{ sugarizer_location }}"
creates: "{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
- name: Create symbolic link /library/www/html/sugarizer - name: Create symbolic link /library/www/html/sugarizer
file: file:
src: "{{ sugarizer_location }}/{{ sugarizer_version }}" src: "{{ sugarizer_location }}/{{ sugarizer_version }}"
dest: "{{ sugarizer_location }}/sugarizer" dest: "{{ sugarizer_location }}/sugarizer"
state: link state: link
- name: Untar to /library/www/html/{{ sugarizer_server_version }}
unarchive:
src: "{{ downloads_dir }}/{{ sugarizer_server_version }}.tar.gz"
dest: "{{ sugarizer_location }}"
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/index.html"
- name: Create symbolic link /library/www/html/sugarizer
file:
src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
dest: "{{ sugarizer_location }}/sugarizer-server"
state: link
- name: Set up Node.js 6.x apt sources (debuntu) - name: Set up Node.js 6.x apt sources (debuntu)
shell: curl -sL https://deb.nodesource.com/setup_6.x | bash - shell: curl -sL https://deb.nodesource.com/setup_6.x | bash -
when: internet_available and is_debuntu and not is_ubuntu_18 when: internet_available and is_debuntu and not is_ubuntu_18
@ -52,36 +79,37 @@
# attempting to reinstall npm is broken on Raspbian 9 # attempting to reinstall npm is broken on Raspbian 9
- name: Check for Sugarizer already installed - name: Check for Sugarizer already installed
stat: stat:
path: "{{ sugarizer_location }}/sugarizer/server/node_modules" path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
register: npm register: npm
ignore_errors: true
- name: Set a flag to abort second attempt to install - name: Set a flag to abort second attempt to install
set_fact: set_fact:
npm_exists: True npm_exists: True
when: npm.stat.exists is defined and npm.stat.exists when: npm.stat is defined and npm.stat.exists
- name: Create systemd files and copy our ini file - name: Create systemd files and copy our ini file
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
owner: root owner: root
group: root group: root
mode: 0644
with_items: with_items:
- { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service'} - { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
- { src: 'sugarizer.ini' , dest: '{{ sugarizer_location }}/sugarizer/server' } - { src: 'sugarizer.ini' , dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
# - { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available' } - { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available',mode: '0644' }
#- name: Create the symlink enabling the rewrite - name: Create the symlink enabling the rewrite
# file: src=/etc/apache2/sites-available/sugarizer.conf file: src=/etc/apache2/sites-available/sugarizer.conf
# dest=/etc/apache2/sites-enabled/sugarizer.conf dest=/etc/apache2/sites-enabled/sugarizer.conf
# state=link state=link
- name: Create the express framework for Node.js (OS's other than Fedora 18) - name: Create the express framework for Node.js (OS's other than Fedora 18)
shell: npm install shell: npm install
args: args:
chdir: "{{ sugarizer_location }}/sugarizer/server" chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
creates: "{{ sugarizer_location }}/sugarizer/server/node_modules" creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/server/node_modules"
when: not is_F18 and not npm_exists when: not is_F18 and not npm_exists
- name: Create the express framework for Node.js (Fedora 18) - name: Create the express framework for Node.js (Fedora 18)

View file

@ -1,3 +1,2 @@
RewriteRule ^/sugarizer(.*)$ http://localhost:8089/sugarizer$1 [P,L] RewriteEngine on
ProxyPassReverse /sugarizer http://localhost:8010/sugarizer RewriteRule ^/sugarizer(.*)$ http://localhost:8089$1 [PT]
ProxyRequests Off

View file

@ -1,7 +1,20 @@
; Sugarizer configuration file [information]
name = Sugarizer Server
description = Your Sugarizer Server
[web] [web]
port = 8089 port = {{ sugarizer_port }}
[security]
min_password_size = 4
max_age = 172800000
https = false
certificate_file = ../server.crt
key_file = ../server.key
strict_ssl = false
[client]
path = ../sugarizer/
[database] [database]
server = localhost server = localhost
@ -11,13 +24,16 @@ name = sugarizer
[presence] [presence]
port = 8039 port = 8039
[statistics]
active = true
[collections] [collections]
users = users users = users
journal = journal journal = journal
stats = stats
[activities] [activities]
activities_directory_name = activities activities_directory_name = activities
activities_path = ../activities
template_directory_name = ActivityTemplate template_directory_name = ActivityTemplate
activity_info_path = activity/activity.info activity_info_path = activity/activity.info
favorites = org.sugarlabs.GearsActivity,org.sugarlabs.MazeWebActivity,org.olpcfrance.PaintActivity,org.olpcfrance.TamTamMicro,org.olpcfrance.MemorizeActivity,org.olpg-france.physicsjs,org.sugarlabs.CalculateActivity,org.sugarlabs.TurtleBlocksJS,org.sugarlabs.Clock,,org.olpcfrance.RecordActivity,org.olpcfrance.Abecedarium,org.olpcfrance.KAView,org.olpcfrance.FoodChain,org.olpc-france.labyrinthjs,org.olpcfrance.TankOp,org.sugarlabs.ChatPrototype,org.olpcfrance.Gridpaint,org.olpc-france.LOLActivity,org.sugarlabs.StopwatchActivity,org.sugarlabs.GTDActivity,org.sugarlabs.Markdown,org.laptop.WelcomeWebActivity favorites = org.sugarlabs.GearsActivity,org.sugarlabs.MazeWebActivity,org.olpcfrance.PaintActivity,org.olpcfrance.TamTamMicro,org.olpcfrance.MemorizeActivity,org.olpg-france.physicsjs,org.sugarlabs.CalculateActivity,org.sugarlabs.TurtleBlocksJS,org.sugarlabs.Clock,org.sugarlabs.SpeakActivity,org.sugarlabs.moon,org.olpcfrance.RecordActivity,org.olpcfrance.Abecedarium,org.olpcfrance.videoviewer,org.olpcfrance.FoodChain,org.olpc-france.labyrinthjs,org.olpcfrance.TankOp,org.sugarlabs.ChatPrototype,org.olpcfrance.Gridpaint,org.olpc-france.LOLActivity,org.olpcfrance.sharednotes,org.sugarlabs.ColorMyWorldActivity,com.homegrownapps.xoeditor,com.homegrownapps.reflection,com.homegrownapps.abacus,org.sugarlabs.Blockrain,org.sugarlabs.StopwatchActivity,com.homegrownapps.flip,org.somosazucar.JappyActivity,org.olpcfrance.qrcode,org.sugarlabs.Markdown,org.sugarlabs.gameOfLife,org.sugarlabs.Scratch,org.sugarlabs.FotoToonJs

View file

@ -1,18 +1,20 @@
[unit] [Unit]
Description=Node.js Sugarizer Server Description=Node.js Sugarizer Server
# Requires=After=mongodb.service # Requires the mongodb service to run first Requires=mongodb.service
After=mongodb.service # Requires the mongodb service to run first
[Service] [Service]
WorkingDirectory={{ sugarizer_location }}/sugarizer/server/ WorkingDirectory=/opt/iiab/sugarizer-server/
ExecStart=/usr/bin/node sugarizer.js ExecStart=/usr/bin/node /opt/iiab/sugarizer-server/sugarizer.js
Type=simple
Restart=always Restart=always
#RestartSec=10 # Restart service after 10 seconds if node service crashes RestartSec=10
StandardOutput=syslog # Output to syslog StandardOutput=syslog
StandardError=syslog # Output to syslog StandardError=syslog
SyslogIdentifier=sugarizer SyslogIdentifier=sugarizer
#User=<alternate user> #User=<alternate user>
#Group=<alternate group> #Group=<alternate group>
Environment=NODE_ENV=production #Environment=NODE_ENV=production
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -328,6 +328,7 @@ pathagar_enabled: False
# Sugarizer # Sugarizer
sugarizer_install: True sugarizer_install: True
sugarizer_enabled: False sugarizer_enabled: False
sugarizer_port: 8089
# 8-MGMT-TOOLS # 8-MGMT-TOOLS