]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Write suggested config values to timestamped config file
authorJohannes Truschnigg <johannes@truschnigg.info>
Sun, 20 Mar 2022 15:05:50 +0000 (16:05 +0100)
committerJohannes Truschnigg <johannes@truschnigg.info>
Sun, 20 Mar 2022 15:05:50 +0000 (16:05 +0100)
sqm_lagthrottle_suggest_config.sh

index 51ab8c695c40afbb2d8e911b779654592b95f244..c55d58bede435e6d35f18ab3b48862733e128dd3 100755 (executable)
 #  You should have received a copy of the GNU General Public License
 #  along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-for p in sort sleep cat awk tee fping
+TZ=UTC
+LC_ALL=C
+export TZ LC_ALL
+
+for p in sort sleep cat awk tee date fping
 do
   type "${p}" >/dev/null || { printf 'FATAL: Required program "%s" not installed.\n' "${p}" >&2; exit 1; }
 done
 
 fpo="/tmp/fping_${$}.out"
 sto="${fpo}.stats"
+cfgo="./sqm_lagthrottle.conf.$(date +%s)"
 POTENTIAL_PING_PEERS='1.1.1.1 8.8.8.8 a.root-servers.net b.root-servers.net c.root-servers.net d.root-servers.net e.root-servers.net f.root-servers.net g.root-servers.net h.root-servers.net i.root-servers.net j.root-servers.net k.root-servers.net l.root-servers.net m.root-servers.net fastly.com fast.com gstatic.com'
 
 set -u
@@ -29,6 +34,8 @@ set -u
 echo "This script will ping potential peers for two minutes," >&2
 echo "record stats, and recommend configuration values for sqm_lagthrottle.sh" >&2
 echo "" >&2
+printf 'Suggested values will also be written to "%s"\n' "${cfgo}" >&2
+echo "" >&2
 echo "Please keep your Internet-directed traffic at a minimum while pinging." >&2
 echo "" >&2
 echo "Hit the [ENTER] key when ready, or [CTRL]+[C] to abort..." >&2
@@ -93,7 +100,7 @@ END {
   {
     #print p " " peers_pinglist[p]
   }
-}' "${fpo}"
+}' "${fpo}" | tee -a "${cfgo}"
 
 awk '
 {
@@ -112,7 +119,7 @@ END {
     }
   }
   printf "\"\n"
-}' "${sto}"
+}' "${sto}" | tee -a "${cfgo}"
 
 echo "" >&2
 echo "" >&2