Skip to content

Commit

Permalink
Update: Fabmodules
Browse files Browse the repository at this point in the history
Changed fabmodules repo to use FLW fork
Added .config/autostart script for guests
Removed python webserver and redirected shortcuts
Updated tests ;)
  • Loading branch information
red-stripe committed Dec 10, 2018
1 parent 852d232 commit d2d425d
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 77 deletions.
12 changes: 3 additions & 9 deletions cookbooks/fabmodules/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# fabmodules

This cookbook installs [fabmodules](https://github.com/FabModules/fabmodules-html5) from the [FabLabWgtn git repo](https://github.com/FabLabWgtn/fabmodules-html5).
It creates a system service to automatically run on startup and creates a desktop shortcut for [guest](https://github.com/FabLabWgtn/fab_chef/tree/master/cookbooks/guest_setup) users.
It creates a desktop shortcut for [guest](https://github.com/FabLabWgtn/fab_chef/tree/master/cookbooks/guest_setup) users and auto-starts when they login.

**Note:** This script does _not_ install or configure any machines automatically.
Vinyl cutters / PCB mill need to be manually setup matching output setting from [fabmodules](https://github.com/FabLabWgtn/fabmodules-html5/tree/master/outputs)

TODO:
Add and autostart systemctl services for fablocal.service & fabnode.services
```
systemctl enable fablocal.service
systemctl start fablocal.service
systemctl status fablocal.service
```

`systemctl daemon-reload`
Move guest logs from `/tmp/` to `/var/log/fabmodules` when guests logout.

Notes from vinyl install
```
#lsusb - find that roland vinyl cutter
#sudo usb_printerid /dev/usb/lp0
Expand Down
6 changes: 3 additions & 3 deletions cookbooks/fabmodules/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
license 'GNU GPLv3'
description 'Installs/Configures fabmodules'
long_description 'Installs/Configures fabmodules'
version '0.1.7'
version '0.2.0'
chef_version '>= 12.14' if respond_to?(:chef_version)

# The `issues_url` points to the location where issues for this cookbook are
# tracked. A `View Issues` link will be displayed on this cookbook's page when
# uploaded to a Supermarket.
#
# issues_url 'https://github.com/<insert_org_here>/fabmodules/issues'
# issues_url 'https://github.com/FabLabWgtn/fab_chef/issues'

# The `source_url` points to the development repository for this cookbook. A
# `View Source` link will be displayed on this cookbook's page when uploaded to
# a Supermarket.
#
# source_url 'https://github.com/<insert_org_here>/fabmodules'
# source_url 'https://github.com/FabLabWgtn/fab_chef'
52 changes: 18 additions & 34 deletions cookbooks/fabmodules/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
action :install
end

execute 'install npm dependants' do
command 'npm install node-static serve-static ws'
end

apt_package 'cups-bsd' do
action :install
end
Expand Down Expand Up @@ -86,6 +82,11 @@
action :checkout
end


execute 'install node_modules' do
command 'npm install /opt/fabmodules/'
end

directory '/opt/fabmodules' do
owner 'root'
group 'fabmodules'
Expand Down Expand Up @@ -113,48 +114,31 @@
group 'fabmodules'
end

#Create system service to auto luanch fabmodules
template '/usr/local/bin/fabmodules-local.sh' do
source 'fabmodules-local.sh.erb'
owner 'root'
group 'root'
mode '0744'
action :create
end

template '/etc/systemd/system/fablocal.service' do
source 'fablocal.service.erb'
owner 'root'
group 'root'
mode '0664'
action :create
#add desktop shortcut & startup script for guest users
%w[ /etc/guest-session /etc/guest-session/skel /etc/guest-session/skel/Desktop /etc/guest-session/skel/.config /etc/guest-session/skel/.config/autostart ].each do |path|
directory path do
owner 'root'
group 'root'
mode '0755'
end
end

template '/usr/local/bin/fabmodules-node.sh' do
source 'fabmodules-node.sh.erb'
template '/usr/local/bin/fabmodules-start.sh' do
source 'fabmodules-start.sh.erb'
owner 'root'
group 'root'
mode '0744'
mode '0755'
action :create
end

template '/etc/systemd/system/fabnode.service' do
source 'fabnode.service.erb'
template '/etc/guest-session/skel/.config/autostart/fabmodules-autostart.desktop' do
source 'fabmodules-autostart.desktop.erb'
owner 'root'
group 'root'
mode '0664'
mode '0755'
action :create
end

#add desktop shortcut for guest users
%w[ /etc/guest-session /etc/guest-session/skel /etc/guest-session/skel/Desktop ].each do |path|
directory path do
owner 'root'
group 'root'
mode '0755'
end
end

template '/etc/guest-session/skel/Desktop/fabmodules.desktop' do
source 'shortcut_fabmodules.desktop.erb'
owner 'root'
Expand Down
10 changes: 0 additions & 10 deletions cookbooks/fabmodules/templates/fablocal.service.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Fabmodules html autostart
Type=Application
NoDisplay=true
X-Ubuntu-Gettext-Domain=lightdm
Exec=/usr/local/bin/fabmodules-start.sh
2 changes: 0 additions & 2 deletions cookbooks/fabmodules/templates/fabmodules-local.sh.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
echo "Launching fabmodules as" $USER | ts '[%Y-%m-%d %H:%M:%S]' >> /var/log/fabmodules/mod_server.log
exec node /opt/fabmodules/mod_server/mod_server.js | ts '[%Y-%m-%d %H:%M:%S]' >> /var/log/fabmodules/mod_server.log
echo "Launching fabmodules as" $USER | ts '[%Y-%m-%d %H:%M:%S]' >> /tmp/mod_server.log
exec node /opt/fabmodules/mod_server/mod_server.js | ts '[%Y-%m-%d %H:%M:%S]' >> /tmp/mod_server.log
10 changes: 0 additions & 10 deletions cookbooks/fabmodules/templates/fabnode.service.erb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Type=Application
Comment=This launches the locally installed FabModules Website
Icon=application-x-executable
Name=FabModules (local)
Exec=firefox http://localhost:8000
Exec=firefox http://localhost:12345
18 changes: 12 additions & 6 deletions cookbooks/fabmodules/test/integration/default/default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
its('mode') { should cmp '0775' }
end

describe file('/opt/fabmodules/node_modules') do
it { should exist }
it { should be_directory }
its('mode') { should cmp '0755' }
end

describe file('/opt/fabmodules/mod_server') do
it { should exist }
its('group') { should eq 'fabmodules' }
Expand All @@ -87,14 +93,14 @@
its('mode') { should cmp '0775' }
end

describe file('/usr/local/bin/fabmodules-node.sh') do
describe file('/etc/guest-session/skel/.config/autostart/fabmodules-autostart.desktop') do
it { should exist }
end

describe file('/usr/local/bin/fabmodules-start.sh') do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0744' }
end

describe file('/etc/systemd/system/fabnode.service') do
describe file('/usr/local/bin/fabmodules-start.sh') do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0664' }
end

1 comment on commit d2d425d

@red-stripe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the active fabmodules session would log to /var/log/fabmodules/mod_server.log but guest account restrictions won't allow them to write there. For now, there is a long in /tmp to debug and issues during an active session.

Please sign in to comment.