Ver código fonte

Use tldsate instead of ntp #24

Bob Mottram 11 anos atrás
pai
commit
ca6ae2e144
1 arquivos alterados com 204 adições e 4 exclusões
  1. 204
    4
      beaglebone.txt

+ 204
- 4
beaglebone.txt Ver arquivo

1
 #+TITLE: FreedomBone
1
 #+TITLE: FreedomBone
2
 #+AUTHOR: Bob Mottram
2
 #+AUTHOR: Bob Mottram
3
 #+EMAIL: bob@robotics.uk.to
3
 #+EMAIL: bob@robotics.uk.to
4
-#+KEYWORDS: freedombox, debian, beaglebone, friendica, email, web server, home server, internet, censorship, surveillance, social network, irc, jabber, chat
4
+#+KEYWORDS: freedombox, debian, beaglebone, friendica, email, web server, home server, internet, censorship, surveillance, social network, irc, jabber
5
 #+DESCRIPTION: Turn the Beaglebone Black into a personal communications server
5
 #+DESCRIPTION: Turn the Beaglebone Black into a personal communications server
6
 #+OPTIONS: ^:nil
6
 #+OPTIONS: ^:nil
7
 #+STYLE: <link rel="stylesheet" type="text/css" href="index.css" />
7
 #+STYLE: <link rel="stylesheet" type="text/css" href="index.css" />
690
 
690
 
691
 it should return your domain name.
691
 it should return your domain name.
692
 
692
 
693
-** Install NTP
693
+** Install time synchronisation
694
 
694
 
