(Fix up grammar. Because of UsrMove, add both %{_bindir} and /bin/ paths) |
|||
Line 2: | Line 2: | ||
/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. | /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: SHELLS(5) | See: man SHELLS(5) | ||
= How to handle new shells in Fedora packages = | = How to handle new shells in Fedora packages = | ||
As this file can be edited by | As this file can be edited by sysadmins, we need to first determine if relevant lines are already in the file. | ||
If | 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": | ||
<pre> | <pre> | ||
Line 13: | Line 13: | ||
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 | ||
Line 20: | Line 22: | ||
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 | ||
</pre> | </pre> | ||
[[Category:Packaging guidelines drafts]] | [[Category:Packaging guidelines drafts]] |
Revision as of 07:27, 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 SHELLS(5)
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