Fuckit I don't understand how to properly manage systemctl service with debian files while having flexibility on when the api restart happens, let's manage everything with the regen conf

This commit is contained in:
Alexandre Aubin 2021-12-01 21:06:53 +01:00
parent 613fc67bd1
commit 8eaa701230
5 changed files with 15 additions and 11 deletions

View file

@ -4,9 +4,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
Environment=DAEMON_OPTS= ExecStart=/usr/bin/yunohost-api
EnvironmentFile=-/etc/default/yunohost-api
ExecStart=/usr/bin/yunohost-api $DAEMON_OPTS
Restart=always Restart=always
RestartSec=5 RestartSec=5
TimeoutStopSec=30 TimeoutStopSec=30

4
debian/rules vendored
View file

@ -8,7 +8,3 @@ override_dh_auto_build:
# Generate bash completion file # Generate bash completion file
python3 doc/generate_bash_completion.py python3 doc/generate_bash_completion.py
python3 doc/generate_manpages.py --gzip --output doc/yunohost.8.gz python3 doc/generate_manpages.py --gzip --output doc/yunohost.8.gz
override_dh_installinit:
dh_installinit -pyunohost --name=yunohost-api --noscripts
dh_installinit -pyunohost --name=yunohost-firewall --noscripts

View file

@ -1,4 +0,0 @@
# Override yunohost-api options.
# Example to log debug: DAEMON_OPTS="--debug"
#
#DAEMON_OPTS=""

View file

@ -56,7 +56,16 @@ do_init_regen() {
chown root:root /var/cache/yunohost chown root:root /var/cache/yunohost
chmod 700 /var/cache/yunohost chmod 700 /var/cache/yunohost
cp yunohost-api.service /etc/systemd/system/yunohost-api.service
cp yunohost-firewall.service /etc/systemd/system/yunohost-firewall.service
cp yunoprompt.service /etc/systemd/system/yunoprompt.service cp yunoprompt.service /etc/systemd/system/yunoprompt.service
systemctl daemon-reload
systemctl enable yunohost-api.service
systemctl start yunohost-api.service
# Yunohost-firewall is enabled only during postinstall, not init, not 100% sure why
cp dpkg-origins /etc/dpkg/origins/yunohost cp dpkg-origins /etc/dpkg/origins/yunohost
# Change dpkg vendor # Change dpkg vendor
@ -142,6 +151,8 @@ HandleLidSwitchDocked=ignore
HandleLidSwitchExternalPower=ignore HandleLidSwitchExternalPower=ignore
EOF EOF
cp yunohost-api.service ${pending_dir}/etc/systemd/system/yunohost-api.service
cp yunohost-firewall.service ${pending_dir}/etc/systemd/system/yunohost-firewall.service
cp yunoprompt.service ${pending_dir}/etc/systemd/system/yunoprompt.service cp yunoprompt.service ${pending_dir}/etc/systemd/system/yunoprompt.service
if [[ "$(yunohost settings get 'security.experimental.enabled')" == "True" ]]; then if [[ "$(yunohost settings get 'security.experimental.enabled')" == "True" ]]; then
@ -219,6 +230,9 @@ do_post_regen() {
} }
[[ ! "$regen_conf_files" =~ "nftables.service.d/ynh-override.conf" ]] || systemctl daemon-reload [[ ! "$regen_conf_files" =~ "nftables.service.d/ynh-override.conf" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "login.conf.d/ynh-override.conf" ]] || systemctl daemon-reload [[ ! "$regen_conf_files" =~ "login.conf.d/ynh-override.conf" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "yunohost-firewall.service" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "yunohost-api.service" ]] || systemctl daemon-reload
if [[ "$regen_conf_files" =~ "yunoprompt.service" ]]; then if [[ "$regen_conf_files" =~ "yunoprompt.service" ]]; then
systemctl daemon-reload systemctl daemon-reload
action=$([[ -e /etc/systemd/system/yunoprompt.service ]] && echo 'enable' || echo 'disable') action=$([[ -e /etc/systemd/system/yunoprompt.service ]] && echo 'enable' || echo 'disable')