Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 90 lines (74 sloc) 1.57 KB
#!/usr/bin/env ruby
# hookit is installed as a bundled app, so we need bundler to load it for us
$:.unshift '/opt/gonano/hookit/vendor/bundle'
require 'bundler/setup'
# load hookit/setup to bootstrap hookit and import the dsl
require 'hookit/setup'
# Import service (and start)
directory '/etc/service/cache' do
recursive true
end
directory '/etc/service/cache/log' do
recursive true
end
template '/etc/service/cache/log/run' do
mode 0755
source 'log-run.erb'
variables ({ svc: "cache" })
end
template '/etc/service/cache/run' do
mode 0755
variables ({ exec: "redis-server /data/etc/redis/redis.conf 2>&1" })
end
sleep 5
service "cache" do
action :enable
end
ensure_socket 'cache' do
port '6379'
action :listening
end
# Attach the IP if provided
if payload[:ips]
# set up persistance
file "/etc/nanoinit.d/eth00" do
content <<-EOF
#!/bin/bash
case $1 in
start)
if [[ ! $(ifconfig) =~ eth0:0 ]]; then
ifconfig eth0:0 #{payload[:ips][:default]}
arping -A -c 10 -I eth0 #{payload[:ips][:default]}
fi
;;
stop)
if [[ $(ifconfig) =~ eth0:0 ]]; then
ifconfig eth0:0 down
fi
;;
*)
echo "$0 start|stop"
exit 1
;;
esac
EOF
mode 0755
end
# bring up interface
execute "bring up vip" do
command <<-EOF
/etc/nanoinit.d/eth00 start
EOF
end
end
if Dir.exist? "/opt/nanobox/cron"
directory '/etc/service/cron'
hook_file '/etc/service/cron/run' do
source 'cron'
mode 0755
end
service 'cron' do
action :enable
only_if { File.exist?('/etc/service/cron/run') }
end
end
You can’t perform that action at this time.