Skip to content

Commit d2d425d

Browse files
committed
Update: Fabmodules
Changed fabmodules repo to use FLW fork Added .config/autostart script for guests Removed python webserver and redirected shortcuts Updated tests ;)
1 parent 852d232 commit d2d425d

File tree

10 files changed

+45
-77
lines changed

10 files changed

+45
-77
lines changed

cookbooks/fabmodules/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
# fabmodules
22

33
This cookbook installs [fabmodules](https://github.com/FabModules/fabmodules-html5) from the [FabLabWgtn git repo](https://github.com/FabLabWgtn/fabmodules-html5).
4-
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.
4+
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.
55

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

99
TODO:
10-
Add and autostart systemctl services for fablocal.service & fabnode.services
11-
```
12-
systemctl enable fablocal.service
13-
systemctl start fablocal.service
14-
systemctl status fablocal.service
15-
```
16-
17-
`systemctl daemon-reload`
10+
Move guest logs from `/tmp/` to `/var/log/fabmodules` when guests logout.
1811

12+
Notes from vinyl install
1913
```
2014
#lsusb - find that roland vinyl cutter
2115
#sudo usb_printerid /dev/usb/lp0

cookbooks/fabmodules/metadata.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
license 'GNU GPLv3'
55
description 'Installs/Configures fabmodules'
66
long_description 'Installs/Configures fabmodules'
7-
version '0.1.7'
7+
version '0.2.0'
88
chef_version '>= 12.14' if respond_to?(:chef_version)
99

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

1616
# The `source_url` points to the development repository for this cookbook. A
1717
# `View Source` link will be displayed on this cookbook's page when uploaded to
1818
# a Supermarket.
1919
#
20-
# source_url 'https://github.com/<insert_org_here>/fabmodules'
20+
# source_url 'https://github.com/FabLabWgtn/fab_chef'

cookbooks/fabmodules/recipes/default.rb

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@
5454
action :install
5555
end
5656

57-
execute 'install npm dependants' do
58-
command 'npm install node-static serve-static ws'
59-
end
60-
6157
apt_package 'cups-bsd' do
6258
action :install
6359
end
@@ -86,6 +82,11 @@
8682
action :checkout
8783
end
8884

85+
86+
execute 'install node_modules' do
87+
command 'npm install /opt/fabmodules/'
88+
end
89+
8990
directory '/opt/fabmodules' do
9091
owner 'root'
9192
group 'fabmodules'
@@ -113,48 +114,31 @@
113114
group 'fabmodules'
114115
end
115116

116-
#Create system service to auto luanch fabmodules
117-
template '/usr/local/bin/fabmodules-local.sh' do
118-
source 'fabmodules-local.sh.erb'
119-
owner 'root'
120-
group 'root'
121-
mode '0744'
122-
action :create
123-
end
124-
125-
template '/etc/systemd/system/fablocal.service' do
126-
source 'fablocal.service.erb'
127-
owner 'root'
128-
group 'root'
129-
mode '0664'
130-
action :create
117+
#add desktop shortcut & startup script for guest users
118+
%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|
119+
directory path do
120+
owner 'root'
121+
group 'root'
122+
mode '0755'
123+
end
131124
end
132125

133-
template '/usr/local/bin/fabmodules-node.sh' do
134-
source 'fabmodules-node.sh.erb'
126+
template '/usr/local/bin/fabmodules-start.sh' do
127+
source 'fabmodules-start.sh.erb'
135128
owner 'root'
136129
group 'root'
137-
mode '0744'
130+
mode '0755'
138131
action :create
139132
end
140133

141-
template '/etc/systemd/system/fabnode.service' do
142-
source 'fabnode.service.erb'
134+
template '/etc/guest-session/skel/.config/autostart/fabmodules-autostart.desktop' do
135+
source 'fabmodules-autostart.desktop.erb'
143136
owner 'root'
144137
group 'root'
145-
mode '0664'
138+
mode '0755'
146139
action :create
147140
end
148141

149-
#add desktop shortcut for guest users
150-
%w[ /etc/guest-session /etc/guest-session/skel /etc/guest-session/skel/Desktop ].each do |path|
151-
directory path do
152-
owner 'root'
153-
group 'root'
154-
mode '0755'
155-
end
156-
end
157-
158142
template '/etc/guest-session/skel/Desktop/fabmodules.desktop' do
159143
source 'shortcut_fabmodules.desktop.erb'
160144
owner 'root'

cookbooks/fabmodules/templates/fablocal.service.erb

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Desktop Entry]
2+
Name=Fabmodules html autostart
3+
Type=Application
4+
NoDisplay=true
5+
X-Ubuntu-Gettext-Domain=lightdm
6+
Exec=/usr/local/bin/fabmodules-start.sh

cookbooks/fabmodules/templates/fabmodules-local.sh.erb

Lines changed: 0 additions & 2 deletions
This file was deleted.

cookbooks/fabmodules/templates/fabmodules-node.sh.erb renamed to cookbooks/fabmodules/templates/fabmodules-start.sh.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
echo "Launching fabmodules as" $USER | ts '[%Y-%m-%d %H:%M:%S]' >> /var/log/fabmodules/mod_server.log
3-
exec node /opt/fabmodules/mod_server/mod_server.js | ts '[%Y-%m-%d %H:%M:%S]' >> /var/log/fabmodules/mod_server.log
2+
echo "Launching fabmodules as" $USER | ts '[%Y-%m-%d %H:%M:%S]' >> /tmp/mod_server.log
3+
exec node /opt/fabmodules/mod_server/mod_server.js | ts '[%Y-%m-%d %H:%M:%S]' >> /tmp/mod_server.log

cookbooks/fabmodules/templates/fabnode.service.erb

Lines changed: 0 additions & 10 deletions
This file was deleted.

cookbooks/fabmodules/templates/shortcut_fabmodules.desktop.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Type=Application
44
Comment=This launches the locally installed FabModules Website
55
Icon=application-x-executable
66
Name=FabModules (local)
7-
Exec=firefox http://localhost:8000
7+
Exec=firefox http://localhost:12345

cookbooks/fabmodules/test/integration/default/default_test.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
its('mode') { should cmp '0775' }
7575
end
7676

77+
describe file('/opt/fabmodules/node_modules') do
78+
it { should exist }
79+
it { should be_directory }
80+
its('mode') { should cmp '0755' }
81+
end
82+
7783
describe file('/opt/fabmodules/mod_server') do
7884
it { should exist }
7985
its('group') { should eq 'fabmodules' }
@@ -87,14 +93,14 @@
8793
its('mode') { should cmp '0775' }
8894
end
8995

90-
describe file('/usr/local/bin/fabmodules-node.sh') do
96+
describe file('/etc/guest-session/skel/.config/autostart/fabmodules-autostart.desktop') do
97+
it { should exist }
98+
end
99+
100+
describe file('/usr/local/bin/fabmodules-start.sh') do
91101
it { should exist }
92-
its('group') { should eq 'root' }
93-
its('mode') { should cmp '0744' }
94102
end
95103

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

0 commit comments

Comments
 (0)