695
-To synchronise time.
695
+#+BEGIN_VERSE
696
+/You may delay, but time will not./
697
+
698
+-- Benjamin Franklin
699
+#+END_VERSE
700
+
701
+It's convenient to have the clock on your server automatically synchronised with other servers on the internet so that you don't need to set the clock manually.
702
+
703
+First install some prerequisites.
704
+
705
+#+BEGIN_SRC: bash
706
+apt-get install build-essential automake git
707
+#+END_SRC
708
+
709
+Now download and install tlsdate.
710
+
711
+#+BEGIN_SRC: bash
712
+cd /tmp
713
+git clone https://github.com/ioerror/tlsdate.git
714
+cd tlsdate
715
+./autogen.sh
716
+./configure
717
+make
718
+make install
719
+#+END_SRC
720
+
721
+Create an init script.
722
+
723
+#+BEGIN_SRC: bash
724
+emacs /etc/init.d/tlsdated
725
+#+END_SRC
726
+
727
+Add the following:
728
+
729
+#+BEGIN_SRC: bash
730
+#!/bin/sh
731
+### BEGIN INIT INFO
732
+# Provides:          tlsdate
733
+# Required-Start:    $network $local_fs $remote_fs
734
+# Required-Stop:     $local_fs $remote_fs
735
+# Default-Start:     2 3 4 5
736
+# Default-Stop:      0 1 6
737
+# Short-Description: secure parasitic rdate replacement
738
+# Description:       tlsdate sets the local clock by securely connecting with
739
+#                    TLS to remote servers and extracting the remote time out
740
+#                    of the secure handshake. Unlike ntpdate, tlsdate uses
741
+#                    TCP, for instance connecting to a remote HTTPS or TLS
742
+#                    enabled service, and provides some protection against
743
+#                    adversaries that try to feed you malicious time
744
+#                    information.
745
+#
746
+### END INIT INFO
747
+
748
+# Author: Jacob Appelbaum <jacob@appelbaum.net>
749
+
750
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
751
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin
752
+DESC="secure parasitic rdate replacement daemon"
753
+NAME=tlsdated
754
+DAEMON=/usr/local/sbin/tlsdated
755
+DAEMON_ARGS=""
756
+PIDFILE=/var/run/$NAME.pid
757
+SCRIPTNAME=/etc/init.d/$NAME
758
+
759
+# Exit if the package is not installed
760
+[ -x $DAEMON ] || exit 0
761
+
762
+# Read configuration variable file if it is present
763
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
764
+
765
+# Load the VERBOSE setting and other rcS variables
766
+. /lib/init/vars.sh
767
+
768
+# Define LSB log_* functions.
769
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
770
+. /lib/lsb/init-functions
771
+
772
+#
773
+# Function that starts the daemon/service
774
+#
775
+do_start()
776
+{
777
+    # Return
778
+    #   0 if daemon has been started
779
+    #   1 if daemon was already running
780
+    #   2 if daemon could not be started
781
+    start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
782
+		--exec $DAEMON --test > /dev/null \
783
+        || return 1
784
+    start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
785
+		--exec $DAEMON -- \
786
+        $DAEMON_ARGS \
787
+        || return 2
788
+    # Add code here, if necessary, that waits for the process to be ready
789
+    # to handle requests from services started subsequently which depend
790
+    # on this one.  As a last resort, sleep for some time.
791
+}
792
+
793
+#
794
+# Function that stops the daemon/service
795
+#
796
+do_stop()
797
+{
798
+    # Return
799
+    #   0 if daemon has been stopped
800
+    #   1 if daemon was already stopped
801
+    #   2 if daemon could not be stopped
802
+    #   other if a failure occurred
803
+    start-stop-daemon --stop --quiet --retry=TERM/5/KILL/1 --pidfile $PIDFILE \
804
+		--name $NAME
805
+        RETVAL="$?"
806
+        [ "$RETVAL" = 2 ] && return 2
807
+    # Wait for children to finish too if this is a daemon that forks
808
+    # and if the daemon is only ever run from this initscript.
809
+    # If the above conditions are not satisfied then add some other code
810
+    # that waits for the process to drop all resources that could be
811
+    # needed by services started subsequently.  A last resort is to
812
+    # sleep for some time.
813
+    start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
814
+        [ "$?" = 2 ] && return 2
815
+        # Many daemons don't delete their pidfiles when they exit.
816
+        rm -f $PIDFILE
817
+        return "$RETVAL"
818
+}
819
+
820
+#
821
+# Function that sends a SIGHUP to the daemon/service
822
+#
823
+do_reload() {
824
+    #
825
+    # If the daemon can reload its configuration without
826
+    # restarting (for example, when it is sent a SIGHUP),
827
+    # then implement that here.
828
+    #
829
+    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
830
+    return 0
831
+}
832
+
833
+case "$1" in
834
+  start)
835
+    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
836
+    do_start
837
+    case "$?" in
838
+         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
839
+              2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
840
+              esac
841
+  ;;
842
+  stop)
843
+  [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
844
+  do_stop
845
+  case "$?" in
846
+       0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
847
+            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
848
+            esac
849
+            ;;
850
+  status)
851
+       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
852
+       ;;
853
+  #reload|force-reload)
854
+  #
855
+  # If do_reload() is not implemented then leave this commented out
856
+  # and leave 'force-reload' as an alias for 'restart'.
857
+  #
858
+  #log_daemon_msg "Reloading $DESC" "$NAME"
859
+  #do_reload
860
+  #log_end_msg $?
861
+  #;;
862
+  restart|force-reload)
863
+  #
864
+  # If the "reload" option is implemented then remove the
865
+  # 'force-reload' alias
866
+  #
867
+  log_daemon_msg "Restarting $DESC" "$NAME"
868
+  do_stop
869
+  case "$?" in
870
+    0|1)
871
+        do_start
872
+        case "$?" in
873
+            0) log_end_msg 0 ;;
874
+            1) log_end_msg 1 ;; # Old process is still running
875
+            *) log_end_msg 1 ;; # Failed to start
876
+            esac
877
+        ;;
878
+    *)
879
+    # Failed to stop
880
+    log_end_msg 1
881
+    ;;
882
+    esac
883
+    ;;
884
+  *)
885
+  echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
886
+  exit 3
887
+  ;;
888
+esac
889
+
890
+:
891
+#+END_SRC
892
+
893
+Save and exit, then start the daemon.
696
 
894
 
697
 #+BEGIN_SRC: bash
895
 #+BEGIN_SRC: bash
698
-apt-get install ntp
896
+chmod +x /etc/init.d/tlsdated
897
+update-rc.d tlsdated defaults
898
+service tlsdated start
699
 #+END_SRC
899
 #+END_SRC
700
 
900
 
701
 ** Install fail2ban
901
 ** Install fail2ban