From c7c0b1597b5537e94bc97d8c566348a16a65c490 Mon Sep 17 00:00:00 2001 From: WojRep Date: Tue, 15 Mar 2022 19:33:13 +0100 Subject: [PATCH] Create no_root.sh --- pomocnicze_skrypty/no_root.sh | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pomocnicze_skrypty/no_root.sh diff --git a/pomocnicze_skrypty/no_root.sh b/pomocnicze_skrypty/no_root.sh new file mode 100644 index 00000000..5c71b80c --- /dev/null +++ b/pomocnicze_skrypty/no_root.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +sudo systemd stop flaga.service > /dev/null +sudo systemd disable flaga.service > /dev/null +sudo systemd daemon-reload > /dev/null +sudo rm /var/www/flaga/flaga.sock > /dev/null + +mkdir -p ~/.config/systemd/user/ +mv /etc/systemd/system/flaga.service /var/www/flaga/pliki_serwerowe/*.backup + +cat << EOF > ~/.config/systemd/user/flaga.service +[Unit] +After=network.target +Description=Flaga - Programowanie xD + +[Service] +WorkingDirectory=/var/www/flaga +Environment="PATH=/var/www/flaga/flagaenv/bin" + +ExecStart=/var/www/flaga/flagaenv/bin/gunicorn --workers 3 --bind unix:flaga.sock -m 007 app:app +ExecStartPost=sleep 5 +ExecStartPost=chown :www-data /var/www/flaga/flaga.sock + +Restart=on-failure +ExecReload=/bin/kill -s HUP $MAINPID +KillMode=mixed +TimeoutStopSec=5 + +Restart=always +RestartSec=60 +PrivateTmp=true + +[Install] +WantedBy=default.target +EOF + +systemctl --user daemon-reload +systemctl --user status flaga.service +systemctl --user start flaga.service +loginctl enable-linger $USER +