#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= admin_mail="$(ynh_user_get_info --username=$admin --key=mail)" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low #================================================= # SPECIFIC SETUP #================================================= # PRE-CONFIGURE CACHET #================================================= ynh_script_progression --message="Pre-configuring Cachet..." --weight=10 ynh_add_config --template="../conf/.env.example" --destination="$install_dir/.env" #================================================= # INSTALL AND INITIALIZE COMPOSER #================================================= ynh_script_progression --message="Installing with composer..." ynh_install_composer --install_args="--optimize-autoloader" #================================================= # FINALIZE CACHET INSTALLATION #================================================= ynh_script_progression --message="Installing Cachet..." mkdir -p "$install_dir/storage/app/public" exec_artisan "key:generate" exec_artisan "cachet:install" #================================================= # FINALIZE CACHET CONFIGURATION #================================================= ynh_script_progression --message="Finalizing Cachet configuration..." password_hash="$(cd $install_dir ; php$YNH_PHP_VERSION artisan tinker -q --no-ansi <<< "echo Hash::make('$password');" |head -n 1)" password_pash="${password_hash::-1}" # Remove last character # Populate MySQL database ynh_add_config --template="../conf/init-mysql.sql" --destination="$install_dir/init-mysql.sql" ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < "$install_dir/init-mysql.sql" ynh_delete_file_checksum --file="$install_dir/init-mysql.sql" #REMOVEME? ynh_secure_remove --file="$install_dir/init-mysql.sql" ynh_add_config --template="../conf/production.php" --destination="$install_dir/bootstrap/cachet/production.php" chown $app: $install_dir/bootstrap/cachet/production.php #================================================= # SECURE FILES AND DIRECTORIES #================================================= # Set permissions to app files chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" chown -R $app: "${install_dir}/.env" "${install_dir}/storage/" "${install_dir}/bootstrap/" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last