1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jenkins_ynh.git synced 2024-09-03 19:26:18 +02:00
jenkins_ynh/scripts/restore

53 lines
1.5 KiB
Text
Raw Normal View History

2016-11-30 17:49:37 +01:00
#!/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
2016-11-30 17:51:05 +01:00
sudo apt-get install default-jre-headless -y
2016-11-30 17:49:37 +01:00
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