79fdad81519ed5eb48fe1945d1cb34fce78bd01c
[pl_sshd.git] / pl_sshd.spec
1 Summary: SSH server config for PlanetLab
2 Name: pl_sshd
3 Version: 1.0
4 Release: 3
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.6 2003/12/03 22:33:50 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             #
75             # don't try to start/restart various things automatically,
76             # it's too ugly (particularly if we're upgrading while
77             # connected over ssh)
78             #
79             echo
80             echo "You need to manually restart autofs and sshd, and"
81             echo "start the pl_sshd (ssh on port 806) service."
82             echo "Make sure you know what you're doing, particularly"
83             echo "if you're making this change over an ssh connection."
84             echo
85         fi
86 fi
87
88 %preun
89 RUNLEVEL=`/sbin/runlevel`
90
91 if [ "$1" -ge "0" ]; then
92         #
93         # stop pl_sshd, remove it from rcX.d init dirs, remove link
94         # to sshd's pam config
95         #
96         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/pl_sshd stop
97         chkconfig --del pl_sshd
98         rm -f /etc/pam.d/pl_sshd
99
100         #
101         # remove funky config options for sshd (so that when we restart
102         # things will operate normally i.e., without automount magic)
103         #
104         rm /etc/sysconfig/sshd
105         if [ "$RUNLEVEL" != "unknown" ]; then
106             echo
107             echo "You need to manually restart sshd."
108             echo "Make sure you know what you're doing, particularly"
109             echo "if you're making this change over an ssh connection."
110             echo
111         fi
112
113         #
114         # stop automounter, remove entry from auto.master, restart if
115         # necessary
116         #
117         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/autofs stop
118         auto_master=/etc/auto.master
119         mv $auto_master $auto_master.pl_sshd.preun
120         sed -e '\,^/var/pl_sshd/keys,d' $auto_master.pl_sshd.preun \
121             >$auto_master
122
123         [ "$RUNLEVEL" != "unknown" ] && /etc/init.d/autofs start
124 fi
125
126
127 %postun
128
129
130 %changelog
131 * Mon Dec  1 2003 Steve Muir <smuir@cs.princeton.edu>
132 - initial creation from files in sidewinder repository
133