Browse code

Add pre install scripts to openssh, rpcbind

Change-Id: If6c344cf909b6dd7906791227a7a8f8128049784
Reviewed-on: http://photon-jenkins.eng.vmware.com/510
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: suezzelur <anishs@vmware.com>

suezzelur authored on 2016/02/06 09:41:31
Showing 2 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	'Free version of the SSH connectivity tools
2 2
 Name:		openssh
3 3
 Version:	6.6p1
4
-Release:	5%{?dist}
4
+Release:	6%{?dist}
5 5
 License:	BSD
6 6
 URL:		http://openssh.org
7 7
 Group:		System Environment/Security
... ...
@@ -18,9 +18,9 @@ BuildRequires:  krb5
18 18
 BuildRequires:  e2fsprogs-devel
19 19
 BuildRequires:  systemd
20 20
 Requires:       systemd
21
-Requires:		openssl
22
-Requires:		Linux-PAM
23
-Requires: 		shadow
21
+Requires:	openssl
22
+Requires:	Linux-PAM
23
+Requires: 	shadow
24 24
 %description
25 25
 The OpenSSH package contains ssh clients and the sshd daemon. This is
26 26
 useful for encrypting authentication and subsequent traffic over a 
... ...
@@ -91,29 +91,22 @@ EOF
91 91
 %check
92 92
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
93 93
 
94
+%pre
95
+getent group sshd >/dev/null || groupadd -g 50 sshd
96
+getent passwd sshd >/dev/null || useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd
94 97
 %preun
95 98
 /bin/systemctl disable sshd-keygen.service
96 99
 /bin/systemctl disable sshd.service
97 100
 %post
98 101
 /sbin/ldconfig
99 102
 chown -v root:sys /var/lib/sshd
100
-if ! getent group sshd >/dev/null; then
101
-	groupadd -g 50 sshd
102
-fi
103
-if ! getent passwd sshd >/dev/null; then
104
-	useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd
105
-fi
106 103
 /bin/systemctl enable sshd-keygen.service
107 104
 /bin/systemctl enable sshd.service
108 105
 
109 106
 %postun
110 107
 /sbin/ldconfig
111
-if getent passwd sshd >/dev/null; then
112
-	userdel sshd
113
-fi
114
-if getent group sshd >/dev/null; then
115
-	groupdel sshd
116
-fi
108
+%systemd_postun_with_restart sshd.service sshd-keygen.service
109
+
117 110
 %clean
118 111
 rm -rf %{buildroot}/*
119 112
 %files
... ...
@@ -134,11 +127,13 @@ rm -rf %{buildroot}/*
134 134
 %{_mandir}/man8/*
135 135
 %attr(700,root,sys)/var/lib/sshd
136 136
 %changelog
137
-*   Tue Jan 12 2016 Anish Swaminathan <anishs@vmware.com>  6.6p1-5
138
--   Change config file attributes.
139
-*   Thu Dec 10 2015 Xiaolin Li <xiaolinl@vmware.com> 6.6p1-4
140
--   Add systemd to Requires and BuildRequires.
141
--   Use systemctl to enable/disable service.
137
+*	Fri Feb 05 2016 Anish Swaminathan <anishs@vmware.com> 6.6p1-6
138
+-	Add pre install scripts in the rpm
139
+*   	Tue Jan 12 2016 Anish Swaminathan <anishs@vmware.com>  6.6p1-5
140
+-   	Change config file attributes.
141
+*   	Thu Dec 10 2015 Xiaolin Li <xiaolinl@vmware.com> 6.6p1-4
142
+-   	Add systemd to Requires and BuildRequires.
143
+-   	Use systemctl to enable/disable service.
142 144
 *	Fri Jul 17 2015 Divya Thaluru <dthaluru@vmware.com> 6.6p1-3
143 145
 -	Enabling ssh-keygen service by default and fixed service file to execute only once.
144 146
 *	Tue May 19 2015 Sharath George <sharathg@vmware.com> 6.6p1-2
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	RPC program number mapper
2 2
 Name:		rpcbind
3 3
 Version:	0.2.3
4
-Release:	3%{?dist}
4
+Release:	4%{?dist}
5 5
 License:	BSD
6 6
 URL:		http://nfsv4.bullopensource.org
7 7
 Group:	    Applications/Daemons
... ...
@@ -51,36 +51,39 @@ install -m644 %{SOURCE3} %{buildroot}/etc/sysconfig/rpcbind
51 51
 %check
52 52
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
53 53
 
54
+%pre
55
+rpcid=`getent passwd rpc | cut -d: -f 3`
56
+if [ -n "$rpcid" -a "$rpcid" != "31" ]; then
57
+	userdel  rpc 2> /dev/null || :
58
+	groupdel rpc 2> /dev/null || : 
59
+fi
60
+if [ -z "$rpcid" -o "$rpcid" != "31" ]; then
61
+	groupadd -g 31 rpc > /dev/null 2>&1
62
+	useradd -d /var/lib/rpcbind -g rpc -s /bin/false -u 31 rpc > /dev/null 2>&1
63
+fi
54 64
 %preun
55 65
 %systemd_preun rpcbind.service rpcbind.socket
66
+if [ $1 -eq 0 ]; then
67
+	userdel  rpc 2>/dev/null || :
68
+	groupdel rpc 2>/dev/null || :
69
+fi
56 70
 
57 71
 %post
58 72
 /sbin/ldconfig
59 73
 chown -v root:sys /var/lib/rpcbind
60
-if ! getent group rpc >/dev/null; then
61
-	groupadd -g 31 rpc
62
-fi
63
-if ! getent passwd rpc >/dev/null; then
64
-	useradd -d /var/lib/rpcbind -g rpc -s /bin/false -u 31 rpc
65
-fi
66 74
 systemctl enable rpcbind.socket >/dev/null 2>&1
67 75
 systemctl enable rpcbind.service >/dev/null 2>&1
68 76
 
69
-
70 77
 %postun
71 78
 /sbin/ldconfig
72 79
 %systemd_postun_with_restart rpcbind.service rpcbind.socket
73
-if getent passwd rpc >/dev/null; then
74
-	userdel rpc
75
-fi
76
-if getent group rpc >/dev/null; then
77
-	groupdel rpc
78
-fi
79 80
 
80 81
 %clean
81 82
 rm -rf %{buildroot}/*
82 83
 %changelog
83
-*	Mon Feb 03 2016 Anish Swaminathan <anishs@vmware.com> 0.2.3-3
84
+*	Fri Feb 05 2016 Anish Swaminathan <anishs@vmware.com> 0.2.3-4
85
+-	Add pre install scripts in the rpm
86
+*	Wed Feb 03 2016 Anish Swaminathan <anishs@vmware.com> 0.2.3-3
84 87
 -	Edit scripts in the rpm
85 88
 *   	Thu Dec 10 2015 Xiaolin Li <xiaolinl@vmware.com>  0.2.3-2
86 89
 -   	Add systemd to Requires and BuildRequires.