#!/bin/sh # ------- # netconfig-server ncfg script to manage ca-certificates # (c) 2009 Luis Garcia # -------- set -e # PATH y variables PATH="/sbin:/bin:/usr/sbin:/usr/bin" # Funciones die(){ echo "$1" >&2 exit 1 } usage(){ die "Usage: $0 {export|unexport} CERT1 [... CERTn]" } # main # libs . "/usr/share/llxcfg-ncfg-certs/llxcfg-ncfg-certs-common" >/dev/null 2>&1 || die "Error: file \"$_\" not found" CERT_EXPORT_DIR="$NCFG_CERTS_SRVDIR/ncfg-certs" ACTION="$1" echo " unexport export " |grep -q " $ACTION " || usage shift [ "$1" ] || usage case $ACTION in unexport) # remove certificates from netconfig while [ "$1" ] ; do rm -f "$CERT_EXPORT_DIR/$1" lliurex-certs del "$CERT_EXPORT_DIR" shift done ;; export) # cp certificates to netconfig path while [ "$1" ] ; do rc=0 CERT_FILE="$(lliurex-pki -s "$1")" || rc=$? if [ $rc -eq 0 -a "$CERT_FILE" -a -r "$CERT_FILE" ] ; then llxcfg-install --mode=644 "$CERT_FILE" "$CERT_EXPORT_DIR/$1" lliurex-certs add "$CERT_EXPORT_DIR" fi shift done ;; *) usage ;; esac rc=0 llxcfg-netconfig-server update || rc=$? exit $rc