2017-06-08 13:32:01 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-06-13 22:19:11 +02:00
|
|
|
|
source ./_common.sh
|
2017-06-08 13:32:01 +02:00
|
|
|
|
|
2017-06-13 22:19:11 +02:00
|
|
|
|
# Get app settings
|
2017-06-08 13:32:01 +02:00
|
|
|
|
admin=$(ynh_app_setting_get "$app" admin)
|
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
|
language=$(ynh_app_setting_get "$app" language)
|
2017-06-13 22:19:11 +02:00
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
2017-06-08 13:32:01 +02:00
|
|
|
|
|
|
|
|
|
# Copy source files
|
2017-06-13 22:19:11 +02:00
|
|
|
|
final_path=/var/www/$app
|
|
|
|
|
|
|
|
|
|
### MySQL (can be removed if not used) ###
|
|
|
|
|
# If your app use a MySQL database you can use these lines to bootstrap
|
|
|
|
|
# a database, an associated user and save the password in app settings.
|
2017-06-08 13:32:01 +02:00
|
|
|
|
#
|
2017-06-13 22:19:11 +02:00
|
|
|
|
# # Generate MySQL password and create database
|
|
|
|
|
dbuser=$app
|
|
|
|
|
dbname=$app
|
|
|
|
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
|
|
|
|
2017-06-20 19:10:50 +02:00
|
|
|
|
extract_monica $final_path
|
|
|
|
|
#ynh_setup_source $final_path
|
2017-06-13 22:19:11 +02:00
|
|
|
|
|
2017-06-23 18:50:31 +02:00
|
|
|
|
# install new dependencies
|
|
|
|
|
ynh_package_install g++ php7.0-curl
|
|
|
|
|
|
2017-06-13 22:19:11 +02:00
|
|
|
|
# create a user
|
|
|
|
|
first_name=$(ynh_user_get_info $admin 'firstname')
|
|
|
|
|
last_name=$(ynh_user_get_info $admin 'lastname')
|
|
|
|
|
email=$(ynh_user_get_info $admin 'mail')
|
|
|
|
|
|
|
|
|
|
sudo sed -i "s/yuno_firstname/$first_name/g" ../conf/CreateUser.php
|
|
|
|
|
sudo sed -i "s/yuno_lastname/$last_name/g" ../conf/CreateUser.php
|
|
|
|
|
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
|
2017-06-20 19:31:15 +02:00
|
|
|
|
sudo cp ../conf/.env $final_path/.env
|
2017-06-13 22:19:11 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2017-06-20 19:38:49 +02:00
|
|
|
|
exec_composer $final_path update
|
2017-06-20 19:26:04 +02:00
|
|
|
|
|
2017-06-13 22:19:11 +02:00
|
|
|
|
# setup application config
|
2017-06-20 19:31:15 +02:00
|
|
|
|
cd $final_path && sudo /usr/bin/php7.0 artisan -q migrate --force
|
|
|
|
|
cd $final_path && sudo /usr/bin/php7.0 artisan -q optimize
|
2017-06-13 22:19:11 +02:00
|
|
|
|
|
|
|
|
|
# Install files and set permissions
|
|
|
|
|
sudo chown -R www-data: "$final_path"
|
2017-06-08 13:32:01 +02:00
|
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
2017-06-13 22:19:11 +02:00
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
2017-06-08 13:32:01 +02:00
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
|
|
|
fi
|