Don't need period after CVS header
[pl_sshd.git] / pl_sshd.spec
1 Summary: SSH server config for PlanetLab
2 Name: pl_sshd
3 Version: 1.0
4 Release: 1
5 Requires: autofs, openssh-server
6 Copyright: GPL
7 URL: http://www.planet-lab.org
8 Group: System Environment/Base
9 Source: %{_fullname}.tar.gz
10
11 %description 
12 SSH server configuration for PlanetLab nodes.  Configures an automounted
13 directory as source for authorized_keys files and points sshd to that
14 directory.
15
16 $Header: /cvs/pl_sshd/pl_sshd.spec,v 1.4 2003/12/01 22:16:47 sjm-pl_sshd Exp $
17 %prep
18 %setup
19
20 %build
21
22
23 %install
24 mkdir -p $RPM_BUILD_ROOT/usr/local/sbin
25 mkdir -p $RPM_BUILD_ROOT/etc/{sysconfig,init.d}
26 mkdir -p $RPM_BUILD_ROOT/var/pl_sshd/keys
27 install -m 0755 pl_sshd.sh $RPM_BUILD_ROOT/usr/local/sbin
28 install -m 0755 pl_sshd $RPM_BUILD_ROOT/etc/init.d
29 install -m 0755 auto.pl_sshd $RPM_BUILD_ROOT/etc
30
31 %clean
32 rm -rf $RPM_BUILD_ROOT
33
34 %files
35 %defattr(-,root,root)
36 %attr(0755,root,root) /usr/local/sbin/pl_sshd.sh
37 %attr(0755,root,root) /etc/init.d/pl_sshd
38 %attr(0755,root,root) /etc/auto.pl_sshd
39
40 %pre
41
42
43 %post
44 RUNLEVEL=`/sbin/runlevel`
45
46 if [ "$1" -ge 1 ]; then
47         # create the magic directory for automount
48         keydir=/var/pl_sshd/keys
49         [ -d $keydir ] || mkdir -p $keydir
50
51         # add appropriate entry to auto.master
52         auto_master=/etc/auto.master
53         auto_master_entry="$keydir /etc/auto.pl_sshd"
54         grep -qF "$auto_master_entry" $auto_master || \
55             echo $auto_master_entry >>$auto_master
56
57         #
58         # use the sysconfig file to tell our system sshd to look in the
59         # magic location for authorized_keys files
60         #
61         sysconfig_sshd=/etc/sysconfig/sshd
62         [ -r $sysconfig_sshd ] && \
63             mv $sysconfig_sshd $sysconfig_sshd.pl_sshd
64         echo "OPTIONS='-o \"AuthorizedKeysFile $keydir/%u/authorized_keys\"'" \
65             >$sysconfig_sshd
66
67         # link sshd pam config to pl_sshd so that we can actually login
68         pam_pl_sshd=/etc/pam.d/pl_sshd
69         [ -r $pam_pl_sshd ] || ln -s sshd $pam_pl_sshd
70
71         chkconfig --add pl_sshd
72
73         if [[ "$RUNLEVEL" != "unknown" ]]; then
74                 /etc/init.d/autofs restart
75                 /etc/init.d/sshd restart
76                 /etc/init.d/pl_sshd start
77         fi
78 fi
79
80 %preun
81 RUNLEVEL=`/sbin/runlevel`
82
83 if [ "$1" -ge "0" ]; then
84         #
85         # stop pl_sshd, remove it from rcX.d init dirs, remove link
86         # to sshd's pam config
87         #
88         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/pl_sshd stop
89         chkconfig --del pl_sshd
90         rm -f /etc/pam.d/pl_sshd
91
92         #
93         # remove funky config options for sshd (so that when we restart
94         # things will operate normally i.e., without automount magic),
95         # then restart
96         #
97         rm /etc/sysconfig/sshd
98         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/sshd restart
99
100         #
101         # stop automounter, remove entry from auto.master, restart if
102         # necessary
103         #
104         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/autofs stop
105         auto_master=/etc/auto.master
106         mv $auto_master $auto_master.pl_sshd.preun
107         sed -e '\,^/var/pl_sshd/keys,d' $auto_master.pl_sshd.preun \
108             >$auto_master
109
110         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/autofs start
111 fi
112
113
114 %postun
115
116
117 %changelog
118 * Mon Dec  1 2003 Steve Muir <smuir@cs.princeton.edu>
119 - initial creation from files in sidewinder repository
120