Re: [systemd-devel] How to get used to systemd vs init
On Wed, Jun 24, 2015 at 8:53 AM, Chad wrote: > Killermoehre, > Thank you for your time and reply. > > I intend to do exactly that when I start using systemd (I am still using > init.d at the moment). In fact I have already suggested that very thing on > the fail2ban mailing list so that can add it to the tree and no custom rule > is needed. To my knowlage there is not a built in/standard way to tie > init.d/iptables to init.d/fail2ban. > > The test for the chains existence is still needed in case the chain is > removed by other means (like a manual delete from the cli). > I have found that I can trust nothing and that I should check/test > everything :) when I think something is impossible or so unlikely that it > will "never happen to me" it inevitably is a problem at the worst possible > moment. I bet some of you know what I mean. > > ^C > I think the best for you will be to read "The systemd for Administrators Blog Series", which is a section at http://www.freedesktop.org/wiki/Software/systemd/ It explains for example how to convert a sysv init script to a systemd service file, what are the changes regarding configuration files with systemd, how to improve the security of your services, analyze the startup,... It will help for the transition from sysv to systemd. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 10:35 PM, killermoehre wrote: Am 24.06.2015 um 02:00 schrieb Chad: On 6/23/2015 4:45 PM, Ronny Chevalier wrote: On Wed, Jun 24, 2015 at 1:37 AM, Chad wrote: Oh, wait this is the reverse of what I want/need (systemd-sysv-generator goes from init.d to systemd, I need from systemd to init.d). I have a nagios script that runs something like: /etc/init.d/httpd status It then reads the output and makes sure httpd is running, if not it takes action depending on the service. I use that method for tons of services. I don't want to have to re-write the modules to use: systemctl status httpd If I did that then I will not be able to rsync the scripts/configs around and would have to maintain 2 versions of the code. I was wondering if there was an easy way to create a /etc/init.d/httpd script that called something like this inside: #!/bin/bash systemctl $1 $0 I know it is not that simple ($0 for example is the full path /etc/init.d/httpd not just the httpd), which is why I am hoping there is a tool for this. If you just want to know if a service is active you can use: systemctl is-active httpd If $? equals 0 then the service is active, else it is not :) If you make your script use this I don't see why you would have to maintain multiple versions, if your intention is to use systemd everywhere. Except that I can not convert all servers I maintain over just like that, it will take time, probably 1-2 years. As to: systemctl is-active httpd, that would work sometimes but not others. For example I check fail2ban by running /etc/init.d/iptables status which outputs all the firewall rules then check that output to make sure the chains for fail2ban are there. If you restart iptables without restarting fail2ban, fail2ban will show as running because the daemon is up, but since the chains are gone it can not ban bad guys. Maybe one of you knows a solution to that (iptables restart without a fail2ban restart), I have not found one for init.d, is this fixed somehow in systemd? That would be another advantage. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel Hi Chad, why don't make a dependency between iptables and fail2ban? This is really easy in systemd with Requires and Wants entries in the services. So you can't restart iptables without automatic trigger of a fail2ban restart. Regards Killermoehre, Thank you for your time and reply. I intend to do exactly that when I start using systemd (I am still using init.d at the moment). In fact I have already suggested that very thing on the fail2ban mailing list so that can add it to the tree and no custom rule is needed. To my knowlage there is not a built in/standard way to tie init.d/iptables to init.d/fail2ban. The test for the chains existence is still needed in case the chain is removed by other means (like a manual delete from the cli). I have found that I can trust nothing and that I should check/test everything :) when I think something is impossible or so unlikely that it will "never happen to me" it inevitably is a problem at the worst possible moment. I bet some of you know what I mean. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
Am 24.06.2015 um 02:00 schrieb Chad: > On 6/23/2015 4:45 PM, Ronny Chevalier wrote: > > On Wed, Jun 24, 2015 at 1:37 AM, Chad wrote: > >> Oh, wait this is the reverse of what I want/need (systemd-sysv-generator > >> goes from init.d to systemd, I need from systemd to init.d). > >> I have a nagios script that runs something like: > >> /etc/init.d/httpd status > >> It then reads the output and makes sure httpd is running, if not it > >> takes > >> action depending on the service. > >> I use that method for tons of services. > >> I don't want to have to re-write the modules to use: > >> systemctl status httpd > >> If I did that then I will not be able to rsync the scripts/configs > >> around > >> and would have to maintain 2 versions of the code. > >> I was wondering if there was an easy way to create a /etc/init.d/httpd > >> script that called something like this inside: > >> #!/bin/bash > >> systemctl $1 $0 > >> I know it is not that simple ($0 for example is the full path > >> /etc/init.d/httpd not just the httpd), which is why I am hoping there > >> is a > >> tool for this. > >> > > If you just want to know if a service is active you can use: > > > > systemctl is-active httpd > > > > If $? equals 0 then the service is active, else it is not :) > > > > If you make your script use this I don't see why you would have to > > maintain multiple versions, if your intention is to use systemd > > everywhere. > Except that I can not convert all servers I maintain over just like > that, it will take time, probably 1-2 years. > > As to: systemctl is-active httpd, that would work sometimes but not > others. For example I check fail2ban by running /etc/init.d/iptables > status which outputs all the firewall rules then check that output to > make sure the chains for fail2ban are there. If you restart iptables > without restarting fail2ban, fail2ban will show as running because the > daemon is up, but since the chains are gone it can not ban bad guys. > > Maybe one of you knows a solution to that (iptables restart without a > fail2ban restart), I have not found one for init.d, is this fixed > somehow in systemd? > That would be another advantage. > > ^C > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel Hi Chad, why don't make a dependency between iptables and fail2ban? This is really easy in systemd with Requires and Wants entries in the services. So you can't restart iptables without automatic trigger of a fail2ban restart. Regards ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 4:45 PM, Ronny Chevalier wrote: On Wed, Jun 24, 2015 at 1:37 AM, Chad wrote: Oh, wait this is the reverse of what I want/need (systemd-sysv-generator goes from init.d to systemd, I need from systemd to init.d). I have a nagios script that runs something like: /etc/init.d/httpd status It then reads the output and makes sure httpd is running, if not it takes action depending on the service. I use that method for tons of services. I don't want to have to re-write the modules to use: systemctl status httpd If I did that then I will not be able to rsync the scripts/configs around and would have to maintain 2 versions of the code. I was wondering if there was an easy way to create a /etc/init.d/httpd script that called something like this inside: #!/bin/bash systemctl $1 $0 I know it is not that simple ($0 for example is the full path /etc/init.d/httpd not just the httpd), which is why I am hoping there is a tool for this. If you just want to know if a service is active you can use: systemctl is-active httpd If $? equals 0 then the service is active, else it is not :) If you make your script use this I don't see why you would have to maintain multiple versions, if your intention is to use systemd everywhere. Except that I can not convert all servers I maintain over just like that, it will take time, probably 1-2 years. As to: systemctl is-active httpd, that would work sometimes but not others. For example I check fail2ban by running /etc/init.d/iptables status which outputs all the firewall rules then check that output to make sure the chains for fail2ban are there. If you restart iptables without restarting fail2ban, fail2ban will show as running because the daemon is up, but since the chains are gone it can not ban bad guys. Maybe one of you knows a solution to that (iptables restart without a fail2ban restart), I have not found one for init.d, is this fixed somehow in systemd? That would be another advantage. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On Wed, Jun 24, 2015 at 1:37 AM, Chad wrote: > Oh, wait this is the reverse of what I want/need (systemd-sysv-generator > goes from init.d to systemd, I need from systemd to init.d). > I have a nagios script that runs something like: > /etc/init.d/httpd status > It then reads the output and makes sure httpd is running, if not it takes > action depending on the service. > I use that method for tons of services. > I don't want to have to re-write the modules to use: > systemctl status httpd > If I did that then I will not be able to rsync the scripts/configs around > and would have to maintain 2 versions of the code. > I was wondering if there was an easy way to create a /etc/init.d/httpd > script that called something like this inside: > #!/bin/bash > systemctl $1 $0 > I know it is not that simple ($0 for example is the full path > /etc/init.d/httpd not just the httpd), which is why I am hoping there is a > tool for this. > If you just want to know if a service is active you can use: systemctl is-active httpd If $? equals 0 then the service is active, else it is not :) If you make your script use this I don't see why you would have to maintain multiple versions, if your intention is to use systemd everywhere. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 4:26 PM, Reindl Harald wrote: Am 24.06.2015 um 01:07 schrieb Chad: You could do something like: systemctl start htt systemctl st or else, and it will complete it. I use bash. This is a cool trick that systemd has over init.d. I know not all programs can do that shell completion, for example /etc/init.d/httpd res does not work (I try it all the time out of tab completion habit!) not true, that's just because you don't use the correct command and call a script which is not known to bash-completion directly [root@honeypot:~]$ service honeypot restart startstatus stop [root@honeypot:~]$ service honeypot ^C [root@honeypot:~]$ cat /etc/redhat-release CentOS release 6.6 (Final) Name: bash-completion Arch: noarch Epoch : 1 Version : 1.3 Release : 7.el6 Size: 576 k Repo: installed Summary : Programmable completion for Bash URL: http://bash-completion.alioth.debian.org/ License : GPLv2+ Beschreibung : bash-completion is a collection of shell functions that take advantage : of the programmable completion feature of bash. [root@honeypot:~]$ rpm -q --file /etc/bash_completion.d/service bash-completion-1.3-7.el6.noarch Mr. Harald, Thanks again for your reply, I did not have bash-completion installed (and did not know it existed). I installed it on one of the servers and sure enough res completes to "restart" now! Cool, I will be adding that to all my servers and to my new server set-up scripts and notes. Super awesome feature! ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 4:25 PM, Ronny Chevalier wrote: On Wed, Jun 24, 2015 at 1:07 AM, Chad wrote: Mr. Chevalier, Thank you for your time and reply. On 6/23/2015 1:30 PM, Ronny Chevalier wrote: On Tue, Jun 23, 2015 at 9:45 PM, Chad wrote: I am sure this is the wrong place to send this e-mail, but I could not find another place to send it. Hi, It is the good place :) Great, thanks. I want to learn and use systemd, but have run into a few problems on my way. Please don't see this as an attack on systemd, I want to learn something new, but change is hard. I am an old school kind of sysadmin and I am planning on moving from CentOS 6 to CentOS 7, but I am having trouble with systemd. I am hoping you know some shortcuts/tricks to help me learn the new way. # 1. I can't spell. With init I don't have to know how to spell things because I have tab complete. I use tab complete for almost every command I type. For example: /e gets -> /etc/ /etc/in gets -> /etc/init /etc/init. gets -> /etc/init.d/ /etc/init.d/ht /etc/init.d/httpd /etc/init.d/httpd restart So I entered 19 characters and got 25 with tab complete. The new systemd way would be to type (23 total characters, no tab complete): systemctl restart httpd Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 system to test on. The real issue is that I have to know (in the above example) that it is httpd not http. With so many systems, distros, and services it is hard to remember every service name exactly (and some names are very long). For example ntpd has a d, but nfs does not. Tab completion fixes this issue for me. How can I use tab completion with systemd? If you use either bash or zsh, systemd provides shell completion for them. You could do something like: systemctl start htt systemctl st or else, and it will complete it. I use bash. This is a cool trick that systemd has over init.d. I know not all programs can do that shell completion, for example /etc/init.d/httpd res does not work (I try it all the time out of tab completion habit!). # 2. How to find all possible services: The init way: ls -l /etc/init/d The systemd way: ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service This seems WAY harder and I have to remember 2 locations instead of 1. There is: systemctl list-unit-files It lists all the units installed on your system. In systemd a unit is a configuration file that can describe a service, a mount point, a device,... So a service is a subtype of unit, see "man 5 systemd.unit" for more information. So if you want to only display the services, you just have to specify the type systemctl list-unit-files --type=service Ok, so that is a lot more to remember than ls -l /etc/init.d, but I can learn it. # 3. List all services and their start levels: In systemd world, start levels equivalent are the targets (see man 5 systemd.target). A target is a synchronisation point between multiple units. For example, there is sysinit.target which is the synchronization point for early boot services. This way a unit can ask to be started only after a specific target, for example. The init way (all services): chkconfig --list The init way (only active services. I use this a lot): chkconfig --list | grep :on The systemd way (all services): systemctl list-unit-files --type=service The systemd way (only active services, I don't know how to do this). systemctl ??? With systemctl you can provide a filter according to the current state of a unit. If you want to list all the active service, you can do: systemctl --state=active --type=service list-units Ok, again more to type and remember, but memorization is not out of the question. # 4. What about the many programs that rely on /etc/init.d/ status/start/stop/restart I have many services that are monitored by nagios or cron jobs (like logrotate) that rely on /etc/init.d/ status/start/stop/restart. I don't want to change them because right now they work on every server and I don't want to have to maintain 2 versions of the code or hunt them all down. There is systemd-sysv-generator which creates wrapper .service for sysv scripts automatically at boot. But you need to specify additional headers if you want to use ordering. See man systemd-sysv-generator. That is what I am looking for (systemd-sysv-generator), but does that mean systemd will not use the .service files and the system will go back to running all start-up scripts in order via init.d style S01-S99? I don't really care that much as boot time does not matter (I rarely reboot and always have a secondary server that can take the load. I run all clusters or active/backup.) No, systemd-sysv-generator will read init scripts and generates equivalent services (a systemd unit). Then systemd will load this services like it loads every other units and infer what needs to be started first according to the configuration in the units. The priority of the S01-S99 is also respected, u
Re: [systemd-devel] How to get used to systemd vs init
Am 24.06.2015 um 01:07 schrieb Chad: You could do something like: systemctl start htt systemctl st or else, and it will complete it. I use bash. This is a cool trick that systemd has over init.d. I know not all programs can do that shell completion, for example /etc/init.d/httpd res does not work (I try it all the time out of tab completion habit!) not true, that's just because you don't use the correct command and call a script which is not known to bash-completion directly [root@honeypot:~]$ service honeypot restart startstatus stop [root@honeypot:~]$ service honeypot ^C [root@honeypot:~]$ cat /etc/redhat-release CentOS release 6.6 (Final) Name: bash-completion Arch: noarch Epoch : 1 Version : 1.3 Release : 7.el6 Size: 576 k Repo: installed Summary : Programmable completion for Bash URL: http://bash-completion.alioth.debian.org/ License : GPLv2+ Beschreibung : bash-completion is a collection of shell functions that take advantage : of the programmable completion feature of bash. [root@honeypot:~]$ rpm -q --file /etc/bash_completion.d/service bash-completion-1.3-7.el6.noarch signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
Am 23.06.2015 um 21:45 schrieb Chad: The new systemd way would be to type (23 total characters, no tab complete): systemctl restart httpd Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 system to test on. maybe you should just install CentOS inside a VM and test it [root@srv-rhsoft:~]$ systemctl restart h halt-local.service haveged.service home.mount hostapd-guest.service httpd-lounge-worker.service hybrid-sleep.target halt.target hibernate.target hostapd-guest-interface.service hostapd.service httpd.service The real issue is that I have to know (in the above example) that it is httpd not http. With so many systems, distros, and services it is hard to remember every service name exactly (and some names are very long). For example ntpd has a d, but nfs does not. Tab completion fixes this issue for me. How can I use tab completion with systemd? as like for any other software - hit the TAB key # 2. How to find all possible services: The init way: ls -l /etc/init/d The systemd way: ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service This seems WAY harder and I have to remember 2 locations instead of 1 nobody but you installs systemd-units in /etc/ and so you have only one location AND customized ones - with sysvinit you had no way to override /etc/init.d/httpd without doing the work after each update again signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On Wed, Jun 24, 2015 at 1:07 AM, Chad wrote: > Mr. Chevalier, > Thank you for your time and reply. > > On 6/23/2015 1:30 PM, Ronny Chevalier wrote: >> >> On Tue, Jun 23, 2015 at 9:45 PM, Chad wrote: >>> >>> I am sure this is the wrong place to send this e-mail, but I could not >>> find >>> another place to send it. >> >> Hi, >> >> It is the good place :) > > Great, thanks. > >>> I want to learn and use systemd, but have run into a few problems on my >>> way. >>> Please don't see this as an attack on systemd, I want to learn something >>> new, but change is hard. >>> >>> I am an old school kind of sysadmin and I am planning on moving from >>> CentOS >>> 6 to CentOS 7, but I am having trouble with systemd. I am hoping you know >>> some shortcuts/tricks to help me learn the new way. >>> >>> # >>> 1. I can't spell. With init I don't have to know how to spell things >>> because >>> I have tab complete. I use tab complete for almost every command I type. >>> For >>> example: >>> /e gets -> /etc/ >>> /etc/in gets -> /etc/init >>> /etc/init. gets -> /etc/init.d/ >>> /etc/init.d/ht /etc/init.d/httpd >>> /etc/init.d/httpd restart >>> So I entered 19 characters and got 25 with tab complete. >>> >>> The new systemd way would be to type (23 total characters, no tab >>> complete): >>> systemctl restart httpd >>> Maybe I could tab complete systemctl, but I don't currently have a CentOS >>> 7 >>> system to test on. >>> >>> The real issue is that I have to know (in the above example) that it is >>> httpd not http. >>> With so many systems, distros, and services it is hard to remember every >>> service name exactly (and some names are very long). For example ntpd has >>> a >>> d, but nfs does not. >>> Tab completion fixes this issue for me. >>> >>> How can I use tab completion with systemd? >> >> If you use either bash or zsh, systemd provides shell completion for them. >> >> You could do something like: >> >> systemctl start htt >> systemctl st >> >> or else, and it will complete it. > > I use bash. This is a cool trick that systemd has over init.d. I know not > all programs can do that shell completion, for example /etc/init.d/httpd > res does not work (I try it all the time out of tab completion habit!). >> >> >>> >>> # >>> 2. How to find all possible services: >>> >>> The init way: >>> ls -l /etc/init/d >>> >>> The systemd way: >>> ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service >>> >>> This seems WAY harder and I have to remember 2 locations instead of 1. >> >> There is: >> >> systemctl list-unit-files >> >> It lists all the units installed on your system. In systemd a unit is >> a configuration file that can describe a service, a mount point, a >> device,... So a service is a subtype of unit, see "man 5 systemd.unit" >> for more information. >> >> So if you want to only display the services, you just have to specify the >> type >> >> systemctl list-unit-files --type=service > > Ok, so that is a lot more to remember than ls -l /etc/init.d, but I can > learn it. >> >> >>> # >>> 3. List all services and their start levels: >>> >> In systemd world, start levels equivalent are the targets (see man 5 >> systemd.target). A target is a synchronisation point between multiple >> units. For example, there is sysinit.target which is the >> synchronization point for early boot services. This way a unit can ask >> to be started only after a specific target, for example. >> >>> The init way (all services): >>> chkconfig --list >>> >>> The init way (only active services. I use this a lot): >>> chkconfig --list | grep :on >>> >>> The systemd way (all services): >>> systemctl list-unit-files --type=service >>> >>> The systemd way (only active services, I don't know how to do this). >>> systemctl ??? >>> >> With systemctl you can provide a filter according to the current state >> of a unit. If you want to list all the active service, you can do: >> >> systemctl --state=active --type=service list-units > > Ok, again more to type and remember, but memorization is not out of the > question. >> >> >>> # >>> 4. What about the many programs that rely on /etc/init.d/ >>> status/start/stop/restart >>> I have many services that are monitored by nagios or cron jobs (like >>> logrotate) that rely on /etc/init.d/ status/start/stop/restart. >>> I don't want to change them because right now they work on every server >>> and >>> I don't want to have to maintain 2 versions of the code or hunt them all >>> down. >> >> There is systemd-sysv-generator which creates wrapper .service for >> sysv scripts automatically at boot. But you need to specify additional >> headers if you want to use ordering. See man systemd-sysv-generator. > > That is what I am looking for (systemd-sysv-generator), but does that mean > systemd will not use the .service files and the system will go back to > running all start-up scripts in order via init.d style S01-S99? > I don't really care that much as boot time does not matter (I rarely reboo
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 1:41 PM, Ronny Chevalier wrote: On Tue, Jun 23, 2015 at 10:16 PM, Chad wrote: On 6/23/2015 1:01 PM, Reindl Harald wrote: Am 23.06.2015 um 21:45 schrieb Chad: The new systemd way would be to type (23 total characters, no tab complete): systemctl restart httpd Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 system to test on. maybe you should just install CentOS inside a VM and test it [root@srv-rhsoft:~]$ systemctl restart h halt-local.service haveged.service home.mount hostapd-guest.service httpd-lounge-worker.service hybrid-sleep.target halt.target hibernate.target hostapd-guest-interface.service hostapd.service httpd.service The real issue is that I have to know (in the above example) that it is httpd not http. With so many systems, distros, and services it is hard to remember every service name exactly (and some names are very long). For example ntpd has a d, but nfs does not. Tab completion fixes this issue for me. How can I use tab completion with systemd? as like for any other software - hit the TAB key # 2. How to find all possible services: The init way: ls -l /etc/init/d The systemd way: ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service This seems WAY harder and I have to remember 2 locations instead of 1 nobody but you installs systemd-units in /etc/ and so you have only one location AND customized ones - with sysvinit you had no way to override /etc/init.d/httpd without doing the work after each update again Harald, Thank you for your reply and time. I will make some time at some point to install CentOS 7 again, I just don't have one installed right now. #1 I did not know you could tab complete that way! i.e. as part of a command argument, not just as part of a path. Guess I learned something new after 20 years :) #2 I can see the advantages of having a local override just like /usr/bin has /usr/local/bin. Out of curiosity is there a reason the team did not follow the local pattern with something like: /lib/systemd/local/system? It is easy enough to create an alias on systems I use often, it will just take time to learn/memorize the new paths, I am so used to /etc/init.d. See http://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ for why /lib/ is not used anymore. Anyway, /usr is considered to be vendor specific (what your distro provides you) and you should not modify it. /etc, in the other hand, is entirely for you. If you want to override a unit configuration, you do not modify /usr/lib/systemd/system/foobar.service but you put your version in /etc/systemd/system/foobar.service. Then you reload the units via systemctl daemon-reload. systemctl also provides a simple tool to do this: systemctl edit --full foobar.service It will copy the unit in /etc and open your editor. When you save and quit, it will automatically run systemctl daemon-reload. You can also only modify just one directive of a unit file by using: systemctl edit foobar.service It will create /etc/systemd/system/foobar.service.d/override.conf and open your editor. In this file you just have to put the lines/directives that you want to modify from the original one, without having to edit the entire unit. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel I guess I am used to /usr/local/bin, /usr/local/src, /lib/local, etc. So I wondered why /usr/lib/systemd for system files and /etc/systemd for local files as opposed to something like /usr/lib/local/systemd or maybe /usr/local/lib/systemd. I don't have strong feelings about it and I did not know any of the history until I read your reply and the link you sent. I know that as a group developers normally have a reason for what they do so I was curios why the move away from the local dir standard. I use /etc/ all the time as you know tons of stuff follows that path, so that one is no big deal. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
Mr. Chevalier, Thank you for your time and reply. On 6/23/2015 1:30 PM, Ronny Chevalier wrote: On Tue, Jun 23, 2015 at 9:45 PM, Chad wrote: I am sure this is the wrong place to send this e-mail, but I could not find another place to send it. Hi, It is the good place :) Great, thanks. I want to learn and use systemd, but have run into a few problems on my way. Please don't see this as an attack on systemd, I want to learn something new, but change is hard. I am an old school kind of sysadmin and I am planning on moving from CentOS 6 to CentOS 7, but I am having trouble with systemd. I am hoping you know some shortcuts/tricks to help me learn the new way. # 1. I can't spell. With init I don't have to know how to spell things because I have tab complete. I use tab complete for almost every command I type. For example: /e gets -> /etc/ /etc/in gets -> /etc/init /etc/init. gets -> /etc/init.d/ /etc/init.d/ht /etc/init.d/httpd /etc/init.d/httpd restart So I entered 19 characters and got 25 with tab complete. The new systemd way would be to type (23 total characters, no tab complete): systemctl restart httpd Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 system to test on. The real issue is that I have to know (in the above example) that it is httpd not http. With so many systems, distros, and services it is hard to remember every service name exactly (and some names are very long). For example ntpd has a d, but nfs does not. Tab completion fixes this issue for me. How can I use tab completion with systemd? If you use either bash or zsh, systemd provides shell completion for them. You could do something like: systemctl start htt systemctl st or else, and it will complete it. I use bash. This is a cool trick that systemd has over init.d. I know not all programs can do that shell completion, for example /etc/init.d/httpd res does not work (I try it all the time out of tab completion habit!). # 2. How to find all possible services: The init way: ls -l /etc/init/d The systemd way: ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service This seems WAY harder and I have to remember 2 locations instead of 1. There is: systemctl list-unit-files It lists all the units installed on your system. In systemd a unit is a configuration file that can describe a service, a mount point, a device,... So a service is a subtype of unit, see "man 5 systemd.unit" for more information. So if you want to only display the services, you just have to specify the type systemctl list-unit-files --type=service Ok, so that is a lot more to remember than ls -l /etc/init.d, but I can learn it. # 3. List all services and their start levels: In systemd world, start levels equivalent are the targets (see man 5 systemd.target). A target is a synchronisation point between multiple units. For example, there is sysinit.target which is the synchronization point for early boot services. This way a unit can ask to be started only after a specific target, for example. The init way (all services): chkconfig --list The init way (only active services. I use this a lot): chkconfig --list | grep :on The systemd way (all services): systemctl list-unit-files --type=service The systemd way (only active services, I don't know how to do this). systemctl ??? With systemctl you can provide a filter according to the current state of a unit. If you want to list all the active service, you can do: systemctl --state=active --type=service list-units Ok, again more to type and remember, but memorization is not out of the question. # 4. What about the many programs that rely on /etc/init.d/ status/start/stop/restart I have many services that are monitored by nagios or cron jobs (like logrotate) that rely on /etc/init.d/ status/start/stop/restart. I don't want to change them because right now they work on every server and I don't want to have to maintain 2 versions of the code or hunt them all down. There is systemd-sysv-generator which creates wrapper .service for sysv scripts automatically at boot. But you need to specify additional headers if you want to use ordering. See man systemd-sysv-generator. That is what I am looking for (systemd-sysv-generator), but does that mean systemd will not use the .service files and the system will go back to running all start-up scripts in order via init.d style S01-S99? I don't really care that much as boot time does not matter (I rarely reboot and always have a secondary server that can take the load. I run all clusters or active/backup.) Is there some trick/3rd party script to create /etc/init.d wrappers/scripts to make all the services work with the old path? Something like: ln -s /lib/systemd/system/.service /etc/init.d/ Or maybe a shell script like: service=`basename "$0"` systemctl $1 $service So I would like to move forward with systemd (and will eventually have to if I want modern/supported OSs), but systemd seems harde
Re: [systemd-devel] How to get used to systemd vs init
On Tue, Jun 23, 2015 at 10:16 PM, Chad wrote: > On 6/23/2015 1:01 PM, Reindl Harald wrote: >> >> >> >> Am 23.06.2015 um 21:45 schrieb Chad: >>> >>> The new systemd way would be to type (23 total characters, no tab >>> complete): >>> systemctl restart httpd >>> Maybe I could tab complete systemctl, but I don't currently have a >>> CentOS 7 system to test on. >> >> >> maybe you should just install CentOS inside a VM and test it >> >> [root@srv-rhsoft:~]$ systemctl restart h >> halt-local.service haveged.service home.mount >> hostapd-guest.service >> httpd-lounge-worker.service hybrid-sleep.target >> halt.target hibernate.target >> hostapd-guest-interface.service hostapd.service httpd.service >> >> >>> The real issue is that I have to know (in the above example) that it is >>> httpd not http. >>> With so many systems, distros, and services it is hard to remember every >>> service name exactly (and some names are very long). For example ntpd >>> has a d, but nfs does not. >>> Tab completion fixes this issue for me. >>> >>> How can I use tab completion with systemd? >> >> >> as like for any other software - hit the TAB key >> >>> # >>> 2. How to find all possible services: >>> >>> The init way: >>> ls -l /etc/init/d >>> >>> The systemd way: >>> ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service >>> >>> This seems WAY harder and I have to remember 2 locations instead of 1 >> >> >> nobody but you installs systemd-units in /etc/ and so you have only one >> location AND customized ones - with sysvinit you >> had no way to override /etc/init.d/httpd without doing the work after each >> update again >> > > Harald, > Thank you for your reply and time. > > I will make some time at some point to install CentOS 7 again, I just don't > have one installed right now. > > #1 I did not know you could tab complete that way! i.e. as part of a command > argument, not just as part of a path. > Guess I learned something new after 20 years :) > > #2 I can see the advantages of having a local override just like /usr/bin > has /usr/local/bin. > Out of curiosity is there a reason the team did not follow the local pattern > with something like: /lib/systemd/local/system? > It is easy enough to create an alias on systems I use often, it will just > take time to learn/memorize the new paths, I am so used to /etc/init.d. > See http://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ for why /lib/ is not used anymore. Anyway, /usr is considered to be vendor specific (what your distro provides you) and you should not modify it. /etc, in the other hand, is entirely for you. If you want to override a unit configuration, you do not modify /usr/lib/systemd/system/foobar.service but you put your version in /etc/systemd/system/foobar.service. Then you reload the units via systemctl daemon-reload. systemctl also provides a simple tool to do this: systemctl edit --full foobar.service It will copy the unit in /etc and open your editor. When you save and quit, it will automatically run systemctl daemon-reload. You can also only modify just one directive of a unit file by using: systemctl edit foobar.service It will create /etc/systemd/system/foobar.service.d/override.conf and open your editor. In this file you just have to put the lines/directives that you want to modify from the original one, without having to edit the entire unit. > ^C > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On Tue, Jun 23, 2015 at 9:45 PM, Chad wrote: > I am sure this is the wrong place to send this e-mail, but I could not find > another place to send it. Hi, It is the good place :) > I want to learn and use systemd, but have run into a few problems on my way. > Please don't see this as an attack on systemd, I want to learn something > new, but change is hard. > > I am an old school kind of sysadmin and I am planning on moving from CentOS > 6 to CentOS 7, but I am having trouble with systemd. I am hoping you know > some shortcuts/tricks to help me learn the new way. > > # > 1. I can't spell. With init I don't have to know how to spell things because > I have tab complete. I use tab complete for almost every command I type. For > example: > /e gets -> /etc/ > /etc/in gets -> /etc/init > /etc/init. gets -> /etc/init.d/ > /etc/init.d/ht /etc/init.d/httpd > /etc/init.d/httpd restart > So I entered 19 characters and got 25 with tab complete. > > The new systemd way would be to type (23 total characters, no tab complete): > systemctl restart httpd > Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 > system to test on. > > The real issue is that I have to know (in the above example) that it is > httpd not http. > With so many systems, distros, and services it is hard to remember every > service name exactly (and some names are very long). For example ntpd has a > d, but nfs does not. > Tab completion fixes this issue for me. > > How can I use tab completion with systemd? If you use either bash or zsh, systemd provides shell completion for them. You could do something like: systemctl start htt systemctl st or else, and it will complete it. > > > # > 2. How to find all possible services: > > The init way: > ls -l /etc/init/d > > The systemd way: > ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service > > This seems WAY harder and I have to remember 2 locations instead of 1. There is: systemctl list-unit-files It lists all the units installed on your system. In systemd a unit is a configuration file that can describe a service, a mount point, a device,... So a service is a subtype of unit, see "man 5 systemd.unit" for more information. So if you want to only display the services, you just have to specify the type systemctl list-unit-files --type=service > > # > 3. List all services and their start levels: > In systemd world, start levels equivalent are the targets (see man 5 systemd.target). A target is a synchronisation point between multiple units. For example, there is sysinit.target which is the synchronization point for early boot services. This way a unit can ask to be started only after a specific target, for example. > The init way (all services): > chkconfig --list > > The init way (only active services. I use this a lot): > chkconfig --list | grep :on > > The systemd way (all services): > systemctl list-unit-files --type=service > > The systemd way (only active services, I don't know how to do this). > systemctl ??? > With systemctl you can provide a filter according to the current state of a unit. If you want to list all the active service, you can do: systemctl --state=active --type=service list-units > > # > 4. What about the many programs that rely on /etc/init.d/ > status/start/stop/restart > I have many services that are monitored by nagios or cron jobs (like > logrotate) that rely on /etc/init.d/ status/start/stop/restart. > I don't want to change them because right now they work on every server and > I don't want to have to maintain 2 versions of the code or hunt them all > down. There is systemd-sysv-generator which creates wrapper .service for sysv scripts automatically at boot. But you need to specify additional headers if you want to use ordering. See man systemd-sysv-generator. > Is there some trick/3rd party script to create /etc/init.d wrappers/scripts > to make all the services work with the old path? > Something like: > ln -s /lib/systemd/system/.service /etc/init.d/ > Or maybe a shell script like: > service=`basename "$0"` > systemctl $1 $service > > So I would like to move forward with systemd (and will eventually have to if > I want modern/supported OSs), but systemd seems harder to deal with and will > break a lot of my existing scripts/cronjobs/monitors. > > > Thank you all for your work on FOSS, you are making the world a better > place!! > > -- > > ^C > Chad Columbus > 20 years of application development and sysadmin > Currently maintaining about 30 CentOS 6 servers. > Have maintained over 1,000 linux servers over the years. > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to get used to systemd vs init
On 6/23/2015 1:01 PM, Reindl Harald wrote: Am 23.06.2015 um 21:45 schrieb Chad: The new systemd way would be to type (23 total characters, no tab complete): systemctl restart httpd Maybe I could tab complete systemctl, but I don't currently have a CentOS 7 system to test on. maybe you should just install CentOS inside a VM and test it [root@srv-rhsoft:~]$ systemctl restart h halt-local.service haveged.service home.mount hostapd-guest.service httpd-lounge-worker.service hybrid-sleep.target halt.target hibernate.target hostapd-guest-interface.service hostapd.service httpd.service The real issue is that I have to know (in the above example) that it is httpd not http. With so many systems, distros, and services it is hard to remember every service name exactly (and some names are very long). For example ntpd has a d, but nfs does not. Tab completion fixes this issue for me. How can I use tab completion with systemd? as like for any other software - hit the TAB key # 2. How to find all possible services: The init way: ls -l /etc/init/d The systemd way: ls -l /lib/systemd/system/*.service /etc/systemd/system/*.service This seems WAY harder and I have to remember 2 locations instead of 1 nobody but you installs systemd-units in /etc/ and so you have only one location AND customized ones - with sysvinit you had no way to override /etc/init.d/httpd without doing the work after each update again Harald, Thank you for your reply and time. I will make some time at some point to install CentOS 7 again, I just don't have one installed right now. #1 I did not know you could tab complete that way! i.e. as part of a command argument, not just as part of a path. Guess I learned something new after 20 years :) #2 I can see the advantages of having a local override just like /usr/bin has /usr/local/bin. Out of curiosity is there a reason the team did not follow the local pattern with something like: /lib/systemd/local/system? It is easy enough to create an alias on systems I use often, it will just take time to learn/memorize the new paths, I am so used to /etc/init.d. ^C ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel