Skip to content

Commit

Permalink
Merge branch 'release/v4.2.9-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeyer42 authored and cesmarvin committed Feb 21, 2023
2 parents cf3a77d + 2860ada commit 741d560
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v4.2.9-2] - 2023-02-21
### Changed
- Extract admin creation and deletion scripts (#111)

## [v4.2.9-1] - 2023-02-14
### Changed
- Upgrade to Redmine 4.2.9; #109
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM registry.cloudogu.com/official/base:3.14.3-1

LABEL NAME="official/redmine" \
VERSION="4.2.9-1" \
VERSION="4.2.9-2" \
maintainer="[email protected]"

# This Dockerfile is based on https://github.com/docker-library/redmine/blob/master/4.0/alpine/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ node('vagrant') {
}

stage('Shell-Check') {
shellCheck("./resources/startup.sh ./resources/post-upgrade.sh ./resources/pre-upgrade.sh ./resources/util.sh ./resources/upgrade-notification.sh ./resources/create-admin.sh ./resources/default-config.sh ./resources/remove-user.sh ./resources/util.sh ./resources/delete-plugin.sh")
shellCheck("./resources/startup.sh ./resources/post-upgrade.sh ./resources/pre-upgrade.sh ./resources/util.sh ./resources/upgrade-notification.sh ./resources/default-config.sh ./resources/util.sh ./resources/delete-plugin.sh")
}

try {
Expand Down
2 changes: 1 addition & 1 deletion dogu.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Name": "official/redmine",
"Version": "4.2.9-1",
"Version": "4.2.9-2",
"DisplayName": "Redmine",
"Description": "Redmine is a flexible project management web application",
"Category": "Development Apps",
Expand Down
32 changes: 0 additions & 32 deletions resources/create-admin.sh

This file was deleted.

44 changes: 44 additions & 0 deletions resources/rails_scripts/create_admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'optparse'

module CreateAdminHelper
@options = {}
OptionParser.new do |opts|
opts.banner = "Usage: get_setting.rb [options]"

opts.on("-u", "--username USERNAME", "username")
opts.on("-p", "--password PASSWORD", "password")
end.parse!(into: @options)

@options[:username] = "" if @options[:username].nil?

def self.options
@options
end

class ActiveSupport::HashWithIndifferentAccess
def symbolize_keys!
transform_keys! { |key| key.to_sym rescue key }
end
end
end

begin
opts = CreateAdminHelper::options
username = opts[:username]
password = opts[:password]
puts "Try to create user '%s'" % username
user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option, :admin => true)
user.login = username
user.password = password
user.password_confirmation = password
user.lastname = username
user.firstname = username
user.mail = "#{username}@#{username}.de"
user.save!
puts 'User saved successfully.'
rescue Exception => error
puts '================================================'
puts error.message
puts '================================================'
raise 'User was not saved.'
end
36 changes: 36 additions & 0 deletions resources/rails_scripts/remove_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'optparse'

module RemoveUserHelper
@options = {}
OptionParser.new do |opts|
opts.banner = "Usage: get_setting.rb [options]"

opts.on("-u", "--username USERNAME", "username")
end.parse!(into: @options)

@options[:username] = "" if @options[:username].nil?

def self.options
@options
end

class ActiveSupport::HashWithIndifferentAccess
def symbolize_keys!
transform_keys! { |key| key.to_sym rescue key }
end
end
end

begin
opts = RemoveUserHelper::options
puts "Try to remove user %s" % opts[:username]
user = User.where(login: opts[:username]).first
puts 'User did not exist' if user.nil?
user.destroy unless user.nil?
puts 'User removed successfully.' unless user.nil?
rescue Exception => error
puts '====================================================='
puts error.message
puts '====================================================='
puts 'User remove failed.'
end
7 changes: 3 additions & 4 deletions resources/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function start_redmine_in_background(){
wait_for_redmine_to_get_healthy 300
}

# Creates an admin user by using the create-admin.sh script
# Creates an admin user by using the create_admin.rb script
function create_temporary_admin() {
echo "Creating temporary admin..."
# The Password must contain a special character, a lowercase letter, a capital letter and a number...
Expand All @@ -170,8 +170,7 @@ function create_temporary_admin() {
# In case we are in restart loop to prevent infinite admin users...
remove_last_temporary_admin

# shellcheck disable=SC1091
source "/create-admin.sh" "${TMP_ADMIN_NAME}" "${TMP_ADMIN_PASSWORD}"
railsConsole "/rails_scripts/create_admin.rb" --username "${TMP_ADMIN_NAME}" --password "${TMP_ADMIN_PASSWORD}" || exit 1
doguctl config -e "last_tmp_admin" "${TMP_ADMIN_NAME}"
}

Expand All @@ -188,7 +187,7 @@ function remove_last_temporary_admin() {
then
echo "Removing last temporary admin..."
# shellcheck disable=SC1091
source "/remove-user.sh" "${LAST_TMP_ADMIN}"
railsConsole "/rails_scripts/remove_user.rb" --username "${LAST_TMP_ADMIN}" || exit 1
doguctl config --rm last_tmp_admin
fi
}
Expand Down

0 comments on commit 741d560

Please sign in to comment.