diff --git a/cookbooks/wekan/attributes.rb b/cookbooks/wekan/attributes.rb deleted file mode 100644 index 044f111..0000000 --- a/cookbooks/wekan/attributes.rb +++ /dev/null @@ -1,17 +0,0 @@ -# ------------------------------------------- -# Specifying the default settings: -# ------------------------------------------- -cmd = 'LANG=C /sbin/ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk "{print $2;}" | cut -d: -f2 | cut -f 1 -d " " | tail -1' -ipaddr = run_command(cmd).stdout.chomp - -node.reverse_merge!({ - 'nvm' => { - 'url_prefix' => 'https://raw.githubusercontent.com/creationix/nvm', - 'url_postfix' => 'install.sh', - 'node_version' => 'v8.11.2' - }, - 'wekan' => { - 'url' => 'https://releases.wekan.team', - 'ipaddr' => ipaddr - } -}) diff --git a/cookbooks/wekan/default.rb b/cookbooks/wekan/default.rb deleted file mode 100644 index 4bcd7f7..0000000 --- a/cookbooks/wekan/default.rb +++ /dev/null @@ -1,10 +0,0 @@ -include_recipe './attributes.rb' - -include_recipe './setup.rb' - -include_recipe './nvm.rb' - -include_recipe './mongodb' - -include_recipe './wekan' - diff --git a/cookbooks/wekan/files/etc/apt/sources.list.d/mongodb-org.list b/cookbooks/wekan/files/etc/apt/sources.list.d/mongodb-org.list deleted file mode 100644 index 3a38401..0000000 --- a/cookbooks/wekan/files/etc/apt/sources.list.d/mongodb-org.list +++ /dev/null @@ -1 +0,0 @@ -deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse diff --git a/cookbooks/wekan/files/etc/consul.d/service-wekan.json b/cookbooks/wekan/files/etc/consul.d/service-wekan.json deleted file mode 100644 index 0ffbb3a..0000000 --- a/cookbooks/wekan/files/etc/consul.d/service-wekan.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "service": { - "name": "wekan", - "port": 3000 - } -} diff --git a/cookbooks/wekan/files/etc/supervisor/conf.d/wekan.conf b/cookbooks/wekan/files/etc/supervisor/conf.d/wekan.conf deleted file mode 100644 index 28e6c32..0000000 --- a/cookbooks/wekan/files/etc/supervisor/conf.d/wekan.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:wekan] -command=/home/wekan/app/wekan.sh -stdout_logfile=/var/log/supervisor/wekan.log -redirect_stderr=true -stdout_logfile_maxbytes=1MB -stdout_logfile_backups=5 -autorestart=true -user=wekan diff --git a/cookbooks/wekan/mongodb.rb b/cookbooks/wekan/mongodb.rb deleted file mode 100644 index 2986fe7..0000000 --- a/cookbooks/wekan/mongodb.rb +++ /dev/null @@ -1,41 +0,0 @@ -execute 'apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927' do - not_if 'apt-key list | grep EA312927' -end - -remote_file '/etc/apt/sources.list.d/mongodb-org.list' do - user 'root' - group 'root' -end - -execute 'apt update' do - not_if "apt show mongodb-org | grep Installed" -end - -file '/etc/mongod.conf' do - action :edit - block do |content| - content.gsub!(/127\.0\.0\.1/, node['wekan']['ipaddr']) - end - - notifies :restart, 'service[mongod]' - - only_if 'grep 127.0.0.1 /etc/mongod.conf' -end - -package 'mongodb-org' do - action :install -end - -service 'mongod' do - action [ :enable, :start ] -end - -[ - 'echo "mongodb-org hold" | dpkg --set-selections', - 'echo "mongodb-org-server hold" | dpkg --set-selections', - 'echo "mongodb-org-shell hold" | dpkg --set-selections', - 'echo "mongodb-org-mongos hold" | dpkg --set-selections', - 'echo "mongodb-org-tools hold" | dpkg --set-selections' -].each do |cmd| - execute cmd -end diff --git a/cookbooks/wekan/nvm.rb b/cookbooks/wekan/nvm.rb deleted file mode 100644 index 35e09e4..0000000 --- a/cookbooks/wekan/nvm.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Calculate the latest peco version: -nvm_url = '' - -begin - require 'net/http' - - uri = URI.parse('https://github.com/creationix/nvm/releases/latest') - - Timeout.timeout(3) do - response = Net::HTTP.get_response(uri) - - vtag = $1 if response.body =~ %r{tag\/(v\d+\.\d+\.\d+)} - - nvm_url = "#{node['nvm']['url_prefix']}/#{vtag}/#{node['nvm']['url_postfix']}" - end -rescue - # Abort the chef client process: - raise 'Cannot connect to http://github.com.' -end - -execute "wget -qO- #{nvm_url} | bash" do - user 'wekan' - cwd '/home/wekan' - - not_if 'test -e /home/wekan/.nvm' -end - -ver = node['nvm']['node_version'] - -execute "su - wekan -c '. /home/wekan/.nvm/nvm.sh; nvm install #{ver}'" do - cwd '/home/wekan' - - not_if "test -e /home/wekan/.nvm/versions/node/#{ver}" -end - -execute "su - wekan -c '. /home/wekan/.nvm/nvm.sh; nvm use #{ver}'" do - cwd '/home/wekan' -end diff --git a/cookbooks/wekan/setup.rb b/cookbooks/wekan/setup.rb deleted file mode 100644 index 91e41ec..0000000 --- a/cookbooks/wekan/setup.rb +++ /dev/null @@ -1,23 +0,0 @@ -# Create a user for managing `wekan`: -user 'wekan' do - home '/home/wekan' - shell '/bin/bash' - password '$6$saltsalt$OpVze2cUKNOKlStVplX0Rwi.W98E3y5kQ7Z22r6WHDEa3UIRovzVBUdv.ivlJAB1g9GRcdCAookz9f3PzZFDz0' - create_home true -end - -# SSH -directory '/home/wekan/.ssh' do - owner 'wekan' - group 'wekan' - mode '700' -end - -# Deploy `~/.ssh/.ssh/authorized_keys`: -encrypted_remote_file '/home/wekan/.ssh/authorized_keys' do - owner 'wekan' - group 'wekan' - mode '600' - source 'files/home/wekan/.ssh/authorized_keys' - password ENV['ITAMAE_PASSWORD'] -end diff --git a/cookbooks/wekan/templates/home/wekan/app/mongodb-backup.sh b/cookbooks/wekan/templates/home/wekan/app/mongodb-backup.sh deleted file mode 100644 index 8cea9e0..0000000 --- a/cookbooks/wekan/templates/home/wekan/app/mongodb-backup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -e - -DIR=$(mktemp -d) -DATE=$(date "+%Y%m%d") - -mongodump -v --out "${DIR}" -h <%= @ipaddr %> - -tar cvzf "/tmp/wekan-mongodb-bk-${DATE}.tgz" "${DIR}" - -rm -rf "${DIR}" - -exit 0 diff --git a/cookbooks/wekan/templates/home/wekan/app/wekan.sh b/cookbooks/wekan/templates/home/wekan/app/wekan.sh deleted file mode 100644 index d4a19f1..0000000 --- a/cookbooks/wekan/templates/home/wekan/app/wekan.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm - -export PORT=3000 -export ROOT_URL="https://wekan.kazu634.com" -export MONGO_URL="mongodb://<%= @ipaddr %>:27017/wekan" - -/home/wekan/.nvm/versions/node/<%= @node_ver %>/bin/node /home/wekan/app/wekan/bundle/main.js diff --git a/cookbooks/wekan/wekan.rb b/cookbooks/wekan/wekan.rb deleted file mode 100644 index add3c62..0000000 --- a/cookbooks/wekan/wekan.rb +++ /dev/null @@ -1,112 +0,0 @@ -# Calculate the latest peco version: -wekan_url = '' -vtag = '' - -begin - require 'net/http' - - uri = URI.parse('https://github.com/wekan/wekan/releases/latest') - - Timeout.timeout(3) do - response = Net::HTTP.get_response(uri) - - vtag = $1 if response.body =~ %r{tag\/v(\d+\.\d+)} - - wekan_url = "#{node['wekan']['url']}/wekan-#{vtag}.tar.gz" - end -rescue - # Abort the chef client process: - raise 'Cannot connect to http://github.com.' -end - -directory '/home/wekan/app' do - owner 'wekan' - group 'wekan' - - mode '755' -end - -app_dir = "/home/wekan/app/#{vtag}" -directory app_dir do - owner 'wekan' - group 'wekan' - - mode '755' -end - -tmp = "/tmp/wekan-#{vtag}.tar.gz" -execute "wget #{wekan_url} -O #{tmp}" do - not_if "test -e #{app_dir}/bundle" -end - -execute "tar xvzf #{tmp} -C /home/wekan/app/#{vtag}" do - user 'wekan' - - not_if "test -e #{app_dir}/bundle" -end - -template '/home/wekan/app/wekan.sh' do - action :create - owner 'wekan' - group 'wekan' - mode '744' - - variables(ipaddr: node['wekan']['ipaddr'], node_ver: node['nvm']['node_version']) - - notifies :restart, 'service[supervisor]' -end - -template '/home/wekan/app/mongodb-backup.sh' do - action :create - owner 'wekan' - group 'wekan' - mode '744' - - variables(ipaddr: node['wekan']['ipaddr']) -end - -link '/home/wekan/app/wekan' do - to app_dir - user 'wekan' - force true -end - -# Deploy the `supervisord` configuration: -remote_file '/etc/supervisor/conf.d/wekan.conf' do - owner 'root' - group 'root' - mode '644' - - notifies :restart, 'service[supervisor]' -end - -# Deploy the `conusl` service file: -remote_file '/etc/consul.d/service-wekan.json' do - owner 'root' - group 'root' - mode '644' - - notifies :restart, 'service[supervisor]' -end - -service 'supervisor' do - action :nothing -end - -# Firewall settings here: -%w( 3000/tcp ).each do |p| - execute "ufw allow #{p}" do - user 'root' - - not_if "LANG=c ufw status | grep #{p}" - - notifies :run, 'execute[ufw reload-or-enable]' - end -end - -execute 'ufw reload-or-enable' do - user 'root' - command 'LANG=C ufw reload | grep skipping && ufw --force enable || exit 0' - - action :nothing -end