From 69f062f5379c7d70dbc7f644c7501e8c7441da27 Mon Sep 17 00:00:00 2001 From: Andrew Cantino Date: Mon, 10 Apr 2017 15:03:18 +1200 Subject: [PATCH] Cleanup openshift configuration since it is not supported (#1954) --- .openshift/action_hooks/build | 7 - .openshift/action_hooks/deploy | 25 ---- .openshift/action_hooks/post_deploy | 6 - .openshift/action_hooks/post_start_ruby-2.0 | 16 --- .openshift/action_hooks/post_stop_ruby-2.0 | 16 --- .openshift/action_hooks/pre_build | 24 ---- .openshift/action_hooks/pre_start_ruby-2.0 | 21 --- .openshift/action_hooks/pre_stop_ruby-2.0 | 16 --- .openshift/cron/README.cron | 22 --- .openshift/cron/daily/.gitignore | 0 .openshift/cron/hourly/.gitignore | 0 .openshift/cron/minutely/.gitignore | 0 .openshift/cron/monthly/.gitignore | 0 .openshift/cron/weekly/README | 16 --- .openshift/cron/weekly/chrono.dat | 1 - .openshift/cron/weekly/chronograph | 3 - .openshift/cron/weekly/jobs.allow | 12 -- .openshift/cron/weekly/jobs.deny | 7 - .openshift/markers/README | 8 -- bin/setup_openshift | 150 -------------------- 20 files changed, 350 deletions(-) delete mode 100755 .openshift/action_hooks/build delete mode 100755 .openshift/action_hooks/deploy delete mode 100755 .openshift/action_hooks/post_deploy delete mode 100755 .openshift/action_hooks/post_start_ruby-2.0 delete mode 100755 .openshift/action_hooks/post_stop_ruby-2.0 delete mode 100755 .openshift/action_hooks/pre_build delete mode 100755 .openshift/action_hooks/pre_start_ruby-2.0 delete mode 100755 .openshift/action_hooks/pre_stop_ruby-2.0 delete mode 100644 .openshift/cron/README.cron delete mode 100644 .openshift/cron/daily/.gitignore delete mode 100644 .openshift/cron/hourly/.gitignore delete mode 100644 .openshift/cron/minutely/.gitignore delete mode 100644 .openshift/cron/monthly/.gitignore delete mode 100644 .openshift/cron/weekly/README delete mode 100644 .openshift/cron/weekly/chrono.dat delete mode 100755 .openshift/cron/weekly/chronograph delete mode 100644 .openshift/cron/weekly/jobs.allow delete mode 100644 .openshift/cron/weekly/jobs.deny delete mode 100644 .openshift/markers/README delete mode 100755 bin/setup_openshift diff --git a/.openshift/action_hooks/build b/.openshift/action_hooks/build deleted file mode 100755 index 42b073ff49..0000000000 --- a/.openshift/action_hooks/build +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# This is a simple build script and will be executed on your CI system if -# available. Otherwise it will execute while your application is stopped -# before the deploy step. This script gets executed directly, so it -# could be python, php, ruby, etc. - -echo "-> Build step" \ No newline at end of file diff --git a/.openshift/action_hooks/deploy b/.openshift/action_hooks/deploy deleted file mode 100755 index c6f98b4705..0000000000 --- a/.openshift/action_hooks/deploy +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# This deploy hook gets executed after dependencies are resolved and the -# build hook has been run but before the application has been started back -# up again. This script gets executed directly, so it could be python, php, -# ruby, etc. - -echo "-> Deploy step" - -pushd ${OPENSHIFT_REPO_DIR} > /dev/null - -echo "DATABASE_NAME=${OPENSHIFT_APP_NAME}" > ${OPENSHIFT_REPO_DIR}/.env -echo "DATABASE_USERNAME=${OPENSHIFT_MYSQL_DB_USERNAME}" >> ${OPENSHIFT_REPO_DIR}/.env -echo "DATABASE_PASSWORD=${OPENSHIFT_MYSQL_DB_PASSWORD}" >> ${OPENSHIFT_REPO_DIR}/.env -echo "DATABASE_HOST=${OPENSHIFT_MYSQL_DB_HOST}" >> ${OPENSHIFT_REPO_DIR}/.env -echo "DATABASE_PORT=${OPENSHIFT_MYSQL_DB_PORT}" >> ${OPENSHIFT_REPO_DIR}/.env -echo "DATABASE_SOCKET=${OPENSHIFT_MYSQL_DB_SOCKET}" >> ${OPENSHIFT_REPO_DIR}/.env - -chmod ugo+r ${OPENSHIFT_REPO_DIR}/.env - -source ${OPENSHIFT_REPO_DIR}/.env - -gem install bundler -echo "Migrating" -RAILS_ENV="production" bundle exec rake db:migrate -popd > /dev/null diff --git a/.openshift/action_hooks/post_deploy b/.openshift/action_hooks/post_deploy deleted file mode 100755 index 3851db8688..0000000000 --- a/.openshift/action_hooks/post_deploy +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# This is a simple post deploy hook executed after your application -# is deployed and started. This script gets executed directly, so -# it could be python, php, ruby, etc. - -echo "-> Post deploy step" \ No newline at end of file diff --git a/.openshift/action_hooks/post_start_ruby-2.0 b/.openshift/action_hooks/post_start_ruby-2.0 deleted file mode 100755 index 3298810642..0000000000 --- a/.openshift/action_hooks/post_start_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Post start ruby step" \ No newline at end of file diff --git a/.openshift/action_hooks/post_stop_ruby-2.0 b/.openshift/action_hooks/post_stop_ruby-2.0 deleted file mode 100755 index 0af86bb604..0000000000 --- a/.openshift/action_hooks/post_stop_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Post stop ruby step" \ No newline at end of file diff --git a/.openshift/action_hooks/pre_build b/.openshift/action_hooks/pre_build deleted file mode 100755 index ba1e8f8177..0000000000 --- a/.openshift/action_hooks/pre_build +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# This is a simple script and will be executed on your CI system if -# available. Otherwise it will execute while your application is stopped -# before the build step. This script gets executed directly, so it -# could be python, php, ruby, etc. - -echo "-> Pre-build step" - -STORED_ASSETS="${OPENSHIFT_DATA_DIR}/assets" -LIVE_ASSETS="${OPENSHIFT_REPO_DIR}/public/assets" - -# Ensure our stored assets directory exists -if [ ! -d "${STORED_ASSETS}" ]; then - echo " Creating permanent assets directory" - mkdir "${STORED_ASSETS}" -fi - -# Create symlink to stored assets unless we're uploading our own assets -if [ -d "${LIVE_ASSETS}" ]; then - echo " WARNING: Assets included in git repository, not using stored assets" -else - echo " Restoring stored assets" - ln -s "${STORED_ASSETS}" "${LIVE_ASSETS}" -fi diff --git a/.openshift/action_hooks/pre_start_ruby-2.0 b/.openshift/action_hooks/pre_start_ruby-2.0 deleted file mode 100755 index 04cbea8ed3..0000000000 --- a/.openshift/action_hooks/pre_start_ruby-2.0 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Pro start ruby step" - -if [ -f ${OPENSHIFT_REPO_DIR}/.env ] -then - source ${OPENSHIFT_REPO_DIR}/.env -fi diff --git a/.openshift/action_hooks/pre_stop_ruby-2.0 b/.openshift/action_hooks/pre_stop_ruby-2.0 deleted file mode 100755 index 22ee1943fa..0000000000 --- a/.openshift/action_hooks/pre_stop_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Pre stop ruby step" \ No newline at end of file diff --git a/.openshift/cron/README.cron b/.openshift/cron/README.cron deleted file mode 100644 index 6a2593fdde..0000000000 --- a/.openshift/cron/README.cron +++ /dev/null @@ -1,22 +0,0 @@ -Run scripts or jobs on a periodic basis -======================================= -Any scripts or jobs added to the minutely, hourly, daily, weekly or monthly -directories will be run on a scheduled basis (frequency is as indicated by the -name of the directory) using run-parts. - -run-parts ignores any files that are hidden or dotfiles (.*) or backup -files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} - -The presence of two specially named files jobs.deny and jobs.allow controls -how run-parts executes your scripts/jobs. - jobs.deny ===> Prevents specific scripts or jobs from being executed. - jobs.allow ===> Only execute the named scripts or jobs (all other/non-named - scripts that exist in this directory are ignored). - -The principles of jobs.deny and jobs.allow are the same as those of cron.deny -and cron.allow and are described in detail at: - http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Automating_System_Tasks.html#s2-autotasks-cron-access - -See: man crontab or above link for more details and see the the weekly/ - directory for an example. - diff --git a/.openshift/cron/daily/.gitignore b/.openshift/cron/daily/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.openshift/cron/hourly/.gitignore b/.openshift/cron/hourly/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.openshift/cron/minutely/.gitignore b/.openshift/cron/minutely/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.openshift/cron/monthly/.gitignore b/.openshift/cron/monthly/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.openshift/cron/weekly/README b/.openshift/cron/weekly/README deleted file mode 100644 index 7c3e659fe2..0000000000 --- a/.openshift/cron/weekly/README +++ /dev/null @@ -1,16 +0,0 @@ -Run scripts or jobs on a weekly basis -===================================== -Any scripts or jobs added to this directory will be run on a scheduled basis -(weekly) using run-parts. - -run-parts ignores any files that are hidden or dotfiles (.*) or backup -files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles -the files named jobs.deny and jobs.allow specially. - -In this specific example, the chronograph script is the only script or job file -executed on a weekly basis (due to white-listing it in jobs.allow). And the -README and chrono.dat file are ignored either as a result of being black-listed -in jobs.deny or because they are NOT white-listed in the jobs.allow file. - -For more details, please see ../README.cron file. - diff --git a/.openshift/cron/weekly/chrono.dat b/.openshift/cron/weekly/chrono.dat deleted file mode 100644 index fc4abb87cb..0000000000 --- a/.openshift/cron/weekly/chrono.dat +++ /dev/null @@ -1 +0,0 @@ -Time And Relative D...n In Execution (Open)Shift! diff --git a/.openshift/cron/weekly/chronograph b/.openshift/cron/weekly/chronograph deleted file mode 100755 index 61de949f43..0000000000 --- a/.openshift/cron/weekly/chronograph +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "`date`: `cat $(dirname \"$0\")/chrono.dat`" diff --git a/.openshift/cron/weekly/jobs.allow b/.openshift/cron/weekly/jobs.allow deleted file mode 100644 index 42b1627689..0000000000 --- a/.openshift/cron/weekly/jobs.allow +++ /dev/null @@ -1,12 +0,0 @@ -# -# Script or job files listed in here (one entry per line) will be -# executed on a weekly-basis. -# -# Example: The chronograph script will be executed weekly but the README -# and chrono.dat files in this directory will be ignored. -# -# The README file is actually ignored due to the entry in the -# jobs.deny which is checked before jobs.allow (this file). -# -chronograph - diff --git a/.openshift/cron/weekly/jobs.deny b/.openshift/cron/weekly/jobs.deny deleted file mode 100644 index 73c945008a..0000000000 --- a/.openshift/cron/weekly/jobs.deny +++ /dev/null @@ -1,7 +0,0 @@ -# -# Any script or job files listed in here (one entry per line) will NOT be -# executed (read as ignored by run-parts). -# - -README - diff --git a/.openshift/markers/README b/.openshift/markers/README deleted file mode 100644 index abfa46cec7..0000000000 --- a/.openshift/markers/README +++ /dev/null @@ -1,8 +0,0 @@ -Markers -=========== - -Adding marker files to this directory will have the following effects: - -force_clean_build - Previous output from bundle install --deployment will be - removed and all gems will be reinstalled according to the current - Gemfile/Gemfile.lock. diff --git a/bin/setup_openshift b/bin/setup_openshift deleted file mode 100755 index a7de1adcc0..0000000000 --- a/bin/setup_openshift +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'setup_tools')) -include SetupTools - -if ARGV.length > 0 - mode = ARGV.shift -else - mode = '' -end - -unless `which rhc` =~ /rhc/ - puts "It looks like the 'rhc' command line tool hasn't been installed yet. Please install" - puts "it with 'gem install rhc', run 'rhc setup', and then run this script again." - exit 1 -end - -def grab_openshift_config! - grab_config_with_cmd!("rhc env list") -end - -def set_env(key, value) - capture("rhc env set #{key}=#{value}") -end - -def check_login! - token_file = Dir[File.join(File.expand_path('~/.openshift'), 'token_*')].first - unless token_file - puts "It looks like you need to log in to OpenShift. Please run 'rhc setup' before continuing a choose the option to 'Generate a token now', then run bin/setup_openshift again." - exit 1 - end - - unless (Time.now - File.stat(token_file).mtime).to_i < 60 * 60 * 24 * 5 - puts "Please run 'rhc logout' and then 'rhc account' to refresh your session, then run bin/setup_openshift again." - exit 1 - end - - puts "Welcome #{`rhc account`.scan(/Login (.*?) on /).first.first}! It looks like you're logged into OpenShift." - puts -end - -check_login! - -info = capture("rhc app show") -just_made = false -if info =~ /must specify an application/i - foreman_cartridge = 'http://cartreflect-claytondev.rhcloud.com/reflect?github=cantino/huginn-openshift-foreman-cartridge' - cmd = "rhc app create huginn ruby-2.0 mysql-5.5 #{foreman_cartridge} -s -r tmp-huginn" - puts "It looks like you don't have an OpenShift app set up yet for this repo. I can make one for you." - if yes?("Would you like me to create an OpenShift app for you now in this repo?") - puts "Okay, this may take a moment..." - puts `#{cmd}` - - git_config = capture("git config --list -f tmp-huginn/.git/config").split("\n") - git_config.grep(/^rhc\./).each do |line| - path, value = line.split('=') - puts `git config #{path} #{value}` - end - - url = git_config.grep(/^remote\.origin\.url/).first.split('=').last - puts "Adding remote #{url}" - puts `git remote add openshift #{url}` - - puts "Removing tmp OpenShift repo" - puts `rm -rf ./tmp-huginn` - - puts "Updating git" - puts `git fetch openshift` - - info = capture("rhc app show") - just_made = true - else - puts "Okay, exiting so you can do it." - exit 0 - end -elsif info =~ /Application '.*?' not found/ - puts "It looks like you've deleted your OpenShift app. If that's the case, you should" - puts "edit .git/config and remove the sections under [rhc] and under [remote \"openshift\"]." - exit 1 -end - -app_name, app_url = info.scan(/^([\w\d]+) @ https?:\/\/([^\/ ]+)/i).flatten -confirm_app_name app_name unless just_made -grab_openshift_config! -print_config -set_defaults! - -first_time = mode =~ /^first/i -unless $config['DOMAIN'] - set_value 'DOMAIN', app_url, force: false - first_time = true -end - -set_value 'BUNDLE_WITHOUT', 'development:test' -puts `rhc ssh huginn 'gem install bundler'` - -puts -puts "To setup outbound email, we suggest using Gmail. See the 'Outgoing email settings' section in .env.example." -puts "You'll need to set those environment variables in OpenShift using 'rhc env set VARIABLE=VALUE'" -puts - -branch = capture("git rev-parse --abbrev-ref HEAD") -if first_time || yes?("Should I push your current branch (#{branch}) to OpenShift?", default: :yes) - puts "This may take a moment..." - puts capture("git push openshift #{branch}:master -f") -end - -if first_time - puts "Restarting..." - puts capture("rhc app restart") - puts capture("rhc cartridge restart foreman") - puts "Done!" - puts - puts - puts "I can make an admin user on your new Huginn instance and setup some example Agents." - if yes?("Should I create a new admin user and some example Agents?", default: :yes) - done = false - while !done - seed_email = nag "Okay, what is your email address?" - seed_username = nag "And what username would you like to login as?" - seed_password = nag "Finally, what password would you like to use?", noecho: true - puts "\nJust a moment..." - - result = capture("rhc ssh huginn 'cd $OPENSHIFT_REPO_DIR && RAILS_ENV=production bundle exec rake db:seed SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}'") - puts result - if result =~ /Validation failed/ - puts "ERROR:" - puts - puts result - puts - else - done = true - end - end - puts - puts - puts "Okay, you should be all set! Visit http://#{app_url} and login as '#{seed_username}' with your password." - puts - puts "If you'd like to make more users, you can visit http://#{app_url}/users/sign_up and use the invitation code:" - else - puts - puts "Visit https://#{app_url}/users/sign_up and use the invitation code shown below:" - end - puts - puts "\t#{$config['INVITATION_CODE']}" - puts - puts "We recommend that you read https://github.com/cantino/huginn/wiki/Run-Huginn-for-free-on-OpenShift and setup Pingdom to keep your app awake!" -end - -puts -puts "Done!"