Everything Related To The Beaglebone SBC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
1.7 KiB

  1. #!/bin/sh -e
  2. # 5-19-2020 Ken postboot
  3. #
  4. # This is useful for Beaglebone Debian images 4-6-2020 or later.
  5. #
  6. # Create a folder in /home/debian/cronjobs. mkdir ~/cronjobs
  7. #
  8. # Put this file in the cronjobs folder
  9. #
  10. # Edit THIS file for Country and Time Zone see America/New_York below.
  11. #
  12. # Since this needs root permission add as sudo crontab -e use full path names
  13. #
  14. # And add the following string. 1> and 2> need to be on the same line.
  15. #
  16. # @reboot sh /home/debian/cronjobs/postboot.sh 1>/home/debian/cronjobs/log
  17. # 2>/home/debian/cronjobs/log
  18. #
  19. # Setup /etc/default/bb-boot if not set for your network. sudo nano /etc/default/bb-boot
  20. #
  21. # After completed test it sudo reboot
  22. #
  23. # After systems comes up check log file. cat ~/cronjobs/log . The log file only shows current boot.
  24. #
  25. # That's it.
  26. #
  27. if ! id | grep -q root; then
  28. /bin/echo "Must be run as root"
  29. exit
  30. fi
  31. if [ -f /etc/default/bb-boot ] ; then
  32. . /etc/default/bb-boot
  33. fi
  34. if [ "x${USB_CONFIGURATION}" = "x" ] ; then
  35. USB0_SUBNET=192.168.7
  36. DNS_NAMESERVER=8.8.8.8
  37. fi
  38. /bin/echo "=== Boot ==="
  39. # Sleep 20 to allow system to complete reboot.
  40. /bin/sleep 20
  41. /bin/echo "Set Nameserver and Gateway"
  42. /bin/echo "Nameserver ${DNS_NAMESERVER}, GW ${USB0_SUBNET}.1"
  43. /bin/echo "nameserver ${DNS_NAMESERVER}" > /etc/resolv.conf
  44. /bin/echo "Set route with gw ${USB0_SUBNET}.1"
  45. /sbin/route add default gw ${USB0_SUBNET}.1 || true
  46. /bin/sleep 2
  47. /bin/echo "Display route"
  48. # /sbin/netstat -rn
  49. /sbin/route
  50. /bin/echo "Set timezone"
  51. # Check your timezone |---------------|
  52. /usr/bin/timedatectl set-timezone America/New_York
  53. /usr/bin/timedatectl status
  54. # Correct date/time and time zone should be displayed
  55. /bin/echo -n "Finished at " ; /bin/date
  56. /bin/echo " "