1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jirafeau_ynh.git synced 2024-09-03 19:35:53 +02:00
jirafeau_ynh/scripts/upgrade

85 lines
2.9 KiB
Text
Raw Normal View History

2014-01-13 13:50:38 +01:00
#!/bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin_user=$YNH_APP_ARG_ADMIN_USER
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
2014-01-13 13:50:38 +01:00
# Remove trailing "/" for next commands
path=${path%/}
# Set upload password, allowing an empty one
if [[ -z "$upload_password" ]]; then
sed -i "s@YNH_UPLOAD_PASSWORD@@g" ../conf/config.local.php
else
sed -i "s@YNH_UPLOAD_PASSWORD@'$upload_password'@g" ../conf/config.local.php
fi
2014-01-13 13:50:38 +01:00
# Copy files to the right place
final_path=/var/www/$app
var_root=/home/yunohost.app/$app
2014-01-13 13:50:38 +01:00
sudo mkdir -p $final_path
2014-03-07 01:37:42 +01:00
sudo rm -rf $final_path/*
sudo cp -r ../sources/* $final_path
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.local.php
sed -i "s@YNH_VAR_ROOT@$var_root@g" ../conf/config.local.php
sed -i "s@YNH_ADMIN_USER@$admin_user@g" ../conf/config.local.php
sudo cp ../conf/config.local.php $final_path/lib
sudo rm $final_path/install.php
2014-01-13 13:50:38 +01:00
# Files owned by root, www-data can just read
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R root: $final_path
2014-03-07 01:37:42 +01:00
sudo mkdir -p $var_root/{files,links,async,block}
sudo chown -R www-data:root $var_root
sudo chmod -R 700 $var_root
2014-01-13 13:50:38 +01:00
# Modify Nginx configuration file and copy it to Nginx conf directory
if [[ "$path" == "" ]]; then
sed -i "s@YNH_WWW_LOCATION@/@g" ../conf/nginx.conf
else
sed -i "s@YNH_WWW_LOCATION@$path@g" ../conf/nginx.conf
fi
2014-01-13 13:50:38 +01:00
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
2014-03-07 01:37:42 +01:00
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
2014-03-07 01:37:42 +01:00
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
2014-07-22 21:23:48 +02:00
if [ "$is_public" = "Yes" ];
2014-01-13 13:50:38 +01:00
then
sudo yunohost app setting $app unprotected_uris -v "/"
2014-01-13 13:50:38 +01:00
fi
2014-03-07 01:37:42 +01:00
sudo service php5-fpm restart
2014-01-13 13:50:38 +01:00
sudo service nginx reload
sudo yunohost app ssowatconf
2014-03-07 01:37:42 +01:00