mirror of
https://github.com/YunoHost-Apps/jenkins_ynh.git
synced 2024-09-03 19:26:18 +02:00
helpers et petites corrections
This commit is contained in:
parent
5f0226c62a
commit
8b9b9c5ae8
5 changed files with 39 additions and 25 deletions
|
@ -5,8 +5,8 @@ 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)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
|
||||
# The parameter $1 is the backup directory location
|
||||
|
@ -22,4 +22,4 @@ 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
|
||||
sudo cp -a /etc/default/$app $backup_dir/etc
|
||||
|
|
|
@ -47,11 +47,11 @@ FIND_PORT 8080 # Cherche un port libre.
|
|||
|
||||
|
||||
# Enregistre les infos dans la config YunoHost
|
||||
sudo yunohost app setting $app domain -v $domain
|
||||
sudo yunohost app setting $app path -v $path
|
||||
sudo yunohost app setting $app is_public -v $is_public
|
||||
sudo yunohost app setting $app port -v $port
|
||||
sudo yunohost app setting $app final_path -v $final_path
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app port $port
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
|
||||
|
||||
echo "Install dependencies..."
|
||||
|
@ -85,7 +85,7 @@ 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
|
||||
|
||||
# Jenkins est public par défaut, au moins pour le téléchargement de jenkins-cli.jar
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
@ -155,7 +155,7 @@ sudo rm "$tempfile"
|
|||
# Si Jenkins est privé, retire l'autorisation publique.
|
||||
if [ "$is_public" = "No" ];
|
||||
then # Retire l'accès public
|
||||
sudo yunohost app setting $app unprotected_uris -d
|
||||
ynh_app_setting_delete $app unprotected_uris
|
||||
fi
|
||||
|
||||
# Clean hosts
|
||||
|
|
|
@ -8,7 +8,8 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
|
||||
# Retire le service du monitoring de Yunohost.
|
||||
if sudo yunohost service status | grep -q $app # Test l'existence du service dans Yunohost
|
||||
|
|
|
@ -6,13 +6,12 @@ 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)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
if [ -d $final_path ]; then
|
||||
echo "There is already a directory: $final_path " >&2
|
||||
exit 1
|
||||
ynh_die "There is already a directory: $final_path"
|
||||
fi
|
||||
|
||||
# The parameter $1 is the uncompressed restore directory location
|
||||
|
@ -21,8 +20,7 @@ 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
|
||||
ynh_die "There is already a nginx conf file at this path: $conf"
|
||||
fi
|
||||
sudo cp -a $backup_dir/nginx.conf $conf
|
||||
|
||||
|
@ -41,12 +39,27 @@ sudo apt-get install jenkins -y
|
|||
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 cp -a $backup_dir/etc /etc/default/$app
|
||||
|
||||
sudo service $app restart # Redémarre jenkins pour prendre en compte les modifications
|
||||
tempfile="$(mktemp)"
|
||||
tail -f -n1 /var/log/$app/$app.log > "$tempfile" & # Suit le démarrage dans le log
|
||||
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
|
||||
|
||||
# Ajoute le service au monitoring de Yunohost.
|
||||
sudo yunohost service add $app --log "/var/log/$app/$app.log"
|
||||
|
||||
# Reload webserver
|
||||
sudo service nginx reload
|
||||
|
||||
# Surveille le démarrage du service.
|
||||
for i in `seq 1 60`
|
||||
do # La boucle attend le démarrage de jenkins Ou 60 secondes.
|
||||
if grep -q "INFOS: Jenkins is fully up and running" "$tempfile"; then
|
||||
break # Si le log annonce le démarrage de jenkins, sort de la boucle.
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
kill -s 15 $PID_TAIL > /dev/null # Arrête l'exécution de tail.
|
||||
sudo rm "$tempfile"
|
||||
|
|
|
@ -9,10 +9,10 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
path=$(sudo yunohost app setting $app path)
|
||||
is_public=$(sudo yunohost app setting $app is_public)
|
||||
port=$(sudo yunohost app setting $app port)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
|
||||
# Copie le fichier de config nginx
|
||||
|
@ -24,9 +24,9 @@ sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|||
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
else
|
||||
sudo yunohost app setting $app unprotected_uris -d
|
||||
ynh_app_setting_delete $app unprotected_uris
|
||||
fi
|
||||
|
||||
sudo service nginx reload
|
||||
|
|
Loading…
Add table
Reference in a new issue