1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
agendav_ynh/scripts/install
Salamandar b18498adc4
Manifestv2 port (#71)
* Testing (#70)

* Fix upgrade

* Bump package version

* Auto-update README

* Upgrade to version 2.6.0 (#67)

* Upgrade to v2.6.0

* Auto-update README

Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Upgrade auto-updater (#69)

* Auto-update README

* [autopatch] Upgrade auto-updater

* Auto-update README

---------

Co-authored-by: tituspijean <titus@pijean.ovh>

* Update _common.sh

* Update _common.sh

* Update manifest.json

* Auto-update README

---------

Co-authored-by: tituspijean <tituspijean@outlook.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: tituspijean <titus@pijean.ovh>

* Manifestv2 port

* Add a final chmod on the install_dir

* Update manifest.toml

* cleaning

---------

Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>
Co-authored-by: tituspijean <tituspijean@outlook.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: tituspijean <titus@pijean.ovh>
2023-09-27 12:41:57 +02:00

109 lines
3.6 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# GET THE CALDAV APP
#=================================================
caldav_info=$(_ynh_agendav_find_caldav_app)
caldav_app="$(cut -d " " -f 1 <<< "$caldav_info")"
caldav_baseurl="$(cut -d " " -f 2 <<< "$caldav_info")"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
# Generate random encryption key
encryptkey=$(ynh_string_random --length=24)
ynh_app_setting_set --app="$app" --key=encryptkey --value="$encryptkey"
# Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone)
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_baseurl="${caldav_url}${caldav_baseurl}"
ynh_add_config --template="../conf/settings.php" --destination="${install_dir}/web/config/settings.php"
#=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#=================================================
ynh_script_progression --message="Initialising AgenDAV..." --weight=3
(
cd "$install_dir" || ynh_die
"php$phpversion" agendavcli migrations:migrate --no-interaction
)
chown -R "$app:www-data" "$install_dir"
# Only agendav user should write here
chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig}
# The agendav user should read here, but does not need to write
# Other users should not be able to read as it stores passwords.
chown -R "$app:www-data" "$install_dir/web/config/"
chmod -R 750 "$install_dir/web/config/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
mkdir -p "/var/log/$app"
chown -R "$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