diff --git a/.gitignore b/.gitignore index a323b8e..b902d81 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ *.tmp scratch.* chrony_statistics.log -conf-* log_backup_* influxdata-archive.key status.txt \ No newline at end of file diff --git a/info-level-conf-huawaii/50-tty.rules b/conf-level-debug/50-tty.rules similarity index 100% rename from info-level-conf-huawaii/50-tty.rules rename to conf-level-debug/50-tty.rules diff --git a/info-level-conf-huawaii/boot-firmware-config.txt b/conf-level-debug/boot-firmware-config.txt similarity index 100% rename from info-level-conf-huawaii/boot-firmware-config.txt rename to conf-level-debug/boot-firmware-config.txt diff --git a/conf-level-debug/chrony.conf b/conf-level-debug/chrony.conf new file mode 100644 index 0000000..1f6c954 --- /dev/null +++ b/conf-level-debug/chrony.conf @@ -0,0 +1,47 @@ +# SHM refclock is shared memory driver, it is populated by GPSd and read by chrony +# it is SHM 0 +# refid is what we want to call this source = NMEA +# offset = 0.000 means we do not yet know the delay +# precision is how precise this is. not 1e-3 = 1 millisecond, so not very precision +# poll 0 means poll every 2^0 seconds = 1 second poll interval +# filter 3 means take the average/median (forget which) of the 3 most recent readings. NMEA can be jumpy so we're averaging here +refclock SHM 0 refid NMEA offset 0.000 precision 1e-6 poll 0 filter 3 + +# PPS refclock is PPS specific, with /dev/pps0 being the source +# refid PPS means call it the PPS source +# lock NMEA means this PPS source will also lock to the NMEA source for time of day info +# offset = 0.0 means no offset... this should probably always remain 0 +# poll 3 = poll every 2^3=8 seconds. polling more frequently isn't necessarily better +# trust means we trust this time. the NMEA will be kicked out as false ticker eventually, so we need to trust the combo +refclock PPS /dev/pps0 refid PPS lock NMEA offset 0.0 poll 3 trust + +# full loggginggg +log tracking measurements statistics + +# allow local connections to ntp +allow 10.0.0.0/24 + +# manual +manual + +# tell clients im the big dog +local stratum 1 + +# NTS Servers +## Stratum 1 +### Wiktel +server ntp1.wiktel.com iburst nts maxsamples 1 +server ntp2.wiktel.com iburst nts maxsamples 1 +## Stratum 2 +### Ubuntu +server 1.ntp.ubuntu.com iburst nts maxsamples 1 +server 2.ntp.ubuntu.com iburst nts maxsamples 1 +### System76 +server ohio.time.system76.com iburst nts maxsamples 1 +server virginia.time.system76.com iburst nts maxsamples 1 +### Cifelli +server stratum1.time.cifelli.xyz iburst nts maxsamples 1 +server time.cifelli.xyz iburst nts maxsamples 1 +## Stratum 3 +### Cloudflare +server time.cloudflare.com iburst nts maxsamples 1 \ No newline at end of file diff --git a/info-level-conf-huawaii/gpsd b/conf-level-debug/gpsd similarity index 100% rename from info-level-conf-huawaii/gpsd rename to conf-level-debug/gpsd diff --git a/conf-level-debug/grafana.ini b/conf-level-debug/grafana.ini new file mode 100644 index 0000000..5cc4ab2 --- /dev/null +++ b/conf-level-debug/grafana.ini @@ -0,0 +1,26 @@ +instance_name = "Precision Timekeeping" + +[server] +# Protocol (http, https, h2, socket) +protocol = https + +# The http port to use +http_port = 3000 + +[log] +# Either "debug", "info", "warn", "error", "critical", default is "info" +level = debug + +# Either "console", "file", "syslog". Default is console and file +# Use space to separate multiple modes, e.g. "console file" +mode = console file + +[log.file] +# log line format, valid options are text, console and json +format = text + +# This enables automated log rotate(switch of following options), default is true +log_rotate = true + +# Max line number of single file, default is 1000000 +max_lines = 1000000 \ No newline at end of file diff --git a/info-level-conf-huawaii/hwclock-set b/conf-level-debug/hwclock-set similarity index 100% rename from info-level-conf-huawaii/hwclock-set rename to conf-level-debug/hwclock-set diff --git a/conf-level-debug/influxdb.conf b/conf-level-debug/influxdb.conf new file mode 100644 index 0000000..33cc3f3 --- /dev/null +++ b/conf-level-debug/influxdb.conf @@ -0,0 +1,21 @@ +# report usage statistics to influxdb company +reporting-enabled = false + +[meta] + # Where the metadata/raft database is stored + dir = "/var/lib/influxdb/meta" + +[data] + # The directory where the TSM storage engine stores TSM files. + dir = "/var/lib/influxdb/data" + + # The directory where the TSM storage engine stores WAL files. + wal-dir = "/var/lib/influxdb/wal" + + # Trace logging provides more verbose output around the tsm engine. Turning + # this on can provide more useful output for debugging tsm engine issues. + trace-logging-enabled = true + +[logging] + format = "auto" + level = "info" \ No newline at end of file diff --git a/info-level-conf-huawaii/root-crontab b/conf-level-debug/root-crontab similarity index 100% rename from info-level-conf-huawaii/root-crontab rename to conf-level-debug/root-crontab diff --git a/info-level-conf-huawaii/sudoers b/conf-level-debug/sudoers similarity index 100% rename from info-level-conf-huawaii/sudoers rename to conf-level-debug/sudoers diff --git a/conf-level-debug/telegraf.conf b/conf-level-debug/telegraf.conf new file mode 100644 index 0000000..03ba957 --- /dev/null +++ b/conf-level-debug/telegraf.conf @@ -0,0 +1,22 @@ +[global_tags] +[agent] + interval = "10s" + round_interval = true + metric_batch_size = 10000 + metric_buffer_limit = 1000000 + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + precision = "0s" + logfile = "/var/log/telegraf/telegraf.log" + debug = true + +[[inputs.chrony]] + metrics = ["tracking", "measurements", "statistics"] + timeout = "3s" + +[[outputs.influxdb]] + urls = ["http://127.0.0.1:8086"] + database = "Chrony_Stats" + timeout = "3s" + # skip_database_creation = true diff --git a/conf-level-info/50-tty.rules b/conf-level-info/50-tty.rules new file mode 100644 index 0000000..9c16d1e --- /dev/null +++ b/conf-level-info/50-tty.rules @@ -0,0 +1,5 @@ +SUBSYSTEM=="pps[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[A-Z]*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="i2c[A-Z]-*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="rtc[0-9]*", GROUP="dialout", MODE="0660" \ No newline at end of file diff --git a/conf-level-info/boot-firmware-config.txt b/conf-level-info/boot-firmware-config.txt new file mode 100644 index 0000000..0c7f36c --- /dev/null +++ b/conf-level-info/boot-firmware-config.txt @@ -0,0 +1,10 @@ + +# Precision Timekeeping Fuckery Additions +## GPS PPS GPIO Signal +dtoverlay=pps-gpio,gpiopin=18 +## GPS GPIO UART +enable_uart=1 +init_uart_baud=9600 +## I2C Hardware RTC Overlay +dtoverlay=i2c-rtc,ds3231 +# End Precision Timekeeping Fuckery Additions \ No newline at end of file diff --git a/info-level-conf-huawaii/chrony.conf b/conf-level-info/chrony.conf similarity index 100% rename from info-level-conf-huawaii/chrony.conf rename to conf-level-info/chrony.conf diff --git a/conf-level-info/gpsd b/conf-level-info/gpsd new file mode 100644 index 0000000..3cadb5e --- /dev/null +++ b/conf-level-info/gpsd @@ -0,0 +1,14 @@ +# USB might be /dev/ttyACM0 +# serial might be /dev/ttyS0 +# pps might be /dev/pps0 +DEVICES="/dev/ttyS0 /dev/pps0" + +# -n means start without a client connection (i.e. at boot) +# -s 9600 is to set baud to 9600 +GPSD_OPTIONS="-n -s 9600" + +# also start in general +START_DAEMON="true" + +# Automatically hot add/remove USB GPS devices via gpsdctl +# USBAUTO="true" diff --git a/info-level-conf-huawaii/grafana.ini b/conf-level-info/grafana.ini similarity index 100% rename from info-level-conf-huawaii/grafana.ini rename to conf-level-info/grafana.ini diff --git a/conf-level-info/hwclock-set b/conf-level-info/hwclock-set new file mode 100644 index 0000000..a30559c --- /dev/null +++ b/conf-level-info/hwclock-set @@ -0,0 +1,2 @@ +#!/bin/sh +# dev=$1 \ No newline at end of file diff --git a/info-level-conf-huawaii/influxdb.conf b/conf-level-info/influxdb.conf similarity index 100% rename from info-level-conf-huawaii/influxdb.conf rename to conf-level-info/influxdb.conf diff --git a/conf-level-info/root-crontab b/conf-level-info/root-crontab new file mode 100644 index 0000000..32a89a1 --- /dev/null +++ b/conf-level-info/root-crontab @@ -0,0 +1,8 @@ +# notify webhook of reboot +@reboot bash /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" + +# set the system time from the RTC every reboot +@reboot /usr/sbin/hwclock -s 2>> /var/log/root-crontab.log + +# set the RTC from the system time every four hours +0 */4 * * * /usr/sbin/hwclock -w 2>> /var/log/root-crontab.log diff --git a/conf-level-info/sudoers b/conf-level-info/sudoers new file mode 100644 index 0000000..c2ad7dc --- /dev/null +++ b/conf-level-info/sudoers @@ -0,0 +1,47 @@ +# +# This file MUST be edited with the 'visudo' command as root. +# +# Please consider adding local content in /etc/sudoers.d/ instead of +# directly modifying this file. +# +# See the man page for details on how to write a sudoers file. +# +Defaults env_reset +Defaults mail_badpass +Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# This fixes CVE-2005-4890 and possibly breaks some versions of kdesu +# (#1011624, https://bugs.kde.org/show_bug.cgi?id=452532) +Defaults use_pty + +# This preserves proxy settings from user environments of root +# equivalent users (group sudo) +#Defaults:%sudo env_keep += "http_proxy https_proxy ftp_proxy all_proxy no_proxy" + +# This allows running arbitrary commands, but so does ALL, and it means +# different sudoers have their choice of editor respected. +#Defaults:%sudo env_keep += "EDITOR" + +# Completely harmless preservation of a user preference. +#Defaults:%sudo env_keep += "GREP_COLOR" + +# While you shouldn't normally run git as root, you need to with etckeeper +#Defaults:%sudo env_keep += "GIT_AUTHOR_* GIT_COMMITTER_*" + +# Per-user preferences; root won't have sensible values for them. +#Defaults:%sudo env_keep += "EMAIL DEBEMAIL DEBFULLNAME" + +# "sudo scp" or "sudo rsync" should be able to use your SSH agent. +#Defaults:%sudo env_keep += "SSH_AGENT_PID SSH_AUTH_SOCK" + +# User privilege specification +root ALL=(ALL:ALL) ALL + +# Allow members of group sudo to execute any command +# %sudo ALL=(ALL:ALL) ALL + +# passwordless sudo for sudo group +%sudo ALL = (ALL) NOPASSWD: ALL + +# See sudoers(5) for more information on "@include" directives: +@includedir /etc/sudoers.d \ No newline at end of file diff --git a/info-level-conf-huawaii/telegraf.conf b/conf-level-info/telegraf.conf similarity index 100% rename from info-level-conf-huawaii/telegraf.conf rename to conf-level-info/telegraf.conf diff --git a/conf-level-warn/50-tty.rules b/conf-level-warn/50-tty.rules new file mode 100644 index 0000000..9c16d1e --- /dev/null +++ b/conf-level-warn/50-tty.rules @@ -0,0 +1,5 @@ +SUBSYSTEM=="pps[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[A-Z]*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="i2c[A-Z]-*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="rtc[0-9]*", GROUP="dialout", MODE="0660" \ No newline at end of file diff --git a/conf-level-warn/boot-firmware-config.txt b/conf-level-warn/boot-firmware-config.txt new file mode 100644 index 0000000..0c7f36c --- /dev/null +++ b/conf-level-warn/boot-firmware-config.txt @@ -0,0 +1,10 @@ + +# Precision Timekeeping Fuckery Additions +## GPS PPS GPIO Signal +dtoverlay=pps-gpio,gpiopin=18 +## GPS GPIO UART +enable_uart=1 +init_uart_baud=9600 +## I2C Hardware RTC Overlay +dtoverlay=i2c-rtc,ds3231 +# End Precision Timekeeping Fuckery Additions \ No newline at end of file diff --git a/conf-level-warn/chrony.conf b/conf-level-warn/chrony.conf new file mode 100644 index 0000000..b388cb1 --- /dev/null +++ b/conf-level-warn/chrony.conf @@ -0,0 +1,44 @@ +# SHM refclock is shared memory driver, it is populated by GPSd and read by chrony +# it is SHM 0 +# refid is what we want to call this source = NMEA +# offset = 0.000 means we do not yet know the delay +# precision is how precise this is. not 1e-3 = 1 millisecond, so not very precision +# poll 0 means poll every 2^0 seconds = 1 second poll interval +# filter 3 means take the average/median (forget which) of the 3 most recent readings. NMEA can be jumpy so we're averaging here +refclock SHM 0 refid NMEA offset 0.000 precision 1e-6 poll 0 filter 3 + +# PPS refclock is PPS specific, with /dev/pps0 being the source +# refid PPS means call it the PPS source +# lock NMEA means this PPS source will also lock to the NMEA source for time of day info +# offset = 0.0 means no offset... this should probably always remain 0 +# poll 3 = poll every 2^3=8 seconds. polling more frequently isn't necessarily better +# trust means we trust this time. the NMEA will be kicked out as false ticker eventually, so we need to trust the combo +refclock PPS /dev/pps0 refid PPS lock NMEA offset 0.0 poll 3 trust + +# allow local connections to ntp +allow 10.0.0.0/24 + +# manual +manual + +# tell clients im the big dog +local stratum 1 + +# NTS Servers +## Stratum 1 +### Wiktel +server ntp1.wiktel.com iburst nts maxsamples 1 +server ntp2.wiktel.com iburst nts maxsamples 1 +## Stratum 2 +### Ubuntu +server 1.ntp.ubuntu.com iburst nts maxsamples 1 +server 2.ntp.ubuntu.com iburst nts maxsamples 1 +### System76 +server ohio.time.system76.com iburst nts maxsamples 1 +server virginia.time.system76.com iburst nts maxsamples 1 +### Cifelli +server stratum1.time.cifelli.xyz iburst nts maxsamples 1 +server time.cifelli.xyz iburst nts maxsamples 1 +## Stratum 3 +### Cloudflare +server time.cloudflare.com iburst nts maxsamples 1 \ No newline at end of file diff --git a/conf-level-warn/gpsd b/conf-level-warn/gpsd new file mode 100644 index 0000000..3cadb5e --- /dev/null +++ b/conf-level-warn/gpsd @@ -0,0 +1,14 @@ +# USB might be /dev/ttyACM0 +# serial might be /dev/ttyS0 +# pps might be /dev/pps0 +DEVICES="/dev/ttyS0 /dev/pps0" + +# -n means start without a client connection (i.e. at boot) +# -s 9600 is to set baud to 9600 +GPSD_OPTIONS="-n -s 9600" + +# also start in general +START_DAEMON="true" + +# Automatically hot add/remove USB GPS devices via gpsdctl +# USBAUTO="true" diff --git a/conf-level-warn/grafana.ini b/conf-level-warn/grafana.ini new file mode 100644 index 0000000..b3525ea --- /dev/null +++ b/conf-level-warn/grafana.ini @@ -0,0 +1,26 @@ +instance_name = "Precision Timekeeping" + +[server] +# Protocol (http, https, h2, socket) +protocol = https + +# The http port to use +http_port = 3000 + +[log] +# Either "debug", "info", "warn", "error", "critical", default is "info" +level = warn + +# Either "console", "file", "syslog". Default is console and file +# Use space to separate multiple modes, e.g. "console file" +mode = console file + +[log.file] +# log line format, valid options are text, console and json +format = text + +# This enables automated log rotate(switch of following options), default is true +log_rotate = true + +# Max line number of single file, default is 1000000 +max_lines = 1000000 \ No newline at end of file diff --git a/conf-level-warn/hwclock-set b/conf-level-warn/hwclock-set new file mode 100644 index 0000000..a30559c --- /dev/null +++ b/conf-level-warn/hwclock-set @@ -0,0 +1,2 @@ +#!/bin/sh +# dev=$1 \ No newline at end of file diff --git a/conf-level-warn/influxdb.conf b/conf-level-warn/influxdb.conf new file mode 100644 index 0000000..7b46287 --- /dev/null +++ b/conf-level-warn/influxdb.conf @@ -0,0 +1,21 @@ +# report usage statistics to influxdb company +reporting-enabled = false + +[meta] + # Where the metadata/raft database is stored + dir = "/var/lib/influxdb/meta" + +[data] + # The directory where the TSM storage engine stores TSM files. + dir = "/var/lib/influxdb/data" + + # The directory where the TSM storage engine stores WAL files. + wal-dir = "/var/lib/influxdb/wal" + + # Trace logging provides more verbose output around the tsm engine. Turning + # this on can provide more useful output for debugging tsm engine issues. + trace-logging-enabled = false + +[logging] + format = "auto" + level = "warn" \ No newline at end of file diff --git a/conf-level-warn/root-crontab b/conf-level-warn/root-crontab new file mode 100644 index 0000000..32a89a1 --- /dev/null +++ b/conf-level-warn/root-crontab @@ -0,0 +1,8 @@ +# notify webhook of reboot +@reboot bash /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" + +# set the system time from the RTC every reboot +@reboot /usr/sbin/hwclock -s 2>> /var/log/root-crontab.log + +# set the RTC from the system time every four hours +0 */4 * * * /usr/sbin/hwclock -w 2>> /var/log/root-crontab.log diff --git a/conf-level-warn/sudoers b/conf-level-warn/sudoers new file mode 100644 index 0000000..c2ad7dc --- /dev/null +++ b/conf-level-warn/sudoers @@ -0,0 +1,47 @@ +# +# This file MUST be edited with the 'visudo' command as root. +# +# Please consider adding local content in /etc/sudoers.d/ instead of +# directly modifying this file. +# +# See the man page for details on how to write a sudoers file. +# +Defaults env_reset +Defaults mail_badpass +Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# This fixes CVE-2005-4890 and possibly breaks some versions of kdesu +# (#1011624, https://bugs.kde.org/show_bug.cgi?id=452532) +Defaults use_pty + +# This preserves proxy settings from user environments of root +# equivalent users (group sudo) +#Defaults:%sudo env_keep += "http_proxy https_proxy ftp_proxy all_proxy no_proxy" + +# This allows running arbitrary commands, but so does ALL, and it means +# different sudoers have their choice of editor respected. +#Defaults:%sudo env_keep += "EDITOR" + +# Completely harmless preservation of a user preference. +#Defaults:%sudo env_keep += "GREP_COLOR" + +# While you shouldn't normally run git as root, you need to with etckeeper +#Defaults:%sudo env_keep += "GIT_AUTHOR_* GIT_COMMITTER_*" + +# Per-user preferences; root won't have sensible values for them. +#Defaults:%sudo env_keep += "EMAIL DEBEMAIL DEBFULLNAME" + +# "sudo scp" or "sudo rsync" should be able to use your SSH agent. +#Defaults:%sudo env_keep += "SSH_AGENT_PID SSH_AUTH_SOCK" + +# User privilege specification +root ALL=(ALL:ALL) ALL + +# Allow members of group sudo to execute any command +# %sudo ALL=(ALL:ALL) ALL + +# passwordless sudo for sudo group +%sudo ALL = (ALL) NOPASSWD: ALL + +# See sudoers(5) for more information on "@include" directives: +@includedir /etc/sudoers.d \ No newline at end of file diff --git a/conf-level-warn/telegraf.conf b/conf-level-warn/telegraf.conf new file mode 100644 index 0000000..425e1fa --- /dev/null +++ b/conf-level-warn/telegraf.conf @@ -0,0 +1,22 @@ +[global_tags] +[agent] + interval = "10s" + round_interval = true + metric_batch_size = 10000 + metric_buffer_limit = 1000000 + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + precision = "0s" + logfile = "/var/log/telegraf/telegraf.log" + # debug = true + +[[inputs.chrony]] + metrics = ["tracking"] + timeout = "3s" + +[[outputs.influxdb]] + urls = ["http://127.0.0.1:8086"] + database = "Chrony_Stats" + timeout = "3s" + # skip_database_creation = true diff --git a/time_fuckery.sh b/time_fuckery.sh index 3e6258a..1ddea6e 100644 --- a/time_fuckery.sh +++ b/time_fuckery.sh @@ -421,7 +421,7 @@ phase_five () { # running (warn level) # bash ./reconfig_full.sh ./running-warn-level-conf # debug/dev mode - reconfigure_full "$git_dir/info-level-conf-huawaii" + reconfigure_full "$git_dir/info-level-conf-info" # enable services echo -e "\nEnabling Services..."