Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create no_root.sh #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions pomocnicze_skrypty/no_root.sh
Original file line number Diff line number Diff line change
@@ -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