From 3cd76426b9b8266e8ec66620c4ab11c6f2b40a7b Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 13 Apr 2020 12:47:13 +0200 Subject: [PATCH] Support some other configuration files, but they only differs in the name. --- build_key-pass.sh | 28 ++++++++++++++++++++++++++-- create_key_config.sh | 5 +++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/build_key-pass.sh b/build_key-pass.sh index 3f67a46..56af24f 100755 --- a/build_key-pass.sh +++ b/build_key-pass.sh @@ -727,6 +727,21 @@ fi if $_copy_to_user_home_dir ; then _home_dir=$(eval echo "~$user_name") _target_dir="${_home_dir}/VPN/${_CLIENT_CN}" + + echononl " Backup existing dir '${_target_dir}'.." + if [[ -d "$_target_dir" ]] ; then + mv "${_target_dir}" "${_target_dir}.$_date" > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi + else + echo_skipped + fi + + _failed=false echo "" echononl " Copy key material into dir '${_target_dir}'.." @@ -741,6 +756,7 @@ if $_copy_to_user_home_dir ; then if [[ -n "$ORG_SHORTCUT" ]]; then cp -a "$_client_conf_file" "${_target_dir}/${ORG_SHORTCUT}-$(basename $_client_conf_file)" >> $log_file 2>&1 + cp -a "$_client_conf_file" "${_target_dir}/${ORG_SHORTCUT} $(basename $_client_conf_file)" >> $log_file 2>&1 else cp -a "$_client_conf_file" "${_target_dir}/${KEY_CN/VPN-/}-$(basename $_client_conf_file)" >> $log_file 2>&1 fi @@ -748,12 +764,20 @@ if $_copy_to_user_home_dir ; then _failed=true fi - # - Configuration for Windows OpenVPN + # - For historical reasons # - - cp -a "$_client_conf_file" "${_target_dir}/${_CLIENT_CN}.ovpn" + cp -a "$_client_conf_file" "${_target_dir}/client-$(basename $_client_conf_file)" >> $log_file 2>&1 if [[ $? -ne 0 ]] ; then _failed=true fi + + # - Configuration for Windows OpenVPN + # - + cp -a "$_client_conf_file" "${_target_dir}/${_CLIENT_CN}.ovpn" >> $log_file 2>&1 + if [[ $? -ne 0 ]] ; then + _failed=true + fi + cp -a "${_CLIENT_CERT}" "${_target_dir}" >> $log_file 2>&1 if [[ $? -ne 0 ]] ; then _failed=true diff --git a/create_key_config.sh b/create_key_config.sh index e78929e..8840ed4 100755 --- a/create_key_config.sh +++ b/create_key_config.sh @@ -669,12 +669,17 @@ if [[ $? -ne 0 ]] ; then fi if [[ -n "$ORG_SHORTCUT" ]]; then cp -a "$_client_conf_file" "${_target_dir}/${ORG_SHORTCUT}-$(basename $_client_conf_file)" >> $log_file 2>&1 + cp -a "$_client_conf_file" "${_target_dir}/${ORG_SHORTCUT} $(basename $_client_conf_file)" >> $log_file 2>&1 else cp -a "$_client_conf_file" "${_target_dir}/${KEY_CN/VPN-/}-$(basename $_client_conf_file)" >> $log_file 2>&1 fi if [[ $? -ne 0 ]] ; then _failed=true fi +cp -a "$_client_conf_file" "${_target_dir}/client-$(basename $_client_conf_file)" >> $log_file 2>&1 +if [[ $? -ne 0 ]] ; then + _failed=true +fi cp -a "$_client_conf_file" "${_target_dir}/${_CLIENT_CN}.ovpn" if [[ $? -ne 0 ]] ; then _failed=true