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

add daemon

This commit is contained in:
Éric Gaspar 2023-08-21 10:05:52 +02:00
parent 57c3bb36f9
commit ecc8c1f98c
7 changed files with 77 additions and 36 deletions

View file

@ -1,2 +0,0 @@
# Run poller periodically to update Friendica
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/bin/worker.php

22
conf/systemd.service Normal file
View file

@ -0,0 +1,22 @@
[Unit]
Description=Friendica daemon
After=network.target mariadb.service
Requires=network.target remote-fs.target nss-lookup.target
[Service]
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
Type=simple
StandardOutput=null
StandardError=syslog
ExecStart=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php start
ExecStop=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php stop
PIDFile=friendica/daemon.pid
PrivateTmp=true
InaccessibleDirectories=/home /root /boot /opt /mnt /media
ReadOnlyDirectories=/etc /usr
Restart=always
[Install]
WantedBy=multi-user.target

View file

@ -34,11 +34,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP VARIOUS FILES
# BACKUP SYSTEMD
#=================================================
# Backup cron job
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE MYSQL DATABASE

View file

@ -59,6 +59,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated nginx config
ynh_add_nginx_config
# Create a dedicated PHP-FPM configy
ynh_add_fpm_config --usage=low --footprint=low
ynh_add_systemd_config
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
#=================================================
# ADD A CONFIGURATION
#=================================================
@ -67,27 +74,10 @@ ynh_script_progression --message="Adding the LDAP Auth addon configuration file.
# LDAP addon config
ynh_add_config --template="../conf/addon.config.php" --destination="$install_dir/config/addon.config.php"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP_FPM..." --weight=4
# Create a dedicated PHP-FPM configy
ynh_add_fpm_config --usage=low --footprint=low
# 3 - some extra folders
mkdir -p "$install_dir/view/smarty3"
chmod -R 775 "$install_dir/view/smarty3"
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setting up the cron job..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# INSTALL FRIENDICA
#=================================================
@ -106,6 +96,13 @@ pushd "$install_dir"
ynh_exec_as "$app" php$phpversion bin/console.php addon enable ldapauth
popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,9 +10,20 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE NGINX CONFIGURATION
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
ynh_remove_systemd_config
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -23,9 +34,6 @@ ynh_remove_fpm_config
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -37,18 +37,21 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -22,6 +22,13 @@ timezone=$(cat /etc/timezone)
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# CHECK THE PATH
#=================================================
@ -122,14 +129,14 @@ ynh_add_nginx_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
ynh_add_systemd_config
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
# Run Composer
pushd "$install_dir"
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
@ -137,6 +144,13 @@ pushd "$install_dir"
#ynh_exec_as "$app" bin/console config system addon ldapauth
popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================