2013-12-12 12:12:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
2017-10-30 17:52:57 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./experimental_helper.sh
|
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
2016-12-08 16:12:16 +01:00
|
|
|
|
2013-12-12 12:12:22 +01:00
|
|
|
# Retrieve arguments
|
2017-10-30 17:52:57 +01:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2019-11-01 22:04:11 +01:00
|
|
|
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH)
|
2017-10-30 17:52:57 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2018-08-04 00:35:34 +02:00
|
|
|
final_path="/opt/yunohost/$app"
|
2013-12-12 12:12:22 +01:00
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# Generate random password and save
|
|
|
|
secret=$(ynh_string_random)
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_app_setting_set --app $app --key final_path --value "$final_path"
|
|
|
|
ynh_app_setting_set --app $app --key secret --value "$secret"
|
2018-08-20 22:51:26 +02:00
|
|
|
|
|
|
|
# Check destination directory
|
2019-11-01 22:04:11 +01:00
|
|
|
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
2018-08-20 22:51:26 +02:00
|
|
|
|
|
|
|
# Register (book) web path
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
2018-08-20 22:51:26 +02:00
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
2013-12-12 12:12:22 +01:00
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
# INSTALL DEPENDENCIES
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=7
|
2019-05-08 15:02:14 +02:00
|
|
|
ynh_install_app_dependencies $dependances
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# CREATE A MYSQL DATABASE
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring MySQL database..."
|
2017-10-30 17:52:57 +01:00
|
|
|
db_user=$app
|
2019-11-01 22:04:11 +01:00
|
|
|
db_name=$(ynh_sanitize_dbid --db_name $app)
|
|
|
|
ynh_app_setting_set --app $app --key db_name --value "$db_name"
|
|
|
|
ynh_mysql_setup_db --db_user "$db_user" --db_name "$db_name"
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Installing sources files..." --weight=10
|
|
|
|
install_sources
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# Modify assets to take path into account
|
|
|
|
# TODO: try to include this as a patch if still needed
|
|
|
|
# find ../sources/syncserver/page/sync_files/ -type f -exec sed -i -e "s@media\/img@$path_url\/media\/img@g" {} \;
|
|
|
|
|
|
|
|
# NGINX CONFIGURATION
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring nginx"
|
2017-10-30 17:52:57 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
if [ "$path_url" == "/" ]
|
2014-11-15 17:24:32 +01:00
|
|
|
then
|
2017-10-30 17:52:57 +01:00
|
|
|
# $finalnginxconf comes from ynh_add_nginx_config
|
|
|
|
# uwsgi_param is only needed for non-root installation
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_replace_string --match_string "uwsgi_param " --replace_string "#uwsgi_param " --target_file "$finalnginxconf"
|
|
|
|
ynh_replace_string --match_string "uwsgi_modifier1 " --replace_string "#uwsgi_modifier1 " --target_file "$finalnginxconf"
|
2014-11-15 17:24:32 +01:00
|
|
|
fi
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_store_file_checksum --file "$finalnginxconf"
|
2018-09-06 14:57:35 +02:00
|
|
|
systemctl reload nginx
|
2014-11-15 17:24:32 +01:00
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
# CREATE DEDICATED USER
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring system user..."
|
|
|
|
ynh_system_user_create --username "$app" --home_dir "$final_path"
|
2018-09-05 22:23:48 +02:00
|
|
|
|
|
|
|
# create config file syncserver.ini
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring application..."
|
2018-09-05 22:23:48 +02:00
|
|
|
rm "$final_path/syncserver.ini"
|
|
|
|
ln -s "/etc/uwsgi/apps-available/$app.ini" "$final_path/syncserver.ini"
|
|
|
|
|
|
|
|
# configure uwsgi
|
|
|
|
ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
|
|
|
|
|
|
|
# MODIFY A CONFIG FILE
|
|
|
|
# TODO: fix this css patch
|
|
|
|
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/firefox_sync-bundle.css
|
|
|
|
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/responsive-bundle.css
|
2017-10-30 17:52:57 +01:00
|
|
|
|
2018-09-05 22:23:48 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2017-10-30 17:52:57 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
ynh_script_progression --message="Protecting directory"
|
|
|
|
set_permissions
|
|
|
|
|
|
|
|
# SETUP SSOWAT
|
2017-11-16 23:23:51 +01:00
|
|
|
# accessible by everyone (authentification is done by firefox accounts)
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring permissions"
|
|
|
|
ynh_app_setting_set --app $app --key skipped_uris --value "/"
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|