/[gentoo-x86]/net-proxy/sshproxy/sshproxy-0.6.0_beta2-r1.ebuild
Gentoo

Contents of /net-proxy/sshproxy/sshproxy-0.6.0_beta2-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Tue Apr 5 21:46:43 2011 UTC (4 years, 4 months ago) by arfrever
Branch: MAIN
Changes since 1.3: +6 -2 lines
Use Python 2 (bug #315879).

(Portage version: 2.2.0_alpha29_p9/cvs/Linux x86_64)

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-proxy/sshproxy/sshproxy-0.6.0_beta2-r1.ebuild,v 1.3 2011/01/19 07:58:50 xarthisius Exp $
4
5 EAPI="3"
6 PYTHON_DEPEND="2"
7
8 inherit distutils eutils
9
10 DESCRIPTION="sshproxy is an ssh gateway to apply ACLs on ssh connections"
11 HOMEPAGE="http://sshproxy-project.org/"
12 SRC_URI="http://sshproxy-project.org/download/${P}.tar.gz"
13
14 LICENSE="GPL-2"
15 SLOT="0"
16 KEYWORDS="~amd64 ~x86"
17
18 IUSE="client-only mysql minimal"
19 # mysql: install the mysql_db backend driver
20 # minimal: do not install extra plugins
21 # client-only: install only the client wrappers
22
23 DEPEND="!client-only? (
24 >=dev-python/paramiko-1.6.2
25 mysql? ( >=dev-python/mysql-python-1.2.0 )
26 )"
27 RDEPEND="${DEPEND}
28 net-misc/openssh"
29
30 pkg_setup() {
31 python_set_active_version 2
32 python_pkg_setup
33
34 enewgroup sshproxy
35 enewuser sshproxy -1 -1 /var/lib/sshproxy sshproxy
36 }
37
38 src_prepare() {
39 # avoid conflicts with net-misc/putty and net-misc/pssh
40 # by renaming pscp and pssh scripts (#248193 and #278794)
41 epatch "${FILESDIR}"/${P}-rename-wrappers.patch
42 sed -i -e 's/pscp/spscp/g;s/pssh/spssh/g' doc/* && \
43 mv bin/pssh bin/spssh && \
44 mv bin/pscp bin/spscp && \
45 mv doc/pscp.1 doc/spscp.1 && \
46 mv doc/pssh.1 doc/spssh.1 || die "failed to rename pscp or pssh files"
47 ewarn "For avoiding conflicts with net-misc/putty and net-misc/pssh,"
48 ewarn "pscp and pssh scripts have been renamed as spscp respectively spssh."
49 }
50
51 src_install () {
52 dobin bin/spssh
53 dobin bin/spscp
54 if ! use client-only; then
55 distutils_src_install
56
57 diropts -o sshproxy -g sshproxy -m0750
58 keepdir /var/lib/sshproxy
59 keepdir /var/log/sshproxy
60
61 # Create a default sshproxy.ini
62 dodir /etc/sshproxy
63 insopts -o root -g sshproxy -m0600
64 insinto /etc/sshproxy
65 doins "${FILESDIR}/sshproxy.ini"
66 local BLOWFISH_SECRET=$(printf "%04hX%04hX%04hX%04hX\n" ${RANDOM} ${RANDOM} ${RANDOM} ${RANDOM})
67 sed -i -e "s/%BLOWFISH_SECRET%/${BLOWFISH_SECRET}/" \
68 -e "s/%HOSTNAME%/${HOSTNAME}/" \
69 "${D}/etc/sshproxy/sshproxy.ini"
70
71 insopts -o sshproxy -g sshproxy -m0600
72 rm -rf "${D}/usr/lib/sshproxy/spexpect"
73 if use minimal; then
74 local p
75 for p in acl_funcs console_extra logusers; do
76 rm -rf "${D}/usr/lib/sshproxy/${p}"
77 done
78 else
79 keepdir /var/log/sshproxy/logusers
80 { # initialize a reasonable value for the logusers plugin
81 echo
82 echo "[logusers]"
83 echo "logdir = /var/log/sshproxy/logusers"
84 echo
85 } >> "${D}/etc/sshproxy/sshproxy.ini"
86 fi
87
88 # init/conf files for sshproxy daemon
89 newinitd "${FILESDIR}/sshproxyd.initd" sshproxyd
90 newconfd "${FILESDIR}/sshproxyd.confd" sshproxyd
91
92 # install manpages
93 doman doc/spscp.1
94 doman doc/spssh.1
95 if ! use client-only; then
96 doman doc/sshproxy.ini.5
97 doman doc/sshproxy-setup.8
98 doman doc/sshproxyd.8
99 fi
100
101 if use mysql; then
102 insinto /usr/share/sshproxy/mysql_db
103 doins misc/mysql_db.sql
104 doins misc/sshproxy-mysql-user.sql
105 else
106 rm -rf "${D}/usr/lib/sshproxy/mysql_db"
107 sed -i -e 's/[ \t]\+mysql//' \
108 "${D}/etc/init.d/sshproxyd"
109 fi
110 fi
111 }
112
113 pkg_postinst () {
114 echo
115 einfo "Don't forget to set the following environment variables"
116 einfo " SSHPROXY_HOST (default to localhost)"
117 einfo " SSHPROXY_PORT (default to 2242)"
118 einfo " SSHPROXY_USER (default to \$USER)"
119 einfo "for each sshproxy user."
120 if ! use client-only; then
121 distutils_pkg_postinst
122
123 echo
124 einfo "If this is your first installation, run"
125 einfo " emerge --config =${CATEGORY}/${PF}"
126 einfo "to initialize the backend and configure sshproxy."
127 echo
128 einfo "There is no need to install sshproxy on a client machine."
129 einfo "You can connect to a SSH server using this proxy by running"
130 einfo " ssh -tp PROXY_PORT PROXY_USER@PROXY_HOST -- REMOTE_USER@REMOTE_HOST"
131 fi
132 }
133
134 pkg_config() {
135 if [[ -d "${ROOT}/usr/lib/sshproxy/mysql_db" ]]; then
136 local PASSWD=$(printf "%04hX%04hX%04hX%04hX\n" ${RANDOM} ${RANDOM} ${RANDOM} ${RANDOM})
137 local SHARE="${ROOT}/usr/share/sshproxy/mysql_db"
138 local DB_HOST DB_PORT
139 read -p "Enter the MySQL host (default localhost): " DB_HOST
140 [[ -n "${DB_HOST}" ]] || DB_HOST=localhost
141 read -p "Enter the MySQL port (default 3306): " DB_PORT
142 [[ -n "${DB_PORT}" ]] || DB_PORT=3306
143
144 ewarn "When prompted for a password, enter your MySQL root password"
145 ewarn
146
147 if mysql -h ${DB_HOST} -P ${DB_PORT} -u root -p <<EOF ; then
148 CREATE DATABASE sshproxy;
149 USE sshproxy;
150 $(sed -e "s/sshproxypw/${PASSWD}/g" "${SHARE}/sshproxy-mysql-user.sql")
151 $(<"${SHARE}/mysql_db.sql")
152 EOF
153
154 {
155 echo
156 echo "[client_db.mysql]"
157 echo "host = ${DB_HOST}"
158 echo "password = ${PASSWD}"
159 echo "db = sshproxy"
160 echo "user = sshproxy"
161 echo "port = ${DB_PORT}"
162 echo
163 echo "[acl_db.mysql]"
164 echo "host = ${DB_HOST}"
165 echo "password = ${PASSWD}"
166 echo "db = sshproxy"
167 echo "user = sshproxy"
168 echo "port = ${DB_PORT}"
169 echo
170 echo "[site_db.mysql]"
171 echo "host = ${DB_HOST}"
172 echo "password = ${PASSWD}"
173 echo "db = sshproxy"
174 echo "user = sshproxy"
175 echo "port = ${DB_PORT}"
176 } >> "${ROOT}/etc/sshproxy/sshproxy.ini"
177
178 sed -i -e 's/^\(\(acl\|client\|site\)_db = \)ini_db/\1mysql_db/g' \
179 "${ROOT}/etc/sshproxy/sshproxy.ini"
180 grep -q "^plugin_list .* mysql_db" \
181 "${ROOT}/etc/sshproxy/sshproxy.ini" || \
182 sed -i -e 's/^\(plugin_list = .*\)$/\1 mysql_db/g' \
183 "${ROOT}/etc/sshproxy/sshproxy.ini"
184 else
185 ewarn "Failed to create MySQL database!"
186 ewarn "If the database already existed and you want to replace it,"
187 ewarn "hit Ctrl-C now and drop the old database by running the command:"
188 ewarn " /usr/bin/mysqladmin -h ${DB_HOST} -P ${DB_PORT} -u root -p drop sshproxy"
189 read -p "Hit Ctrl-C to stop the procedure or Enter to continue " key
190 fi
191 fi
192
193 INITD_STARTUP="/etc/init.d/sshproxyd start" chroot "${ROOT}" \
194 sshproxy-setup -u sshproxy -c /etc/sshproxy
195 }

  ViewVC Help
Powered by ViewVC 1.1.20