Skip to content

Commit

Permalink
Merge pull request thuantran#394 from jumpsmm7/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jumpsmm7 authored Jun 17, 2022
2 parents 16138f0 + 302db3a commit fa6075e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
19 changes: 9 additions & 10 deletions gen/manager
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,18 @@ check_dns_environment () {

dnscrypt_proxy_run () {
local lock_dir
local pid
local pid_file
local start
local end
local runtime
lock_dir="/tmp/dnscrypt-proxy"
pid_file="${lock_dir}/pid"
if ( mkdir ${lock_dir} ) 2> /dev/null; then
printf "%s\n" "$$" > $pid_file
trap 'rm -rf "$lock_dir"; exit $?' EXIT
start="$(date +%s)"
$1
end="$(date +%s)"
runtime="$((end-start))"
logger -st "$NAME" "$1 took $runtime second(s) to complete."
rm -rf "$lock_dir"
if ( mkdir ${lock_dir} ) 2> /dev/null || { [ -e "${pid_file}" ] && [ -n "$(sed -n '2p' $pid_file)" ]; }; then
( trap 'rm -rf "$lock_dir"; exit $?' EXIT; while [ -z "$(sed -n '2p' $pid_file)" ]; do sleep 1; done; rm -rf "$lock_dir"; )& pid="$!"
{ printf "%s\n" "$pid" > $pid_file; start="$(date +%s)"; $1; end="$(date +%s)"; runtime="$((end-start))"; printf "%s\n" "$runtime" >> $pid_file; logger -st "$NAME" "$1 took $runtime second(s) to complete."; };
else
logger -st "$NAME" "Lock owned by $(cat $pid_file) exists; preventing duplicate runs!"
logger -st "$NAME" "Lock owned by $(sed -n '1p' $pid_file) exists; preventing duplicate runs!"
fi
}

Expand Down Expand Up @@ -236,6 +234,7 @@ update_opendns () {
esac
}

if { [ "$2" != "x" ] && printf "%s" "$1" | /bin/grep -qE "^(((dnscrypt-)?(start|stop)|restart|kill)$)"; }; then { service "$1"_dnscrypt-proxy >/dev/null 2>&1; exit; }; fi
{ for PID in $(pidof "$(basename "$0")"); do if { awk '{ print }' "/proc/${PID}/cmdline" | grep -q monitor-start; } && [ "$PID" != "$$" ]; then { MON_PID="$PID"; }; fi; done; };

unset TZ
Expand Down
2 changes: 1 addition & 1 deletion gen/manager.md5sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
962af2001694e072e43fc9cc40f45f9d
49f935ee453a17c3cf62302155b37ca3
20 changes: 12 additions & 8 deletions installer
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗ bigeyes0x0 #
#██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝ Current Maintainer: #
#██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗ SomeWhereOverTheRainBow #
#██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║ v2.4.4 #
#██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║ v2.4.5 #
#╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝ #
###################################################################################################################

Expand All @@ -27,7 +27,7 @@
# shellcheck disable=SC3057
# shellcheck disable=SC3060

DI_VERSION="v2.4.4"
DI_VERSION="v2.4.5"
export DI_VERSION

readonly LATEST_URL="https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases/latest"
Expand Down Expand Up @@ -124,10 +124,12 @@ backup_restore () {
"${TARG_DIR}/odoh-relays.md.minisig" \
"${TARG_DIR}/dnscrypt-resolvers.csv" \
"${TARG_DIR}/dnscrypt-resolvers.csv.minisig"
for i in init-start services-stop; do if { ! grep -q "${TARG_DIR}/manager $i &" "/jffs/scripts/${i}" && grep -q "${TARG_DIR}/manager $i" "/jffs/scripts/${i}"; }; then del_jffs_script "/jffs/scripts/${i}"; fi; done
write_manager_script /jffs/scripts/init-start "init-start &"
write_manager_script /jffs/scripts/services-stop "services-stop &"
write_manager_script /jffs/scripts/dnsmasq.postconf dnsmasq
write_manager_script /jffs/scripts/init-start init-start
write_manager_script /jffs/scripts/services-stop services-stop
write_command_script /jffs/scripts/service-event-end 'if echo "$2" | /bin/grep -q "^dnscrypt-proxy"; then { sh /jffs/dnscrypt/manager "${1}" & }; fi # Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
del_between_magic /jffs/scripts/service-event-end '# Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
write_command_script /jffs/scripts/service-event-end 'if printf "%s" "$@" | /bin/grep -qE "^(((((dnscrypt-)?(start|stop)|restart|kill))_?.*dnscrypt-proxy)$)"; then { sh /jffs/dnscrypt/manager "$(printf "%s" "$@" | /bin/grep -oE "^(((dnscrypt-)?(start|stop)|restart|kill))")" x & }; fi # Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
if ! setup_dnscrypt; then
end_op_message 1
return
Expand Down Expand Up @@ -1041,10 +1043,12 @@ inst_dnscrypt () {
"${TARG_DIR}/odoh-relays.md.minisig" \
"${TARG_DIR}/dnscrypt-resolvers.csv" \
"${TARG_DIR}/dnscrypt-resolvers.csv.minisig"
for i in init-start services-stop; do if { ! grep -q "${TARG_DIR}/manager $i &" "/jffs/scripts/${i}" && grep -q "${TARG_DIR}/manager $i" "/jffs/scripts/${i}"; }; then del_jffs_script "/jffs/scripts/${i}"; fi; done
write_manager_script /jffs/scripts/init-start "init-start &"
write_manager_script /jffs/scripts/services-stop "services-stop &"
write_manager_script /jffs/scripts/dnsmasq.postconf dnsmasq
write_manager_script /jffs/scripts/init-start init-start
write_manager_script /jffs/scripts/services-stop services-stop
write_command_script /jffs/scripts/service-event-end 'if echo "$2" | /bin/grep -q "^dnscrypt-proxy"; then { sh /jffs/dnscrypt/manager "${1}" & }; fi # Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
del_between_magic /jffs/scripts/service-event-end '# Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
write_command_script /jffs/scripts/service-event-end 'if printf "%s" "$@" | /bin/grep -qE "^(((((dnscrypt-)?(start|stop)|restart|kill))_?.*dnscrypt-proxy)$)"; then { sh /jffs/dnscrypt/manager "$(printf "%s" "$@" | /bin/grep -oE "^(((dnscrypt-)?(start|stop)|restart|kill))")" x & }; fi # Asuswrt-Merlin-Dnscrypt-Proxy-Installer'
if ! setup_dnscrypt; then
end_op_message 1
return
Expand Down
2 changes: 1 addition & 1 deletion installer.md5sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
83a818d42a5e1dffdcaae1bfea0e0b2f
b2cfe616a029416e95df15c7ce175323

0 comments on commit fa6075e

Please sign in to comment.