Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabmodules-html5 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cookbooks/fabmodules/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.vagrant
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~

# Bundler
Gemfile.lock
gems.locked
bin/*
.bundle/*

# test kitchen
.kitchen/
.kitchen.local.yml

# Chef
Berksfile.lock
.zero-knife.rb
Policyfile.lock.json
.delivery/
25 changes: 25 additions & 0 deletions cookbooks/fabmodules/.kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
driver:
name: vagrant

provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true

verifier:
name: inspec

platforms:
- name: ubuntu-16.04

suites:
- name: default
run_list:
- recipe[fabmodules::default]
verifier:
inspec_tests:
- test/integration/default
attributes:
4 changes: 4 additions & 0 deletions cookbooks/fabmodules/Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

metadata
11 changes: 11 additions & 0 deletions cookbooks/fabmodules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# fabmodules CHANGELOG

This file is used to list changes made in each version of the fabmodules cookbook.

# 0.2.0

Initial release.

- change 0.1.7
- change 0.2.0
Change from using a system service to gnome autostart to resolve x session ownership issues on guest account.
675 changes: 675 additions & 0 deletions cookbooks/fabmodules/LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions cookbooks/fabmodules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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 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:
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
#node /opt/fabmodules/mod_server/mod_server.js
#in groups fabmodules & dialout
#write access to /opt/fabmodules
#/opt/fabmodules/package.json exits
#/dev/ttyUSB0
#sudo lpr -PRoland-GX-24 -oraw test.camm
#description = Roland GX-24
#device URL = usb://Roland/GX-24?serial=DAN8585
#make & model = generic text-only printer

#send command lpr -PRoland-GX-24

#sudo adduser $USER lpr --- is this nesscary???
```
104 changes: 104 additions & 0 deletions cookbooks/fabmodules/chefignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Put files/directories that should be ignored in this file when uploading
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.

# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db

# SASS #
########
.sass-cache

# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log

## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/

# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
kitchen.yml*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml

# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*

# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp

# Bundler #
###########
vendor/*

# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json

# Cookbooks #
#############
CONTRIBUTING*
CHANGELOG*
TESTING*

# Vagrant #
###########
.vagrant
Vagrantfile
20 changes: 20 additions & 0 deletions cookbooks/fabmodules/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name 'fabmodules'
maintainer 'Fab Lab Wgtn'
maintainer_email '[email protected]'
license 'GNU GPLv3'
description 'Installs/Configures fabmodules'
long_description 'Installs/Configures fabmodules'
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/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/FabLabWgtn/fab_chef'
148 changes: 148 additions & 0 deletions cookbooks/fabmodules/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#
# Cookbook:: fabmodules
# Recipe:: default
#
# Copyright:: 2018, The Authors, All Rights Reserved.

#Create fabmodules group and add admin to it

user 'fabmodules' do
username 'fabmodules'
group 'dialout'
action :create
end

user 'fab-admin' do
username 'fab-admin'
group 'dialout'
action :create
end

group 'fab-admin' do
append true
group_name 'fab-admin'
members ['fab-admin']
action :create
end

group 'fabmodules' do
append true
group_name 'fabmodules'
members ['fab-admin','fabmodules']
action :create
end

#install dependencies
apt_repository 'nodejs' do
uri 'https://deb.nodesource.com/node_8.x'
components ['main']
key 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key'
keyserver 'deb.nodesource.com'
end

apt_update

apt_package 'nodejs' do #includes npm
action :install
end

apt_package 'build-essential' do
action :install
end

apt_package 'moreutils' do
action :install
end

apt_package 'cups-bsd' do
action :install
end

apt_package 'python-serial' do
action :install
end

apt_package 'python-tk' do
action :install
end

apt_package 'python-pip' do
action :install
end

apt_package 'wget' do
action :install
end

#Install fabmodules
git '/opt/fabmodules' do
repository 'https://github.com/FabLabWgtn/fabmodules-html5'
revision 'master'
depth 1
action :checkout
end


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

directory '/opt/fabmodules' do
owner 'root'
group 'fabmodules'
mode '0775'
action :create
end

directory '/opt/fabmodules/mod_server' do
owner 'root'
group 'fabmodules'
mode '0775'
action :create
end

directory '/var/log/fabmodules' do
owner 'root'
group 'fabmodules'
mode '0775'
action :create
end

file '/var/log/fabmodules/mod_server.log' do
mode '0775'
owner 'root'
group 'fabmodules'
end

#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-start.sh' do
source 'fabmodules-start.sh.erb'
owner 'root'
group 'root'
mode '0755'
action :create
end

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

template '/etc/guest-session/skel/Desktop/fabmodules.desktop' do
source 'shortcut_fabmodules.desktop.erb'
owner 'root'
group 'root'
mode '0755'
action :create
end
3 changes: 3 additions & 0 deletions cookbooks/fabmodules/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true
require 'chefspec'
require 'chefspec/berkshelf'
Loading