mirror of
https://github.com/YunoHost-Apps/monica_ynh.git
synced 2024-09-03 19:46:23 +02:00
add upgrade of app
This commit is contained in:
parent
9e58aa24bc
commit
58f09fdec3
1 changed files with 43 additions and 36 deletions
|
@ -3,57 +3,64 @@
|
||||||
# Exit on command errors and treat unset variables as an error
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# See comments in install script
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source ./_common.sh
|
||||||
|
|
||||||
# Retrieve app settings
|
# Get app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
path_url=$(ynh_app_setting_get "$app" path_url)
|
|
||||||
admin=$(ynh_app_setting_get "$app" admin)
|
admin=$(ynh_app_setting_get "$app" admin)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
language=$(ynh_app_setting_get "$app" language)
|
language=$(ynh_app_setting_get "$app" language)
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
# Remove trailing "/" for next commands
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
path_url=${path_url%/}
|
|
||||||
|
|
||||||
# Copy source files
|
# Copy source files
|
||||||
src_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $src_path
|
|
||||||
sudo cp -a ../sources/. $src_path
|
|
||||||
|
|
||||||
# Set permissions to app files
|
### MySQL (can be removed if not used) ###
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
# If your app use a MySQL database you can use these lines to bootstrap
|
||||||
sudo chown -R root: $src_path
|
# a database, an associated user and save the password in app settings.
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
||||||
nginx_conf=../conf/nginx.conf
|
|
||||||
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
|
|
||||||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
|
||||||
# If a dedicated php-fpm process is used:
|
|
||||||
#
|
#
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
# # Generate MySQL password and create database
|
||||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
dbuser=$app
|
||||||
|
dbname=$app
|
||||||
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# extract_monica $final_path
|
||||||
# If a dedicated php-fpm process is used:
|
ynh_setup_source $final_path
|
||||||
# # Modify PHP-FPM pool configuration and copy it to the pool directory
|
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
|
# create a user
|
||||||
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
|
first_name=$(ynh_user_get_info $admin 'firstname')
|
||||||
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
last_name=$(ynh_user_get_info $admin 'lastname')
|
||||||
# sudo cp ../conf/php-fpm.conf $finalphpconf
|
email=$(ynh_user_get_info $admin 'mail')
|
||||||
# sudo chown root: $finalphpconf
|
|
||||||
# sudo chmod 644 $finalphpconf
|
sudo sed -i "s/yuno_firstname/$first_name/g" ../conf/CreateUser.php
|
||||||
# sudo service php5-fpm restart
|
sudo sed -i "s/yuno_lastname/$last_name/g" ../conf/CreateUser.php
|
||||||
### PHP end ###
|
sudo sed -i "s/yuno_email/$email/g" ../conf/CreateUser.php
|
||||||
|
sudo cp ../conf/CreateUser.php $final_path/database/seeds/CreateUser.php
|
||||||
|
|
||||||
|
# setup application config
|
||||||
|
sudo cp ../conf/.env $final_path/.env
|
||||||
|
|
||||||
|
sudo sed -i "s/yunouser/$dbuser/g" $final_path/.env
|
||||||
|
sudo sed -i "s/yunopass/$dbpass/g" $final_path/.env
|
||||||
|
sudo sed -i "s/yunobase/$dbname/g" $final_path/.env
|
||||||
|
sudo sed -i "s/yunomail/$email/g" $final_path/.env
|
||||||
|
sudo sed -i "s/yunodomain/$domain/g" $final_path/.env
|
||||||
|
# uses commas because path url contains a slash
|
||||||
|
sudo sed -i "s,yunopath,${path_url},g" $final_path/.env
|
||||||
|
|
||||||
|
# setup application config
|
||||||
|
cd $final_path && /usr/bin/php7.0 artisan -q migrate --force
|
||||||
|
cd $final_path && /usr/bin/php7.0 artisan -q optimize
|
||||||
|
|
||||||
|
# Install files and set permissions
|
||||||
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
if [[ $is_public -eq 1 ]]; then
|
if [[ $is_public -eq 1 ]]; then
|
||||||
# See install script
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload nginx service
|
|
||||||
sudo service nginx reload
|
|
||||||
|
|
Loading…
Reference in a new issue