1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bozon_ynh.git synced 2024-09-03 18:16:09 +02:00
bozon_ynh/scripts/install

91 lines
2.7 KiB
Text
Raw Normal View History

#!/bin/bash
2016-03-23 19:30:43 +01:00
2017-07-26 21:32:00 +02:00
set -eu
source _common.sh
2016-10-13 06:51:38 +02:00
source /usr/share/yunohost/helpers
2016-05-23 21:40:55 +02:00
# manage script failure
ynh_abort_if_errors
2016-04-05 20:03:26 +02:00
# retrieve arguments
2017-01-17 20:08:23 +01:00
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
2017-01-17 20:08:23 +01:00
is_public=$YNH_APP_ARG_IS_PUBLIC
2017-01-18 19:10:07 +01:00
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
backup_core_only=$YNH_APP_ARG_BACKUP_CORE_ONLY
2017-01-07 12:41:56 +01:00
2016-04-04 20:01:54 +02:00
# definie useful vars
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
2016-03-23 19:30:43 +01:00
2016-04-05 20:03:26 +02:00
# check domain/path availability
path_url=$(ynh_normalize_url_path "$path_url")
ynh_webpath_available "$domain" "$path_url"
ynh_webpath_register "$app" "$domain" "$path_url"
myynh_check_path "$final_path"
2016-03-23 19:30:43 +01:00
# check that admin user is an existing account
ynh_user_exists "$admin"
2016-10-13 06:51:38 +02:00
# add required packages
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
2016-04-26 20:17:27 +02:00
2016-04-05 20:03:26 +02:00
# save app settings
2016-10-13 06:51:38 +02:00
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path "$path_url"
ynh_app_setting_set "$app" is_public $is_public
ynh_app_setting_set "$app" admin_user "$admin"
ynh_app_setting_set "$app" backup_core_only $backup_core_only
# create a dedicated system user
ynh_system_user_create "$app"
# download & unpack bozon
TMPDIR=$(mktemp -d)
ynh_setup_source "$TMPDIR"
# clean & copy files needed to final folder
2017-09-22 19:33:28 +02:00
myynh_clean_source
mv "$TMPDIR" "$final_path"
2016-03-23 19:30:43 +01:00
# create private & data folders
myynh_create_dir "$final_path/private"
myynh_create_dir "$data_path/uploads"
myynh_create_dir "$data_path/thumbs"
2017-09-22 19:33:28 +02:00
ln -s "$data_path/uploads" "$final_path/uploads"
ln -s "$data_path/thumbs" "$final_path/thumbs"
# set permissions
2017-07-07 17:03:57 +02:00
myynh_set_permissions
2016-03-25 09:32:16 +01:00
2016-04-05 20:03:26 +02:00
# configure nginx settings
2018-05-26 14:44:52 +02:00
if [ "$path_url" != "/" ]; then
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
2018-05-26 13:17:41 +02:00
fi
ynh_add_nginx_config
2016-03-23 19:30:43 +01:00
2016-05-23 20:59:08 +02:00
# copy and set php-fpm configuration
2018-05-26 13:17:41 +02:00
ynh_add_fpm_config
# set temporary public access for curl call
2016-10-13 06:51:38 +02:00
ynh_app_setting_set "$app" unprotected_uris "/"
2017-09-23 19:01:29 +02:00
yunohost app ssowatconf
2016-10-13 06:51:38 +02:00
# fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
2019-11-18 10:23:03 +01:00
admin_url="/index.php?p=login"
2019-11-18 12:36:05 +01:00
myynh_local_curl $admin_url
sleep 1
2019-11-18 10:23:03 +01:00
myynh_local_curl $admin_url "creation=1" "login=$admin" "pass=$password" "confirm=$password"
2016-04-20 22:15:16 +02:00
2016-04-05 20:03:26 +02:00
# if app is private, remove url to SSOWat conf from skipped_uris
if [ $is_public -eq 0 ]
2016-03-23 19:30:43 +01:00
then
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
ynh_app_setting_set "$app" protected_regex "$regexList"
2016-03-23 19:30:43 +01:00
fi