{"id":874,"date":"2015-05-14T12:07:54","date_gmt":"2015-05-14T19:07:54","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=874"},"modified":"2015-05-14T12:10:08","modified_gmt":"2015-05-14T19:10:08","slug":"systemd-using-systemctl-and-legacy-init-scripts","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/systemd-using-systemctl-and-legacy-init-scripts\/","title":{"rendered":"Systemd using systemctl and legacy init scripts"},"content":{"rendered":"
I recently played with the Solus Linux distribution to check out budgie on the desktop. Solus(previously evolveOS) use systemd like most distributions now do. Of course anything I test is inside a VM and I wanted to get the Virtualbox Guest Additions to work. During the guest additions install from ISO it does complain about not knowing the distribution and for the most part when the OS is not recognized Virtualbox Guest Additions install then just stick the init scripts in \/etc\/init.d and let you figure it out.<\/p>\n
Since I wanted to play with systemd a little bit here is what I did to make the guest additions scripts run at boot. \u00a0Here is a link with some comparisons between systemd and sysvinit:\u00a0https:\/\/fedoraproject.org\/wiki\/SysVinit_to_Systemd_Cheatsheet<\/p>\n
Lets add some units so systemctl can do its work.<\/p>\n
\r\n$ pwd\r\n\/usr\/lib\/systemd\/system\r\n\r\n$ cat vboxadd.service\r\n[Unit]\r\nDocumentation=man:systemd-sysv-generator(8)\r\nSourcePath=\/etc\/init.d\/vboxadd\r\nDescription=LSB: VirtualBox Linux Additions kernel modules\r\nBefore=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target\r\nConflicts=shutdown.target\r\n\r\n[Service]\r\nType=forking\r\nRestart=no\r\nTimeoutSec=5min\r\nIgnoreSIGPIPE=no\r\nKillMode=process\r\nGuessMainPID=no\r\nRemainAfterExit=yes\r\nExecStart=\/etc\/init.d\/vboxadd start\r\nExecStop=\/etc\/init.d\/vboxadd stop\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\nOk let's enable the unit.<\/p>\n
\r\n$ systemctl enable vboxadd.service\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/vboxadd.service to \/usr\/lib64\/systemd\/system\/vboxadd.service.\r\n\r\n$ systemctl status vboxadd.service\r\n\u25cf vboxadd.service - LSB: VirtualBox Linux Additions kernel modules\r\n Loaded: loaded (\/etc\/init.d\/vboxadd; enabled; vendor preset: enabled)\r\n Active: inactive (dead)\r\n Docs: man:systemd-sysv-generator(8)\r\n<\/pre>\nNow start this service.<\/p>\n
\r\n$ systemctl start vboxadd.service\r\n<\/pre>\nAnd check it's status.<\/p>\n
\r\n$ systemctl status vboxadd.service\r\n\u25cf vboxadd.service - LSB: VirtualBox Linux Additions kernel modules\r\n Loaded: loaded (\/etc\/init.d\/vboxadd; enabled; vendor preset: enabled)\r\n Active: active (exited) since Thu 2015-05-14 13:39:40 CDT; 2s ago\r\n Docs: man:systemd-sysv-generator(8)\r\n Process: 610 ExecStart=\/etc\/init.d\/vboxadd start (code=exited, status=0\/SUCCESS)\r\n\r\nMay 14 13:39:40 solus vboxadd[610]: Starting the VirtualBox Guest Additions ...done.\r\n<\/pre>\nYou can now do the same for the other two init scripts namely vboxadd-service and vboxadd-x11.<\/p>\n
\r\n$ cat vboxadd-service.service\r\n[Unit]\r\nDocumentation=man:systemd-sysv-generator(8)\r\nSourcePath=\/etc\/init.d\/vboxadd-service\r\nDescription=LSB: VirtualBox Additions service\r\nBefore=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target\r\nAfter=vboxadd.service\r\nConflicts=shutdown.target\r\n\r\n[Service]\r\nType=forking\r\nRestart=no\r\nTimeoutSec=5min\r\nIgnoreSIGPIPE=no\r\nKillMode=process\r\nGuessMainPID=no\r\nRemainAfterExit=yes\r\nExecStart=\/etc\/init.d\/vboxadd-service start\r\nExecStop=\/etc\/init.d\/vboxadd-service stop\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n$ systemctl enable vboxadd-service.service\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/vboxadd-service.service to \/usr\/lib64\/systemd\/system\/vboxadd-service.service.\r\n\r\n$ systemctl start vboxadd-service.service\r\n\r\n$ systemctl status vboxadd-service.service\r\n\u25cf vboxadd-service.service - LSB: VirtualBox Additions service\r\n Loaded: loaded (\/etc\/init.d\/vboxadd-service; enabled; vendor preset: enabled)\r\n Active: active (running) since Thu 2015-05-14 13:46:01 CDT; 1s ago\r\n Docs: man:systemd-sysv-generator(8)\r\n Process: 614 ExecStart=\/etc\/init.d\/vboxadd-service start (code=exited, status=0\/SUCCESS)\r\n CGroup: \/system.slice\/vboxadd-service.service\r\n \u2514\u2500622 \/usr\/sbin\/VBoxService\r\n\r\nMay 14 13:46:01 solus vboxadd-service[614]: Starting VirtualBox Guest Addition service ...done.\r\n\r\n$ cat vboxadd-x11.service\r\n[Unit]\r\nDocumentation=man:systemd-sysv-generator(8)\r\nSourcePath=\/etc\/init.d\/vboxadd-x11\r\nDescription=LSB: VirtualBox Linux Additions kernel modules\r\n\r\n[Service]\r\nType=forking\r\nRestart=no\r\nTimeoutSec=5min\r\nIgnoreSIGPIPE=no\r\nKillMode=process\r\nGuessMainPID=no\r\nRemainAfterExit=yes\r\nExecStart=\/etc\/init.d\/vboxadd-x11 start\r\nExecStop=\/etc\/init.d\/vboxadd-x11 stop\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n$ systemctl enable vboxadd-x11.service\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/vboxadd-x11.service to \/usr\/lib64\/systemd\/system\/vboxadd-x11.service.\r\n\r\n$ systemctl start vboxadd-x11.service\r\n\r\n$ systemctl status vboxadd-x11.service\r\n\u25cf vboxadd-x11.service - LSB: VirtualBox Linux Additions kernel modules\r\n Loaded: loaded (\/etc\/init.d\/vboxadd-x11; enabled; vendor preset: enabled)\r\n Active: active (exited) since Thu 2015-05-14 13:47:04 CDT; 4s ago\r\n Docs: man:systemd-sysv-generator(8)\r\n Process: 649 ExecStart=\/etc\/init.d\/vboxadd-x11 start (code=exited, status=0\/SUCCESS)\r\n<\/pre>\nAt this point after reboot looks like systemd ran the scripts. \u00a0Let's see if the vbox scripts\/units show as a dependency for multi-user.<\/p>\n
\r\n$ systemctl show -p "Wants" multi-user.target\r\nWants=systemd-logind.service systemd-update-utmp-runlevel.service NetworkManager.service dbus.service getty.target vboxadd.service vboxadd-x11.service systemd-resolved.service vboxadd-service.service remote-fs.target systemd-ask-password-wall.path systemd-user-sessions.service\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"I recently played with the Solus Linux distribution to check out budgie on the desktop. Solus(previously evolveOS) use systemd like<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,24],"tags":[],"class_list":["post-874","post","type-post","status-publish","format-standard","hentry","category-systemd","category-virtualbox"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=874"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/874\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}