1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ampache_ynh.git synced 2024-09-03 18:15:55 +02:00
ampache_ynh/scripts/install
2023-12-24 09:45:18 +01:00

112 lines
3.7 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
secret_key=$(ynh_string_random --length=24)
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1
ynh_add_fpm_config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# LOAD DEFAULT DATABASE
#=================================================
ynh_script_progression --message="Loading default database..." --weight=2
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < "$install_dir/resources/sql/ampache.sql"
#=================================================
# INSTALL MULTIMEDIA DIRECTORIES
#=================================================
ynh_script_progression --message="Installing multimedia directories..." --weight=5
ynh_multimedia_build_main_dir
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="ampache.cfg.php" --destination="$install_dir/config/ampache.cfg.php"
chmod 650 "$install_dir/config/ampache.cfg.php"
chown $app: "$install_dir/config/ampache.cfg.php"
#=================================================
# INSTALL WITH COMPOSER
#=================================================
ynh_script_progression --message="Installing with Composer..." --weight=45
# Install composer
ynh_install_composer --workdir=$install_dir
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..." --weight=5
# Installation with curl
ynh_local_curl /update.php?action=update
#=================================================
# LOAD ADMIN DATABASE
#=================================================
ynh_script_progression --message="Loading admin database..." --weight=2
ynh_add_config --template="admin.sql" --destination="/tmp/admin.sql"
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < /tmp/admin.sql
ynh_secure_remove --file=/tmp/admin.sql
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
mkdir -p "/var/log/$app"
chown $app: "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last