[ssl_mgmt] Add option to only generate openssl.cnf
This commit is contained in:
parent
e428424cf0
commit
d6f92888a8
|
@ -30,11 +30,15 @@ usage ()
|
||||||
progname=$1
|
progname=$1
|
||||||
echo "Usage :"
|
echo "Usage :"
|
||||||
echo
|
echo
|
||||||
echo "$progname renew <service>"
|
echo "$progname [-c] renew <service>"
|
||||||
echo "$progname -h"
|
echo "$progname -h"
|
||||||
echo
|
echo
|
||||||
echo "First form renew the certificate of the given service"
|
echo "First form renew the certificate of the given service"
|
||||||
echo
|
echo
|
||||||
|
echo "Possible option:"
|
||||||
|
echo
|
||||||
|
echo "-c Only generate the configuration"
|
||||||
|
echo
|
||||||
echo "Second form prints this help."
|
echo "Second form prints this help."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,13 +67,16 @@ ask_user_default_no ()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test number of argument is correct and their value are correct also.
|
# Parse arguments and test their number and value is correct.
|
||||||
test_args ()
|
parse_args ()
|
||||||
{
|
{
|
||||||
local - user domain
|
local - user domain action
|
||||||
while getopts "h" opt
|
config_only=""
|
||||||
|
while getopts "ch" opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
"c")
|
||||||
|
config_only=yes ;;
|
||||||
"h")
|
"h")
|
||||||
if [ $# -gt 1 ]
|
if [ $# -gt 1 ]
|
||||||
then
|
then
|
||||||
|
@ -80,7 +87,8 @@ test_args ()
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
if [ $# -ne 2 -o "$1" != "renew" ]
|
eval action="\${$OPTIND:-}"
|
||||||
|
if [ $(($#-$OPTIND+1)) -ne 2 -o "$action" != "renew" ]
|
||||||
then
|
then
|
||||||
usage $(basename "$0")
|
usage $(basename "$0")
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -215,7 +223,7 @@ main ()
|
||||||
{
|
{
|
||||||
local - ret servicesok
|
local - ret servicesok
|
||||||
ret=0
|
ret=0
|
||||||
test_args "$@"
|
parse_args "$@"
|
||||||
# This test should be useless if rights on this file are corrects
|
# This test should be useless if rights on this file are corrects
|
||||||
# (that is 770 for root:gt owner)
|
# (that is 770 for root:gt owner)
|
||||||
if must_sudo
|
if must_sudo
|
||||||
|
@ -238,6 +246,10 @@ main ()
|
||||||
servicesok=""
|
servicesok=""
|
||||||
get_cert_params
|
get_cert_params
|
||||||
generate_config
|
generate_config
|
||||||
|
if [ -n "$config_only" ]
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if ! generate_cert
|
if ! generate_cert
|
||||||
then
|
then
|
||||||
ret=1
|
ret=1
|
||||||
|
@ -245,7 +257,15 @@ main ()
|
||||||
servicesok="$servicesok${servicesok:+ }$service"
|
servicesok="$servicesok${servicesok:+ }$service"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "You should restart the following services: $servicesok"
|
if [ -z "$config_only" ]
|
||||||
|
then
|
||||||
|
if [ -n "$servicesok" ]
|
||||||
|
then
|
||||||
|
echo "You should restart the following services: $servicesok"
|
||||||
|
else
|
||||||
|
echo "No certificate generated"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue