gist-ynh/scripts/restore

61 lines
1.6 KiB
Bash
Executable file

#!/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
sudo mkdir -p /var/www/
sudo git clone https://gitnet.fr/deblan/gist $src_path
git config --global user.email "www-data@$domain"
git config --global user.email "www-data@$domain"
cd $src_path
sudo wget https://getcomposer.org/installer
sudo php installer
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
sudo rm -f installer
php -r "echo ini_get('memory_limit').PHP_EOL;" # debug
foo bar # debug
sudo apt-get update -y
sudo apt-get install npm -y
sudo npm install -g bower
sudo mv propel-dist.yaml propel.yaml
sudo sed -i "s@user: root@user: $dbuser@" propel.yaml
sudo sed -i "s@password: root@password: $dbpass@" propel.yaml
export PATH="$PATH:."
sudo make
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