forked from redmine-git-hosting/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.sh
102 lines (77 loc) · 2.5 KB
/
plugin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
GITHUB_USER=${GITHUB_USER:-jbox-web}
GITHUB_PROJECT=${GITHUB_PROJECT:-redmine_git_hosting}
GITHUB_SOURCE="${GITHUB_USER}/${GITHUB_PROJECT}"
PLUGIN_PATH=${PLUGIN_PATH:-$GITHUB_SOURCE}
PLUGIN_NAME=${PLUGIN_NAME:-$GITHUB_PROJECT}
PLUGIN_DIR="redmine/plugins/${PLUGIN_NAME}"
CONTRIB_DATA_DIR="${PLUGIN_DIR}/contrib/travis/data"
function install_plugin() {
install_plugin_libs
move_plugin
install_database
install_gemfile
install_rspec
install_plugin_dependencies
}
## PRIVATE
function install_plugin_libs() {
log_title "INSTALL ADDITIONAL PACKAGES"
sudo apt-get install -qq libicu-dev libssh2-1 libssh2-1-dev cmake
log_ok
}
function move_plugin() {
log_title "MOVE PLUGIN"
# Move GITHUB_USER/GITHUB_PROJECT to redmine/plugins dir
mv "${PLUGIN_PATH}" "${REDMINE_NAME}/plugins"
# Remove parent dir (GITHUB_USER)
rmdir $(dirname ${PLUGIN_PATH})
log_ok
log_title "CREATE SYMLINK"
ln -s "${REDMINE_NAME}" "redmine"
log_ok
}
function install_database() {
log_title "INSTALL DATABASE FILE"
if [ "$DATABASE_ADAPTER" == "mysql" ] ; then
echo "Type : mysql"
cp "${CONTRIB_DATA_DIR}/db_files/database_mysql.yml" "redmine/config/database.yml"
else
echo "Type : postgres"
cp "${CONTRIB_DATA_DIR}/db_files/database_postgres.yml" "redmine/config/database.yml"
fi
log_ok
}
function install_gemfile() {
log_title "INSTALL RAILS 4 GEMFILE"
cp "${CONTRIB_DATA_DIR}/gem_files/rails4.gemfile" "${PLUGIN_DIR}/Gemfile"
log_ok
}
function install_rspec() {
log_title "INSTALL RSPEC FILE"
mkdir "redmine/spec"
cp "${PLUGIN_DIR}/spec/root_spec_helper.rb" "redmine/spec/spec_helper.rb"
log_ok
}
function install_plugin_dependencies() {
git_clone 'redmine_bootstrap_kit' 'https://github.com/jbox-web/redmine_bootstrap_kit.git'
git_clone 'redmine_sidekiq' 'https://github.com/ogom/redmine_sidekiq.git'
install_ssh_key
install_gitolite
}
function install_ssh_key() {
log_title "INSTALL ADMIN SSH KEY"
ssh-keygen -N '' -f "${PLUGIN_DIR}/ssh_keys/redmine_gitolite_admin_id_rsa"
log_ok
}
function install_gitolite() {
log_title "INSTALL GITOLITE V3"
sudo useradd --create-home git
sudo -n -u git -i git clone https://github.com/sitaramc/gitolite.git
sudo -n -u git -i mkdir bin
sudo -n -u git -i gitolite/install -to /home/git/bin
sudo cp "${PLUGIN_DIR}/ssh_keys/redmine_gitolite_admin_id_rsa.pub" /home/git/
sudo chown git.git /home/git/redmine_gitolite_admin_id_rsa.pub
sudo -n -u git -i gitolite setup -pk redmine_gitolite_admin_id_rsa.pub
log_ok
}