Did everything for DELETE hopefully
parent
06283b88f5
commit
645fcabc64
|
@ -7,9 +7,14 @@
|
|||
# 4: config file not found
|
||||
# 5: nsupdate failed
|
||||
|
||||
[ ${#} -eq 3 ] || exit 3
|
||||
CONFIG_FILE='/etc/wgapi/config'
|
||||
[ -f "${CONFIG_FILE}" ] || exit 4
|
||||
if ! [ ${#} -eq 3 ]; then
|
||||
printf 'ERROR! Invalid number of arguments to %s: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
exit 3
|
||||
fi; if ! [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR! %s couldnt find %s\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
exit 4
|
||||
fi
|
||||
source "${CONFIG_FILE}"
|
||||
|
||||
"${LIB_DIR}/ns_update_send" "update add ${1}. ${DNS_TTL} A ${2}
|
||||
|
|
|
@ -8,10 +8,19 @@
|
|||
# 5: nsupdate failed
|
||||
|
||||
CONFIG_FILE='/etc/wgapi/config'
|
||||
[ ${#} -eq 3 ] || exit 3
|
||||
[ -f "${CONFIG_FILE}" ] || exit 5
|
||||
if ! [ ${#} -eq 3 ]; then
|
||||
printf 'ERROR! Invalid number of arguments to %s: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
exit 3
|
||||
fi; if ! [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR! %s couldnt find %s\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
exit 4
|
||||
fi
|
||||
source "${CONFIG_FILE}"
|
||||
# Keep these updates seperate because the zones are different
|
||||
( "${LIB_DIR}/ns_update_send" "update delete ${1}. A\nupdate delete ${1}. AAAA\n update delete *.${1}. CNAME"
|
||||
"${LIB_DIR}/ns_update_send" "update delete $(./rev_ipv4 "${2}") PTR"
|
||||
"${LIB_DIR}/ns_update_send" "update delete $(./rev_ipv6 "${3}") PTR" ) || exit 5
|
||||
|
||||
"${LIB_DIR}/ns_update_send" "update add ${1}. A
|
||||
update delete ${1}. AAAA
|
||||
update delete *.${1}. CNAME.
|
||||
send
|
||||
update delete $("${LIB_DIR}/ns_update_rev_ipv4" "${2}") PTR.
|
||||
send
|
||||
update delete $("${LIB_DIR}/ns_update_rev_ipv6" "${3}") PTR" || exit 5
|
||||
|
|
|
@ -15,16 +15,13 @@ CONFIG_FILE='/etc/wgapi/config'
|
|||
if ! [ ${#} -eq 3 ]; then
|
||||
printf 'ERROR! Invalid number of arguments to %s: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
exit 3
|
||||
fi
|
||||
if ! [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR! %s couldnt find %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
fi; if ! [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR! %s couldnt find %s\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
exit 4
|
||||
fi
|
||||
if ! [ -x '/usr/bin/openssl' ]; then
|
||||
fi; if ! [ -x '/usr/bin/openssl' ]; then
|
||||
printf 'ERROR! /usr/bin/openssl not found!\n' >>"${LOGFILE}"
|
||||
exit 5
|
||||
fi
|
||||
if ! [ -f '/etc/ssl/openssl.cnf' ]; then
|
||||
fi; if ! [ -f '/etc/ssl/openssl.cnf' ]; then
|
||||
printf 'ERROR! /etc/ssl/openssl.cnf not found!\n' >>"${LOGFILE}"
|
||||
exit 5
|
||||
fi
|
||||
|
|
|
@ -4,9 +4,20 @@
|
|||
# USAGE: del hostname username
|
||||
# ERRORS:
|
||||
# 3: Bad usage
|
||||
# 4: Not root
|
||||
# 4: Missing config file
|
||||
# 5: Failed to delete files
|
||||
|
||||
[ ${#} -eq 2 ] || exit 3
|
||||
(( EUID == 0 )) || exit 4
|
||||
rm -rf "${SSL_CONFIG_DIR:?}/${username:?}/${hostname:?}/" 2>/dev/null
|
||||
rm -rf "${SSL_CONFIG_DIR:?}/${username:?}/${hostname:?}.*" 2>/dev/null
|
||||
CONFIG_FILE='/etc/wgapi/config'
|
||||
if ! [ ${#} -eq 2 ]; then
|
||||
printf 'ERROR! Invalid number of arguments to %s: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
exit 3
|
||||
fi; if ! [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR! %s couldnt find %s\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
exit 4
|
||||
fi
|
||||
source "${CONFIG_FILE}"
|
||||
|
||||
if ! sudo rm -rf "${SSL_CONFIG_DIR:?}/${username:?}/${hostname:?}/" 2>/dev/null; then
|
||||
printf 'ERROR! %s failed to delete %s!\n' "${0}" "${SSL_CONFIG_DIR}/${username}/${hostname}/" >>"${LOGFILE}"
|
||||
exit 5
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue