/
install
133 lines (104 loc) · 5.74 KB
/
install
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
jenkins_version=$(ynh_app_upstream_version)
ynh_app_setting_set --app="$app" --key="overwrite_nginx" --value="1"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --source_id="jenkins-plugin-manager" --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# INSTALL JENKINS
#=================================================
ynh_script_progression --message="Installing Jenkins..."
# Download jenkins deb file and install it.
dpkg --install --force-confnew "$install_dir/jenkins.deb" || true
dpkg_install_failed=$(dpkg-query -f '${status} ${package}\n' -W | awk '$4 ~ /^jenkins.*/ && $3 != "installed" {print $4}' | wc -l)
if [[ $dpkg_install_failed -ge 1 ]]; then
ynh_print_warn --message="The service jenkins cannot be started for now."
fi
#=================================================
# SETUP APPLICATION
#=================================================
ynh_script_progression --message="Setting up application on port $port..."
echo "$jenkins_version" >> "$install_dir/jenkins.install.InstallUtil.lastExecVersion"
echo "$jenkins_version" >> "$install_dir/jenkins.install.UpgradeWizard.state"
chown "$app:$app" "$install_dir/jenkins.install.InstallUtil.lastExecVersion"
chown "$app:$app" "$install_dir/jenkins.install.UpgradeWizard.state"
ynh_replace_string --target_file="/lib/systemd/system/jenkins.service" \
--match_string="Environment=\"JENKINS_PORT=8080\"" \
--replace_string="Environment=\"JENKINS_PORT=$port\"\nEnvironment=\"JENKINS_PREFIX=$path\""
systemctl daemon-reload --quiet
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
if [[ $dpkg_install_failed -ge 1 ]]; then
dpkg --configure -a
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="config.xml" --destination="$install_dir/config.xml"
chown "$app:$app" "$install_dir/config.xml"
#=================================================
# INSTALL PLUGINS
#=================================================
ynh_script_progression --message="Installing plugins..."
jenkins_plugin_manager=(
ynh_exec_warn_less java -jar "$install_dir/jenkins-plugin-manager.jar" --war /usr/share/java/jenkins.war --plugin-download-directory="$install_dir/plugins"
)
# Install plugins for http authentication and ldap.
"${jenkins_plugin_manager[@]}" --plugins reverse-proxy-auth-plugin
# Install recommended plugins (those from Setup Wizard)
"${jenkins_plugin_manager[@]}" --plugins cloudbees-folder # Folders Plugin
"${jenkins_plugin_manager[@]}" --plugins antisamy-markup-formatter # OWASP Markup Formatter Plugin
"${jenkins_plugin_manager[@]}" --plugins pam-auth # PAM Authentication plugin
"${jenkins_plugin_manager[@]}" --plugins mailer # Mailer Plugin
"${jenkins_plugin_manager[@]}" --plugins ldap # LDAP Plugin
"${jenkins_plugin_manager[@]}" --plugins matrix-auth # Matrix Authorization Strategy Plugin
"${jenkins_plugin_manager[@]}" --plugins build-timeout # Build timeout plugin
"${jenkins_plugin_manager[@]}" --plugins credentials-binding # Credentials Binding Plugin
"${jenkins_plugin_manager[@]}" --plugins timestamper # Timestamper
"${jenkins_plugin_manager[@]}" --plugins ws-cleanup # Workspace Cleanup Plugin
"${jenkins_plugin_manager[@]}" --plugins ant # Ant Plugin
"${jenkins_plugin_manager[@]}" --plugins gradle # Gradle Plugin
"${jenkins_plugin_manager[@]}" --plugins workflow-aggregator # Pipeline
"${jenkins_plugin_manager[@]}" --plugins pipeline-stage-view # Pipeline: Stage View Plugin
"${jenkins_plugin_manager[@]}" --plugins git # Git plugin
"${jenkins_plugin_manager[@]}" --plugins github-branch-source # GitHub Branch Source Plugin
"${jenkins_plugin_manager[@]}" --plugins subversion # Subversion Plug-in
"${jenkins_plugin_manager[@]}" --plugins email-ext # Email Extension Plugin
"${jenkins_plugin_manager[@]}" --plugins ssh-slaves # SSH Slaves plugin
# Install extra comfort plugins
# Handle terminal colours. Enhance the readability of the terminal.
"${jenkins_plugin_manager[@]}" --plugins ansicolor
# Monitoring of the local file system. Allow to monitor a directory and trig a job if a file has been modified.
"${jenkins_plugin_manager[@]}" --plugins fstrigger
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Service is provided by the deb package
yunohost service add "$app" --description="Jenkins Continuous Integration Server"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"