1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snipeit_ynh.git synced 2024-09-03 20:26:16 +02:00
snipeit_ynh/scripts/install

81 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
# fr -> fr-FR
language="${language}-${language^^}"
ynh_app_setting_set --app="$app" --key="language" --value="$language"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
ynh_setup_source --dest_dir="$install_dir"
chown -R "$app:www-data" "$install_dir"
# setup page tries to access https://$domain$path/.env and fails on self signed certs
ynh_replace_string --target_file="$install_dir/app/Http/Controllers/SettingsController.php" \
--match_string="->get(URL::to('.env'))" \
--replace_string="->withoutVerifying()->get(URL::to('.env'))"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
app_key=""
ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
chmod 600 "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building $app..."
ynh_install_composer
# setup application config
pushd "$install_dir"
ynh_exec_as "$app" "php$phpversion" artisan key:generate -n --force --env
ynh_exec_as "$app" "php$phpversion" artisan migrate -n --force
ynh_exec_as "$app" "php$phpversion" artisan config:clear -n
ynh_exec_as "$app" "php$phpversion" artisan config:cache -n
popd
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
ynh_app_setting_set --app="$app" --key="app_key" --value="$app_key"
ynh_store_file_checksum --file="$install_dir/.env"
# Set permissions to app files
chown -R "$app:www-data" "$install_dir"
chmod -R o-rwx "$install_dir"
chmod -R 755 "$install_dir/storage"
chmod -R 755 "$install_dir/public/uploads"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_fpm_config
ynh_add_nginx_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last