get_revoked_keys.sh: support of multiple OpenVPN installations added.
This commit is contained in:
parent
206c9a11bf
commit
2b203bd0c1
@ -22,6 +22,31 @@ trim() {
|
|||||||
echo -n "$var"
|
echo -n "$var"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
is_number() {
|
||||||
|
|
||||||
|
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||||
|
|
||||||
|
# - also possible
|
||||||
|
# -
|
||||||
|
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||||
|
#return $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||||
|
}
|
||||||
|
|
||||||
|
is_int() {
|
||||||
|
return $(test "$@" -eq "$@" > /dev/null 2>&1);
|
||||||
|
}
|
||||||
|
|
||||||
|
echononl(){
|
||||||
|
echo X\\c > /tmp/shprompt$$
|
||||||
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
echo -e -n "$*\\c" 1>&2
|
||||||
|
else
|
||||||
|
echo -e -n "$*" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
|
}
|
||||||
|
|
||||||
fatal(){
|
fatal(){
|
||||||
echo ""
|
echo ""
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
@ -84,10 +109,62 @@ fi
|
|||||||
# --- Read Configurations from $conf_file
|
# --- Read Configurations from $conf_file
|
||||||
# -------------
|
# -------------
|
||||||
|
|
||||||
|
declare -a conf_file_arr=()
|
||||||
|
declare -a conf_name_arr=()
|
||||||
|
for _conf_file in `ls ${working_dir}/conf/server-*.conf 2>/dev/null` ; do
|
||||||
|
conf_file_arr+=("${_conf_file}")
|
||||||
|
_basename=$(basename $_conf_file)
|
||||||
|
_tmp_name=${_basename%%.*}
|
||||||
|
_tmp_name=${_tmp_name#*-}
|
||||||
|
conf_name_arr+=("$_tmp_name")
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${#conf_file_arr[@]} -lt 1 ]] ; then
|
||||||
|
fatal "NO Configuration found!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
declare -i i=0
|
||||||
|
|
||||||
|
if [[ ${#conf_file_arr[@]} -gt 1 ]] ; then
|
||||||
|
echo ""
|
||||||
|
echo "Which Configuration should be loaded?"
|
||||||
|
echo ""
|
||||||
|
for _conf_file in ${conf_file_arr[@]} ; do
|
||||||
|
echo " [${i}] ${conf_name_arr[${i}]}"
|
||||||
|
(( i++ ))
|
||||||
|
done
|
||||||
|
_OK=false
|
||||||
|
echo
|
||||||
|
echononl "Eingabe: "
|
||||||
|
while ! $_OK ; do
|
||||||
|
read _IN
|
||||||
|
if is_number "$_IN" && [[ -n ${conf_file_arr[$_IN]} ]]; then
|
||||||
|
conf_file=${conf_file_arr[$_IN]}
|
||||||
|
service_name="${conf_name_arr[$_IN]}"
|
||||||
|
_OK=true
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo -e "\tFalsche Eingabe !"
|
||||||
|
echo ""
|
||||||
|
echononl "Eingabe: "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
else
|
||||||
|
conf_file=${conf_file_arr[0]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
|
||||||
if [[ -f "$conf_file" ]] ; then
|
if [[ -f "$conf_file" ]] ; then
|
||||||
source "$conf_file"
|
source "$conf_file"
|
||||||
else
|
else
|
||||||
warn "No configuration file 'conf_file' not found.\n Loading defaults.."
|
warn "No configuration file 'conf_file' for OpenVON Service '$service_name' found.\n Loading defaults.."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -122,16 +199,16 @@ if [[ ${#revoked_serial_arr[@]} -gt 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
info "No revoked OpenVPN keys in \033[1m${KEY_DIR}\033[m exists"
|
info "No revoked keys in \033[1m${KEY_DIR}\033[m for OpenVPN service \033[1m$service_name\033[m exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [[ ${#revoked_cn_arr[@]} -gt 0 ]]; then
|
if [[ ${#revoked_cn_arr[@]} -gt 0 ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "Revoked Keys in \033[32m\033[1m${KEY_DIR}\033[m:"
|
echo -e "Revoked Keys for OpenVPN service \033[1m$service_name\033[m in \033[32m\033[1m${KEY_DIR}\033[m:"
|
||||||
else
|
else
|
||||||
echo "Revoked Keys in ${KEY_DIR}:"
|
echo "Revoked Keys for OpenVPN service '$service_name' in '${KEY_DIR}':"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
for _val in ${revoked_cn_arr[@]} ; do
|
for _val in ${revoked_cn_arr[@]} ; do
|
||||||
|
Loading…
Reference in New Issue
Block a user