commit 1e0a24acf9cc7ded4967434c4701cb3571192d5d Author: Kolan Sh Date: Sun May 20 14:04:03 2012 +0400 Initial commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d65628 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +SHELL = /bin/sh +PREFIX = /usr + +all: + +install: + install -d ${DESTDIR}/usr/sbin + install --mode=755 sbin/*.sh ${DESTDIR}/usr/sbin diff --git a/pkgs/gentoo/app-admin/htpasswd/Manifest b/pkgs/gentoo/app-admin/htpasswd/Manifest new file mode 100644 index 0000000..8fa9312 --- /dev/null +++ b/pkgs/gentoo/app-admin/htpasswd/Manifest @@ -0,0 +1 @@ +EBUILD htpasswd-9999.ebuild 807 RMD160 3e4b4a314e68e5d15c2bc11f42f8bded6e88ab9f SHA1 b519df1ddac57fff6fbc9674ce6610b15bc1f050 SHA256 1d4a19202512df0e12bfd57a8adf3c46efaf057dc5ada02d261224ec06018d27 diff --git a/pkgs/gentoo/app-admin/htpasswd/htpasswd-9999.ebuild b/pkgs/gentoo/app-admin/htpasswd/htpasswd-9999.ebuild new file mode 100644 index 0000000..b7ef71d --- /dev/null +++ b/pkgs/gentoo/app-admin/htpasswd/htpasswd-9999.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=4 + +inherit eutils + +if [[ ${PV} == "9999" ]] ; then + EGIT_REPO_URI=${EGIT_REPO_URI:-"git://github.com/backbone/htpasswd.git"} + inherit git-2 + KEYWORDS="" +else + SRC_URI="ftp://backbone.ws/projects/htpasswd/${P}.tar.bz2" + KEYWORDS="-* ~x86 ~amd64" +fi + +DESCRIPTION="Automated Gentoo upgrading" + +HOMEPAGE="https://chili.backbone.ws/projects/htpasswd" + +SLOT="0" + +LICENSE="GPL-3" + +IUSE="" + +DEPEND="" + +RDEPEND="${DEPEND}" + +src_prepare() { + if [[ ${PV} == "9999" ]] ; then + # Allow user patches to be applied without modifying the ebuild + epatch_user + fi +} + +src_install() { + if [[ ${PV} == "9999" ]] ; then + emake install DESTDIR="${D}" + else + emake install DESTDIR="${D}" || die + fi +} diff --git a/sbin/htpasswd.sh b/sbin/htpasswd.sh new file mode 100755 index 0000000..d0e4be3 --- /dev/null +++ b/sbin/htpasswd.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Замена для httpasswd, чтобы Apache не ставить =) +# Input params +fname=$1 +realm=$2 +user=$3 +if [[ "$1" == "-c" ]]; then + fname=$2 + realm=$3 + user=$4 + touch $fname + chmod 640 $fname +else + if [[ ! -r "$fname" ]]; then + echo "Could not open passwd file $fname for reading." + echo "Use -c option to create new one." + exit 1 + fi +fi + +# Entering password +#is_new_user=`cat $fname | cut -d\: -f1|grep ^$user$` +is_new_user=`cat $fname | grep "^$user\:$realm\:"` + +if [[ "$is_new_user" == "" ]]; then + echo "Adding password for $user in realm \"$realm\"." +else + echo "Changing password for $user in realm \"$realm\"." +fi + + +read -s -p "New password: " pass +echo +read -s -p "Re-type new password: " pass_retry +echo +if [[ "$pass" != "$pass_retry" ]]; then + echo "They don't match, sorry." + pass= + pass_retry= + exit 1 +fi +pass_retry= + +hash=`echo -n "$user:$realm:$pass" | md5sum | cut -b -32` + +# New user +if [[ "$is_new_user" == "" ]]; then + echo $user:$realm:$hash >> $fname + if [[ "$?" != "0" ]]; then + echo "md5digest: Unable to update file $fname" + echo "Use -c option to create new one." + fi + pass= + +# Changing password +else + sed -i "s/^$user:$realm:.*$/$user:$realm:$hash/" $fname + if [[ "$?" != "0" ]]; then + echo "md5digest: Unable to update file $fname" + echo "Use -c option to create new one." + fi + pass= +fi + +exit 0 +