mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
New helpers ynh_add_systemd_config and ynh_remove_systemd_config (#287)
* New helpers ynh_add_systemd_config and ynh_remove_systemd_config Standard file for systemd service. * ynh_subsistute_char was renamed ynh_replace_string * Upgrade helpers * Add some description of which keywords are replaced by which variable
This commit is contained in:
parent
80242a8edc
commit
a006868cbe
1 changed files with 40 additions and 2 deletions
|
@ -62,13 +62,51 @@ ynh_remove_logrotate () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated systemd config
|
||||||
#
|
#
|
||||||
# This will use a template in ../conf/nginx.conf
|
# This will use a template in ../conf/systemd.service
|
||||||
# and will replace the following keywords with
|
# and will replace the following keywords with
|
||||||
# global variables that should be defined before calling
|
# global variables that should be defined before calling
|
||||||
# this helper :
|
# this helper :
|
||||||
#
|
#
|
||||||
|
# __APP__ by $app
|
||||||
|
# __FINALPATH__ by $final_path
|
||||||
|
#
|
||||||
|
# usage: ynh_add_systemd_config
|
||||||
|
ynh_add_systemd_config () {
|
||||||
|
finalsystemdconf="/etc/systemd/system/$app.service"
|
||||||
|
ynh_backup_if_checksum_is_different "$finalsystemdconf"
|
||||||
|
sudo cp ../conf/systemd.service "$finalsystemdconf"
|
||||||
|
|
||||||
|
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||||
|
# Substitute in a nginx config file only if the variable is not empty
|
||||||
|
if test -n "${final_path:-}"; then
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
|
||||||
|
fi
|
||||||
|
if test -n "${app:-}"; then
|
||||||
|
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
|
||||||
|
fi
|
||||||
|
ynh_store_file_checksum "$finalsystemdconf"
|
||||||
|
|
||||||
|
sudo chown root: "$finalsystemdconf"
|
||||||
|
sudo systemctl enable $app
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove the dedicated systemd config
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_systemd_config
|
||||||
|
ynh_remove_systemd_config () {
|
||||||
|
finalsystemdconf="/etc/systemd/system/$app.service"
|
||||||
|
if [ -e "$finalsystemdconf" ]; then
|
||||||
|
sudo systemctl stop $app
|
||||||
|
sudo systemctl disable $app
|
||||||
|
ynh_secure_remove "$finalsystemdconf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
#
|
||||||
|
# This will use a template in ../conf/nginx.conf
|
||||||
# __PATH__ by $path_url
|
# __PATH__ by $path_url
|
||||||
# __DOMAIN__ by $domain
|
# __DOMAIN__ by $domain
|
||||||
# __PORT__ by $port
|
# __PORT__ by $port
|
||||||
|
|
Loading…
Add table
Reference in a new issue