Add systemd conf for new service yunohost-portal-api

This commit is contained in:
Alexandre Aubin 2021-12-27 12:44:20 +01:00
parent 45baaead36
commit bd564e6a53
3 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,14 @@
[Unit]
Description=YunoHost Portal API
After=network.target
[Service]
User=ynh-portal
Type=simple
ExecStart=/usr/bin/yunohost-portal-api
Restart=always
RestartSec=5
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target

2
debian/postinst vendored
View file

@ -29,6 +29,8 @@ do_configure() {
yunohost diagnosis run --force yunohost diagnosis run --force
fi fi
systemctl restart yunohost-portal-api
# Trick to let yunohost handle the restart of the API, # Trick to let yunohost handle the restart of the API,
# to prevent the webadmin from cutting the branch it's sitting on # to prevent the webadmin from cutting the branch it's sitting on
if systemctl is-enabled yunohost-api --quiet if systemctl is-enabled yunohost-api --quiet

View file

@ -56,7 +56,10 @@ 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
getent passwd ynh-portal &>/dev/null || useradd --no-create-home --shell /usr/sbin/nologin --system --user-group ynh-portal
cp yunohost-api.service /etc/systemd/system/yunohost-api.service cp yunohost-api.service /etc/systemd/system/yunohost-api.service
cp yunohost-portal-api.service /etc/systemd/system/yunohost-portal-api.service
cp yunohost-firewall.service /etc/systemd/system/yunohost-firewall.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
@ -64,6 +67,10 @@ do_init_regen() {
systemctl enable yunohost-api.service systemctl enable yunohost-api.service
systemctl start yunohost-api.service systemctl start yunohost-api.service
systemctl enable yunohost-portal-api.service
systemctl start yunohost-portal-api.service
# Yunohost-firewall is enabled only during postinstall, not init, not 100% sure why # 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
@ -152,6 +159,7 @@ HandleLidSwitchExternalPower=ignore
EOF EOF
cp yunohost-api.service ${pending_dir}/etc/systemd/system/yunohost-api.service cp yunohost-api.service ${pending_dir}/etc/systemd/system/yunohost-api.service
cp yunohost-portal-api.service ${pending_dir}/etc/systemd/system/yunohost-portal-api.service
cp yunohost-firewall.service ${pending_dir}/etc/systemd/system/yunohost-firewall.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
@ -169,6 +177,13 @@ EOF
do_post_regen() { do_post_regen() {
regen_conf_files=$1 regen_conf_files=$1
getent passwd ynh-portal &>/dev/null || useradd --no-create-home --shell /usr/sbin/nologin --system --user-group ynh-portal
if [ ! -e /etc/yunohost/.ssowat_cookie_secret ]; then
dd if=/dev/urandom bs=1 count=1000 2>/dev/null | tr --complement --delete 'A-Za-z0-9' | head -c 64 > /etc/yunohost/.ssowat_cookie_secret
fi
chown ynh-portal:root /etc/yunohost/.ssowat_cookie_secret
chmod 400 /etc/yunohost/.ssowat_cookie_secret
###################### ######################
# Enfore permissions # # Enfore permissions #
###################### ######################
@ -225,10 +240,12 @@ do_post_regen() {
systemctl daemon-reload systemctl daemon-reload
systemctl restart ntp systemctl restart ntp
} }
[[ ! "$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-firewall.service" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "yunohost-api.service" ]] || systemctl daemon-reload [[ ! "$regen_conf_files" =~ "yunohost-api.service" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "yunohost-portal-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
@ -241,6 +258,9 @@ do_post_regen() {
systemctl $action proc-hidepid --quiet --now systemctl $action proc-hidepid --quiet --now
fi fi
systemctl enable yunohost-portal-api.service --quiet
systemctl is-active yunohost-portal-api --quiet || systemctl start yunohost-portal-api.service
# Change dpkg vendor # Change dpkg vendor
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor # see https://wiki.debian.org/Derivatives/Guidelines#Vendor
if readlink -f /etc/dpkg/origins/default | grep -q debian; if readlink -f /etc/dpkg/origins/default | grep -q debian;