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
2018-03-12 23:46:34 +01:00

116 lines
3.2 KiB
Bash

#!/bin/bash
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin_ampache=$YNH_APP_ARG_ADMIN
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
# 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
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app admin $admin_ampache
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# get sources and copy files to the right place
ampache_ynh_getsources
cp ../conf/admin.sql /tmp/
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
# Initialize database and store mysql password for upgrade
ynh_mysql_setup_db "$app" "$app"
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < "$final_path/sql/ampache.sql"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
# Change variables in Ampache configuration
ampache_ynh_prepareconfig
ynh_replace_string "yunoadmin" "$admin_ampache" /tmp/admin.sql
ynh_replace_string "RANDOMKEYTOCHANGE" $(ynh_string_random 24) $final_path/config/ampache.cfg.php
#=================================================
# NGINX CONFIGURATION
#=================================================
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
fi
ynh_add_nginx_config
#=================================================
# INSTALL DEPENDENCIES
#=================================================
# Install dependency
ynh_install_app_dependencies libav-tools
#=================================================
# SPECIFIC SETUP
#=================================================
# Ampache installation
ampache_ynh_install
# Create multimedia directories if necessary
ynh_multimedia_build_main_dir
#=================================================
# RELOAD SSOWAT
#=================================================
# Regenerate SSOwat conf
ampache_ynh_reloadservices
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Pre config ampache
ampache_ynh_doconfig
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < /tmp/admin.sql
#=================================================
# CLEANING
#=================================================
# Clean install
ynh_secure_remove /tmp/admin.sql