2014-12-09 21:00:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-11-30 17:45:05 +01:00
|
|
|
|
2017-03-19 22:50:12 +01:00
|
|
|
source _common.sh
|
2017-03-19 18:28:38 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2016-11-30 17:45:05 +01:00
|
|
|
|
2022-05-22 14:58:59 +02:00
|
|
|
jenkins_version=$(ynh_app_upstream_version)
|
2022-05-24 01:06:35 +02:00
|
|
|
|
2021-02-25 23:05:04 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-02-14 13:31:37 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
ynh_setup_source --source_id="jenkins-plugin-manager" --dest_dir="$install_dir"
|
2017-03-19 18:28:38 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2017-03-19 18:28:38 +01:00
|
|
|
|
2017-05-15 14:34:58 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL JENKINS
|
|
|
|
#=================================================
|
2021-04-10 20:50:48 +02:00
|
|
|
ynh_script_progression --message="Installing Jenkins..."
|
2017-05-15 14:34:58 +02:00
|
|
|
|
2019-01-13 18:07:28 +01:00
|
|
|
# Download jenkins deb file and install it.
|
2024-02-14 13:31:37 +01:00
|
|
|
dpkg --install --force-confnew "$install_dir/jenkins.deb" || true
|
2023-06-27 20:44:55 +02:00
|
|
|
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
|
2024-02-14 13:31:37 +01:00
|
|
|
ynh_print_warn --message="The service jenkins cannot be started for now."
|
2023-06-27 20:44:55 +02:00
|
|
|
fi
|
2017-05-15 14:34:58 +02:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
2021-02-25 23:05:04 +01:00
|
|
|
# SETUP APPLICATION
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
2024-02-14 13:31:37 +01:00
|
|
|
ynh_script_progression --message="Setting up application on port $port..."
|
2021-02-25 23:05:04 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
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"
|
2019-01-21 19:29:42 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
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\""
|
2022-05-22 14:58:59 +02:00
|
|
|
systemctl daemon-reload --quiet
|
2017-05-15 14:34:58 +02:00
|
|
|
|
2024-03-19 00:08:28 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
2018-07-13 17:33:05 +02:00
|
|
|
|
2023-06-27 20:44:55 +02:00
|
|
|
if [[ $dpkg_install_failed -ge 1 ]]; then
|
2024-02-14 13:31:37 +01:00
|
|
|
dpkg --configure -a
|
2023-06-27 20:44:55 +02:00
|
|
|
fi
|
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
#=================================================
|
|
|
|
# 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"
|
|
|
|
|
2022-05-22 14:58:59 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL PLUGINS
|
|
|
|
#=================================================
|
2021-04-10 20:50:48 +02:00
|
|
|
ynh_script_progression --message="Installing plugins..."
|
2019-01-30 15:56:18 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
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"
|
|
|
|
)
|
2019-01-21 19:29:42 +01:00
|
|
|
|
2019-01-13 18:07:28 +01:00
|
|
|
# Install plugins for http authentication and ldap.
|
2024-02-14 13:31:37 +01:00
|
|
|
"${jenkins_plugin_manager[@]}" --plugins reverse-proxy-auth-plugin
|
2017-12-16 23:20:29 +01:00
|
|
|
|
2019-01-13 18:07:28 +01:00
|
|
|
# Install recommended plugins (those from Setup Wizard)
|
2024-02-14 13:31:37 +01:00
|
|
|
"${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
|
2017-12-16 23:20:29 +01:00
|
|
|
|
2019-01-13 18:07:28 +01:00
|
|
|
# Install extra comfort plugins
|
|
|
|
# Handle terminal colours. Enhance the readability of the terminal.
|
2024-02-14 13:31:37 +01:00
|
|
|
"${jenkins_plugin_manager[@]}" --plugins ansicolor
|
2021-02-25 23:05:04 +01:00
|
|
|
# Monitoring of the local file system. Allow to monitor a directory and trig a job if a file has been modified.
|
2024-02-14 13:31:37 +01:00
|
|
|
"${jenkins_plugin_manager[@]}" --plugins fstrigger
|
2019-01-30 15:56:18 +01:00
|
|
|
|
2021-02-25 23:05:04 +01:00
|
|
|
#=================================================
|
2024-02-14 13:31:37 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-02-25 23:05:04 +01:00
|
|
|
#=================================================
|
2024-02-14 13:31:37 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2021-02-25 23:05:04 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-02-25 23:05:04 +01:00
|
|
|
|
2024-02-14 13:31:37 +01:00
|
|
|
# Service is provided by the deb package
|
|
|
|
yunohost service add "$app" --description="Jenkins Continuous Integration Server"
|
2021-02-25 23:05:04 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-04-10 20:50:48 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2021-02-25 23:05:04 +01:00
|
|
|
|
|
|
|
# Start a systemd service
|
2024-03-19 00:08:28 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
2019-01-21 13:08:17 +01:00
|
|
|
|
2019-01-30 15:56:18 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-04-10 20:50:48 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|