From Fedora Project Wiki
(Fix up grammar. Because of UsrMove, add both %{_bindir} and /bin/ paths)
(wiki syntax)
 
(One intermediate revision by the same user 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: man 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 sysadmins, we need to first determine if relevant lines are already in the file.
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":
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":


<pre>
<pre>

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