diff options
author | Martin Wilke <miwi@FreeBSD.org> | 2006-11-23 22:36:05 +0000 |
---|---|---|
committer | Martin Wilke <miwi@FreeBSD.org> | 2006-11-23 22:36:05 +0000 |
commit | a8e0f5eaf976df63a611df1deb8a9acde64d7c57 (patch) | |
tree | 3838e754aec34bc7492c9cb13dc0e8c29036ed02 /net/wired/pkg-install | |
parent | 3fc923c38eaaec6746df8dd11dc63a9329efb26d (diff) |
Notes
Diffstat (limited to 'net/wired/pkg-install')
-rw-r--r-- | net/wired/pkg-install | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/net/wired/pkg-install b/net/wired/pkg-install new file mode 100644 index 000000000000..3667f4bf8fe8 --- /dev/null +++ b/net/wired/pkg-install @@ -0,0 +1,80 @@ +#!/bin/sh +# +# ex:ts=4 + +ask() { + local question default answer + + question=$1 + default=$2 + if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then + read -p "${question} [${default}]? " answer + fi + echo ${answer:-${default}} +} + +yesno() { + local question default answer + + question=$1 + default=$2 + while :; do + answer=$(ask "${question}" "${default}") + case "${answer}" in + [Yy]*) return 0;; + [Nn]*) return 1;; + esac + echo "Please answer yes or no." + done +} + +make_account() { + local u g gcos + + u=$1 + g=$2 + gcos=$3 + + if pw group show "${g}" >/dev/null 2>&1; then + echo "You already have a group \"${g}\", so I will use it." + else + echo "You need a group \"${g}\"." + if which -s pw && yesno "Would you like me to create it" y + then + pw groupadd ${g} || exit + echo "Done." + else + echo "Please create it, and try again." + exit 1 + fi + fi + + if pw user show "${u}" >/dev/null 2>&1; then + echo "You already have a user \"${u}\", so I will use it." + else + echo "You need a user \"${u}\"." + if which -s pw && yesno "Would you like me to create it" y + then + pw useradd ${u} -g ${g} -c "${gcos}" -d /nonexistent -s /sbin/nologin -h - || exit + echo "Done." + else + echo "Please create it, and try again." + exit 1 + fi + fi +} + +case $2 in + +PRE-INSTALL) + make_account wired wired "Wired server" + ;; + +POST-INSTALL) + openssl req -batch -new -x509 -nodes -out ${PKG_PREFIX}/wired/etc/certificate.pem.sample -keyout ${PKG_PREFIX}/wired/etc/certificate.pem.sample; + if [ ! -f ${PKG_PREFIX}/wired/etc/certificate.pem ]; then + cp -p ${PKG_PREFIX}/wired/etc/certificate.pem.sample ${PKG_PREFIX}/wired/etc/certificate.pem; + fi + ;; + +esac |