erplibre/script/systemd/install_daemon.sh

69 lines
2.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
. ./env_var.sh
#EL_USER="erplibre"
#EL_HOME="/${EL_USER}"
#EL_HOME_ERPLIBRE="${EL_HOME}/erplibre"
#EL_HOME_ODOO="${EL_HOME_ERPLIBRE}/odoo"
#EL_INSTALL_WKHTMLTOPDF="True"
#EL_PORT="8069"
#EL_SUPERADMIN="admin"
#EL_CONFIG="${EL_USER}"
#--------------------------------------------------
# Adding ERPLibre as a daemon with SystemD
#--------------------------------------------------
echo -e "\n* Create init file"
sudo rm -f /tmp/${EL_CONFIG}
cat <<EOF >/tmp/${EL_CONFIG}
[Unit]
Description=${EL_USER}
Requires=postgresql.service
After=network.target network-online.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=${EL_USER}
PermissionsStartOnly=true
User=${EL_USER}
Group=${EL_USER}
Restart=always
RestartSec=5
PIDFile=${EL_HOME_ERPLIBRE}/.venv.erplibre/service.pid
[FIX] systemd : lancer run.sh par bash, contre les echecs 203/EXEC erplibre.service mourait en 3 ms sur openSUSE s390x, « status=203/EXEC », sans jamais entrer dans le script. Ce code ne dit pas que run.sh a echoue : il dit que systemd n'a pas pu l'EXECUTER. Quatre causes le produisent — bit x absent, shebang qui ne resout pas, /home monte noexec, SELinux refusant l'execve (Leap 16 est passe a SELinux). Les distinguer demande un acces a la machine ; les traiter ensemble ne le demande pas. Passe a « /bin/bash run.sh », le fichier n'est plus qu'une donnee lue : noexec et SELinux ne portent que sur l'execve, et le bit x devient sans objet. Mesure : un script en 644 refuse en direct, execute par bash. Les trois generateurs ecrivaient la meme ligne, les trois sont corriges. Le venv n'y est pour rien — odoo_bin.sh l'active deja, et c'est celui d'Odoo, pas celui des outils. --- EN --- erplibre.service died in 3 ms on openSUSE s390x, "status=203/EXEC", never entering the script. That code does not say run.sh failed: it says systemd could not EXECUTE it. Four causes produce it — missing x bit, unresolvable shebang, /home mounted noexec, SELinux denying execve (Leap 16 switched to SELinux). Telling them apart needs access to the machine; handling them together does not. Run as "/bin/bash run.sh", the file is merely data being read: noexec and SELinux only cover execve, and the x bit becomes moot. Measured: a 644 script refused directly, executed fine through bash. All three generators wrote the same line; all three are fixed. The venv is not involved — odoo_bin.sh already activates it, and it is Odoo's, not the tooling one. Assisted-by: Claude Opus 5 (cherry picked from commit 6f8cee84b72fd016fa188d204f280b011594627c)
2026-08-13 18:14:45 -04:00
ExecStart=/bin/bash ${EL_HOME_ERPLIBRE}/run.sh
WorkingDirectory=${EL_HOME_ERPLIBRE}
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
EOF
echo -e "* Security Init File"
sudo cp /tmp/${EL_CONFIG} /etc/systemd/system/${EL_CONFIG}.service
sudo chmod 755 /etc/systemd/system/${EL_CONFIG}.service
sudo chown root: /etc/systemd/system/${EL_CONFIG}.service
echo -e "* Start ERPLibre on Startup"
sudo systemctl daemon-reload
sudo systemctl enable ${EL_CONFIG}.service
#echo "-----------------------------------------------------------"
#echo "Done! The ERPLibre server is up and running. Specifications:"
#echo "Port: ${EL_PORT}"
#echo "Port Long Polling: ${EL_LONGPOLLING_PORT}"
#echo "User service: ${EL_USER}"
#echo "User PostgreSQL: ${EL_USER}"
#echo "Code location: ${EL_USER}"
#echo "Addons folder: ${EL_USER}/${EL_CONFIG}/addons/"
#echo "SystemD file ERPLibre: /etc/systemd/system/${EL_CONFIG}.service"
#echo "Start ERPLibre service: sudo systemctl start ${EL_CONFIG}"
#echo "Stop ERPLibre service: sudo systemctl stop ${EL_CONFIG}"
#echo "Restart ERPLibre service: sudo systemctl restart ${EL_CONFIG}"
#echo "Status ERPLibre service: sudo systemctl status ${EL_CONFIG}"
#echo "Logs ERPLibre service: sudo journalctl -feu ${EL_CONFIG}"
#echo "-----------------------------------------------------------"
echo -e "* Starting ERPLibre Service"
sudo systemctl restart ${EL_CONFIG}.service