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