Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.
Strony: 1
Na stronie: https://linuxconfig.org/how-to-automatically-execut … systemd-linux
jest sciezka:
ExecStart=/usr/local/bin/
natomiast na stronie Morfika: https://morfikov.github.io/post/firewall-na-linuxow … ny-klienckie/
jest sciezka:
ExecStart=/bin/sh -c "/etc/filtr/"
Selinux mam wylaczony:
root@debian:/home/robin# selinuxenabled && echo enabled || echo disabled bash: selinuxenabled: command not found disabled
Dla systemd v231 na tej stronie: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
ExecStart=/usr/sbin/
Tu jest jeszcze inaczej: https://forums.plex.tv/discussion/222270/debian-jes … ling-to-start
ExecStart=/bin/sh -c '/usr/lib/
Ja to rozumiem tak, ze parametr "ExecStart=" okresla co i z jakiej lokalizacji ma wystartowac, a to implikuje pytanie: gdzie umieszczac skrypt startowy?
Pytanie, czy roznica ma jakies znaczenie dlaczego,i ktora opcje stosowac dla systemd v.215 na Jessie?
Tutaj: http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.service jest duzo na ten temat, ale nie bardzo kumam.
Pozdro.
Ostatnio edytowany przez Novi-cjusz (2016-11-21 11:25:46)
Offline
Jak masz pliki/skrypty, które musisz uruchomić, i są one w różnych miejscach, to chyba logiczne, że ścieżka do tych plików się zmienia. Systemd nie trawi gołych skryptów i trzeba je uruchomić w jakimś shellu, dlatego masz /bin/sh -c "/sciezka/do/skryptu.sh"
Offline
Wlasnie to jest pytanie: jakie zasady rzadza umieszczaniem skryptow w roznych miejscach a nie jednym? Byloby latwiej.
Dlaczego umiesciles skrypt /etc/filtr/iptables_filtr.sh w takiej lokalizacji? A nie innej?
Ostatnio edytowany przez Novi-cjusz (2016-11-21 11:32:46)
Offline
Dziekuje, o taka odpowiedz chodzilo.
Offline
Myslalem,ze to juz bedzie koniec klopotow, ale do konca daleko.
Ale po kolei.
Stworzylem skrypt startowy w lokalizacji:
/etc/filtr/iptables_filter.sh
z zawartoscia:
#!/bin/sh iptables -F iptables -X iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT ip6tables -F ip6tables -X ip6tables -P INPUT DROP ip6tables -P FORWARD DROP ip6tables -P OUTPUT ACCEPT ip6tables -A INPUT -i lo -j ACCEPT ip6tables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
nadalem mu uprawnienia:
chmod +x /etc/filtr/iptables_filter.sh
Stworzylem usluge firewall dla systemd czyli plik w lokalizacji:
/etc/systemd/system/firewall.service
z zawartoscia:
[Unit] Description=firewall Documentation=man:iptables DefaultDependencies=no Wants=network-pre.target systemd-modules-load.service Before=network-pre.target After=systemd-modules-load.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/sh -c "/etc/filtr/iptables_filter.sh" [Install] WantedBy=multi-user.target
przeladowalem:
systemctl daemon-reload
wlaczam usluge:
systemctl enable firewall.service
i taki wynik:
root@debian:/etc# systemctl enable firewall.service Synchronizing state for firewall.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d firewall defaults insserv: script firewall is not an executable regular file, skipped! Executing /usr/sbin/update-rc.d firewall enable update-rc.d: error: cannot find a LSB script for firewall
Ostatnio edytowany przez Novi-cjusz (2016-11-21 17:14:08)
Offline
jest pusty plik o taki tytule
root@debian:/etc/init.d# cat /etc/init.d/firewall root@debian:/etc/init.d#
Ostatnio edytowany przez Novi-cjusz (2016-11-21 17:45:23)
Offline
juz go nie ma
Pelny sukces:
root@debian:~# systemctl daemon-reload root@debian:~# systemctl enable firewall.service root@debian:~# systemctl start firewall.service root@debian:~# systemctl status firewall.service ● firewall.service - firewall Loaded: loaded (/etc/systemd/system/firewall.service; enabled) Active: active (exited) since Mon 2016-11-21 16:38:07 GMT; 13min ago Docs: man:iptables Main PID: 224 (code=exited, status=0/SUCCESS) CGroup: /system.slice/firewall.service Nov 21 16:38:07 debian systemd[1]: Started firewall. Nov 21 16:51:04 debian systemd[1]: Started firewall.
Ostatnio edytowany przez Novi-cjusz (2016-11-21 17:50:54)
Offline
Moze troche za wczesnie sie znowu ucieszylem.
Firewall service, loaded, active ale niestety (exited) a powinno byc running.
Znalazlem takie zdanie:
State active (exited) means that systemd has successfully run the commands but that it does not know there is a daemon to monitor.
i jeszcze:
ACTIVE: A summary state about whether the unit is active. This is usually a fairly basic way to tell if the unit has started successfully or not.
Co to wlasciwie znaczy, "exited" jak zamienic na "running"?
Offline
Bo nie do konca rozumiem roznice znaczenia tych 2 slow.
"Running" rozumiem jako "biegnacy tzn trwajacy" O,k
"Exited" jako "wyszedl, zakonczyl, zaprzestal" i to mnie niepokoi.
Doczytalem, ze jest to relacja miedzy kontrola procesu przez Kernela lub daemona ?? - nie jestem pewien.
Status of .service says "active (exited)" in green. (e.g. iptables)
This is perfectly normal. In the case with iptables it is because there is no daemon to run, it is controlled in the kernel. Therefore, it exits after the rules have been loaded.
Z tych statusow:
root@debian:/home/robin# systemctl status firewall.service ● firewall.service - firewall Loaded: loaded (/etc/systemd/system/firewall.service; enabled) Active: active (exited) since Wed 2016-11-23 09:06:56 GMT; 34min ago Docs: man:iptables Process: 227 ExecStart=/bin/sh -c /etc/filtr/iptables_filter.sh (code=exited, status=0/SUCCESS) Main PID: 227 (code=exited, status=0/SUCCESS) CGroup: /system.slice/firewall.service Nov 23 09:06:56 debian systemd[1]: Started firewall. root@debian:/home/robin# systemctl status cgrulesngd.service ● cgrulesngd.service - LSB: start and stop the cgroups rules engine daemon Loaded: loaded (/etc/init.d/cgrulesngd). Active: active (running) since Wed 2016-11-23 09:07:14 GMT; 34min ago Process: 1264 ExecStart=/etc/init.d/cgrulesngd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/cgrulesngd.service └─1323 /usr/sbin/cgrulesengd -n -Q Nov 23 09:07:12 debian cgrulesngd[1264]: Starting CGroup Rules Engine Daemon.... Nov 23 09:07:14 debian systemd[1]: Started LSB: start and stop the cgroups ...n. Hint: Some lines were ellipsized, use -l to show in full. root@debian:/home/robin# systemctl status cgstart.service ● cgstart.service - "CGSTART - Zakładam strukturę grup do cgroup ;)" Loaded: loaded (/etc/systemd/system/cgstart.service; enabled) Active: active (exited) since Wed 2016-11-23 09:06:56 GMT; 35min ago Process: 208 ExecStart=/usr/local/sbin/cgstart (code=exited, status=0/SUCCESS) Main PID: 208 (code=exited, status=0/SUCCESS) CGroup: /system.slice/cgstart.service Nov 23 09:06:56 debian systemd[1]: Started "CGSTART - Zakładam strukturę gr…;)". Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. Hint: Some lines were ellipsized, use -l to show in full.
wyciagam wniosek, ze "exited" jest tam gdzie nie ma daemona, natomiast tam gdzie daemon jest to jest "running"
Chyba dobrze?
Czytalem TUTAJ
niewiele pomoglo
Ostatnio edytowany przez Novi-cjusz (2016-11-23 11:11:31)
Offline
To jest dla mnie czytelne, skrypt sie wykonal i zglosil kod wyjscia, natomiast demon pracuje ciegle w tle.
Kryterium jest czas, skonczenie wykonania-exit, trwanie dzialania - run.
Dziekuje za wyjasnienie.
Przy okazji, jest mozliwosc upgrade systemd mam 215 a jest juz 231, czytalem ze to niebezpieczne dla systemu.
Ostatnio edytowany przez Novi-cjusz (2016-11-23 11:40:52)
Offline
Strony: 1