diff Makefile @ 2:ecf6bac512ae default tip

cleanup make for c6/c7/fedora
author Carl Byington <carl@five-ten-sg.com>
date Tue, 14 Mar 2017 18:42:47 -0700
parents 0e3c9806a620
children
line wrap: on
line diff
--- a/Makefile	Thu Mar 02 12:45:31 2017 -0800
+++ b/Makefile	Tue Mar 14 18:42:47 2017 -0700
@@ -5,31 +5,26 @@
 r := $(shell grep Wrote: mylog | grep -v debuginfo | awk '{print $$2}')
 b := $(shell basename ${r})
 m := google-authenticator.pp
+c6 := $(shell grep -q 'CentOS .* 6' /etc/system-release && echo 1 || echo 0)
+sy := $(shell which systemctl 2>/dev/null)
 
 all:
-	yum -y install pam-devel selinux-policy-devel
+	yum -y install pam-devel selinux-policy-devel qrencode-devel
 	rpmbuild --rebuild google-authenticator-1.0-0.gita096a62.fc24.6.src.rpm >mylog 2>&1
 	grep Wrote: mylog
-	make -f /usr/share/selinux/devel/Makefile
+	[ ${c6} -eq 1 ] && make -f /usr/share/selinux/devel/Makefile
 
 install:
 	[ -f ${r} ] || /bin/false
 	yum -y install ${r}
-	semodule -i ${m}
+	[ ${c6} -eq 1 ] && semodule -i ${m}
 	sed -i -e 's/PAM-1.0/PAM-1.0\nauth		  required	   pam_google_authenticator.so nullok/g' /etc/pam.d/sshd
 	sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
-	service sshd restart
-
-install-centos7:
-	[ -f ${r} ] || /bin/false
-	yum -y install ${r}
-	sed -i -e 's/PAM-1.0/PAM-1.0\nauth		  required	   pam_google_authenticator.so nullok/g' /etc/pam.d/sshd
-	sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
-	systemctl restart sshd.service
+	[ -z "${sy}" ] && service sshd restart || systemctl restart sshd.service
 
 setup:
 	google-authenticator
-	# authenticator setup creates the file with the wrong label.
+	# authenticator setup creates the file with the wrong label on C6
 	restorecon ~/.google_authenticator