-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
60 lines (50 loc) · 1.88 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- mode: ruby -*-
# vi: set ft=ruby :
# ninjaDVA clock
def provisionFile(config, from, to, options={mode: "775"})
config.vm.provision "file", source: from, destination: "/tmp/#{File.basename(from)}"
config.vm.provision "shell", inline: "install -m #{options[:mode]} /tmp/#{File.basename(from)} #{to}"
end
Vagrant.configure("2") do |config|
config.vm.define "clock"
# deactivate the standard shared folder
config.vm.synced_folder ".", "/vagrant", disabled:true
# name and version of vm image
config.vm.box = "bento/debian-10"
#set hostname for vm
config.vm.hostname = "clock"
ENV['LC_ALL']="en_US.UTF-8"
config.vm.provision "shell", inline: "mkdir -p /var/www && chmod a+rwX /var/www"
config.vm.provision "shell", inline: "rm -rf /var/www/clock"
config.vm.provision "file", source: "./www", destination: "/var/www/clock"
config.vm.provision "shell", inline: "chmod go-w -R /var/www"
provisionFile(config,"nodejs-ws","/var/www/")
config.vm.provision "shell", inline: <<-END
apt-get -y update
apt-get -y install dirmngr webfs
apt-key adv --recv-keys 1655A0AB68576280
echo "deb http://deb.nodesource.com/node_12.x buster main" > /etc/apt/sources.list.d/nodejs.list
apt-get -y update
apt-get -y install nodejs
cd /var/www
npm install ws
npm install winston@next
npm install pm2 -g
pm2 startup
pm2 start nodejs-ws
pm2 save
END
provisionFile(config,"webfsd.conf","/etc/", mode: 660)
config.vm.provision "shell", inline: "service webfs restart"
if File.exists?("../ninjadva.rb")
config.trigger.before :up do
# generate dashboard files
require "erb"
["dashboard-admin/clockadmin","dashboard-widgets/clockwidget"].each{|basename|
File.open("ninjadva/#{basename}.html","w"){|target| target << ERB.new(File.read("ninjadva/#{basename}.html.erb")).result }
}
end
require "../ninjadva"
NinjaDVA.new(config, link_widget_links: [])
end
end