Merge pull request #4478 from pfaffman/kunena3-config-environment

kunena3: All config can be done via environment variables
This commit is contained in:
Régis Hanol 2016-10-03 08:51:14 +02:00 committed by GitHub
commit 5d3eb81ad1
1 changed files with 26 additions and 10 deletions

View File

@ -1,15 +1,31 @@
require "mysql2" require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb") require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# HOWTO: https://meta.discourse.org/t/importing-from-kunena-3/43776 # If you change this script's functionality, please consider making a note here:
# https://meta.discourse.org/t/importing-from-kunena-3/43776
# Before running this script, paste these lines into your shell,
# then use arrow keys to edit the values
=begin
export DB_HOST="localhost"
export DB_NAME="kunena"
export DB_USER="kunena"
export DB_PW="kunena"
export KUNENA_PREFIX="jos_" # "iff_" sometimes
export IMAGE_PREFIX="http://EXAMPLE.com/media/kunena/attachments"
export PARENT_FIELD="parent_id" # "parent" in some versions
=end
class ImportScripts::Kunena < ImportScripts::Base class ImportScripts::Kunena < ImportScripts::Base
KUNENA_DB = "kunena" DB_HOST ||= ENV['DB_HOST'] || "localhost"
KUNENA_PREFIX = "jos_" # "iff_" sometimes DB_NAME ||= ENV['DB_NAME'] || "kunena"
# Path to [attachment]s DB_USER ||= ENV['DB_USER'] || "kunena"
IMAGE_PREFIX = "http://EXAMPLE.com/media/kunena/attachments" DB_PW ||= ENV['DB_PW'] || "kunena"
PARENT_FIELD = "parent_id" # try "parent" in case of "Unknown column 'parent_id'" KUNENA_PREFIX ||= ENV['KUNENA_PREFIX'] || "jos_" # "iff_" sometimes
IMAGE_PREFIX ||= ENV['IMAGE_PREFIX'] || "http://EXAMPLE.com/media/kunena/attachments"
PARENT_FIELD ||= ENV['PARENT_FIELD'] || "parent_id" # "parent" in some versions
def initialize def initialize
super super
@ -17,10 +33,10 @@ class ImportScripts::Kunena < ImportScripts::Base
@users = {} @users = {}
@client = Mysql2::Client.new( @client = Mysql2::Client.new(
host: "HOSTNAME", host: DB_HOST,
username: "DATABASE_USER_NAME", username: DB_USER,
password: "DATABASE_USER_PASSWORD", password: DB_PW,
database: KUNENA_DB database: DB_NAME
) )
end end