gist-ynh/scripts/restore

56 lines
1.4 KiB
Plaintext
Raw Normal View History

2016-09-27 22:35:52 +02:00
#!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper
# will be located in the current directory, regarding the last argument.
# Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Restore sources & data
src_path=/var/www/$app
2016-09-27 22:49:43 +02:00
sudo mkdir -p /var/www/
sudo git clone https://gitnet.fr/deblan/gist $src_path
2016-09-27 22:35:52 +02:00
git config --global user.email "www-data@$domain"
git config --global user.email "www-data@$domain"
2016-09-27 22:49:43 +02:00
cd $src_path
2016-09-27 22:53:04 +02:00
sudo curl -sS https://getcomposer.org/installer | sudo php
2016-09-27 22:49:43 +02:00
sudo mv composer.phar composer
sudo chmod +x composer
2016-09-27 22:35:52 +02:00
sudo apt-get update -y
sudo apt-get install npm -y
sudo npm install -g bower
2016-09-27 22:49:43 +02:00
sudo mv propel-dist.yaml propel.yaml
sudo sed -i "s@user: root@user: $dbuser@"
sudo sed -i "s@password: root@password: $dbpass@"
export PATH="$PATH:."
sudo make
2016-09-27 22:35:52 +02:00
sudo chown -R root: $src_path
sudo chown -R www-data: $src_path/data/git/
# Restore NGINX configuration
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Restart webserver
sudo service nginx reload