#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # 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" 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 api_secret="$(ynh_string_random --length=32)" app_key="$(ynh_string_random --length=32)" phantomjs_key=$(ynh_string_random --length=32) mail_from_address="$(ynh_user_get_info "$admin" mail)" mail_from_name="$(ynh_user_get_info "$admin" firstname) $(ynh_user_get_info "$admin" lastname)" ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret ynh_app_setting_set --app=$app --key=app_key --value=$app_key ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key ynh_app_setting_set --app=$app --key=mail_from_address --value=$mail_from_address ynh_app_setting_set --app=$app --key=mail_from_name --value=$mail_from_name ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" chmod 600 "$install_dir/.env" chown $app:$app "$install_dir/.env" #================================================= # INSTALL PHANTOMJS #================================================= ynh_script_progression --message="Installing PhantomJS..." --weight=1 _install_phantomjs #================================================= # BUILD THE APPLICATION #================================================= ynh_script_progression --message="Building the application..." --weight=1 pushd "$install_dir" # Run the database migrations and initially fill the db "php$phpversion" artisan migrate --force "php$phpversion" artisan db:seed --force # thanks to cloudron for this! # This comments the check at https://github.com/invoiceninja/invoiceninja/blob/cadd1a3b44aed3dc5bd28d623efd4bb51c6d895a/app/Http/Controllers/AppController.php#L47 # We pre-setup various parts already thus the .env file has to exist sed -e "s/^.*app is already configured.*/ /" -i app/Http/Controllers/AppController.php popd #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated PHP-FPM config ynh_add_fpm_config ynh_add_config --template="../conf/invoiceninja.cron" --destination="/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" chown root: "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last