Deprecated /etc/sysconfig/nfs
Remove nfs server legacy systemd unit files Signed-off-by: Steve Dickson <steved@redhat.com>
This commit is contained in:
parent
2526b0af60
commit
9c46e381f9
22
nfs-convert.service
Normal file
22
nfs-convert.service
Normal file
@ -0,0 +1,22 @@
|
||||
[Unit]
|
||||
Description=Preprocess NFS configuration convertion
|
||||
DefaultDependencies=no
|
||||
|
||||
Before=nfs-server.service nfs-mountd.service nfs-idmapd.service
|
||||
Before=nfs-blkmap.service rpc-statd.service rpc-gssd.service
|
||||
Before=rpc-statd-notify.service
|
||||
|
||||
After=initrd-root-fs.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/nfs-utils/nfsconvert.sh
|
||||
|
||||
[Install]
|
||||
RequiredBy=nfs-server.service
|
||||
RequiredBy=nfs-mountd.service
|
||||
RequiredBy=nfs-idmapd.service
|
||||
RequiredBy=nfs-blkmap.service
|
||||
RequiredBy=rpc-statd.service
|
||||
RequiredBy=rpc-gssd.service
|
||||
RequiredBy=rpc-statd-notify.service
|
@ -4,7 +4,7 @@ diff -up nfs-utils-2.3.1/systemd/nfs-server.service.orig nfs-utils-2.3.1/systemd
|
||||
@@ -26,6 +26,7 @@ Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStartPre=/usr/sbin/exportfs -r
|
||||
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS
|
||||
ExecStart=/usr/sbin/rpc.nfsd
|
||||
+ExecStart=-/bin/sh -c 'if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi'
|
||||
ExecStop=/usr/sbin/rpc.nfsd 0
|
||||
ExecStopPost=/usr/sbin/exportfs -au
|
||||
|
21
nfs-utils-2.3.3-nfsconf-usegssproxy.patch
Normal file
21
nfs-utils-2.3.3-nfsconf-usegssproxy.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff -up nfs-utils-2.3.3/nfs.conf.orig nfs-utils-2.3.3/nfs.conf
|
||||
--- nfs-utils-2.3.3/nfs.conf.orig 2018-10-31 12:09:28.905622992 -0400
|
||||
+++ nfs-utils-2.3.3/nfs.conf 2018-10-31 12:13:28.843301421 -0400
|
||||
@@ -11,7 +11,7 @@
|
||||
[gssd]
|
||||
# use-memcache=0
|
||||
# use-machine-creds=1
|
||||
-# use-gss-proxy=0
|
||||
+use-gss-proxy=1
|
||||
# avoid-dns=1
|
||||
# limit-to-legacy-enctypes=0
|
||||
# context-timeout=0
|
||||
@@ -69,6 +69,5 @@
|
||||
# outgoing-port=
|
||||
# outgoing-addr=
|
||||
# lift-grace=y
|
||||
-#
|
||||
-[svcgssd]
|
||||
-# principal=
|
||||
+
|
||||
+#tag1234 - Used for install purposes only
|
@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
|
||||
Name: nfs-utils
|
||||
URL: http://linux-nfs.org/
|
||||
Version: 2.3.3
|
||||
Release: 1.rc1%{?dist}
|
||||
Release: 2.rc1%{?dist}
|
||||
Epoch: 1
|
||||
|
||||
# group all 32bit related archs
|
||||
@ -11,18 +11,20 @@ Epoch: 1
|
||||
Source0: https://www.kernel.org/pub/linux/utils/nfs-utils/%{version}/%{name}-%{version}.tar.xz
|
||||
Source1: id_resolver.conf
|
||||
Source2: nfs.sysconfig
|
||||
Source3: nfs-utils_env.sh
|
||||
Source4: lockd.conf
|
||||
Source5: 24-nfs-server.conf
|
||||
Source3: lockd.conf
|
||||
Source4: 24-nfs-server.conf
|
||||
Source5: nfsconvert.py
|
||||
Source6: nfsconvert.sh
|
||||
Source7: nfs-convert.service
|
||||
|
||||
Patch001: nfs-utils.2.3.4-rc1.patch
|
||||
|
||||
Patch100: nfs-utils-1.2.1-statdpath-man.patch
|
||||
Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch
|
||||
Patch102: nfs-utils-1.2.5-idmap-errmsg.patch
|
||||
Patch103: nfs-utils-2.1.1-nfs-config.patch
|
||||
Patch104: nfs-utils-2.3.1-systemd-gssproxy-restart.patch
|
||||
Patch105: nfs-utils-2.3.3-man-tcpwrappers.patch
|
||||
Patch103: nfs-utils-2.3.1-systemd-gssproxy-restart.patch
|
||||
Patch104: nfs-utils-2.3.3-man-tcpwrappers.patch
|
||||
Patch105: nfs-utils-2.3.3-nfsconf-usegssproxy.patch
|
||||
|
||||
Provides: exportfs = %{epoch}:%{version}-%{release}
|
||||
Provides: nfsstat = %{epoch}:%{version}-%{release}
|
||||
@ -147,23 +149,15 @@ install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/request-key.d
|
||||
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/nfs
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/run/sysconfig
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/scripts
|
||||
install -m 755 %{SOURCE3} $RPM_BUILD_ROOT/%{_libexecdir}/nfs-utils/nfs-utils_env.sh
|
||||
install -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/lockd.conf
|
||||
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/gssproxy
|
||||
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/lockd.conf
|
||||
install -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/gssproxy
|
||||
install -m 755 %{SOURCE5} $RPM_BUILD_ROOT%{_sbindir}/nfsconvert
|
||||
install -m 755 %{SOURCE6} $RPM_BUILD_ROOT/%{_libexecdir}/nfs-utils/nfsconvert.sh
|
||||
install -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{_pkgdir}/system
|
||||
|
||||
rm -rf $RPM_BUILD_ROOT%{_libdir}/*.{a,la}
|
||||
rm -rf $RPM_BUILD_ROOT%{_libdir}/libnfsidmap/*.{a,la}
|
||||
|
||||
#
|
||||
# For backwards compatablity
|
||||
#
|
||||
cd $RPM_BUILD_ROOT%{_unitdir}
|
||||
ln -s nfs-server.service nfs.service
|
||||
ln -s rpc-gssd.service nfs-secure.service
|
||||
ln -s nfs-idmapd.service nfs-idmap.service
|
||||
ln -s rpc-statd.service nfs-lock.service
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rpc_pipefs
|
||||
|
||||
touch $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rmtab
|
||||
@ -227,7 +221,12 @@ if [ $1 -eq 1 ] ; then
|
||||
/bin/systemctl enable nfs-client.target >/dev/null 2>&1 || :
|
||||
/bin/systemctl start nfs-client.target >/dev/null 2>&1 || :
|
||||
fi
|
||||
%systemd_post nfs-config
|
||||
|
||||
# Check to see if converting to /etc/nfs.conf is needed
|
||||
grep "nfs.conf" /etc/sysconfig/nfs > /dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
/bin/systemctl enable nfs-convert >/dev/null 2>&1 || :
|
||||
fi
|
||||
%systemd_post nfs-server
|
||||
|
||||
%preun
|
||||
@ -248,6 +247,9 @@ fi
|
||||
%triggerin -- nfs-utils > 1:2.1.1-3
|
||||
/bin/systemctl try-restart gssproxy || :
|
||||
|
||||
%triggerpostun -- nfs-utils < 1:2.3.3.2
|
||||
/usr/bin/chattr -i %{_sysconfdir}/sysconfig/nfs || :
|
||||
|
||||
%files
|
||||
%config(noreplace) /etc/sysconfig/nfs
|
||||
%config(noreplace) /etc/nfsmount.conf
|
||||
@ -285,11 +287,13 @@ fi
|
||||
%{_sbindir}/nfsidmap
|
||||
%{_sbindir}/blkmapd
|
||||
%{_sbindir}/nfsconf
|
||||
%{_sbindir}/nfsconvert
|
||||
%{_mandir}/*/*
|
||||
%{_pkgdir}/*/*
|
||||
%attr(755,root,root) %{_libexecdir}/nfs-utils/nfs-utils_env.sh
|
||||
|
||||
%attr(4755,root,root) /sbin/mount.nfs
|
||||
%attr(755,root,root) %{_libexecdir}/nfs-utils/nfsconvert.sh
|
||||
|
||||
/sbin/mount.nfs4
|
||||
/sbin/umount.nfs
|
||||
/sbin/umount.nfs4
|
||||
@ -309,6 +313,10 @@ fi
|
||||
%{_libdir}/libnfsidmap.so
|
||||
|
||||
%changelog
|
||||
* Mon Nov 5 2018 Steve Dickson <steved@redhat.com> 2.3.3-2.rc1
|
||||
- Deprecated /etc/sysconfig/nfs
|
||||
- Remove nfs server legacy systemd unit files
|
||||
|
||||
* Sat Oct 27 2018 Steve Dickson <steved@redhat.com> 2.3.3-1.rc1
|
||||
- Changed /var/lib/nfs/rpc_pipefs to have 555 permissions
|
||||
- Removed tcp wrappers support from man pages
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Extract configuration from /etc/sysconfig/nfs and write
|
||||
# environment variables to /run/sysconfig/nfs-utils to be
|
||||
# used by systemd nfs-config service
|
||||
#
|
||||
|
||||
nfs_config=/etc/sysconfig/nfs
|
||||
if test -r $nfs_config; then
|
||||
. $nfs_config
|
||||
fi
|
||||
|
||||
if [ -n "$NFSD_V4_GRACE" ]; then
|
||||
grace="-G $NFSD_V4_GRACE"
|
||||
fi
|
||||
|
||||
if [ -n "$NFSD_V4_LEASE" ]; then
|
||||
lease="-L $NFSD_V4_LEASE"
|
||||
fi
|
||||
|
||||
if [ -n "$RPCNFSDCOUNT" ]; then
|
||||
nfsds=$RPCNFSDCOUNT
|
||||
else
|
||||
nfsds=8
|
||||
fi
|
||||
|
||||
if [ -n "$RPCNFSDARGS" ]; then
|
||||
nfsdargs="$RPCNFSDARGS $grace $lease $nfsds"
|
||||
else
|
||||
nfsdargs="$grace $lease $nfsds"
|
||||
fi
|
||||
|
||||
mkdir -p /run/sysconfig
|
||||
{
|
||||
echo RPCNFSDARGS=\"$nfsdargs\"
|
||||
echo RPCMOUNTDARGS=\"$RPCMOUNTDOPTS\"
|
||||
echo STATDARGS=\"$STATDARGS\"
|
||||
echo SMNOTIFYARGS=\"$SMNOTIFYARGS\"
|
||||
echo RPCIDMAPDARGS=\"$RPCIDMAPDARGS\"
|
||||
echo RPCGSSDARGS=\"$RPCGSSDARGS\"
|
||||
echo RPCSVCGSSDARGS=\"$RPCSVCGSSDARGS\"
|
||||
echo BLKMAPDARGS=\"$BLKMAPDARGS\"
|
||||
echo GSS_USE_PROXY=\"$GSS_USE_PROXY\"
|
||||
} > /run/sysconfig/nfs-utils
|
322
nfsconvert.py
Normal file
322
nfsconvert.py
Normal file
@ -0,0 +1,322 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Read in the deprecated /etc/sysconfig/nfs file and
|
||||
set the corresponding values in nfs.conf
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import subprocess
|
||||
import configparser
|
||||
|
||||
CONF_NFS = '/etc/nfs.conf'
|
||||
CONF_IDMAP = '/etc/idmapd.conf'
|
||||
SYSCONF_NFS = '/etc/sysconfig/nfs'
|
||||
SYSCONF_BACKUP = ".rpmsave"
|
||||
CONF_TOOL = '/usr/sbin/nfsconf'
|
||||
|
||||
# options for nfsd found in RPCNFSDARGS
|
||||
OPTS_NFSD = 'dH:p:rR:N:V:stTuUG:L:'
|
||||
LONG_NFSD = ['debug', 'host=', 'port=', 'rdma=', 'nfs-version=', 'no-nfs-version=',
|
||||
'tcp', 'no-tcp', 'udp', 'no-udp', 'grace-time=', 'lease-time=']
|
||||
CONV_NFSD = {'-d': (CONF_NFS, 'nfsd', 'debug', 'all'),
|
||||
'-H': (CONF_NFS, 'nfsd', 'host', ','),
|
||||
'-p': (CONF_NFS, 'nfsd', 'port', '$1'),
|
||||
'-r': (CONF_NFS, 'nfsd', 'rdma', 'nfsrdma'),
|
||||
'-R': (CONF_NFS, 'nfsd', 'rdma', '$1'),
|
||||
'-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
|
||||
'-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
|
||||
'-t': (CONF_NFS, 'nfsd', 'tcp', '1'),
|
||||
'-T': (CONF_NFS, 'nfsd', 'tcp', '0'),
|
||||
'-u': (CONF_NFS, 'nfsd', 'udp', '1'),
|
||||
'-U': (CONF_NFS, 'nfsd', 'udp', '0'),
|
||||
'-G': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
|
||||
'-L': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
|
||||
'$1': (CONF_NFS, 'nfsd', 'threads', '$1'),
|
||||
'--debug': (CONF_NFS, 'nfsd', 'debug', 'all'),
|
||||
'--host': (CONF_NFS, 'nfsd', 'host', ','),
|
||||
'--port': (CONF_NFS, 'nfsd', 'port', '$1'),
|
||||
'--rdma': (CONF_NFS, 'nfsd', 'rdma', '$1'),
|
||||
'--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
|
||||
'--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
|
||||
'--tcp': (CONF_NFS, 'nfsd', 'tcp', '1'),
|
||||
'--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
|
||||
'--udp': (CONF_NFS, 'nfsd', 'udp', '1'),
|
||||
'--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
|
||||
'--grace-time': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
|
||||
'--lease-time': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
|
||||
}
|
||||
|
||||
# options for mountd found in RPCMOUNTDOPTS
|
||||
OPTS_MOUNTD = 'go:d:H:p:N:nrs:t:V:'
|
||||
LONG_MOUNTD = ['descriptors=', 'debug=', 'nfs-version=', 'no-nfs-version=',
|
||||
'port=', 'no-tcp', 'ha-callout=', 'state-directory-path=',
|
||||
'num-threads=', 'reverse-lookup', 'manage-gids', 'no-udp']
|
||||
|
||||
CONV_MOUNTD = {'-g': (CONF_NFS, 'mountd', 'manage-gids', '1'),
|
||||
'-o': (CONF_NFS, 'mountd', 'descriptors', '$1'),
|
||||
'-d': (CONF_NFS, 'mountd', 'debug', '$1'),
|
||||
'-H': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
|
||||
'-p': (CONF_NFS, 'mountd', 'port', '$1'),
|
||||
'-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
|
||||
'-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
|
||||
'-n': (CONF_NFS, 'nfsd', 'tcp', '0'),
|
||||
'-s': (CONF_NFS, 'mountd', 'stat-directory-path', '$1'),
|
||||
'-t': (CONF_NFS, 'mountd', 'threads', '$1'),
|
||||
'-r': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
|
||||
'-u': (CONF_NFS, 'nfsd', 'udp', '0'),
|
||||
'--manage-gids': (CONF_NFS, 'mountd', 'manage-gids', '1'),
|
||||
'--descriptors': (CONF_NFS, 'mountd', 'descriptors', '$1'),
|
||||
'--debug': (CONF_NFS, 'mountd', 'debug', '$1'),
|
||||
'--ha-callout': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
|
||||
'--port': (CONF_NFS, 'mountd', 'port', '$1'),
|
||||
'--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
|
||||
'--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
|
||||
'--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
|
||||
'--state-directory-path': (CONF_NFS, 'mountd', 'state-directory-path', '$1'),
|
||||
'--num-threads': (CONF_NFS, 'mountd', 'threads', '$1'),
|
||||
'--reverse-lookup': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
|
||||
'--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
|
||||
}
|
||||
|
||||
# options for statd found in STATDARG
|
||||
OPTS_STATD = 'o:p:T:U:n:P:H:'
|
||||
LONG_STATD = ['outgoing-port=', 'port=', 'name=', 'state-directory-path=',
|
||||
'ha-callout=', 'nlm-port=', 'nlm-udp-port=']
|
||||
CONV_STATD = {'-o': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
|
||||
'-p': (CONF_NFS, 'statd', 'port', '$1'),
|
||||
'-T': (CONF_NFS, 'lockd', 'port', '$1'),
|
||||
'-U': (CONF_NFS, 'lockd', 'udp-port', '$1'),
|
||||
'-n': (CONF_NFS, 'statd', 'name', '$1'),
|
||||
'-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
|
||||
'-H': (CONF_NFS, 'statd', 'ha-callout', '$1'),
|
||||
'--outgoing-port': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
|
||||
'--port': (CONF_NFS, 'statd', 'port', '$1'),
|
||||
'--name': (CONF_NFS, 'statd', 'name', '$1'),
|
||||
'--state-directory-path': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
|
||||
'--ha-callout': (CONF_NFS, 'statd', 'ha-callout', '$1'),
|
||||
'--nlm-port': (CONF_NFS, 'lockd', 'port', '$1'),
|
||||
'--nlm-udp-port': (CONF_NFS, 'lockd', 'udp-port', '$1'),
|
||||
}
|
||||
|
||||
# options for sm-notify found in SMNOTIFYARGS
|
||||
OPTS_SMNOTIFY = 'dm:np:v:P:'
|
||||
CONV_SMNOTIFY = {'-d': (CONF_NFS, 'sm-notify', 'debug', 'all'),
|
||||
'-m': (CONF_NFS, 'sm-notify', 'retry-time', '$1'),
|
||||
'-n': (CONF_NFS, 'sm-notify', 'update-state', '1'),
|
||||
'-p': (CONF_NFS, 'sm-notify', 'outgoing-port', '$1'),
|
||||
'-v': (CONF_NFS, 'sm-notify', 'outgoing-addr', '$1'),
|
||||
'-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
|
||||
}
|
||||
|
||||
# options for idmapd found in RPCIDMAPDARGS
|
||||
OPTS_IDMAPD = 'vp:CS'
|
||||
CONV_IDMAPD = {'-v': (CONF_IDMAP, 'general', 'verbosity', '+'),
|
||||
'-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
|
||||
'-C': (CONF_IDMAP, 'general', 'client-only', '1'),
|
||||
'-S': (CONF_IDMAP, 'general', 'server-only', '1'),
|
||||
}
|
||||
|
||||
# options for gssd found in RPCGSSDARGS
|
||||
OPTS_GSSD = 'Mnvrp:k:d:t:T:R:lD'
|
||||
CONV_GSSD = {'-M': (CONF_NFS, 'gssd', 'use-memcache', '1'),
|
||||
'-n': (CONF_NFS, 'gssd', 'root_uses_machine_creds', '0'),
|
||||
'-v': (CONF_NFS, 'gssd', 'verbosity', '+'),
|
||||
'-r': (CONF_NFS, 'gssd', 'rpc-verbosity', '+'),
|
||||
'-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
|
||||
'-k': (CONF_NFS, 'gssd', 'keytab-file', '$1'),
|
||||
'-d': (CONF_NFS, 'gssd', 'cred-cache-directory', '$1'),
|
||||
'-t': (CONF_NFS, 'gssd', 'context-timeout', '$1'),
|
||||
'-T': (CONF_NFS, 'gssd', 'rpc-timeout', '$1'),
|
||||
'-R': (CONF_NFS, 'gssd', 'preferred-realm', '$1'),
|
||||
'-l': (CONF_NFS, 'gssd', 'limit-to-legacy-enctypes', '0'),
|
||||
'-D': (CONF_NFS, 'gssd', 'avoid-dns', '0'),
|
||||
}
|
||||
|
||||
# options for blkmapd found in BLKMAPDARGS
|
||||
OPTS_BLKMAPD = ''
|
||||
CONV_BLKMAPD = {}
|
||||
|
||||
# meta list of all the getopt lists
|
||||
GETOPT_MAPS = [('RPCNFSDARGS', OPTS_NFSD, LONG_NFSD, CONV_NFSD),
|
||||
('RPCMOUNTDOPTS', OPTS_MOUNTD, LONG_MOUNTD, CONV_MOUNTD),
|
||||
('STATDARG', OPTS_STATD, LONG_STATD, CONV_STATD),
|
||||
('STATDARGS', OPTS_STATD, LONG_STATD, CONV_STATD),
|
||||
('SMNOTIFYARGS', OPTS_SMNOTIFY, [], CONV_SMNOTIFY),
|
||||
('RPCIDMAPDARGS', OPTS_IDMAPD, [], CONV_IDMAPD),
|
||||
('RPCGSSDARGS', OPTS_GSSD, [], CONV_GSSD),
|
||||
('BLKMAPDARGS', OPTS_BLKMAPD, [], CONV_BLKMAPD),
|
||||
]
|
||||
|
||||
# map for all of the single option values
|
||||
VALUE_MAPS = {'LOCKD_TCPPORT': (CONF_NFS, 'lockd', 'port', '$1'),
|
||||
'LOCKD_UDPPORT': (CONF_NFS, 'lockd', 'udp-port', '$1'),
|
||||
'RPCNFSDCOUNT': (CONF_NFS, 'nfsd', 'threads', '$1'),
|
||||
'NFSD_V4_GRACE': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
|
||||
'NFSD_V4_LEASE': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
|
||||
'MOUNTD_PORT': (CONF_NFS, 'mountd', 'port', '$1'),
|
||||
'STATD_PORT': (CONF_NFS, 'statd', 'port', '$1'),
|
||||
'STATD_OUTGOING_PORT': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
|
||||
'STATD_HA_CALLOUT': (CONF_NFS, 'statd', 'ha-callout', '$1'),
|
||||
'GSS_USE_PROXY': (CONF_NFS, 'gssd', 'use-gss-proxy', '$1')
|
||||
}
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
""" Print error to stderr """
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
def makesub(param, value):
|
||||
""" Variable substitution """
|
||||
return param.replace('$1', value)
|
||||
|
||||
def set_value(value, entry):
|
||||
""" Set a configuration value by running nfsconf tool"""
|
||||
cfile, section, tag, param = entry
|
||||
|
||||
tag = makesub(tag, value)
|
||||
param = makesub(param, value)
|
||||
if param == '+':
|
||||
param = value
|
||||
if param == ',':
|
||||
param = value
|
||||
args = [CONF_TOOL, "--file", cfile, "--set", section, tag, param]
|
||||
|
||||
try:
|
||||
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error running nfs-conf tool:\n %s" % (e.output.decode()))
|
||||
print("Args: %s\n" % args)
|
||||
raise Exception
|
||||
|
||||
def convert_getopt(optname, options, optstring, longopts, conversions):
|
||||
""" Parse option string into seperate config items
|
||||
|
||||
Take a getopt string and a table of conversions
|
||||
parse it all and spit out the converted config
|
||||
|
||||
Keyword arguments:
|
||||
options -- the argv string to convert
|
||||
optstring -- getopt format option list
|
||||
conversions -- table of translations
|
||||
"""
|
||||
optcount = 0
|
||||
try:
|
||||
args = options.strip('\"').split()
|
||||
optlist, optargs = getopt.gnu_getopt(args, optstring, longopts=longopts)
|
||||
except getopt.GetoptError as err:
|
||||
eprint(err)
|
||||
raise Exception
|
||||
|
||||
setlist = {}
|
||||
for (k, v) in optlist:
|
||||
if k in conversions:
|
||||
# it's already been set once
|
||||
param = conversions[k][3]
|
||||
tag = k + makesub(conversions[k][2], v)
|
||||
if tag in setlist:
|
||||
value = setlist[tag][0]
|
||||
# is it a cummulative entry
|
||||
if param == '+':
|
||||
value = str(int(value) + 1)
|
||||
if param == ',':
|
||||
value += "," + v
|
||||
else:
|
||||
if param == '+':
|
||||
value = "1"
|
||||
elif param == ',':
|
||||
value = v
|
||||
else:
|
||||
value = v
|
||||
setlist[tag] = (value, conversions[k])
|
||||
else:
|
||||
if v:
|
||||
eprint("Ignoring unrecognised option %s=%s in %s" % (k, v, optname))
|
||||
else:
|
||||
eprint("Ignoring unrecognised option %s in %s" % (k, optname))
|
||||
|
||||
|
||||
for v, c in setlist.values():
|
||||
try:
|
||||
set_value(v, c)
|
||||
optcount += 1
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
i = 1
|
||||
for o in optargs:
|
||||
opname = '$' + str(i)
|
||||
if opname in conversions:
|
||||
try:
|
||||
set_value(o, conversions[opname])
|
||||
optcount += 1
|
||||
except Exception:
|
||||
raise
|
||||
else:
|
||||
eprint("Unrecognised trailing arguments")
|
||||
raise Exception
|
||||
i += 1
|
||||
|
||||
return optcount
|
||||
|
||||
def map_values():
|
||||
""" Main function """
|
||||
mapcount = 0
|
||||
|
||||
# Lets load the old config
|
||||
with open(SYSCONF_NFS) as cfile:
|
||||
file_content = '[sysconf]\n' + cfile.read()
|
||||
sysconfig = configparser.RawConfigParser()
|
||||
sysconfig.read_string(file_content)
|
||||
|
||||
# Map all the getopt option lists
|
||||
for (name, opts, lopts, conv) in GETOPT_MAPS:
|
||||
if name in sysconfig['sysconf']:
|
||||
try:
|
||||
mapcount += convert_getopt(name, sysconfig['sysconf'][name], opts,
|
||||
lopts, conv)
|
||||
except Exception:
|
||||
eprint("Error whilst converting %s to nfsconf options." % (name))
|
||||
raise
|
||||
|
||||
# Map the single value options
|
||||
for name, opts in VALUE_MAPS.items():
|
||||
if name in sysconfig['sysconf']:
|
||||
try:
|
||||
value = sysconfig['sysconf'][name]
|
||||
set_value(value.strip('\"'), opts)
|
||||
mapcount += 1
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
# All went well, move aside the old file
|
||||
# but dont bother if there were no changes and
|
||||
# an old config file already exists
|
||||
backupfile = SYSCONF_NFS + SYSCONF_BACKUP
|
||||
if mapcount > 0 or not os.path.exists(backupfile):
|
||||
try:
|
||||
os.replace(SYSCONF_NFS, backupfile)
|
||||
except OSError as err:
|
||||
eprint("Error moving old config %s: %s" % (SYSCONF_NFS, err))
|
||||
raise
|
||||
|
||||
# Create a new dummy file
|
||||
with open(SYSCONF_NFS, 'w') as f:
|
||||
f.write("#\n")
|
||||
f.write("# This file is no longer used to configure NFS\n")
|
||||
f.write("#\n")
|
||||
f.write("# ALL configuration values are in /etc/nfs.conf. See nfs.conf(5).\n")
|
||||
f.write("#\n")
|
||||
f.write("# To set lockd kernel module parameters please see\n")
|
||||
f.write("# /etc/modprobe.d/lockd.conf\n")
|
||||
f.write("#\n")
|
||||
f.write("\n")
|
||||
|
||||
# Main routine
|
||||
try:
|
||||
map_values()
|
||||
except Exception as e:
|
||||
eprint(e)
|
||||
eprint("Conversion failed. Please correct the error and try again.")
|
||||
exit(1)
|
49
nfsconvert.sh
Normal file
49
nfsconvert.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Convert /etc/sysconfig/nfs values in /etc/nfs.conf valuse
|
||||
#
|
||||
|
||||
#
|
||||
# No file no conversion
|
||||
#
|
||||
if [ ! -f /etc/sysconfig/nfs ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# See if the conversion happen already
|
||||
#
|
||||
grep "nfs.conf" /etc/sysconfig/nfs > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f /etc/nfs.conf.rpmnew ]; then
|
||||
# See if it is the we want to use
|
||||
grep tag1234 /etc/nfs.conf.rpmnew > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
cp /etc/nfs.conf /etc/nfs.conf.rpmsave
|
||||
cat /etc/nfs.conf.rpmnew | sed '/tag123/d' > /etc/nfs.conf
|
||||
rm /etc/nfs.conf.rpmnew
|
||||
fi
|
||||
else
|
||||
cp /etc/nfs.conf /etc/nfs.conf.rpmsave
|
||||
fi
|
||||
|
||||
#
|
||||
# Do the conversion
|
||||
#
|
||||
/usr/sbin/nfsconvert
|
||||
|
||||
#
|
||||
# If successful, make the file immutable.
|
||||
# This is to ensure that configuration management
|
||||
# software gets an error trying to modify it.
|
||||
#
|
||||
# Run `chattr -i /etc/sysconfig/nfs` as root
|
||||
# to make it mutable again.
|
||||
#
|
||||
if [ $? -eq 0 ]; then
|
||||
chattr +i /etc/sysconfig/nfs
|
||||
fi
|
Loading…
Reference in New Issue
Block a user