-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVagrantfile
71 lines (68 loc) · 2.16 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
61
62
63
64
65
66
67
68
69
70
71
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# This is totally not an overkill
#
Vagrant.configure("2") do |config|
config.vm.box = "devuan"
config.vm.box_url = "https://files.devuan.org/devuan_jessie/virtual/devuan_jessie_1.0.0_amd64_vagrant.box"
config.ssh.username = 'root'
config.ssh.forward_agent = false
config.vm.guest = :debian
config.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define "tasksched" do |tasksched|
tasksched.vm.network "forwarded_port", guest: 5000, host: 5000
tasksched.vm.hostname = "tasksched-vm"
tasksched.vm.provision "shell", inline: <<-SHELL
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
# Update keyring
apt-get update -q
apt-get install -qy devuan-keyring
# Switch to Round Robin mirrors
sed -i 's/auto.mirror/deb/g' /etc/apt/sources.list
# Upgrade VM to ascii
sed -i 's/jessie/ascii/g' /etc/apt/sources.list
apt-get update -q
apt-get dist-upgrade -qy
apt-get upgrade -qy
# Install dependencies
apt-get install make git task -qy
# Add NodeJS repositories
echo "deb http://deb.nodesource.com/node_9.x/ stretch main" >> /etc/apt/sources.list.d/nodejs.list
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
apt-get update -qy
# Do install NodeJS
apt-get install nodejs -qy
# Create user
adduser --disabled-password --gecos "" tasks
# Get actual code
git clone https://github.com/AnotherKamila/tasksched /srv/tasksched
chown -R tasks:tasks /srv/tasksched
# Create one-line exec script
cat >/srv/tasksched.sh << SH
#!/bin/sh
cd /srv/tasksched
make run
SH
# Fix permissions
chmod 755 /srv/tasksched.sh
# Install and setup monit
apt-get install monit -qy
sed -i 's/ set daemon 120/ set daemon 30/g' /etc/monit/monitrc
cat >/etc/monit/conf.d/tasksched << MONIT
check process tasksched
matching "node"
start program = "/srv/tasksched.sh"
as uid "tasks" and gid "tasks"
stop program = "/usr/bin/killall node"
if failed host 127.0.0.1 port 5000 then restart
MONIT
# Reboot, we want those kernel patches
reboot
SHELL
end
end