# HG changeset patch # User Christophe Lincoln # Date 1486852883 -3600 # Node ID 2cf65ee102b877c215c074c0c6074212342fa7e1 # Parent 781f12e0836c43061bda5470c1d94e67dee3031a Add sdt SliTaz Distro Tracker diff -r 781f12e0836c -r 2cf65ee102b8 sdt/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdt/Makefile Sat Feb 11 23:41:23 2017 +0100 @@ -0,0 +1,9 @@ +# Makefile for SDT - SliTaz Distro Tracker Tools +# +DESTDIR?= +PREFIX?=/usr + +install: + install -m 0755 -d $(DESTDIR)$(PREFIX)/bin + install -m 0755 sdt $(DESTDIR)$(PREFIX)/bin + diff -r 781f12e0836c -r 2cf65ee102b8 sdt/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdt/README Sat Feb 11 23:41:23 2017 +0100 @@ -0,0 +1,11 @@ +SDT +================================================================================ + +SDT stand for SliTaz Distro Tracker. A small set of tools to track and +build a DB of SliTaz live and insall systems. + +sdt: is the cmdline client +Web interface is on scn.slitaz.org/?sdt + +The CGI web interface work as a TinyCM plugin, code can be found in +slitaz-forge/scn HG repository. diff -r 781f12e0836c -r 2cf65ee102b8 sdt/sdt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdt/sdt Sat Feb 11 23:41:23 2017 +0100 @@ -0,0 +1,80 @@ +#!/bin/sh +# +# SDT - SliTaz Distro Tracker Cmdline client +# +# (C) SliTaz GNU/Linux 2017 - BSD License +# +. /lib/libtaz.sh + +version="0.1" +url="http://scn.slitaz.org/" +tmp="/tmp/$(basename $0).msg" +date="$(date +%Y%m%d)" + +get_geoloc() { + # freegeoip.net/{format}/{ip_or_hostname} + # Exemple: wget freegeoip.net/csv/${ip} -O /tmp/geoloc + wget -q "${url}?sdt=geoloc" -O ${tmp} + ip=$(cat ${tmp}) && rm ${tmp} + wget -q freegeoip.net/csv/${ip} -O /tmp/geoloc + country=$(cat /tmp/geoloc | cut -d ',' -f 3 ) + echo "$country" && rm -f /tmp/geoloc +} + +get_mode() { + if grep -q "root=/dev/null" /proc/cmdline; then + echo "live" + else + echo "install" + fi +} + +case "$1" in + get-stats) + # Get some info from the DB + newline + boldify "SDT Stats" + separator + if wget -q -T 5 --spider ${url}; then + echo "Tracker in online..." + wget -q "${url}?sdt=raw" -O ${tmp} && cat ${tmp} && rm ${tmp} + else + echo "Tracker in unreachable..." + fi + separator && newline ;; + send) + # Send stats to online DB + user="$2" + [ "$user" ] || user="anonymous" + country=$(get_geoloc) + release=$(cat /etc/slitaz-release) + kernel=$(uname -r) + mode=$(get_mode) + cat << EOT + +$(boldify "Informations sent to SliTaz Distro Tracker") +$(separator) +User : ${user} +Country : ${country} +Release : SliTaz ${release} +Kernel : ${kernel} +Running : ${mode} +EOT + separator && newline + echo "Send these data to SliTaz Distro Tracker ? " + echo -n "Press 'c' then ENTER to continue or any other key to quit: " + read anser && newline + if [ "$anser" != "c" ]; then + exit 0 + fi + echo "Sending data to: $url" && newline + wget -q --user-agent "SliTaz/SDT" \ +"${url}?sdt=add&user=${user}&country=${country}&release=${release}&kernel=${kernel}&mode=${mode}" \ + -O ${tmp} && cat ${tmp} && rm ${tmp} + ;; + *) + newline + echo "$(boldify 'Usage:') $(basename $0) [get-stats|send] [username]" + newline ;; +esac +exit 0