From Fedora Project Wiki
m (Finalization for review.)
(wiki syntax)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Preamble =
= Preamble =
/etc/shells is a text file which controls system login shell of users. It contains a set of valid shells which can be used in the system.
<code>/etc/shells</code> is a text file which controls system login shell of users. It contains a set of valid shells which can be used in the system.


See: SHELLS(5)
See: <code>man 5 SHELLS</code> for more information.


= How to handle new shells in Fedora packages =
= How to handle new shells in Fedora packages =
As this file can be edited by any people as default, we need to first determine if relevant lines are already existed.
As this file can be edited by sysadmins, we need to first determine if relevant lines are already in the file.
If existed already, then just echo relevant binary path to the file. Thus, here is an example of package with shell "foo" underneath /usr/bin:
If they don't already exist then we just need to echo the shell's binary path to the file. Since Fedora 17 and later make <code>/bin</code> a symlink to <code>/usr/bin</code> we need to place both paths into the <code>/etc/shells</code> file.  Here is an example of the scriptlet to package with shell named "foo":


<code>
<pre>
%post
%post
if [ "$1" = 1 ]; then
if [ "$1" = 1 ]; then
    if [ ! -f %{_sysconfdir}/shells ] ; then
  if [ ! -f %{_sysconfdir}/shells ] ; then
        echo "%{_bindir}/foo" > %{_sysconfdir}/shells
    echo "%{_bindir}/foo" > %{_sysconfdir}/shells
    echo "/bin/foo" >> %{_sysconfdir}/shells
   else
   else
     grep -q "^%{_bindir}/foo$" %{_sysconfdir}/shells || echo "%{_bindir}/foo" >> %{_sysconfdir}/shells
     grep -q "^%{_bindir}/foo$" %{_sysconfdir}/shells || echo "%{_bindir}/foo" >> %{_sysconfdir}/shells
    grep -q "^/bin/foo$" %{_sysconfdir}/shells || echo "/bin/foo" >> %{_sysconfdir}/shells
fi
fi


%postun
%postun
if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
    sed -i '\!^%{_bindir}/foo$!d' %{_sysconfdir}/shells
  sed -i '\!^%{_bindir}/foo$!d' %{_sysconfdir}/shells
  sed -i '\!^/bin/foo$!d' %{_sysconfdir}/shells
fi
fi
</code>
</pre>


[[Category:Packaging guidelines drafts]]
[[Category:Packaging guidelines drafts]]

Latest revision as of 07:29, 20 February 2014

Preamble

/etc/shells is a text file which controls system login shell of users. It contains a set of valid shells which can be used in the system.

See: man 5 SHELLS for more information.

How to handle new shells in Fedora packages

As this file can be edited by sysadmins, we need to first determine if relevant lines are already in the file. If they don't already exist then we just need to echo the shell's binary path to the file. Since Fedora 17 and later make /bin a symlink to /usr/bin we need to place both paths into the /etc/shells file. Here is an example of the scriptlet to package with shell named "foo":

%post
if [ "$1" = 1 ]; then
  if [ ! -f %{_sysconfdir}/shells ] ; then
    echo "%{_bindir}/foo" > %{_sysconfdir}/shells
    echo "/bin/foo" >> %{_sysconfdir}/shells
  else
    grep -q "^%{_bindir}/foo$" %{_sysconfdir}/shells || echo "%{_bindir}/foo" >> %{_sysconfdir}/shells
    grep -q "^/bin/foo$" %{_sysconfdir}/shells || echo "/bin/foo" >> %{_sysconfdir}/shells
fi

%postun
if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
  sed -i '\!^%{_bindir}/foo$!d' %{_sysconfdir}/shells
  sed -i '\!^/bin/foo$!d' %{_sysconfdir}/shells
fi