Skip to content

Instantly share code, notes, and snippets.

@sshilko
Created January 17, 2020 05:24
Show Gist options
  • Select an option

  • Save sshilko/deeae71fce766d4fe7c81f15344008ae to your computer and use it in GitHub Desktop.

Select an option

Save sshilko/deeae71fce766d4fe7c81f15344008ae to your computer and use it in GitHub Desktop.

Revisions

  1. sshilko created this gist Jan 17, 2020.
    2 changes: 2 additions & 0 deletions cloudflared-daemon.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #!/bin/sh
    nohup /usr/local/bin/cloudflared proxy-dns --port 5053 --upstream https://doh.cleanbrowsing.org/doh/family-filter/ > /dev/null 2>&1 & echo $! > /var/run/cloudflared.pid
    39 changes: 39 additions & 0 deletions etc init.d cloudflared
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #! /bin/sh
    ### BEGIN INIT INFO
    # /etc/init.d/cloudflared
    # Provides: cloudflared
    ### END INIT INFO

    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/
    DAEMON=/usr/local/bin/cloudflared-daemon.sh
    PIDFILE=/var/run/cloudflared.pid

    test -x $DAEMON || exit 0

    . /lib/lsb/init-functions

    case "$1" in
    start)
    log_daemon_msg "Starting cloudflared" "cloudflared"
    start_daemon -p $PIDFILE $DAEMON
    log_end_msg $?
    ;;
    stop)
    log_daemon_msg "Stopping cloudflared" "cloudflared"
    killproc -p $PIDFILE $DAEMON
    log_end_msg $?
    ;;
    force-reload|restart)
    $0 stop
    $0 start
    ;;
    status)
    status_of_proc -p $PIDFILE $DAEMON cloudflared && exit 0 || exit $?
    ;;
    *)
    echo "Usage: /etc/init.d/cloudflared {start|stop}"
    exit 1
    ;;
    esac

    exit 0