{"id":388,"date":"2016-03-01T21:57:39","date_gmt":"2016-03-02T00:57:39","guid":{"rendered":"http:\/\/wordpress.jpcorp.eti.br\/?p=388"},"modified":"2021-12-26T12:31:33","modified_gmt":"2021-12-26T15:31:33","slug":"criando-unit-systemd-para-o-samba-4-centos-7","status":"publish","type":"post","link":"https:\/\/wordpress.jpcorp.eti.br\/?p=388","title":{"rendered":"Criando Unit SystemD para o Samba 4 CentOS 7"},"content":{"rendered":"<p style=\"text-align: justify;\">Ap\u00f3s compilar o Samba 4 no CentOS precisamos criar a Unit para gerenciamento do servi\u00e7o, na documenta\u00e7\u00e3o do Samba 4 possui um <a href=\"https:\/\/wiki.samba.org\/index.php\/Samba4\/InitScript\" target=\"_blank\" rel=\"noopener\">InitScript<\/a> para rodar com SystemV ao qual pode ser criado no CentOS 7 e tamb\u00e9m controlado pelo SystemD, por\u00e9m nos packages do Samba 4 possui o script default para utilizar em SystemD, ap\u00f3s algumas horas acertando e testando encontrei a forma de utilizar.<\/p>\n<h3 style=\"text-align: justify;\">Utilizar o InitScript do SystemV no CentOS 7:<\/h3>\n<h4 style=\"text-align: justify;\">1 - Criar script<\/h4>\n<pre class=\"lang:sh decode:true \"># touch \/etc\/init.d\/samba<\/pre>\n<pre class=\"lang:sh decode:true \"># chmod +x \/etc\/init.d\/samba<\/pre>\n<pre class=\"lang:sh decode:true\"># vi \/etc\/init.d\/samba<\/pre>\n<pre class=\"lang:sh decode:true\">#!\/bin\/bash\r\n#\r\n# samba4        This shell script takes care of starting and stopping\r\n#               samba4 daemons.\r\n#\r\n# chkconfig: - 58 74\r\n# description: Samba 4.0 will be the next version of the Samba suite\r\n# and incorporates all the technology found in both the Samba4 alpha\r\n# series and the stable 3.x series. The primary additional features\r\n# over Samba 3.6 are support for the Active Directory logon protocols\r\n# used by Windows 2000 and above.\r\n\r\n### BEGIN INIT INFO\r\n# Provides: samba4\r\n# Required-Start: $network $local_fs $remote_fs\r\n# Required-Stop: $network $local_fs $remote_fs\r\n# Should-Start: $syslog $named\r\n# Should-Stop: $syslog $named\r\n# Short-Description: start and stop samba4\r\n# Description: Samba 4.0 will be the next version of the Samba suite\r\n# and incorporates all the technology found in both the Samba4 alpha\r\n# series and the stable 3.x series. The primary additional features\r\n# over Samba 3.6 are support for the Active Directory logon protocols\r\n# used by Windows 2000 and above.\r\n### END INIT INFO\r\n\r\n# Source function library.\r\n. \/etc\/init.d\/functions\r\n\r\n\r\n# Source networking configuration.\r\n. \/etc\/sysconfig\/network\r\n\r\n\r\nprog=samba\r\nprog_dir=\/usr\/local\/samba\/sbin\r\nlockfile=\/var\/lock\/subsys\/$prog\r\n\r\n\r\nstart() {\r\n        [ \"$NETWORKING\" = \"no\" ] &amp;&amp; exit 1\r\n#       [ -x \/usr\/sbin\/ntpd ] || exit 5\r\n\r\n                # Start daemons.\r\n                echo -n $\"Starting samba4: \"\r\n                daemon $prog_dir\/$prog -D\r\n        RETVAL=$?\r\n                echo\r\n        [ $RETVAL -eq 0 ] &amp;&amp; touch $lockfile\r\n        return $RETVAL\r\n}\r\n\r\n\r\nstop() {\r\n        [ \"$EUID\" != \"0\" ] &amp;&amp; exit 4\r\n                echo -n $\"Shutting down samba4: \"\r\n        killproc $prog_dir\/$prog\r\n        RETVAL=$?\r\n                echo\r\n        [ $RETVAL -eq 0 ] &amp;&amp; rm -f $lockfile\r\n        return $RETVAL\r\n}\r\n\r\n\r\n# See how we were called.\r\ncase \"$1\" in\r\nstart)\r\n        start\r\n        ;;\r\nstop)\r\n        stop\r\n        ;;\r\nstatus)\r\n        status $prog\r\n        ;;\r\nrestart)\r\n        stop\r\n        start\r\n        ;;\r\nreload)\r\n        echo \"Not implemented yet.\"\r\n        exit 3\r\n        ;;\r\n*)\r\n        echo $\"Usage: $0 {start|stop|status|restart|reload}\"\r\n        exit 2\r\nesac<\/pre>\n<h4 style=\"text-align: justify;\">\u00a02 - Criar Unit a partir do Script acima, adicionar a inicializa\u00e7\u00e3o, neste formato \u00e9 criado uma Unit que chamado o Script e gerencia o servi\u00e7o, ou seja, um gerenciamento escravo<\/h4>\n<pre class=\"lang:sh decode:true\"># chkconfig --add samba<\/pre>\n<pre class=\"lang:sh decode:true \"># chkconfig samba on<\/pre>\n<pre class=\"lang:sh decode:true\"># systemctl status samba\r\n# systemctl start samba<\/pre>\n<p><a href=\"https:\/\/wiki.samba.org\/index.php\/Samba4\/InitScript\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.samba.org\/index.php\/Samba4\/InitScript<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;\">Utilizar Unit do SystemD no CentOS 7:<\/h3>\n<h4 style=\"text-align: justify;\">1 - Criar a Unit<\/h4>\n<pre class=\"lang:sh decode:true \"># touch \/etc\/systemd\/system\/samba.service<\/pre>\n<pre class=\"lang:sh decode:true \"># vi \/etc\/systemd\/system\/samba.service<\/pre>\n<pre class=\"lang:sh decode:true \">[Unit]\r\nDescription=Samba AD Daemon\r\nAfter=syslog.target network.target\r\n\r\n[Service]\r\nType=forking\r\nNotifyAccess=all\r\nPIDFile=\/usr\/local\/samba\/var\/run\/samba.pid\r\nLimitNOFILE=16384\r\nEnvironmentFile=-\/etc\/sysconfig\/samba\r\nExecStart=\/usr\/local\/samba\/sbin\/samba -D\r\nExecReload=\/usr\/bin\/kill -HUP $MAINPID\r\nExecStop=\/usr\/bin\/killall samba\r\nRestart=on-failure\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<h4 style=\"text-align: justify;\">2 - Reiniciar daemon do SystemD e validar Unit<\/h4>\n<pre class=\"lang:sh decode:true \"># systemctl daemon-reload<\/pre>\n<pre class=\"lang:sh decode:true \"># systemctl enable samba\r\n<\/pre>\n<pre class=\"lang:sh decode:true \"># systemctl start samba\r\n<\/pre>\n<pre class=\"lang:sh decode:true \"># systemctl status samba\r\n<\/pre>\n<pre class=\"lang:sh decode:true \"># systemctl stop samba<\/pre>\n<h4>3 - Observa\u00e7\u00e3o<\/h4>\n<p>No CentOS 7 Minimal o comando \"killall\" vem no pacote \"psmisc\", portanto instalar o mesmo.<\/p>\n<p>Valide o diret\u00f3rios que se encontram o bin\u00e1rios do Samba 4.<\/p>\n<p>No pacote do Samba 4, o exemplo de Unit se encontra dentro de \"samba-4.X.X\/packaging\/systemd\/\".<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ap\u00f3s compilar o Samba 4 no CentOS precisamos criar a Unit para gerenciamento do servi\u00e7o, na documenta\u00e7\u00e3o do Samba 4 possui um InitScript para rodar com SystemV ao qual pode ser criado no CentOS 7 e tamb\u00e9m controlado pelo SystemD, por\u00e9m nos packages do Samba 4 possui o script default para utilizar em SystemD, ap\u00f3s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[9,35],"class_list":["post-388","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-samba4"],"_links":{"self":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388"}],"version-history":[{"count":6,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/388\/revisions"}],"predecessor-version":[{"id":1510,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/388\/revisions\/1510"}],"wp:attachment":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}