Re: [systemd-devel] how to run a script which takes about 30 seconds before shutdown
On 11/09/2016 09:43 PM, Andrei Borzenkov wrote: > On Wed, Nov 9, 2016 at 4:11 PM, zeronswrote: >> Hi everyone. >> >> Everyday, I need to do something like `git pull` after system >> bootup and `git push` before shutdown. I am using Ubuntu 16.04. >> I have tried to put some script into /etc/rc0.d/, /etc/rc6.d/, >> each time the script runs, the network has been stopped, so I >> turn to systemd. >> >> >> === Here is a test .service file. >> [Unit] >> Description=test systemd >> Conflicts=reboot.target >> After=network-online.target >> Wants=network-online.target > > network-online.target itself does not do anything. You need some > service that actually does waiting, or at least orders itself > correctly on startup and shutdown. If you are using NetworkManager, it > is NetworkManager-wait-online.service. Is it enabled? > No, that doesn't work. Then I realize the `ping` error message, that is not unknown host, so I put `ifconfig wlp9s0` into `test1.sh`, the result shows that at that moment, the net interface has already been shut off. I change the "After=" and "Wants=" to "After=NetworkManager-wait-online.service" "Wants=NetworkManager-wait-online.service" and, yes, it is enabled. >> >> [Service] >> Type=oneshot >> RemainAfterExit=yes >> ExecStart=-/home/zerons/.bin/test.sh >> ExecStop=/home/zerons/.bin/test1.sh >> >> [Install] >> WantedBy=multi-user.target >> >> >> === and test.sh script, please ignore the destination >> #!/bin/bash >> >> echo "bootup" >> /home/zerons/.bin/test >> timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 >> while [ $? -ne 0 ] >> do >> sleep 1 >> timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 >> done >> >> ping -c 4 www.baidu.com >> /home/zerons/.bin/test 2>&1 >> >> >> === test1.sh >> #!/bin/bash >> >> echo "before shutdown"`date +%T` >> /home/zerons/.bin/test >> ping -c 8 www.baidu.com >>/home/zerons/.bin/test 2>&1 >> >> >> >> === the result, on my laptop >> before shutdown20:04:35 >> PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data. >> 64 bytes from 61.135.169.125: icmp_seq=1 ttl=56 time=9.57 ms >> ping: sendmsg: Network is unreachable >> ... >> ping: sendmsg: Network is unreachable >> >> --- www.a.shifen.com ping statistics --- >> 8 packets transmitted, 1 received, 87% packet loss, time 7048ms >> rtt min/avg/max/mdev = 9.579/9.579/9.579/0.000 ms >> >> >> >> === some other infomation >> I reboot several times, but the `test1.sh` always got 87% packet >> loss,,, >> >> When I take these steps in a Ubuntu16.04 virtual machine, it works >> fine, the `test1.sh` gets 0% packet loss before shutdown. I also >> test on a laptop with SSD, `test1.sh` gets 87% packet loss. >> >> How could I make this work? Is there a way, when `test1.sh` runs, >> all the other services could not be stopped until `test1.sh` returns? >> >> ___ >> systemd-devel mailing list >> systemd-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Automating rollback when there's misconfiguration?
Hi, I'm interested in rollbacking misconfigured network configs back to last working state. Old config is stored by etckeeper which uses git. Can this be achieved with systemd itself or do I have to write whole script/program that listens to systemd dbus? If it's script/program it will be something like: -Hook into "systemd restart" in dbus and if possible, directly into "restart systemd-networkd" -If event contains that restart failed, use that; otherwise read "systemctl is-active systemd-networkd" -Rename broken file to $file.broken -Restore: etckeeper vcs reset -- $file -"systemctl stop that-network-restart-hook-script.service" (so that there's no infinite loop) -"systemctl restart systemd-networkd" -Works -> "systemctl start automatic-net-configuration-rollback.service" -Doesn't -> echo "Rollbacked config file doesn't work either. Repair your network config file manually and start automatic rollback script service after it works." Also is there any kind of config file tester so it could be also run before. Something like: # systemd-config --test my-config.network File is broken! # echo $? # 1 -- Pekka Järvinen ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] systemd-nspawn containers
Hello. Does systemd-nspawn intent to be a full secure container technology? or it maybe already is? what is missing? signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] journal files interoperability between distros wrt compression
Hi, currently, when trying to opan a Fedora journal file from Debian/Ubuntu I get: Journal file .../system.journal uses an unsupported feature, ignoring file. This is probably due to Debian not having lz4 support enabled (yet). We currently only build with XZ compression. I wonder what other distros, besides Debian and Fedora, have chosen here. Do you enable LZ4 or XZ compression? We have a bug report in Debian, which asks us to enable LZ4 compression, because XZ is just too slow for coredumps [1]. Since journal files and coredumps use the same compression, this would mean, new journal files are written using LZ4. Which in turn means, we'd basically have to support LZ4 forever. Is this a concern that is shared by other distros / upstream? [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=832010 -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] how to run a script which takes about 30 seconds before shutdown
On Wed, Nov 9, 2016 at 4:11 PM, zeronswrote: > Hi everyone. > > Everyday, I need to do something like `git pull` after system > bootup and `git push` before shutdown. I am using Ubuntu 16.04. > I have tried to put some script into /etc/rc0.d/, /etc/rc6.d/, > each time the script runs, the network has been stopped, so I > turn to systemd. > > > === Here is a test .service file. > [Unit] > Description=test systemd > Conflicts=reboot.target > After=network-online.target > Wants=network-online.target network-online.target itself does not do anything. You need some service that actually does waiting, or at least orders itself correctly on startup and shutdown. If you are using NetworkManager, it is NetworkManager-wait-online.service. Is it enabled? > > [Service] > Type=oneshot > RemainAfterExit=yes > ExecStart=-/home/zerons/.bin/test.sh > ExecStop=/home/zerons/.bin/test1.sh > > [Install] > WantedBy=multi-user.target > > > === and test.sh script, please ignore the destination > #!/bin/bash > > echo "bootup" >> /home/zerons/.bin/test > timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 > while [ $? -ne 0 ] > do > sleep 1 > timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 > done > > ping -c 4 www.baidu.com >> /home/zerons/.bin/test 2>&1 > > > === test1.sh > #!/bin/bash > > echo "before shutdown"`date +%T` >> /home/zerons/.bin/test > ping -c 8 www.baidu.com >>/home/zerons/.bin/test 2>&1 > > > > === the result, on my laptop > before shutdown20:04:35 > PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data. > 64 bytes from 61.135.169.125: icmp_seq=1 ttl=56 time=9.57 ms > ping: sendmsg: Network is unreachable > ... > ping: sendmsg: Network is unreachable > > --- www.a.shifen.com ping statistics --- > 8 packets transmitted, 1 received, 87% packet loss, time 7048ms > rtt min/avg/max/mdev = 9.579/9.579/9.579/0.000 ms > > > > === some other infomation > I reboot several times, but the `test1.sh` always got 87% packet > loss,,, > > When I take these steps in a Ubuntu16.04 virtual machine, it works > fine, the `test1.sh` gets 0% packet loss before shutdown. I also > test on a laptop with SSD, `test1.sh` gets 87% packet loss. > > How could I make this work? Is there a way, when `test1.sh` runs, > all the other services could not be stopped until `test1.sh` returns? > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] how to run a script which takes about 30 seconds before shutdown
Hi everyone. Everyday, I need to do something like `git pull` after system bootup and `git push` before shutdown. I am using Ubuntu 16.04. I have tried to put some script into /etc/rc0.d/, /etc/rc6.d/, each time the script runs, the network has been stopped, so I turn to systemd. === Here is a test .service file. [Unit] Description=test systemd Conflicts=reboot.target After=network-online.target Wants=network-online.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=-/home/zerons/.bin/test.sh ExecStop=/home/zerons/.bin/test1.sh [Install] WantedBy=multi-user.target === and test.sh script, please ignore the destination #!/bin/bash echo "bootup" >> /home/zerons/.bin/test timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 while [ $? -ne 0 ] do sleep 1 timeout 9 ping -c 1 www.baidu.com >/dev/null 2>&1 done ping -c 4 www.baidu.com >> /home/zerons/.bin/test 2>&1 === test1.sh #!/bin/bash echo "before shutdown"`date +%T` >> /home/zerons/.bin/test ping -c 8 www.baidu.com >>/home/zerons/.bin/test 2>&1 === the result, on my laptop before shutdown20:04:35 PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data. 64 bytes from 61.135.169.125: icmp_seq=1 ttl=56 time=9.57 ms ping: sendmsg: Network is unreachable ... ping: sendmsg: Network is unreachable --- www.a.shifen.com ping statistics --- 8 packets transmitted, 1 received, 87% packet loss, time 7048ms rtt min/avg/max/mdev = 9.579/9.579/9.579/0.000 ms === some other infomation I reboot several times, but the `test1.sh` always got 87% packet loss,,, When I take these steps in a Ubuntu16.04 virtual machine, it works fine, the `test1.sh` gets 0% packet loss before shutdown. I also test on a laptop with SSD, `test1.sh` gets 87% packet loss. How could I make this work? Is there a way, when `test1.sh` runs, all the other services could not be stopped until `test1.sh` returns? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel