mirror of
https://github.com/YunoHost-Apps/jenkins_ynh.git
synced 2024-09-03 19:26:18 +02:00
backup, restore, remove et upgrade
This commit is contained in:
parent
6d8f277677
commit
c9c09b775e
8 changed files with 222 additions and 60 deletions
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Jenkins for YunoHost
|
||||||
|
==================
|
||||||
|
|
||||||
|
[Yunohost project](https://yunohost.org/#/)
|
||||||
|
|
||||||
|
The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.
|
||||||
|
|
||||||
|
https://jenkins.io
|
||||||
|
|
||||||
|
Le script installe les paquets *ca-certificates-java*, *daemon*, *default-jre-headless*, *java-common*, *jenkins*, *libasyncns0*, *libflac8*, *libice6*, *libnspr4*, *libnss3*, *libogg0*, *libpcsclite1*, *libpulse0*, *libsctp1*, *libsm6*, *libsndfile1*, *libvorbis0a*, *libvorbisenc2*, *libx11-xcb1*, *libxtst6*, *lksctp-tools*, *openjdk-7-jre-headless*, *tzdata-java*, *x11-common*.
|
||||||
|
|
||||||
|
**Mise à jour du package:**
|
||||||
|
sudo yunohost app upgrade jenkins -u https://github.com/YunoHost-Apps/jenkins_ynh
|
||||||
|
|
||||||
|
**Multi-utilisateur:** Oui, avec support ldap.
|
23
check_process
Normal file
23
check_process
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
;; Test complet
|
||||||
|
auto_remove=1
|
||||||
|
; Manifest
|
||||||
|
domain="domain.tld" (DOMAIN)
|
||||||
|
path="/path" (PATH)
|
||||||
|
is_public="Yes" (PUBLIC|public=Yes|private=No)
|
||||||
|
; Checks
|
||||||
|
pkg_linter=1
|
||||||
|
setup_sub_dir=1
|
||||||
|
setup_root=1
|
||||||
|
setup_nourl=0
|
||||||
|
setup_private=1
|
||||||
|
setup_public=1
|
||||||
|
upgrade=1
|
||||||
|
backup_restore=1
|
||||||
|
multi_instance=0
|
||||||
|
wrong_user=0
|
||||||
|
wrong_path=1
|
||||||
|
incorrect_path=1
|
||||||
|
corrupt_source=0
|
||||||
|
fail_download_source=0
|
||||||
|
port_already_use=1 (8080)
|
||||||
|
final_path_already_use=0
|
|
@ -1,54 +1,54 @@
|
||||||
{
|
{
|
||||||
"name": "Jenkins",
|
"name": "Jenkins",
|
||||||
"id": "jenkins",
|
"id": "jenkins",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4"
|
"yunohost": ">= 2.4"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Serveur d'intégration continue extensible",
|
"en": "Serveur d'intégration continue extensible",
|
||||||
"fr": "Extendable continuous integration server"
|
"fr": "Extendable continuous integration server"
|
||||||
},
|
},
|
||||||
"url": "https://jenkins.io/index.html",
|
"url": "https://jenkins.io/index.html",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Julien Malik et Maniack Crudelis",
|
"name": "Julien Malik et Maniack Crudelis",
|
||||||
"email": "julien.malik@paraiso.me"
|
"email": "julien.malik@paraiso.me"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx"
|
"nginx"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a domain for Jenkins",
|
"en": "Choose a domain for Jenkins",
|
||||||
"fr": "Choisissez un domaine pour Jenkins"
|
"fr": "Choisissez un domaine pour Jenkins"
|
||||||
},
|
},
|
||||||
"example": "domain.org"
|
"example": "domain.org"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a path for Jenkins",
|
"en": "Choose a path for Jenkins",
|
||||||
"fr": "Choisissez un chemin pour Jenkins"
|
"fr": "Choisissez un chemin pour Jenkins"
|
||||||
},
|
},
|
||||||
"example": "/jenkins",
|
"example": "/jenkins",
|
||||||
"default": "/jenkins"
|
"default": "/jenkins"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Is it a public site?",
|
"en": "Is it a public site?",
|
||||||
"fr": "Est-ce un site public ?"
|
"fr": "Est-ce un site public ?"
|
||||||
},
|
},
|
||||||
"choices": ["Yes", "No"],
|
"choices": ["Yes", "No"],
|
||||||
"default": "Yes"
|
"default": "Yes"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
scripts/backup
Normal file
25
scripts/backup
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
final_path=$(sudo yunohost app setting $app final_path)
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
|
|
||||||
|
# The parameter $1 is the backup directory location
|
||||||
|
# which will be compressed afterward
|
||||||
|
backup_dir=$1/apps/$app
|
||||||
|
sudo mkdir -p "$backup_dir"
|
||||||
|
|
||||||
|
# Backup sources & data
|
||||||
|
sudo cp -a $final_path/. $backup_dir/sources
|
||||||
|
|
||||||
|
# Copy Nginx and YunoHost parameters to make the script "standalone"
|
||||||
|
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
|
||||||
|
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
|
||||||
|
|
||||||
|
# Copie de la configuration de démarrage de Jenkins
|
||||||
|
sudo cp -a /etc/default/$app/. $backup_dir/etc
|
|
@ -82,7 +82,7 @@ sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# Ajoute le service au monitoring de Yunohost.
|
# Ajoute le service au monitoring de Yunohost.
|
||||||
sudo yunohost service add jenkins -l /var/log/$app/$app.log
|
sudo yunohost service add $app -l /var/log/$app/$app.log
|
||||||
|
|
||||||
# Surveille le démarrage du service.
|
# Surveille le démarrage du service.
|
||||||
config_OK=0
|
config_OK=0
|
||||||
|
@ -102,6 +102,27 @@ do # La boucle attend le démarrage de jenkins Ou 60 secondes.
|
||||||
done
|
done
|
||||||
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin reverse-proxy-auth-plugin
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin reverse-proxy-auth-plugin
|
||||||
|
|
||||||
|
# Installation des plugins recommandés (Lors de l'install avec le Setup Wizard)
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin cloudbees-folder # Folders Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin antisamy-markup-formatter # OWASP Markup Formatter Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin pam-auth # PAM Authentication plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin mailer # Mailer Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin ldap # LDAP Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin matrix-auth # Matrix Authorization Strategy Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin build-timeout # Build timeout plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin credentials-binding # Credentials Binding Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin timestamper # Timestamper
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin ws-cleanup # Workspace Cleanup Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin ant # Ant Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin gradle # Gradle Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin workflow-aggregator # Pipeline
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin pipeline-stage-view # Pipeline: Stage View Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin git # Git plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin github-organization-folder # GitHub Organization Folder Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin subversion # Subversion Plug-in
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin email-ext # Email Extension Plugin
|
||||||
|
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin ssh-slaves # SSH Slaves plugin
|
||||||
|
|
||||||
# Configure la sécurité globale avec ldap par défaut.
|
# Configure la sécurité globale avec ldap par défaut.
|
||||||
sudo cp ../conf/config.xml /var/lib/jenkins/
|
sudo cp ../conf/config.xml /var/lib/jenkins/
|
||||||
sudo chown jenkins: /var/lib/jenkins/config.xml
|
sudo chown jenkins: /var/lib/jenkins/config.xml
|
||||||
|
|
|
@ -1,16 +1,35 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting jenkins domain)
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||||
|
|
||||||
sudo rm /etc/nginx/conf.d/$domain.d/jenkins.conf
|
# Récupère les infos de l'application.
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
|
# Retire le service du monitoring de Yunohost.
|
||||||
|
if sudo yunohost service status | grep -q $app # Test l'existence du service dans Yunohost
|
||||||
|
then
|
||||||
|
echo "Remove $app service"
|
||||||
|
sudo yunohost service remove $app
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Supprime Jenkins
|
||||||
sudo apt-get purge jenkins -y
|
sudo apt-get purge jenkins -y
|
||||||
sudo rm /etc/apt/sources.list.d/jenkins.list
|
sudo rm /etc/apt/sources.list.d/jenkins.list
|
||||||
# TODO remove repo key
|
# Récupère l'id de la clé APT de jenkins
|
||||||
|
apt_key=$(sudo apt-key list | grep -B1 "Kohsuke Kawaguchi" | grep pub | cut -d'/' -f2 | cut -d' ' -f1)
|
||||||
|
sudo apt-key del $apt_key # Supprime la clé APT
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
||||||
sudo yunohost service remove jenkins
|
# Régénère la configuration de SSOwat
|
||||||
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
sudo service nginx reload
|
|
||||||
|
|
||||||
|
REMOVE_NGINX_CONF # Suppression de la configuration nginx
|
||||||
|
|
||||||
|
SECURE_REMOVE '/var/lib/$app' # Suppression du dossier de l'application, si il y a des résidus.
|
||||||
|
|
||||||
|
echo -e "\e[0m" # Restore normal color
|
||||||
|
|
51
scripts/restore
Normal file
51
scripts/restore
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
path=$(sudo yunohost app setting $app path)
|
||||||
|
final_path=$(sudo yunohost app setting $app final_path)
|
||||||
|
|
||||||
|
if [ -d $final_path ]; then
|
||||||
|
echo "There is already a directory: $final_path " >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The parameter $1 is the uncompressed restore directory location
|
||||||
|
backup_dir=$1/apps/$app
|
||||||
|
|
||||||
|
# Restore Nginx
|
||||||
|
conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
if [ -f $conf ]; then
|
||||||
|
echo "There is already a nginx conf file at this path: $conf " >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sudo cp -a $backup_dir/nginx.conf $conf
|
||||||
|
|
||||||
|
# Restore YunoHost parameters
|
||||||
|
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
||||||
|
|
||||||
|
echo "Reinstall dependencies..."
|
||||||
|
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
|
||||||
|
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install jenkins -y
|
||||||
|
|
||||||
|
# Restore sources & data
|
||||||
|
sudo cp -a "$backup_dir/sources/." $final_path
|
||||||
|
|
||||||
|
# Restauration de la configuration de démarrage de Jenkins
|
||||||
|
sudo cp -a $backup_dir/etc/. /etc/default/$app
|
||||||
|
|
||||||
|
sudo service $app restart # Redémarre jenkins pour prendre en compte les modifications
|
||||||
|
|
||||||
|
# Ajoute le service au monitoring de Yunohost.
|
||||||
|
sudo yunohost service add $app --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
# Reload webserver
|
||||||
|
sudo service nginx reload
|
|
@ -1,25 +1,33 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||||
|
|
||||||
|
# Récupère les infos de l'application.
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting jenkins domain)
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
path=$(sudo yunohost app setting jenkins path)
|
path=$(sudo yunohost app setting $app path)
|
||||||
path=${path%/}
|
is_public=$(sudo yunohost app setting $app is_public)
|
||||||
is_public=$(sudo yunohost app setting jenkins is_public)
|
port=$(sudo yunohost app setting $app port)
|
||||||
port=$(sudo yunohost app setting jenkins port)
|
|
||||||
|
|
||||||
sudo sed -i "s/HTTP_PORT=.*/HTTP_PORT=$port/g" /etc/default/jenkins
|
|
||||||
|
|
||||||
sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf
|
# Copie le fichier de config nginx
|
||||||
sed -i "s@YNH_PORT@$port@g" ../conf/nginx.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/jenkins.conf
|
# Et modifie les variables dans le fichier de configuration nginx
|
||||||
|
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
sudo sed -i "s@__DOMAIN__@$domain@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting jenkins unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
else
|
else
|
||||||
sudo yunohost app setting jenkins unprotected_uris -d
|
sudo yunohost app setting $app unprotected_uris -d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue