a859784154b4c295852d43fe221b6f9ea044f412
[pl_sshd.git] / pl_sshd.spec
1 #
2 # $Id$
3 #
4 %define url $URL$
5
6 %define name pl_sshd
7 %define version 1.0
8 %define taglevel 10
9
10 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
11
12 Vendor: PlanetLab
13 Packager: PlanetLab Central <support@planet-lab.org>
14 Distribution: PlanetLab %{plrelease}
15 URL: %(echo %{url} | cut -d ' ' -f 2)
16
17 Summary: SSH server config for PlanetLab
18 Name: %{name}
19 Version: %{version}
20 Release: %{release}
21 Requires: openssh-server
22 License: GPL
23 Group: System Environment/Base
24 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
25
26 Source0: %{name}-%{version}.tar.bz2
27
28 %description 
29 SSH server configuration for PlanetLab nodes. Configures an automounted
30 directory as source for authorized_keys files and points sshd to that
31 directory.
32
33 %prep
34 %setup
35
36 %build
37
38
39 %install
40 mkdir -p $RPM_BUILD_ROOT/var/pl_sshd/keys
41 install -D -m 0755 pl_sshd.sh $RPM_BUILD_ROOT/usr/local/sbin/pl_sshd
42 install -D -m 0755 pl_sshd $RPM_BUILD_ROOT/etc/init.d/pl_sshd
43
44 %clean
45 rm -rf $RPM_BUILD_ROOT
46
47 %files
48 %defattr(-,root,root)
49 %dir /var/pl_sshd/keys
50 %attr(0755,root,root) /usr/local/sbin/pl_sshd
51 %attr(0755,root,root) /etc/init.d/pl_sshd
52
53 %pre
54
55
56 %post
57 # 1 = install, 2 = upgrade/reinstall
58 if [ $1 -ge 1 ]; then
59     # link sshd pam config to pl_sshd so that we can actually login
60     pam_pl_sshd=/etc/pam.d/pl_sshd
61     [ -r $pam_pl_sshd ] || ln -s sshd $pam_pl_sshd
62
63     chkconfig --add pl_sshd
64
65     if [ "$1" -gt "1" ]; then  # upgrading
66         #
67         # remove funky config options for sshd (so that when we restart
68         # things will operate normally i.e., without automount magic)
69         #
70         rm -f /etc/sysconfig/sshd
71
72         #
73         # stop automounter, remove entry from auto.master, restart if
74         # necessary
75         #
76         [ "$PL_BOOTCD" != "1" ] && /etc/init.d/autofs stop
77         auto_master=/etc/auto.master
78         orig=$auto_master
79         backup=$auto_master.pl_sshd.post
80         mv $orig $backup
81         sed -e '\,^/var/pl_sshd/keys,d' $backup > $orig && rm $backup || \
82             mv $backup $orig
83
84         [ "$PL_BOOTCD" != "1" ] && /etc/init.d/autofs start
85     fi
86
87     if [[ "$PL_BOOTCD" != "1" ]]; then
88         #
89         # don't try to start/restart various things automatically,
90         # it's too ugly (particularly if we're upgrading while
91         # connected over ssh)
92         #
93         echo
94         echo "You need to manually restart autofs and sshd, and"
95         echo "start the pl_sshd (ssh on port 806) service."
96         echo "Make sure you know what you're doing, particularly"
97         echo "if you're making this change over an ssh connection."
98         echo
99     fi
100 fi
101
102 %preun
103 # 0 = erase, 1 = upgrade
104 if [ $1 -eq 0 ]; then
105         #
106         # stop pl_sshd, remove it from rcX.d init dirs, remove link
107         # to sshd's pam config
108         #
109         [ "$PL_BOOTCD" = "1" ] || /etc/init.d/pl_sshd stop || :
110         chkconfig --del pl_sshd
111         rm -f /etc/pam.d/pl_sshd
112 fi
113
114
115 %postun
116
117
118 %changelog
119 * Wed Nov  2 2005 Steve Muir <smuir@cs.princeton.edu>
120 - don't fanny around using the automounter to access ssh keys in vservers,
121   pl_conf now writes them into the normal locations
122
123 * Wed Oct 12 2005 Steve Muir <smuir@cs.princeton.edu>
124 - fix pl_sshd script name and argv[0] to satisfy re-exec requirements
125
126 * Thu Apr  7 2005 Steve Muir <smuir@cs.princeton.edu>
127 - convert auto.pl_sshd to a python script (simpler and less error-prone)
128
129 * Mon Dec  1 2003 Steve Muir <smuir@cs.princeton.edu>
130 - initial creation from files in sidewinder repository
131