2015-05-31 13:46:25 +02:00
|
|
|
#!/bin/bash
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-14 01:29:27 +01:00
|
|
|
# GENERIC START
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-02-02 03:37:01 +01:00
|
|
|
source _common.sh
|
2021-07-12 13:54:37 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2022-01-14 01:29:27 +01:00
|
|
|
# MANAGE SCRIPT FAILURE
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_clean_setup () {
|
|
|
|
true
|
|
|
|
}
|
2018-03-13 21:49:11 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2021-07-12 12:11:43 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
language=$YNH_APP_ARG_LANGUAGE
|
2022-06-15 23:45:27 +02:00
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
2021-07-12 14:45:08 +02:00
|
|
|
password=$YNH_APP_ARG_PASSWORD
|
2022-06-15 23:45:27 +02:00
|
|
|
is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2021-07-12 12:11:43 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2022-06-16 00:33:32 +02:00
|
|
|
prefix=lime_
|
|
|
|
|
2017-02-02 03:37:01 +01:00
|
|
|
#=================================================
|
2022-01-14 01:29:27 +01:00
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
2017-02-02 03:37:01 +01:00
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2021-07-12 12:11:43 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
# Register (book) web path
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2019-05-21 02:07:00 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2021-07-12 12:28:53 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
2019-05-21 02:07:00 +02:00
|
|
|
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
2022-06-16 00:33:32 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=prefix --value=$prefix
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2015-06-01 00:00:38 +02:00
|
|
|
|
2022-01-14 01:29:27 +01:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2022-07-17 03:23:30 +02:00
|
|
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
2022-01-14 01:29:27 +01:00
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating a MySQL database..." --weight=1
|
|
|
|
|
2021-07-12 12:16:32 +02:00
|
|
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
2021-07-12 12:11:43 +02:00
|
|
|
db_user=$db_name
|
|
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
2018-03-13 21:49:11 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
2015-06-01 00:00:38 +02:00
|
|
|
|
2021-07-12 13:10:03 +02:00
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
|
|
|
chown -R $app:www-data "$final_path"
|
2021-07-12 12:28:53 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2022-01-14 01:29:27 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
2018-03-13 21:49:11 +01:00
|
|
|
ynh_add_fpm_config
|
2022-06-15 23:45:27 +02:00
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2022-01-14 01:29:27 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
# CREATE DATA DIRECTORY
|
2022-01-14 01:29:27 +01:00
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating a data directory..." --weight=1
|
|
|
|
|
2022-06-16 00:33:32 +02:00
|
|
|
datadir=/home/yunohost.app/$app
|
2022-01-14 10:24:42 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
2022-06-15 23:45:27 +02:00
|
|
|
|
2022-06-16 00:33:32 +02:00
|
|
|
mkdir -p $datadir/upload
|
|
|
|
|
2022-01-14 10:24:42 +01:00
|
|
|
# Remove upload if empty
|
2022-01-17 02:48:39 +01:00
|
|
|
rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true
|
2022-01-14 01:29:27 +01:00
|
|
|
chmod -R o-rwx "$datadir"
|
2022-06-16 00:33:32 +02:00
|
|
|
chown -R $app:www-data "$datadir"
|
|
|
|
ln -s $datadir/upload $final_path/upload 2> /dev/null || true
|
2022-01-14 01:29:27 +01:00
|
|
|
|
2022-01-14 02:31:12 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
# ADD A CONFIGURATION
|
2022-01-14 02:31:12 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2022-01-14 02:31:12 +01:00
|
|
|
|
|
|
|
ynh_add_config --template="../conf/config.php" --destination="$final_path/application/config/config.php"
|
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
chmod 400 "$final_path/application/config/config.php"
|
|
|
|
chown $app:$app "$final_path/application/config/config.php"
|
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
# INSTALL APP
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_script_progression --message="Installing app..."
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2018-03-14 14:11:46 +01:00
|
|
|
ls_cli=$final_path/application/commands/console.php
|
2021-07-12 14:45:08 +02:00
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
fullname=$(ynh_user_get_info --username="$admin" --key="fullname")
|
|
|
|
mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
2015-05-31 22:36:35 +02:00
|
|
|
|
2018-03-14 14:11:46 +01:00
|
|
|
# Permission should be correctly set before to do this
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$password" "$fullname" "$mail"
|
2021-07-12 14:45:08 +02:00
|
|
|
|
|
|
|
# Permission should be correctly set before to do this
|
2022-06-16 00:33:32 +02:00
|
|
|
#ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$(ynh_string_random 24)" "$fullname" "$mail"
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
2018-03-14 14:11:46 +01:00
|
|
|
# LOAD SQL SPECIFIC CONFIG
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
ynh_script_progression --message="Loading SQL specific config..."
|
|
|
|
|
2022-01-14 01:29:27 +01:00
|
|
|
ynh_add_config --template="../conf/data.sql" --destination="./data.sql"
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2022-01-14 01:29:27 +01:00
|
|
|
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./data.sql
|
2021-08-29 18:28:18 +02:00
|
|
|
|
2022-01-14 01:29:27 +01:00
|
|
|
ynh_secure_remove --file=./data.sql
|
2021-07-12 12:35:11 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
# ADD NICE THEMES
|
2018-03-14 14:11:46 +01:00
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
#ynh_script_progression --message="Adding nice themes..."
|
2021-07-12 13:35:31 +02:00
|
|
|
|
2022-01-14 10:24:42 +01:00
|
|
|
#ynh_setup_source "$datadir/upload/templates/libreform" libreform
|
2018-03-14 14:11:46 +01:00
|
|
|
#ynh_setup_source "$final_path/upload/templates/librepoll" librepoll
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-15 23:45:27 +02:00
|
|
|
# GENERIC FINALIZATION
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2021-07-12 12:35:11 +02:00
|
|
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
2021-07-12 12:28:53 +02:00
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
# Everyone can access the app.
|
|
|
|
# The "main" permission is automatically created before the install script.
|
|
|
|
ynh_permission_update --permission="main" --add="visitors"
|
|
|
|
|
2022-01-18 21:53:45 +01:00
|
|
|
if [ $is_admin_public -eq 1 ]
|
2021-07-12 12:28:53 +02:00
|
|
|
then
|
2022-06-15 23:45:27 +02:00
|
|
|
allowed_groups="visitors $admin"
|
2022-01-14 01:29:27 +01:00
|
|
|
else
|
2022-06-15 23:45:27 +02:00
|
|
|
allowed_groups="$admin"
|
2021-07-12 12:28:53 +02:00
|
|
|
fi
|
2022-01-14 02:31:12 +01:00
|
|
|
ynh_permission_create --permission="admin" --url="/admin" --allowed=$allowed_groups --show_tile="true"
|
2021-07-12 12:28:53 +02:00
|
|
|
|
2015-05-31 22:36:35 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-07-12 12:28:53 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2021-07-12 12:28:53 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SEND A README FOR THE ADMIN
|
|
|
|
#=================================================
|
2021-07-12 14:06:32 +02:00
|
|
|
ynh_script_progression --message="Sending a readme for the admin..." --weight=1
|
2019-05-21 02:07:00 +02:00
|
|
|
|
2021-07-12 14:06:32 +02:00
|
|
|
message="LimeSurvey was successfully installed :)
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2021-07-12 14:06:32 +02:00
|
|
|
You can now create a poll on this address: https://$domain$path_url/admin/
|
|
|
|
|
|
|
|
If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/limesurvey_ynh/issues"
|
|
|
|
|
|
|
|
ynh_send_readme_to_admin "$message"
|
2019-05-21 02:07:00 +02:00
|
|
|
|
2021-07-12 12:28:53 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|