mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
Merge pull request #106 from YunoHost-Apps/friendica-daemon.service
add daemon
This commit is contained in:
commit
ed39a0fd89
7 changed files with 80 additions and 24 deletions
|
@ -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
22
conf/systemd.service
Normal 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
|
|
@ -45,8 +45,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
|||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# Backup cron job
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
|
|
|
@ -49,12 +49,12 @@ ynh_add_nginx_config
|
|||
# Create a dedicated PHP-FPM configy
|
||||
ynh_add_fpm_config --usage=low --footprint=low
|
||||
|
||||
ynh_add_systemd_config
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||
chown root: "/etc/cron.d/$app"
|
||||
chmod 644 "/etc/cron.d/$app"
|
||||
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
|
@ -86,6 +86,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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
@ -32,18 +39,23 @@ if [ -f $install_dir/.htconfig.php ]; then
|
|||
ynh_secure_remove "$install_dir/.htconfig.php"
|
||||
fi
|
||||
|
||||
# Remove files for upgrade compatibilty from previous versions of Friendica
|
||||
if [ -f $install_dir/.htconfig.php ]; then
|
||||
ynh_secure_remove "$install_dir/config/local.ini.php"
|
||||
ynh_secure_remove "$install_dir/.htconfig.php"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/cron.d/$app" ]; then
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
fi
|
||||
|
||||
# If admin_mail setting doesn't exist, create it
|
||||
if [ -z $email ]; then
|
||||
if [ -z "${email:-}" ]; then
|
||||
email=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
ynh_app_setting_set --app=$app --key=email --value=$email
|
||||
fi
|
||||
|
||||
# If language setting doesn't exist, create it
|
||||
if [ -z $language ]; then
|
||||
if [ -z "${language:-}" ]; then
|
||||
language=en
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
fi
|
||||
|
@ -76,14 +88,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
|
||||
|
@ -91,6 +103,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
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue