1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
limesurvey_ynh/scripts/install
2024-01-23 18:49:28 +01:00

98 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
# Database prefix
prefix=lime_
ynh_app_setting_set --app="$app" --key=prefix --value="$prefix"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
# Move upload directory to data_dir, with a symlink
if [ -d "$data_dir/upload" ]; then
ynh_warn "An upload directory already exist, reusing it."
else
mv "$install_dir/upload" "$data_dir"
fi
ln -s "$data_dir/upload" "$install_dir/upload"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.php" --destination="$install_dir/application/config/config.php"
chmod 400 "$install_dir/application/config/config.php"
chown "$app:$app" "$install_dir/application/config/config.php"
#=================================================
# INSTALL APP
#=================================================
ynh_script_progression --message="Installing app..."
ls_cli="$install_dir/application/commands/console.php"
fullname=$(ynh_user_get_info --username="$admin" --key="fullname")
mail=$(ynh_user_get_info --username="$admin" --key="mail")
# Permission should be correctly set before to do this
ynh_exec_as "$app" "php$phpversion" "$ls_cli" install "$admin" "$password" "$fullname" "$mail"
#=================================================
# LOAD SQL SPECIFIC CONFIG
#=================================================
ynh_script_progression --message="Loading SQL specific config..."
ynh_add_config --template="../conf/data.sql" --destination="./data.sql"
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./data.sql
ynh_secure_remove --file=./data.sql
#=================================================
# ADD NICE THEMES
#=================================================
#ynh_script_progression --message="Adding nice themes..."
#ynh_setup_source "$data_dir/upload/templates/libreform" libreform
#ynh_setup_source "$install_dir/upload/templates/librepoll" librepoll
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last