1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/friendica_ynh.git synced 2024-09-03 18:36:14 +02:00
friendica_ynh/scripts/install

92 lines
3.4 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
email=$(ynh_user_get_info --username="$admin" --key=mail)
timezone=$(cat /etc/timezone)
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression "Storing installation settings..."
ynh_app_setting_set --key=email --value="$email"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
mkdir -p "$install_dir/view/smarty3"
chmod -R 775 "$install_dir/view/smarty3"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
ynh_config_add --template="local-sample.config.php" --destination="$install_dir/config/local.config.php"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated PHP-FPM configy
ynh_config_add_phpfpm
ynh_config_add_systemd --service="$app-daemon"
# Create a dedicated nginx config
ynh_config_add_nginx
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
# Use logrotate to manage application logfile(s)
ynh_config_add_logrotate
# Create a dedicated Fail2Ban config
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression "Adding the LDAP Auth addon configuration file..."
# LDAP addon config
ynh_config_add --template="addon.config.php" --destination="$install_dir/config/addon.config.php"
#=================================================
# INSTALL FRIENDICA
#=================================================
ynh_script_progression "Install Friendica..."
pushd "$install_dir"
# Import Composer dependencies
ynh_exec_as_app "php$php_version" bin/composer.phar install --no-dev --quiet
# Install application
ynh_exec_as_app "php$php_version" bin/console.php -f "$install_dir/config/local.config.php"
# Enable LDAP Auth addon
ynh_exec_as_app "php$php_version" bin/console.php addon enable ldapauth
popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"